1 00:00:00,336 --> 00:00:01,010 PROFESSOR: OK. 2 00:00:01,010 --> 00:00:03,520 So how do we find these stable marriages? 3 00:00:03,520 --> 00:00:05,730 Well there's out procedure for doing it, 4 00:00:05,730 --> 00:00:08,530 which is kind of elegantly described as a day 5 00:00:08,530 --> 00:00:13,090 by day mating ritual that the boys and girls cooperate in. 6 00:00:13,090 --> 00:00:18,030 So let's see what happens on the first day. 7 00:00:18,030 --> 00:00:21,180 On the morning of the first day, each boy 8 00:00:21,180 --> 00:00:24,000 looks at his list of girls and picks 9 00:00:24,000 --> 00:00:27,190 the one that he likes the best, at the top of this list, 10 00:00:27,190 --> 00:00:31,150 and he goes off and serenades her or proposes to her. 11 00:00:31,150 --> 00:00:34,700 So here we have Billy Bob and Brad proposing to Angelina. 12 00:00:34,700 --> 00:00:37,170 That means that on the first day Angelina 13 00:00:37,170 --> 00:00:40,170 was at the top of both Brad's list and Billy Bob's list. 14 00:00:40,170 --> 00:00:42,380 And they're both going to be proposing and asking 15 00:00:42,380 --> 00:00:45,260 if she's willing to marry them. 16 00:00:45,260 --> 00:00:50,110 Well in the afternoon, each girl rejects all but 17 00:00:50,110 --> 00:00:51,310 her favorite suitor. 18 00:00:51,310 --> 00:00:54,360 So in this case, Angelina likes Brad best of all. 19 00:00:54,360 --> 00:00:58,980 So she says to everybody else, if you're not Brad take a hike. 20 00:00:58,980 --> 00:01:00,739 And that's what happens at that stage. 21 00:01:00,739 --> 00:01:02,280 And then in the evening, here we look 22 00:01:02,280 --> 00:01:04,810 at rejected boy, Billy Bob. 23 00:01:04,810 --> 00:01:09,350 A boy who's rejected crosses off the girl who rejected him. 24 00:01:09,350 --> 00:01:12,950 So Billy Bob is going to cross Angelina off his list. 25 00:01:12,950 --> 00:01:14,670 And then the whole ritual is going 26 00:01:14,670 --> 00:01:16,250 to repeat starting the next morning. 27 00:01:16,250 --> 00:01:19,250 Except now Billy Bob will have a different woman 28 00:01:19,250 --> 00:01:21,690 at the top of his list because Angelina's gone forever. 29 00:01:25,100 --> 00:01:29,440 This mating ritual continues until nothing changes. 30 00:01:29,440 --> 00:01:33,160 And that's going to happen exactly when each girl has 31 00:01:33,160 --> 00:01:34,740 at most one suitor. 32 00:01:34,740 --> 00:01:36,620 Because if she has more than one suitor, 33 00:01:36,620 --> 00:01:39,380 she's going to reject the less favorite ones. 34 00:01:39,380 --> 00:01:42,740 So that is the definition of the stopping condition. 35 00:01:42,740 --> 00:01:45,510 And on that day, by definition, no girl 36 00:01:45,510 --> 00:01:47,280 can have more than one suitor. 37 00:01:47,280 --> 00:01:50,520 So she will marry the one suitor she has. 38 00:01:50,520 --> 00:01:54,110 And that's the definition of the marriages that result, 39 00:01:54,110 --> 00:01:58,620 if and when, the mating ritual stops. 40 00:01:58,620 --> 00:02:04,010 And we claim that they are going to be stable marriages. 41 00:02:04,010 --> 00:02:06,400 Now if we think about this process, 42 00:02:06,400 --> 00:02:07,750 it's really a state machine. 43 00:02:07,750 --> 00:02:10,169 In fact, if you think about it, what the states are 44 00:02:10,169 --> 00:02:14,270 is the set of girls on the boys list on any given morning. 45 00:02:14,270 --> 00:02:17,890 And then those states evolve to a new list 46 00:02:17,890 --> 00:02:20,560 after the crossing out happens on the next morning. 47 00:02:20,560 --> 00:02:24,290 So this is kind of a memorable way 48 00:02:24,290 --> 00:02:27,110 to tell a story about the transitions of a state machine. 49 00:02:27,110 --> 00:02:29,470 And we can bring our state machine concepts to bear. 50 00:02:29,470 --> 00:02:30,928 So the first thing we want to prove 51 00:02:30,928 --> 00:02:33,170 is that this state machine terminates. 52 00:02:33,170 --> 00:02:36,870 That is to say, there exists a wedding day. 53 00:02:36,870 --> 00:02:39,880 Then we want to prove that this state 54 00:02:39,880 --> 00:02:41,350 machine is partially correct. 55 00:02:41,350 --> 00:02:46,900 And what that means that when the machine stops, 56 00:02:46,900 --> 00:02:51,250 everyone is married and that the marriages are stable. 57 00:02:51,250 --> 00:02:53,250 So that's our task. 58 00:02:53,250 --> 00:02:54,530 Well termination's easy. 59 00:02:54,530 --> 00:02:56,650 Because if you look at the state, 60 00:02:56,650 --> 00:03:00,910 the state is the boys lists on a given morning. 61 00:03:00,910 --> 00:03:04,620 And things evolve because boys get rejected 62 00:03:04,620 --> 00:03:06,480 and they cross girls off the list. 63 00:03:06,480 --> 00:03:09,510 So what that means, if we take the total number of names 64 00:03:09,510 --> 00:03:13,740 remaining on the boys lists on any given morning, that 65 00:03:13,740 --> 00:03:17,480 is a strictly decreasing and non-negative integer valued 66 00:03:17,480 --> 00:03:18,390 variable. 67 00:03:18,390 --> 00:03:20,410 So by the well-ordering principle, 68 00:03:20,410 --> 00:03:22,090 that's strictly decreasing. 69 00:03:22,090 --> 00:03:28,440 Well-ordered derived variable will reach a minimum value. 70 00:03:28,440 --> 00:03:31,290 And by definition, that's when the algorithm 71 00:03:31,290 --> 00:03:33,220 has to stop because it's strictly increasing. 72 00:03:33,220 --> 00:03:36,890 So it can't move once it's reached its minimum. 73 00:03:36,890 --> 00:03:39,610 So there's a wedding day. 74 00:03:39,610 --> 00:03:40,110 All right. 75 00:03:40,110 --> 00:03:43,860 So now let's examine correctness of this procedure 76 00:03:43,860 --> 00:03:47,600 and figure out what's supposed to happen on the wedding day. 77 00:03:47,600 --> 00:03:49,810 We want to show that everybody's married 78 00:03:49,810 --> 00:03:51,370 and that the marriages are stable. 79 00:03:51,370 --> 00:03:52,870 And in order to do that, we're going 80 00:03:52,870 --> 00:03:56,050 to look at some more derived variables and an invariant that 81 00:03:56,050 --> 00:03:58,930 explains why the mating ritual works. 82 00:03:58,930 --> 00:04:04,480 So the first remark is that the girls improve day by day, 83 00:04:04,480 --> 00:04:06,370 or at least they don't get any worse. 84 00:04:06,370 --> 00:04:09,050 Namely, a girl's favorite tomorrow 85 00:04:09,050 --> 00:04:13,340 will be at least as desirable to her as her favorite today. 86 00:04:13,340 --> 00:04:14,790 That's for any given day. 87 00:04:14,790 --> 00:04:16,769 If you look at a girl's favorite on this day, 88 00:04:16,769 --> 00:04:19,970 and if there is a tomorrow, then her favorite tomorrow 89 00:04:19,970 --> 00:04:23,010 is going to be at least as good as the one she has. 90 00:04:23,010 --> 00:04:24,450 And why is that? 91 00:04:24,450 --> 00:04:28,670 Well because today's favorite will keep serenading her 92 00:04:28,670 --> 00:04:30,300 until he gets rejected. 93 00:04:30,300 --> 00:04:34,390 And he only gets rejected when the girl that he's serenading 94 00:04:34,390 --> 00:04:37,520 gets yet a better suitor. 95 00:04:37,520 --> 00:04:40,370 And so the girls are always going to improve. 96 00:04:40,370 --> 00:04:43,680 We could reformulate this in state machine language 97 00:04:43,680 --> 00:04:46,670 by saying that the rank of a girl's favorite, 98 00:04:46,670 --> 00:04:50,180 where she rates the boy that's serenading her 99 00:04:50,180 --> 00:04:54,320 on her own list of preferences, is a weekly increasing 100 00:04:54,320 --> 00:04:55,300 variable. 101 00:04:55,300 --> 00:04:59,680 It never gets any worse from one day to the next. 102 00:04:59,680 --> 00:05:01,800 By the same reasoning or similar reasoning, 103 00:05:01,800 --> 00:05:07,371 a boy's favorite tomorrow is going to be no better than 104 00:05:07,371 --> 00:05:07,870 today's. 105 00:05:07,870 --> 00:05:09,130 It might be worse. 106 00:05:09,130 --> 00:05:11,795 And so it's no more-- the woman that he's going to say, 107 00:05:11,795 --> 00:05:14,420 tomorrow is no more desirable to him than today's, is basically 108 00:05:14,420 --> 00:05:15,920 because he works straight down his list. 109 00:05:15,920 --> 00:05:17,430 If he hasn't been rejected, he'll 110 00:05:17,430 --> 00:05:19,420 keep serenading the same woman tomorrow. 111 00:05:19,420 --> 00:05:22,550 If he has been rejected, then he's 112 00:05:22,550 --> 00:05:24,150 going to be working on somebody lower 113 00:05:24,150 --> 00:05:26,210 on his list that's less desirable. 114 00:05:26,210 --> 00:05:30,510 So again, the rank of a girl on a boy, that a boy serenades, 115 00:05:30,510 --> 00:05:35,670 is a weekly decreasing derived variable of this process. 116 00:05:35,670 --> 00:05:39,530 And these observations lead us to an invariant that 117 00:05:39,530 --> 00:05:41,270 holds for the mating ritual. 118 00:05:41,270 --> 00:05:45,770 And the invariant is that if you look at any girl G, 119 00:05:45,770 --> 00:05:48,200 and if there's a boy B and G is not 120 00:05:48,200 --> 00:05:51,250 on B's list, that is G must've been crossed off 121 00:05:51,250 --> 00:05:57,120 by B at some point, then the invariant is that the girl 122 00:05:57,120 --> 00:06:03,360 G has a favorite that is better than B. 123 00:06:03,360 --> 00:06:06,480 And the reason is that again, when G rejected B, 124 00:06:06,480 --> 00:06:09,240 she had a better suitor than B. And her suitors keep 125 00:06:09,240 --> 00:06:12,010 getting better by the weekly increasing 126 00:06:12,010 --> 00:06:13,720 property of her suitors. 127 00:06:13,720 --> 00:06:16,810 And therefore, she's going to have 128 00:06:16,810 --> 00:06:21,160 a suitor that she likes better than B, whose list she's not 129 00:06:21,160 --> 00:06:21,660 on. 130 00:06:21,660 --> 00:06:23,930 This holds for all G's and B's. 131 00:06:23,930 --> 00:06:28,890 And that is an invariant from one day to the next. 132 00:06:28,890 --> 00:06:31,130 So let's look at what happens on the wedding day 133 00:06:31,130 --> 00:06:34,770 and use the invariant to prove that everybody's married 134 00:06:34,770 --> 00:06:37,360 and that stability holds. 135 00:06:37,360 --> 00:06:41,670 So the first remark is that each girl has at most one suitor, 136 00:06:41,670 --> 00:06:44,990 and we've observed that's by definition of a wedding day. 137 00:06:44,990 --> 00:06:51,750 And now what we want to prove is that each boy gets married. 138 00:06:51,750 --> 00:06:56,370 Well what's going on with a boy, a boy is either married 139 00:06:56,370 --> 00:06:59,970 because he's serenading the top woman on his list, 140 00:06:59,970 --> 00:07:03,840 or maybe all the women on his list have been crossed off, 141 00:07:03,840 --> 00:07:06,260 then he's not serenading anybody. 142 00:07:06,260 --> 00:07:08,961 So that's the only way he could be not married. 143 00:07:08,961 --> 00:07:10,460 Now the reason that this is the case 144 00:07:10,460 --> 00:07:11,980 is that there's no bigamy here. 145 00:07:11,980 --> 00:07:15,770 So boys serenade only one girl at a time. 146 00:07:15,770 --> 00:07:22,880 So if a boy is married, there's only one possible woman 147 00:07:22,880 --> 00:07:24,120 that he can be married to. 148 00:07:24,120 --> 00:07:27,120 And a woman's married to one possible boy. 149 00:07:27,120 --> 00:07:29,635 So let's now put these facts together and argue 150 00:07:29,635 --> 00:07:31,510 that everybody is married on the wedding day. 151 00:07:31,510 --> 00:07:33,640 And the proof is by contradiction. 152 00:07:33,640 --> 00:07:36,270 Suppose there's some boy B that's not married. 153 00:07:36,270 --> 00:07:39,700 Well that happens exactly when his list is empty. 154 00:07:39,700 --> 00:07:43,170 Otherwise, he'd be serenading somebody and be married to her. 155 00:07:43,170 --> 00:07:45,670 But if his list is empty by the invariant, 156 00:07:45,670 --> 00:07:50,100 every girl has a suitor that she likes 157 00:07:50,100 --> 00:07:53,290 better than B, which means she's going to be married to somebody 158 00:07:53,290 --> 00:07:55,530 that she likes better than B. 159 00:07:55,530 --> 00:07:56,591 Every girl's married. 160 00:07:56,591 --> 00:07:58,590 But there are the same number of boys and girls. 161 00:07:58,590 --> 00:08:01,560 So in fact, given that there's no bigamy, 162 00:08:01,560 --> 00:08:03,710 all the boys have to be married too. 163 00:08:03,710 --> 00:08:06,610 And that settles that one. 164 00:08:06,610 --> 00:08:09,340 So the next crucial property that we're interested in 165 00:08:09,340 --> 00:08:11,360 is stability. 166 00:08:11,360 --> 00:08:13,250 That in fact this set of marriages, 167 00:08:13,250 --> 00:08:16,400 which must come into being on the wedding day, 168 00:08:16,400 --> 00:08:17,630 are all stable. 169 00:08:17,630 --> 00:08:21,410 And the argument for stability has two cases, 170 00:08:21,410 --> 00:08:25,740 both of them trivial that follow immediately from the invariant. 171 00:08:25,740 --> 00:08:28,720 First of all, let's look at an arbitrary boy, Bob. 172 00:08:28,720 --> 00:08:31,210 I claim that he won't be in a rogue couple 173 00:08:31,210 --> 00:08:36,840 with case one, any girl G that's on his final list. 174 00:08:36,840 --> 00:08:39,740 Because if a girl is on his final list, 175 00:08:39,740 --> 00:08:43,740 then he's already married to the best of them. 176 00:08:43,740 --> 00:08:45,600 He marries the girl at the top of his list. 177 00:08:45,600 --> 00:08:49,600 So he's not going to be tempted to switch-- 178 00:08:49,600 --> 00:08:53,770 to be part of a rogue couple with some girl that's still 179 00:08:53,770 --> 00:08:54,920 on his list. 180 00:08:54,920 --> 00:08:57,920 Case two is, he's not going to be in a rogue couple 181 00:08:57,920 --> 00:08:59,590 with a girl that's not on his list. 182 00:08:59,590 --> 00:09:02,370 Because, by the invariant, she's married to somebody 183 00:09:02,370 --> 00:09:04,360 she likes better than him. 184 00:09:04,360 --> 00:09:07,400 So there's no available girl either way for Bob 185 00:09:07,400 --> 00:09:08,680 to be in a rogue couple with. 186 00:09:08,680 --> 00:09:11,840 Bob, of course, is an arbitrary boy. 187 00:09:11,840 --> 00:09:14,190 And therefore, no boy is in a rogue couple. 188 00:09:14,190 --> 00:09:18,450 And indeed, there are no rogue couples.