1 00:00:00,570 --> 00:00:02,990 The following content is provided under a Creative 2 00:00:02,990 --> 00:00:04,510 Commons license. 3 00:00:04,510 --> 00:00:06,850 Your support will help MIT OpenCourseWare 4 00:00:06,850 --> 00:00:11,220 continue to offer high-quality educational resources for free. 5 00:00:11,220 --> 00:00:13,830 To make a donation or view additional materials 6 00:00:13,830 --> 00:00:17,707 from hundreds of MIT courses, visit MIT OpenCourseWare 7 00:00:17,707 --> 00:00:18,332 at ocw.mit.edu. 8 00:00:22,874 --> 00:00:24,290 PROFESSOR: Now generally speaking, 9 00:00:24,290 --> 00:00:28,226 a proof is going to have seven characteristics 10 00:00:28,226 --> 00:00:29,650 that you want to keep in mind. 11 00:00:33,950 --> 00:00:41,470 Good proofs are correct-- that's obviously important-- 12 00:00:41,470 --> 00:00:46,930 complete-- you've got to have all the details there. 13 00:00:46,930 --> 00:00:50,680 All of the key steps have to be there. 14 00:00:50,680 --> 00:00:54,580 They should be clear so we can understand what's going on. 15 00:00:58,070 --> 00:01:00,300 Brief is good. 16 00:01:00,300 --> 00:01:03,630 You don't want to crush somebody with all the details. 17 00:01:03,630 --> 00:01:08,570 You want to get to the key points, and be crisp. 18 00:01:08,570 --> 00:01:10,330 It's really nice if they're elegant. 19 00:01:13,730 --> 00:01:16,320 Now, that means clever. 20 00:01:16,320 --> 00:01:19,397 It's the mathematician's notion of beauty. 21 00:01:19,397 --> 00:01:21,730 Like you go to the art museum, and the artists will say, 22 00:01:21,730 --> 00:01:24,210 wow, that's a beautiful painting. 23 00:01:24,210 --> 00:01:28,160 In mathematics, you say, wow, that's an elegant proof. 24 00:01:28,160 --> 00:01:31,410 It's crisp, clever, short, to the point. 25 00:01:31,410 --> 00:01:33,040 And it's really the highest compliment 26 00:01:33,040 --> 00:01:36,770 you can get from a mathematician, anyway. 27 00:01:36,770 --> 00:01:40,882 And there's a lot of judgment that goes into that. 28 00:01:40,882 --> 00:01:42,340 Just like in art-- there's judgment 29 00:01:42,340 --> 00:01:44,382 over what is great art. 30 00:01:44,382 --> 00:01:45,840 The proof should be well organized. 31 00:01:50,690 --> 00:01:52,950 For example, use lemmas the same way 32 00:01:52,950 --> 00:01:54,500 you would use subroutines in writing 33 00:01:54,500 --> 00:01:58,400 code-- helps to make it clear. 34 00:01:58,400 --> 00:02:00,105 And the proof should be in order. 35 00:02:03,150 --> 00:02:05,030 Sometimes you'll see proofs where things are 36 00:02:05,030 --> 00:02:06,950 done in a haphazard fashion. 37 00:02:06,950 --> 00:02:09,810 All the pieces are there, but they're in the wrong order. 38 00:02:09,810 --> 00:02:13,120 Sometimes-- and they teach this in some high schools-- 39 00:02:13,120 --> 00:02:16,790 they teach you to do proofs backwards. 40 00:02:16,790 --> 00:02:18,850 And the classic thing there is, say you're 41 00:02:18,850 --> 00:02:21,600 trying to prove a equals b. 42 00:02:21,600 --> 00:02:23,530 Well, the proof sometimes will start with what 43 00:02:23,530 --> 00:02:25,080 you're trying to prove. 44 00:02:25,080 --> 00:02:27,200 And then they'll do a bunch of steps. 45 00:02:27,200 --> 00:02:29,270 And then you'll end up with 1 equals 1, 46 00:02:29,270 --> 00:02:32,900 and you'll write a check, because you went 47 00:02:32,900 --> 00:02:35,440 from a equals b to 1 equals 1. 48 00:02:35,440 --> 00:02:37,510 And that's, of course, true. 49 00:02:37,510 --> 00:02:40,250 Now, that's not a good thing to do. 50 00:02:40,250 --> 00:02:45,400 It can be correct if the implications go this way. 51 00:02:45,400 --> 00:02:49,520 Because really, you're starting with a fact-- 1 equals 1-- 52 00:02:49,520 --> 00:02:51,160 and deriving a equals b. 53 00:02:51,160 --> 00:02:54,000 So if, in fact, the implications work this way, 54 00:02:54,000 --> 00:02:55,720 then your proof is right. 55 00:02:55,720 --> 00:02:58,930 But most people, especially as you get farther along, 56 00:02:58,930 --> 00:03:02,470 think about it going from top to bottom. 57 00:03:02,470 --> 00:03:06,330 So don't use this technique, because it'll confuse people. 58 00:03:06,330 --> 00:03:07,940 You're liable to make a mistake. 59 00:03:07,940 --> 00:03:10,790 Just start with 1 equals 1 and work your way from there-- 60 00:03:10,790 --> 00:03:13,210 top down for being in order. 61 00:03:16,140 --> 00:03:21,090 Now, good proofs are very much like good code. 62 00:03:21,090 --> 00:03:23,750 In fact, one of the reasons we care so much about teaching you 63 00:03:23,750 --> 00:03:26,990 how to write a good proof in computer science 64 00:03:26,990 --> 00:03:30,180 is so that later on, you'll be able to prove 65 00:03:30,180 --> 00:03:33,550 that your programs are doing what you expect-- what they're 66 00:03:33,550 --> 00:03:35,680 supposed to do. 67 00:03:35,680 --> 00:03:39,325 Now, there are many famous examples where programs did not 68 00:03:39,325 --> 00:03:40,700 do what they were supposed to do, 69 00:03:40,700 --> 00:03:43,340 with disastrous consequences. 70 00:03:43,340 --> 00:03:48,800 The Airbus A300 was one of the first commercial jets totally 71 00:03:48,800 --> 00:03:49,720 operated by software. 72 00:03:49,720 --> 00:03:54,140 It could take off, fly, and land totally by software. 73 00:03:54,140 --> 00:03:57,600 It was a major advance in the airline industry. 74 00:03:57,600 --> 00:03:59,110 The only problem was, that on one 75 00:03:59,110 --> 00:04:01,140 of the first flights of the A300, 76 00:04:01,140 --> 00:04:05,240 the software accidentally opened the rear door just 77 00:04:05,240 --> 00:04:06,580 before landing. 78 00:04:06,580 --> 00:04:08,940 And the plane crashed as a result. 79 00:04:08,940 --> 00:04:11,740 It was the first plane crash in commercial history because 80 00:04:11,740 --> 00:04:14,130 of a software bug. 81 00:04:14,130 --> 00:04:17,589 There's a famous radiation device for cancer patients 82 00:04:17,589 --> 00:04:19,970 called the Therac-25. 83 00:04:19,970 --> 00:04:23,350 It's famous because it got into a race condition 84 00:04:23,350 --> 00:04:26,070 occasionally, which caused the device 85 00:04:26,070 --> 00:04:29,310 to just slam the patient with radiation-- so much so, 86 00:04:29,310 --> 00:04:30,700 it killed the patient. 87 00:04:30,700 --> 00:04:32,960 And they had multiple examples of this, and of course, 88 00:04:32,960 --> 00:04:35,490 a lot of lawsuits afterwards. 89 00:04:35,490 --> 00:04:39,764 How many of you all remember the 2000 election? 90 00:04:39,764 --> 00:04:40,430 A few of you do. 91 00:04:40,430 --> 00:04:44,320 OK, this will probably be the last class that remembers that. 92 00:04:44,320 --> 00:04:47,030 But that's where Al Gore was going up against George Bush-- 93 00:04:47,030 --> 00:04:49,930 very close election-- all came down to recounting 94 00:04:49,930 --> 00:04:52,060 the votes in Florida. 95 00:04:52,060 --> 00:04:56,370 But in fact, Al Gore got negative 16,000 votes 96 00:04:56,370 --> 00:04:59,590 in one county because of a software bug 97 00:04:59,590 --> 00:05:02,150 in the electronic voting booths, which 98 00:05:02,150 --> 00:05:04,501 I think they got rid of a lot of them in the election 99 00:05:04,501 --> 00:05:05,000 after that. 100 00:05:05,000 --> 00:05:07,010 Because the software was buggy. 101 00:05:07,010 --> 00:05:08,840 So poor Al had enough problem which chads 102 00:05:08,840 --> 00:05:10,090 and funny business in Florida. 103 00:05:10,090 --> 00:05:12,580 But getting negative 16,000 votes certainly 104 00:05:12,580 --> 00:05:14,890 didn't help his chances. 105 00:05:14,890 --> 00:05:17,820 Several years ago, a single faulty command 106 00:05:17,820 --> 00:05:21,320 in a computer system used by United and American Airlines 107 00:05:21,320 --> 00:05:24,800 grounded the entire fleets to both airlines for close 108 00:05:24,800 --> 00:05:26,210 to a day. 109 00:05:26,210 --> 00:05:28,050 Because they couldn't do anything. 110 00:05:28,050 --> 00:05:31,480 They're all run by computer, and the whole thing was screwed up. 111 00:05:31,480 --> 00:05:33,400 So there's lots more examples. 112 00:05:33,400 --> 00:05:36,790 We run into this issue all the time at Akamai. 113 00:05:36,790 --> 00:05:40,760 Akamai is a company started by MIT folks-- by myself, 114 00:05:40,760 --> 00:05:44,850 and Danny Lewin, and a dozen undergrads in the late 1990s. 115 00:05:44,850 --> 00:05:47,720 And we deliver a lot of the content 116 00:05:47,720 --> 00:05:51,850 you get on the web-- Facebook, all the search engines. 117 00:05:51,850 --> 00:05:54,790 A lot of the stuff you go to comes from our servers. 118 00:05:54,790 --> 00:05:56,710 So we've got to be very careful that we 119 00:05:56,710 --> 00:05:58,039 don't have software bugs. 120 00:05:58,039 --> 00:05:58,830 Now, in fact we do. 121 00:05:58,830 --> 00:06:00,710 And we catch them every once in awhile. 122 00:06:00,710 --> 00:06:02,594 But if we got a bad one, it would bring down 123 00:06:02,594 --> 00:06:03,760 all the sites you go to you. 124 00:06:03,760 --> 00:06:05,855 You wouldn't be able to go to those sites anymore. 125 00:06:05,855 --> 00:06:06,980 And everybody would notice. 126 00:06:06,980 --> 00:06:08,355 It would be sort of embarrassing. 127 00:06:10,740 --> 00:06:14,680 Now, this really does matter. 128 00:06:14,680 --> 00:06:18,380 And this is going to sound a little scary, but someday-- 129 00:06:18,380 --> 00:06:20,620 probably 30, 20 years from now, somewhere 130 00:06:20,620 --> 00:06:25,080 in there-- it's possible that all of us, our lives 131 00:06:25,080 --> 00:06:29,490 may depend on the software that some of you write. 132 00:06:29,490 --> 00:06:32,010 In fact, to bring this home how scary it is, 133 00:06:32,010 --> 00:06:34,550 look at the person sitting next to you. 134 00:06:34,550 --> 00:06:38,750 And imagine that in 25 years, your life depends on 135 00:06:38,750 --> 00:06:40,280 whether their code does what it's 136 00:06:40,280 --> 00:06:42,820 supposed to do-- little scary. 137 00:06:47,390 --> 00:06:51,340 That's why we are very motivated to help 138 00:06:51,340 --> 00:06:55,660 you learn how to make rock-solid arguments, 139 00:06:55,660 --> 00:06:58,290 so you don't have code that fries one of your classmates 140 00:06:58,290 --> 00:07:03,040 someday, or puts him in a bad plane situation. 141 00:07:03,040 --> 00:07:07,100 Now unfortunately, writing rock-solid proofs 142 00:07:07,100 --> 00:07:08,910 is a very hard thing to do. 143 00:07:08,910 --> 00:07:11,380 Even the world's best mathematicians 144 00:07:11,380 --> 00:07:13,550 mess them up on a regular basis. 145 00:07:13,550 --> 00:07:18,570 In fact, it's estimated that one third of all published proofs 146 00:07:18,570 --> 00:07:23,330 have bugs, have flaws, that render the proof incorrect. 147 00:07:23,330 --> 00:07:28,040 The trouble often arises because we get lazy. 148 00:07:28,040 --> 00:07:30,570 We don't write down all the details or all the steps. 149 00:07:30,570 --> 00:07:32,880 Because, wow, it's clear. 150 00:07:32,880 --> 00:07:35,740 Let's just move on. 151 00:07:35,740 --> 00:07:39,330 Now, this can be OK. 152 00:07:39,330 --> 00:07:42,010 Not such a good practice, but it dramatically 153 00:07:42,010 --> 00:07:45,100 increases the chances of making a mistake. 154 00:07:45,100 --> 00:07:46,650 And there's some very famous examples 155 00:07:46,650 --> 00:07:48,274 in the math literature from the world's 156 00:07:48,274 --> 00:07:50,320 most famous mathematicians. 157 00:07:50,320 --> 00:07:51,837 Gauss-- and we'll talk about Gauss 158 00:07:51,837 --> 00:07:53,670 later during the term-- he's one of the most 159 00:07:53,670 --> 00:07:55,420 famous mathematicians ever. 160 00:07:55,420 --> 00:07:59,640 He wrote his PhD thesis in 1799. 161 00:07:59,640 --> 00:08:03,440 And it's usually referred to as the first rigorous proof 162 00:08:03,440 --> 00:08:05,350 of the fundamental theorem of algebra. 163 00:08:05,350 --> 00:08:08,130 And that says that every polynomial 164 00:08:08,130 --> 00:08:10,410 has a 0 over the complex numbers-- something 165 00:08:10,410 --> 00:08:12,325 probably a lot of you learned in high school. 166 00:08:12,325 --> 00:08:13,200 You get a polynomial. 167 00:08:13,200 --> 00:08:14,700 You can find roots of the polynomial 168 00:08:14,700 --> 00:08:17,100 over the complex numbers. 169 00:08:17,100 --> 00:08:20,580 But his thesis contains the following quote, 170 00:08:20,580 --> 00:08:24,730 "If a branch of an algebraic curve enters a bounded region, 171 00:08:24,730 --> 00:08:27,870 it must necessarily leave again. 172 00:08:27,870 --> 00:08:31,480 Nobody, to my knowledge, has ever doubted this fact." 173 00:08:31,480 --> 00:08:34,679 Warning signs-- buzzers-- should be going off in your brain. 174 00:08:34,679 --> 00:08:37,090 "But if anybody desires it, then on another occasion, 175 00:08:37,090 --> 00:08:41,100 I intend to give a demonstration which will leave no doubt." 176 00:08:41,100 --> 00:08:44,620 So he's using something that he believes to be true. 177 00:08:44,620 --> 00:08:48,420 He sort of thinks it's clear, that everybody knows it. 178 00:08:48,420 --> 00:08:49,530 But he writes this down. 179 00:08:49,530 --> 00:08:50,946 And when you're writing that down, 180 00:08:50,946 --> 00:08:52,730 you know there's a problem. 181 00:08:52,730 --> 00:08:54,700 And in fact, there's another Fields medalist-- 182 00:08:54,700 --> 00:08:57,800 we talked about Fields medals last week-- Stephen Smale 183 00:08:57,800 --> 00:09:02,650 writes that this was an immense gap in the proof that was not 184 00:09:02,650 --> 00:09:06,500 filled until 1920-- more than 100 years later. 185 00:09:06,500 --> 00:09:08,310 So Gauss never could give the proof, 186 00:09:08,310 --> 00:09:11,870 and nobody did for over a century more. 187 00:09:11,870 --> 00:09:14,830 Remember the Poincare conjecture from last week? 188 00:09:14,830 --> 00:09:17,210 We had Colbert talking about that. 189 00:09:17,210 --> 00:09:22,440 In 1900, Poincare claimed it was a simple fact. 190 00:09:22,440 --> 00:09:25,790 Four years later, he decided it wasn't so simple, 191 00:09:25,790 --> 00:09:28,600 and he demoted his claim to the status of a conjecture. 192 00:09:28,600 --> 00:09:32,240 And of course, this became the famous Poincare conjecture, 193 00:09:32,240 --> 00:09:35,480 which took another century to solve. 194 00:09:35,480 --> 00:09:38,380 So when you think you see yourself doing this, 195 00:09:38,380 --> 00:09:41,714 famous mathematicians do it too, and it catches them. 196 00:09:41,714 --> 00:09:43,130 So you want to not try to do that. 197 00:09:43,130 --> 00:09:46,260 Now, in fact, just to really bring home the point, 198 00:09:46,260 --> 00:09:49,940 we've made a top 10 list of proof techniques 199 00:09:49,940 --> 00:09:52,330 you should not use in 6.042. 200 00:09:52,330 --> 00:09:54,624 So everybody go to the handout here. 201 00:09:54,624 --> 00:09:56,540 In fact, there's lot of them on the back, too, 202 00:09:56,540 --> 00:09:58,730 but on the front page, there's the top 10. 203 00:09:58,730 --> 00:10:01,220 So we're going to go through these. 204 00:10:01,220 --> 00:10:02,910 These are the ones we've most observed 205 00:10:02,910 --> 00:10:05,020 in 6.042 over the years. 206 00:10:05,020 --> 00:10:09,270 Number 10-- proof by throwing in the kitchen sink. 207 00:10:09,270 --> 00:10:11,930 The author writes down every theorem known to mankind, 208 00:10:11,930 --> 00:10:14,445 and then adds a few more for good measure. 209 00:10:14,445 --> 00:10:16,820 Now, this is good, because when you're questioned later-- 210 00:10:16,820 --> 00:10:19,780 you're trying to get a better score on your exam-- 211 00:10:19,780 --> 00:10:22,810 you say, look, the proof contains all the key facts. 212 00:10:22,810 --> 00:10:25,010 They're all here. 213 00:10:25,010 --> 00:10:26,030 And so that does help. 214 00:10:26,030 --> 00:10:28,030 You get extra credit if all the facts are there. 215 00:10:28,030 --> 00:10:31,267 We are literally seen students copy over their crib sheet, 216 00:10:31,267 --> 00:10:33,350 if they got enough time, for a problem they're not 217 00:10:33,350 --> 00:10:37,250 knowing how to solve, just to get all of the facts in there. 218 00:10:37,250 --> 00:10:40,590 Number nine-- proof by example-- the author gives the case n 219 00:10:40,590 --> 00:10:42,290 equals 2 and suggests it contains 220 00:10:42,290 --> 00:10:44,166 most of the ideas of the general proof. 221 00:10:44,166 --> 00:10:45,540 In fact, a student before a class 222 00:10:45,540 --> 00:10:47,690 was telling me on one of the homework problems, 223 00:10:47,690 --> 00:10:50,410 he talked about it to his non-math friends, 224 00:10:50,410 --> 00:10:54,220 and they gave examples, not the proof. 225 00:10:54,220 --> 00:10:57,210 Number eight-- proof by vigorous hand-waving-- one 226 00:10:57,210 --> 00:10:59,440 of my favorites-- I get up here and wave my hands. 227 00:10:59,440 --> 00:11:00,575 And it must be true. 228 00:11:03,330 --> 00:11:06,890 Number seven-- proof by cumbersome notation-- 229 00:11:06,890 --> 00:11:09,080 here the reader gets hopelessly confused, 230 00:11:09,080 --> 00:11:11,060 gives up, and says OK. 231 00:11:11,060 --> 00:11:13,130 In fact, I once had a grad student, 232 00:11:13,130 --> 00:11:15,740 and we called him the encryptor, because he 233 00:11:15,740 --> 00:11:19,900 could take the simplest proof and so encrypt it in notation 234 00:11:19,900 --> 00:11:23,170 and God knows what, you could never understand the proof 235 00:11:23,170 --> 00:11:25,990 and figure out if it was really right or wrong. 236 00:11:25,990 --> 00:11:29,520 That goes well with number six-- proof by exhaustion-- 237 00:11:29,520 --> 00:11:31,850 so does throwing in the kitchen sink. 238 00:11:31,850 --> 00:11:33,870 Number five-- proof by omission-- 239 00:11:33,870 --> 00:11:37,680 you will see that a lot, also by faculty-- "The reader 240 00:11:37,680 --> 00:11:40,300 may easily supply the details. 241 00:11:40,300 --> 00:11:43,150 The other cases are analogous-- trivial." 242 00:11:43,150 --> 00:11:44,400 Experts use that all the time. 243 00:11:44,400 --> 00:11:46,340 You can find a lot of my papers online. 244 00:11:46,340 --> 00:11:48,840 "The proof is trivial"-- very bad. 245 00:11:48,840 --> 00:11:51,920 Every once in a while, it turned out not to be so trivial. 246 00:11:51,920 --> 00:11:55,170 Number four-- proof by picture-- we've seen those, 247 00:11:55,170 --> 00:11:57,000 saw one on Tuesday. 248 00:11:57,000 --> 00:12:00,230 Number three-- proof by vehement assertion-- sort 249 00:12:00,230 --> 00:12:01,800 of like the hand-waving. 250 00:12:01,800 --> 00:12:03,780 The more forceful you are in your argument, 251 00:12:03,780 --> 00:12:06,400 the higher you raise your voice, the more intimidating 252 00:12:06,400 --> 00:12:10,160 you become, doesn't make it more true. 253 00:12:10,160 --> 00:12:14,350 Number two-- proof by appeal to intuition-- you say, 254 00:12:14,350 --> 00:12:17,230 "any moron knows that." 255 00:12:17,230 --> 00:12:20,480 Well, you're sort of reluctant to now question it. 256 00:12:20,480 --> 00:12:23,430 And then number one-- proof by reference to eminent authority. 257 00:12:23,430 --> 00:12:26,480 I saw Fermat on the elevator and he said he had a proof. 258 00:12:26,480 --> 00:12:28,330 I don't think so. 259 00:12:28,330 --> 00:12:31,420 Fermat's been dead for over 300 years. 260 00:12:31,420 --> 00:12:34,840 And he was not so reliable in the first place. 261 00:12:34,840 --> 00:12:37,940 In fact, he has one of the most famous assertions 262 00:12:37,940 --> 00:12:41,860 that turned into a conjecture, called Fermat's last theorem. 263 00:12:41,860 --> 00:12:44,425 And it was not really a theorem by the time he died. 264 00:12:47,620 --> 00:12:49,860 How many people have heard of Fermat's last theorem? 265 00:12:49,860 --> 00:12:51,010 Raise your hand. 266 00:12:51,010 --> 00:12:52,920 Yeah, pretty famous. 267 00:12:52,920 --> 00:12:56,935 It's the one theorem he proved that actually, he didn't prove. 268 00:12:56,935 --> 00:12:59,850 It says, for all n bigger than 2, 269 00:12:59,850 --> 00:13:08,220 there does not exist an x, y, and z in the natural numbers 270 00:13:08,220 --> 00:13:12,040 plus the positive natural numbers such that x to the n 271 00:13:12,040 --> 00:13:15,540 plus y to the n equals z to the n. 272 00:13:15,540 --> 00:13:18,370 Now of course, for n equals 2, that's 273 00:13:18,370 --> 00:13:19,580 just the Pythagorean theorem. 274 00:13:19,580 --> 00:13:22,180 You can find three, four, and five, when 275 00:13:22,180 --> 00:13:24,860 you square them satisfy that. 276 00:13:24,860 --> 00:13:28,970 But it says this does not work for any higher value, 277 00:13:28,970 --> 00:13:31,360 any higher power, than 2. 278 00:13:31,360 --> 00:13:37,030 Now in 1637, Fermat wrote in the margin of a block 279 00:13:37,030 --> 00:13:39,410 that he had discovered a proof of this result, 280 00:13:39,410 --> 00:13:42,510 but the proof was too long to fit in the margin. 281 00:13:42,510 --> 00:13:45,870 And so he wasn't going to supply the details there. 282 00:13:45,870 --> 00:13:47,730 And he never did supply the details. 283 00:13:47,730 --> 00:13:52,750 And it took 350 years and 100s and 100s of pages. 284 00:13:52,750 --> 00:13:55,860 A fellow named Andrew Wiles-- took him personally 285 00:13:55,860 --> 00:13:56,710 over 10 years. 286 00:13:56,710 --> 00:13:58,620 He more or less locked himself in his room 287 00:13:58,620 --> 00:14:01,360 for 10 years, produced 100s of pages, 288 00:14:01,360 --> 00:14:04,350 and he finally did prove Fermat's Last Theorem. 289 00:14:04,350 --> 00:14:06,520 So Fermat was right about one thing-- 290 00:14:06,520 --> 00:14:08,224 it would not fit in the margin. 291 00:14:08,224 --> 00:14:09,640 At least, there's no proof that we 292 00:14:09,640 --> 00:14:12,990 know of that would fit in the margin of a book. 293 00:14:12,990 --> 00:14:16,480 Any questions on proof technique? 294 00:14:16,480 --> 00:14:20,840 We're going to pound a lot on this over the next few weeks. 295 00:14:24,060 --> 00:14:25,650 All right, next we're going to look 296 00:14:25,650 --> 00:14:31,850 at a class of puzzles that was very popular in the late 1800s. 297 00:14:31,850 --> 00:14:36,390 Now, in these puzzles, you have a grid of letters or numbers. 298 00:14:36,390 --> 00:14:39,130 And you've got to slide the letters and numbers around 299 00:14:39,130 --> 00:14:41,750 to put them in order. 300 00:14:41,750 --> 00:14:46,440 And so as an example, here's the problem on a three 301 00:14:46,440 --> 00:14:50,050 by three grid, or an eight puzzle. 302 00:14:50,050 --> 00:15:00,570 You want to find a sequence of moves 303 00:15:00,570 --> 00:15:07,160 to go from this configuration. 304 00:15:07,160 --> 00:15:10,370 I'll do a three by three case. 305 00:15:10,370 --> 00:15:15,060 I have a here, b here, c, d, e, f. 306 00:15:15,060 --> 00:15:18,530 And I've put g and h out of order. 307 00:15:18,530 --> 00:15:22,820 And that square is blank, and I can move tiles or letters 308 00:15:22,820 --> 00:15:23,600 into it. 309 00:15:23,600 --> 00:15:24,670 I'm going to start here. 310 00:15:24,670 --> 00:15:29,170 And I eventually want to get to the configuration 311 00:15:29,170 --> 00:15:31,620 where the letters are all in alphabetical order. 312 00:15:35,720 --> 00:15:37,270 So g and h are in order. 313 00:15:40,290 --> 00:15:43,430 Now, a legal move means you slide a letter 314 00:15:43,430 --> 00:15:44,910 into an adjacent blank square. 315 00:15:58,370 --> 00:16:00,100 And you can go in a row or a column. 316 00:16:10,240 --> 00:16:11,870 OK, everybody understand the game, 317 00:16:11,870 --> 00:16:13,680 what you're supposed to do? 318 00:16:13,680 --> 00:16:14,810 You slide these things. 319 00:16:14,810 --> 00:16:15,680 That could go down. 320 00:16:15,680 --> 00:16:16,600 That could go across. 321 00:16:16,600 --> 00:16:19,450 How many people played a game like this before? 322 00:16:19,450 --> 00:16:21,040 Good, a lot of you. 323 00:16:21,040 --> 00:16:23,270 OK, so I need some volunteers who 324 00:16:23,270 --> 00:16:27,120 are good at solving puzzles that can do this, 325 00:16:27,120 --> 00:16:30,500 have played games like this, that are pretty quick at it. 326 00:16:34,447 --> 00:16:35,280 So I've got it here. 327 00:16:37,930 --> 00:16:39,166 Who would like to come down? 328 00:16:39,166 --> 00:16:40,790 There are prizes if you can solve this. 329 00:16:40,790 --> 00:16:42,655 What we're going to do is solve this. 330 00:16:42,655 --> 00:16:44,530 And see if you can solve it in three minutes. 331 00:16:44,530 --> 00:16:48,170 But I need three students to come on down and do this. 332 00:16:48,170 --> 00:16:49,360 Who'd like to volunteer? 333 00:16:49,360 --> 00:16:52,665 Who thinks they can handle puzzles under pressure? 334 00:16:52,665 --> 00:16:54,470 So you have the g and h out of order. 335 00:16:54,470 --> 00:16:55,695 So it's not so hard. 336 00:16:55,695 --> 00:16:58,960 You move the f down there. 337 00:16:58,960 --> 00:17:02,977 I don't know, play around like that. 338 00:17:02,977 --> 00:17:04,060 So I need some volunteers. 339 00:17:04,060 --> 00:17:07,210 Who'd like to come down and do this? 340 00:17:07,210 --> 00:17:08,089 You can win candy. 341 00:17:08,089 --> 00:17:11,589 I've got candy here. 342 00:17:11,589 --> 00:17:14,609 There's even a prize if you don't make it in three minutes. 343 00:17:14,609 --> 00:17:17,109 Who wants some candy? 344 00:17:17,109 --> 00:17:17,610 Nobody? 345 00:17:17,610 --> 00:17:19,150 Is there a prize if we don't make it? 346 00:17:19,150 --> 00:17:19,940 What's that? 347 00:17:19,940 --> 00:17:21,170 Is there a prize if we don't make it? 348 00:17:21,170 --> 00:17:21,670 There is. 349 00:17:21,670 --> 00:17:22,750 Come on down. 350 00:17:22,750 --> 00:17:27,250 All right, now, who's going to help him out? 351 00:17:27,250 --> 00:17:29,490 I need a couple more people here just to mess him up, 352 00:17:29,490 --> 00:17:31,434 because by himself-- there we go-- good. 353 00:17:31,434 --> 00:17:32,850 Anybody else like to come on down? 354 00:17:32,850 --> 00:17:34,266 Because if we get three, it really 355 00:17:34,266 --> 00:17:37,070 gets hard, because you fight over what moves to make. 356 00:17:37,070 --> 00:17:39,370 Now, what I'd like you all to do is sort of 357 00:17:39,370 --> 00:17:40,746 scream out possibilities for him. 358 00:17:40,746 --> 00:17:42,620 Like he figures it out there, you scream out, 359 00:17:42,620 --> 00:17:44,000 that'll really screw him up. 360 00:17:44,000 --> 00:17:46,339 OK, now, you can't pick them up. 361 00:17:46,339 --> 00:17:47,880 You've just got to slide them around. 362 00:17:47,880 --> 00:17:50,324 And you can go, and we'll go to 2:56, 363 00:17:50,324 --> 00:17:51,490 and see if you can solve it. 364 00:17:51,490 --> 00:17:54,470 If you can solve it, you guys get candy. 365 00:17:57,070 --> 00:17:59,723 And if you can figure it out out there, let them know. 366 00:17:59,723 --> 00:18:02,190 Slide to the gray area. 367 00:18:02,190 --> 00:18:03,780 No, you can't use the gray area. 368 00:18:06,604 --> 00:18:08,270 All right, you've got about two minutes. 369 00:18:08,270 --> 00:18:10,477 They have the g and h in order. 370 00:18:10,477 --> 00:18:12,560 Everything else is pretty well screwed up, though. 371 00:18:15,094 --> 00:18:15,760 What do you got? 372 00:18:15,760 --> 00:18:18,900 A, b, c, d, e, f, h g-- no, no, no, that's where you started, 373 00:18:18,900 --> 00:18:19,400 guys. 374 00:18:19,400 --> 00:18:21,750 That's not it. 375 00:18:21,750 --> 00:18:23,790 It was close, just one was out of order is all. 376 00:18:28,150 --> 00:18:29,850 Just one letter at a time. 377 00:18:29,850 --> 00:18:30,430 There you go. 378 00:18:43,102 --> 00:18:44,060 I think they need help. 379 00:18:44,060 --> 00:18:45,710 We got about a minute ago. 380 00:18:45,710 --> 00:18:46,892 Cannot see anything. 381 00:18:46,892 --> 00:18:47,850 You can't see anything. 382 00:18:47,850 --> 00:18:49,350 Well, I don't know if it would help. 383 00:18:51,830 --> 00:18:53,330 You want to show them where you are? 384 00:18:59,510 --> 00:19:00,570 This is not looking good. 385 00:19:10,947 --> 00:19:12,655 We're pretty close to the end here, guys. 386 00:19:17,610 --> 00:19:23,020 A, b, c, f, e, d, g, h-- g, h is good. 387 00:19:23,020 --> 00:19:24,070 F is not so good. 388 00:19:27,140 --> 00:19:28,965 All right, you got about 30 seconds. 389 00:19:45,030 --> 00:19:46,530 Whoa, what are you guys doing? 390 00:19:46,530 --> 00:19:47,740 One at a time here. 391 00:19:47,740 --> 00:19:49,566 One at the time. 392 00:19:49,566 --> 00:19:53,520 In fact, I think time is up here. 393 00:20:02,940 --> 00:20:04,640 All right, 2:56. 394 00:20:04,640 --> 00:20:07,020 Oh, no, no. 395 00:20:07,020 --> 00:20:08,110 That we don't do. 396 00:20:08,110 --> 00:20:12,020 No diagonal moves-- no, no, no, no. 397 00:20:12,020 --> 00:20:14,680 All right, well, you guys were good sports, 398 00:20:14,680 --> 00:20:16,950 so you do get a prize. 399 00:20:16,950 --> 00:20:20,200 It's not the candy, but I have these wonderful plastic Nerd 400 00:20:20,200 --> 00:20:23,139 Pride pocket protectors for you. 401 00:20:23,139 --> 00:20:24,430 There you go, very good sports. 402 00:20:24,430 --> 00:20:27,570 Thank you, well done. 403 00:20:27,570 --> 00:20:28,400 All right. 404 00:20:28,400 --> 00:20:32,700 [APPLAUSE] 405 00:20:32,700 --> 00:20:35,780 Now, I was a little cruel to these guys, 406 00:20:35,780 --> 00:20:37,780 for a lot of reasons. 407 00:20:37,780 --> 00:20:39,830 It's impossible? 408 00:20:39,830 --> 00:20:41,162 You think? 409 00:20:41,162 --> 00:20:42,930 [INDISTINCT CHATTER] 410 00:20:42,930 --> 00:20:45,590 Yeah it is impossible. 411 00:20:45,590 --> 00:20:47,610 This is impossible to do. 412 00:20:47,610 --> 00:20:50,470 Let's see if we can prove it's impossible. 413 00:20:50,470 --> 00:20:55,230 Because it doesn't seem so hard, necessarily. 414 00:20:55,230 --> 00:20:56,940 But let's take that as a theorem. 415 00:21:02,320 --> 00:21:16,990 There is no sequence of legal moves-- 416 00:21:16,990 --> 00:21:26,680 diagonal moves makes this a lot easier-- to invert g and h 417 00:21:26,680 --> 00:21:37,530 and also return all the other letters to their original order 418 00:21:37,530 --> 00:21:38,106 or position. 419 00:21:49,400 --> 00:21:53,790 Now, to prove this, we're going to use 420 00:21:53,790 --> 00:21:56,530 what's called an invariant. 421 00:21:56,530 --> 00:21:58,910 It's a very powerful and commonly used 422 00:21:58,910 --> 00:22:02,470 concept in computer science, very closely tied to induction, 423 00:22:02,470 --> 00:22:04,500 as we'll see. 424 00:22:04,500 --> 00:22:07,800 In order to show that your system can never 425 00:22:07,800 --> 00:22:11,580 reach a particular special state, 426 00:22:11,580 --> 00:22:13,900 it is sufficient to show there's some property called 427 00:22:13,900 --> 00:22:17,880 the invariant that holds at the initial state, 428 00:22:17,880 --> 00:22:21,540 and that is preserved by every legal move, 429 00:22:21,540 --> 00:22:26,770 and is not present-- does not hold-- in that special state. 430 00:22:26,770 --> 00:22:29,230 The idea is, if you get this magic property called 431 00:22:29,230 --> 00:22:31,540 the invariant and it holds at the start, 432 00:22:31,540 --> 00:22:34,150 and it holds across every step, then 433 00:22:34,150 --> 00:22:36,640 the only states you can reach have 434 00:22:36,640 --> 00:22:39,450 to have to have the property, be invariant. 435 00:22:39,450 --> 00:22:42,850 And if the special state doesn't have that property, 436 00:22:42,850 --> 00:22:45,060 you can't reach it. 437 00:22:45,060 --> 00:22:47,970 All right, so there is going to be 438 00:22:47,970 --> 00:22:50,130 some property we're going to look for that held 439 00:22:50,130 --> 00:22:53,110 at the beginning here-- and the beginning had this set 440 00:22:53,110 --> 00:22:59,420 up-- that holds, is preserved, by every move, 441 00:22:59,420 --> 00:23:03,800 every legal move, but does not hold in this state. 442 00:23:03,800 --> 00:23:06,527 And therefore, you can never reach this state legally. 443 00:23:06,527 --> 00:23:07,360 So they were doomed. 444 00:23:09,880 --> 00:23:12,710 So we've got to figure out what that property is. 445 00:23:15,240 --> 00:23:17,730 And that's always the trick in analyzing 446 00:23:17,730 --> 00:23:19,790 systems or algorithms-- is what's 447 00:23:19,790 --> 00:23:22,930 that key property, the invariant property? 448 00:23:22,930 --> 00:23:24,680 So to figure out the invariant, we sort of 449 00:23:24,680 --> 00:23:27,700 have to look at what happens during a move 450 00:23:27,700 --> 00:23:30,080 in this system-- a transition. 451 00:23:30,080 --> 00:23:33,130 Well, there's two kinds of moves. 452 00:23:33,130 --> 00:23:34,080 There's a row move. 453 00:23:37,860 --> 00:23:45,590 And an example of a row move is you might 454 00:23:45,590 --> 00:23:53,560 have a, b, c, d, g, e, f, h. 455 00:23:53,560 --> 00:23:57,810 And I'm going to move the g its row to the blank square. 456 00:23:57,810 --> 00:23:59,812 So it would become this state. 457 00:24:05,010 --> 00:24:07,720 So g moves rightward into the blank, 458 00:24:07,720 --> 00:24:11,020 and the rest stays the same. 459 00:24:11,020 --> 00:24:16,150 Now, when I make a row move, did the relative order 460 00:24:16,150 --> 00:24:18,135 of the items change? 461 00:24:21,060 --> 00:24:21,624 No. 462 00:24:21,624 --> 00:24:23,040 Of course, to be precise, I better 463 00:24:23,040 --> 00:24:27,280 define what relative order means, or the natural order. 464 00:24:27,280 --> 00:24:39,210 So by the natural order, I mean this ordering-- 1, 2 3, 4, 5, 465 00:24:39,210 --> 00:24:42,100 6, 7, 8, 9. 466 00:24:42,100 --> 00:24:47,070 So if I look at the order here, g moved from 5 to 6, 467 00:24:47,070 --> 00:24:49,090 but didn't change order with respect 468 00:24:49,090 --> 00:24:50,150 to any of the other guys. 469 00:24:52,874 --> 00:24:54,040 Let's state that as a lemma. 470 00:25:02,780 --> 00:25:05,490 Because that'll be very useful. 471 00:25:05,490 --> 00:25:21,920 Lemma 1-- a row move does not change the order 472 00:25:21,920 --> 00:25:24,940 of the items or the letters. 473 00:25:29,480 --> 00:25:33,590 Proof-- well, it's obvious. 474 00:25:39,540 --> 00:25:41,640 No, you can't let me get away with that, right? 475 00:25:41,640 --> 00:25:44,490 Because I'm not to let you get away with that on homework. 476 00:25:44,490 --> 00:25:47,120 That's not so good. 477 00:25:47,120 --> 00:25:51,140 So we've got to be a little more careful in the proof here. 478 00:25:51,140 --> 00:25:54,580 Otherwise, we just head down the path to trouble. 479 00:25:54,580 --> 00:25:57,520 So let's sort of specify, what does a row move 480 00:25:57,520 --> 00:26:03,450 mean-- just get a little bit of math and specification 481 00:26:03,450 --> 00:26:05,140 around it. 482 00:26:05,140 --> 00:26:13,720 Well, in a row move, we move an item-- 483 00:26:13,720 --> 00:26:23,680 a letter-- from some cell i, whatever 484 00:26:23,680 --> 00:26:30,170 i-- it could be anything 1 to 9-- into an adjacent cell. 485 00:26:35,960 --> 00:26:40,720 What are the possibilities for the adjacent cell? 486 00:26:40,720 --> 00:26:50,120 Plus or minus 1, yeah, into cell i minus 1 or i plus 1. 487 00:26:50,120 --> 00:26:51,085 Nothing else moves. 488 00:26:59,230 --> 00:27:05,920 Hence, the order of the items is preserved. 489 00:27:16,640 --> 00:27:19,600 Because if you're going with i to i plus 1, 490 00:27:19,600 --> 00:27:23,450 everything else is in i minus 1 or less, i plus 2 or more. 491 00:27:23,450 --> 00:27:25,790 Relative order does not change in this case. 492 00:27:28,450 --> 00:27:30,570 And I'll claim that's enough. 493 00:27:30,570 --> 00:27:32,910 You know that I've thought about it a little bit. 494 00:27:32,910 --> 00:27:35,820 I've really quantified that i goes to i minus 1 or i plus 1. 495 00:27:35,820 --> 00:27:37,460 Nothing else moves. 496 00:27:37,460 --> 00:27:38,780 Therefore, we're done. 497 00:27:38,780 --> 00:27:40,920 Now, I could've added some more sentences here, 498 00:27:40,920 --> 00:27:42,400 like I talked about. 499 00:27:42,400 --> 00:27:46,050 But this is probably enough in this case, for this guy. 500 00:27:48,610 --> 00:27:53,400 So in fact, if we only had row moves, 501 00:27:53,400 --> 00:27:54,650 there's not much that happens. 502 00:27:54,650 --> 00:27:57,184 The order never changes with row moves. 503 00:27:57,184 --> 00:27:58,100 So we never get there. 504 00:27:58,100 --> 00:27:59,683 But column moves are more interesting. 505 00:28:06,320 --> 00:28:19,042 So as an example of a column move, a, b, c, d, f, h, e, 506 00:28:19,042 --> 00:28:23,220 g-- say I move the g up. 507 00:28:23,220 --> 00:28:33,000 Then I would get this one-- a, b, c, d, f, g-- because g 508 00:28:33,000 --> 00:28:35,420 moved up-- h, e. 509 00:28:35,420 --> 00:28:36,550 So g went to there. 510 00:28:40,240 --> 00:28:43,690 Did the ordering change for this move? 511 00:28:43,690 --> 00:28:46,300 Yeah. 512 00:28:46,300 --> 00:28:48,450 How so? 513 00:28:48,450 --> 00:28:49,570 What things changed order? 514 00:28:49,570 --> 00:28:51,630 Which pairs of letters changed order? 515 00:28:54,576 --> 00:28:56,540 AUDIENCE: G changed [INAUDIBLE]. 516 00:28:56,540 --> 00:29:00,450 PROFESSOR: G changed by three-- moved three in the order. 517 00:29:00,450 --> 00:29:04,837 And what letters did it change relative order with? 518 00:29:04,837 --> 00:29:07,831 AUDIENCE: [INAUDIBLE]. 519 00:29:07,831 --> 00:29:09,830 AUDIENCE: The two preceding it. 520 00:29:09,830 --> 00:29:11,800 PROFESSOR: Yeah, the two preceding it. 521 00:29:11,800 --> 00:29:14,790 g used to be after h and e. 522 00:29:14,790 --> 00:29:18,070 Now it's before h and e. 523 00:29:18,070 --> 00:29:21,750 All right, so it changed relative order with two items. 524 00:29:21,750 --> 00:29:23,300 It changed its position by three. 525 00:29:23,300 --> 00:29:25,100 It moved up three in the ordering. 526 00:29:25,100 --> 00:29:28,020 And so it changed order with the two in between. 527 00:29:28,020 --> 00:29:30,630 Let's look at another one. 528 00:29:30,630 --> 00:29:32,760 Because we're really doing these examples 529 00:29:32,760 --> 00:29:35,190 to hunt for an invariant, is what 530 00:29:35,190 --> 00:29:37,530 we're trying to do here-- something 531 00:29:37,530 --> 00:29:41,710 that will let us prove we can never get to the desired state. 532 00:29:41,710 --> 00:29:43,750 Let's look at this one. 533 00:29:43,750 --> 00:29:54,050 a, b, c, d, g, h, e, f goes to-- I'm 534 00:29:54,050 --> 00:30:05,680 going to move b down this time-- a, c, d, b, g, h, e, f. 535 00:30:05,680 --> 00:30:09,225 So b moves down. 536 00:30:09,225 --> 00:30:12,470 The relative order changes. 537 00:30:12,470 --> 00:30:15,120 Which pairs got changed in the relative order? 538 00:30:19,870 --> 00:30:20,820 AUDIENCE: b. 539 00:30:20,820 --> 00:30:22,264 PROFESSOR: b changed with-- 540 00:30:22,264 --> 00:30:23,430 AUDIENCE: c and [INAUDIBLE]. 541 00:30:23,430 --> 00:30:27,070 PROFESSOR: c and d. 542 00:30:27,070 --> 00:30:30,380 b used to be before c and d. when it moves down here, 543 00:30:30,380 --> 00:30:34,160 it goes after c and d. 544 00:30:34,160 --> 00:30:37,580 Any guess about what Lemma Two is going to be? 545 00:30:37,580 --> 00:30:40,544 What happens when we make a column move? 546 00:30:40,544 --> 00:30:41,460 AUDIENCE: [INAUDIBLE]. 547 00:30:41,460 --> 00:30:44,192 PROFESSOR: Change the order of-- 548 00:30:44,192 --> 00:30:45,108 AUDIENCE: [INAUDIBLE]. 549 00:30:50,030 --> 00:30:52,770 PROFESSOR: Good, so a column move 550 00:30:52,770 --> 00:30:55,971 changes the order of a guy with the previous two 551 00:30:55,971 --> 00:30:58,470 or the next two, which means the relative order of two pairs 552 00:30:58,470 --> 00:30:59,887 change. 553 00:30:59,887 --> 00:31:01,220 So let's take that as Lemma Two. 554 00:31:04,750 --> 00:31:06,660 When we say don't do proof by example, 555 00:31:06,660 --> 00:31:09,220 we don't mean don't try examples. 556 00:31:09,220 --> 00:31:11,300 Because by trying examples, you find out 557 00:31:11,300 --> 00:31:13,370 what you're trying to prove. 558 00:31:13,370 --> 00:31:15,680 So that's good to do. 559 00:31:15,680 --> 00:31:39,600 A column move changes the relative order of precisely two 560 00:31:39,600 --> 00:31:40,670 pairs of items. 561 00:31:46,860 --> 00:31:47,750 So let's prove that. 562 00:31:53,130 --> 00:32:12,010 In a column move, we move an item in cell i for some i 563 00:32:12,010 --> 00:32:22,642 to a blank spot in cell what? 564 00:32:22,642 --> 00:32:24,580 AUDIENCE: [INAUDIBLE]. 565 00:32:24,580 --> 00:32:27,334 PROFESSOR: i minus 3 or i plus 3? 566 00:32:27,334 --> 00:32:28,250 AUDIENCE: [INAUDIBLE]. 567 00:32:31,860 --> 00:32:35,590 PROFESSOR: OK, and just to see that, let's draw out 568 00:32:35,590 --> 00:32:36,340 the natural order. 569 00:32:36,340 --> 00:32:40,890 I've got 1 2, 3, 4, 5, 6, 7, 8, 9. 570 00:32:40,890 --> 00:32:46,690 Column moves could be here-- 1 to 4, and 4 to 1, 2 and 5, 571 00:32:46,690 --> 00:32:51,880 3 and 6, 4 and 7, 5 and 8, 6 and 9. 572 00:32:51,880 --> 00:32:55,810 All 12 possible column moves, this works for. 573 00:32:55,810 --> 00:32:57,310 They're always separated by 3. 574 00:33:00,170 --> 00:33:17,080 And when an item moves three positions, 575 00:33:17,080 --> 00:33:19,540 it changes relative order with two other items. 576 00:33:27,360 --> 00:33:29,950 And you can even write down what they are. 577 00:33:29,950 --> 00:33:36,942 It's i minus 1, i minus 2, or i plus 1, i plus 2. 578 00:33:36,942 --> 00:33:38,650 Those are the guys it changes order with. 579 00:33:42,559 --> 00:33:44,100 All right, we've got two lemmas here. 580 00:33:44,100 --> 00:33:46,380 That one's done now. 581 00:33:46,380 --> 00:33:49,100 In a row move, order does not change. 582 00:33:49,100 --> 00:33:55,070 In a column move, two pairs of letters get flipped. 583 00:33:55,070 --> 00:33:58,240 That's all you can do with this puzzle now. 584 00:33:58,240 --> 00:34:01,950 So can anybody think of something 585 00:34:01,950 --> 00:34:04,890 we can work with to get an invariant here-- something 586 00:34:04,890 --> 00:34:06,460 that won't change? 587 00:34:06,460 --> 00:34:07,710 What we should be focusing on? 588 00:34:07,710 --> 00:34:09,070 Yeah. 589 00:34:09,070 --> 00:34:12,990 AUDIENCE: You can only switch two pairs of items at a time. 590 00:34:12,990 --> 00:34:18,380 So if you don't have an even number [INAUDIBLE] 591 00:34:18,380 --> 00:34:20,850 switch [INAUDIBLE]. 592 00:34:20,850 --> 00:34:22,199 PROFESSOR: Yeah, that's good. 593 00:34:22,199 --> 00:34:24,139 So really, to focus in on there is, 594 00:34:24,139 --> 00:34:27,600 if you have an even number of things out of order 595 00:34:27,600 --> 00:34:30,620 to start, you're going to have an even number forever, 596 00:34:30,620 --> 00:34:32,860 because you can only change two at a time. 597 00:34:32,860 --> 00:34:33,820 That's a great idea. 598 00:34:33,820 --> 00:34:38,159 Let's really specify that now, and define that. 599 00:34:42,840 --> 00:34:52,420 A pair of letters or items, call them L1 and L2-- 600 00:34:52,420 --> 00:35:12,520 they form an inversion, also known as an inverted pair, 601 00:35:12,520 --> 00:35:24,160 if L1 precedes L2 in the alphabet, 602 00:35:24,160 --> 00:35:27,140 but L1 appears after L2 in the puzzle. 603 00:35:38,170 --> 00:35:41,470 All right, so that is an inversion. 604 00:35:41,470 --> 00:35:43,960 So for example, let's see how many inversions 605 00:35:43,960 --> 00:35:45,060 do we have in this case? 606 00:35:49,060 --> 00:35:57,850 We've got a, b, c, f, d, g, e, h. 607 00:35:57,850 --> 00:36:00,550 How many inversions are there in that state of the puzzle? 608 00:36:12,740 --> 00:36:14,070 Yeah? 609 00:36:14,070 --> 00:36:14,950 AUDIENCE: Three. 610 00:36:14,950 --> 00:36:15,908 PROFESSOR: Three, good. 611 00:36:15,908 --> 00:36:17,866 And what are they? 612 00:36:17,866 --> 00:36:20,130 AUDIENCE: d is after f. 613 00:36:20,130 --> 00:36:22,040 PROFESSOR: Yeah, d, f is an inversion. 614 00:36:26,340 --> 00:36:29,600 e, f is an inversion. 615 00:36:29,600 --> 00:36:31,480 And what's the last one? 616 00:36:31,480 --> 00:36:32,250 AUDIENCE: e, g. 617 00:36:32,250 --> 00:36:34,320 PROFESSOR: e, g is an inversion. 618 00:36:34,320 --> 00:36:37,430 Yes, so the answer is there's three inversions 619 00:36:37,430 --> 00:36:39,680 in this puzzle. 620 00:36:39,680 --> 00:36:41,960 And if I keep doing row and column 621 00:36:41,960 --> 00:36:45,200 moves to this, what do I know about the parity 622 00:36:45,200 --> 00:36:47,746 of the number of inversions? 623 00:36:47,746 --> 00:36:50,430 AUDIENCE: [INAUDIBLE]. 624 00:36:50,430 --> 00:36:54,040 PROFESSOR: Will always be odd-- that's sort of interesting. 625 00:36:54,040 --> 00:37:02,180 OK, now, how many inverted pairs are there in the start state 626 00:37:02,180 --> 00:37:05,100 way back over here? 627 00:37:05,100 --> 00:37:08,440 How many inverted pairs here? 628 00:37:08,440 --> 00:37:09,215 One inversion. 629 00:37:14,120 --> 00:37:17,986 How many inversions here? 630 00:37:17,986 --> 00:37:18,485 Zero. 631 00:37:21,960 --> 00:37:27,350 All right, and can you see where we're going to head here now? 632 00:37:27,350 --> 00:37:32,080 If I started with one, that's odd. 633 00:37:32,080 --> 00:37:34,190 And every time I do a row move or column move, 634 00:37:34,190 --> 00:37:35,750 it's going to stay odd. 635 00:37:35,750 --> 00:37:38,930 And I can never get here. 636 00:37:38,930 --> 00:37:41,190 Is that clear what we're trying to do? 637 00:37:41,190 --> 00:37:42,380 So let's keep doing it. 638 00:37:46,550 --> 00:37:47,350 Let's go over here. 639 00:37:59,110 --> 00:38:02,510 All right, so now we'll use Lemma One and Lemma Two 640 00:38:02,510 --> 00:38:05,820 create this notion that we only change the number of inversions 641 00:38:05,820 --> 00:38:07,883 by an even number. 642 00:38:07,883 --> 00:38:28,130 And Lemma Three-- during a move, the number of inversions 643 00:38:28,130 --> 00:38:42,500 can only increase by two, decrease by two, 644 00:38:42,500 --> 00:38:44,230 or stay the same. 645 00:38:49,510 --> 00:38:51,210 And this proof is pretty easy. 646 00:38:51,210 --> 00:38:53,060 There's a couple of cases. 647 00:38:56,910 --> 00:39:01,250 In a row move, what happens? 648 00:39:01,250 --> 00:39:04,380 How does the number of inversions 649 00:39:04,380 --> 00:39:05,629 change in a row move? 650 00:39:05,629 --> 00:39:06,670 AUDIENCE: Stays the same. 651 00:39:06,670 --> 00:39:09,770 PROFESSOR: Stays the same-- no changes-- 652 00:39:09,770 --> 00:39:11,090 and that's by Lemma One. 653 00:39:17,910 --> 00:39:20,725 Now, in a column move, there's three cases. 654 00:39:26,330 --> 00:39:29,432 But we know two pairs change order-- that we know. 655 00:39:29,432 --> 00:39:30,140 That's Lemma Two. 656 00:39:34,117 --> 00:39:35,700 All right, by Lemma Two, we know that. 657 00:39:39,600 --> 00:39:42,857 But the three cases are-- let me start on the next board. 658 00:40:00,780 --> 00:40:07,850 So Case A is that both of the inverted pairs 659 00:40:07,850 --> 00:40:14,030 were in order originally, before the column move. 660 00:40:14,030 --> 00:40:17,720 What happens to the number of inversions in this case, 661 00:40:17,720 --> 00:40:20,588 as a result of the column move? 662 00:40:20,588 --> 00:40:21,777 AUDIENCE: [INAUDIBLE]. 663 00:40:21,777 --> 00:40:22,860 PROFESSOR: Goes up by two. 664 00:40:25,700 --> 00:40:31,080 Case B is that both pairs were inverted 665 00:40:31,080 --> 00:40:34,250 before I made the column move. 666 00:40:34,250 --> 00:40:37,994 What happens to the number of inversions in that case? 667 00:40:37,994 --> 00:40:39,179 AUDIENCE: Decreases by two. 668 00:40:39,179 --> 00:40:41,220 PROFESSOR: Decreases by two-- they were in order, 669 00:40:41,220 --> 00:40:42,700 so they were inverted. 670 00:40:42,700 --> 00:40:46,010 Now when I flop them, they become in order. 671 00:40:46,010 --> 00:40:48,470 So inversions drops by two. 672 00:40:48,470 --> 00:40:51,650 And Case C is there's one of each. 673 00:40:51,650 --> 00:40:53,010 One of the pairs was inverted. 674 00:40:57,150 --> 00:40:58,870 The other wasn't. 675 00:40:58,870 --> 00:41:02,040 What happens to the number of inversions in that case? 676 00:41:02,040 --> 00:41:03,030 AUDIENCE: [INAUDIBLE]. 677 00:41:03,030 --> 00:41:04,321 PROFESSOR: Yes, stays the same. 678 00:41:10,120 --> 00:41:11,339 All right, and we're done. 679 00:41:11,339 --> 00:41:13,880 That's what the lemma says-- I can go up by two, down by two, 680 00:41:13,880 --> 00:41:16,990 or stay the same. 681 00:41:16,990 --> 00:41:21,820 All right, now a simple corollary of this 682 00:41:21,820 --> 00:41:26,200 is that during a move, the parity-- i.e. even or odd 683 00:41:26,200 --> 00:41:29,750 of the number of inversions stays the same. 684 00:41:29,750 --> 00:41:30,870 It can't change at all. 685 00:41:39,450 --> 00:41:45,840 During a move, the parity-- and the parity means even, odd. 686 00:41:45,840 --> 00:41:50,590 Sometimes it's called 0, 1, but the evenness 687 00:41:50,590 --> 00:42:01,460 and the oddness of the number of inversions does not change. 688 00:42:08,456 --> 00:42:11,420 AUDIENCE: Instead of two pairs you mean one pair, right? 689 00:42:11,420 --> 00:42:12,902 PROFESSOR: Where? 690 00:42:12,902 --> 00:42:15,760 AUDIENCE: [INAUDIBLE] pairs. 691 00:42:15,760 --> 00:42:18,530 PROFESSOR: Oops, I mean one pair's inverted, 692 00:42:18,530 --> 00:42:19,984 one pair's not. 693 00:42:19,984 --> 00:42:20,900 AUDIENCE: [INAUDIBLE]. 694 00:42:23,600 --> 00:42:27,860 PROFESSOR: No, I mean two pairs change order in a column move. 695 00:42:27,860 --> 00:42:30,600 Let's go back and look at that. 696 00:42:30,600 --> 00:42:31,980 So I'm doing a column move. 697 00:42:31,980 --> 00:42:36,490 For example, g goes up. 698 00:42:36,490 --> 00:42:38,470 g, h changes order. 699 00:42:38,470 --> 00:42:41,320 g, e changes order. 700 00:42:41,320 --> 00:42:43,610 g changes order with these two guys, 701 00:42:43,610 --> 00:42:47,830 so there's two pairs that got flipped. 702 00:42:47,830 --> 00:42:51,230 So in a column move, two pairs reverse their order. 703 00:42:51,230 --> 00:42:53,240 If they were in order, they become inverted. 704 00:42:53,240 --> 00:42:56,792 If they were inverted, they become in order. 705 00:42:56,792 --> 00:42:57,625 Any other questions? 706 00:43:00,390 --> 00:43:01,350 Yeah. 707 00:43:01,350 --> 00:43:03,270 AUDIENCE: So we're saying that letters can be 708 00:43:03,270 --> 00:43:06,160 numbers in more than one pair? 709 00:43:06,160 --> 00:43:08,470 PROFESSOR: Yes, a letter can be in-- a letter 710 00:43:08,470 --> 00:43:13,250 is in seven pairs, because there's seven other letters. 711 00:43:13,250 --> 00:43:19,000 And in fact, we're looking at a space of 8 times 7 712 00:43:19,000 --> 00:43:22,195 divided by 2-- 28 pairs of letters. 713 00:43:22,195 --> 00:43:26,237 So there could be 28 inversions if they're all out of order. 714 00:43:26,237 --> 00:43:27,070 Any other questions? 715 00:43:30,600 --> 00:43:32,230 OK, well, we're getting there. 716 00:43:32,230 --> 00:43:32,980 We're almost done. 717 00:43:32,980 --> 00:43:35,720 I've got to prove this corollary that during a move, 718 00:43:35,720 --> 00:43:38,210 the evenness or oddness of the number of inversions 719 00:43:38,210 --> 00:43:38,920 does not change. 720 00:43:42,450 --> 00:43:46,410 And that's because adding or subtracting 2 from a number 721 00:43:46,410 --> 00:43:48,440 does not change its parity. 722 00:43:48,440 --> 00:43:51,780 It stays odd or stays even. 723 00:43:51,780 --> 00:44:03,450 So adding or subtracting 2 does not change the parity. 724 00:44:11,987 --> 00:44:14,070 All right, now we're ready to state the invariant. 725 00:44:24,310 --> 00:44:27,930 Anybody tell me what the invariant is going to be? 726 00:44:27,930 --> 00:44:31,805 What's the invariant going to be in this system? 727 00:44:31,805 --> 00:44:33,140 AUDIENCE: [INAUDIBLE]. 728 00:44:33,140 --> 00:44:37,630 PROFESSOR: Yeah, the parity of the number of inversions 729 00:44:37,630 --> 00:44:41,650 is odd, because it starts that way. 730 00:44:41,650 --> 00:44:42,960 It's preserved. 731 00:44:42,960 --> 00:44:45,720 And it won't hold in the desired end state 732 00:44:45,720 --> 00:44:47,182 that we're looking at. 733 00:44:47,182 --> 00:44:48,515 So we can state that as follows. 734 00:44:55,240 --> 00:45:05,810 In every state or configuration reachable 735 00:45:05,810 --> 00:45:13,530 from the start state, which is a, 736 00:45:13,530 --> 00:45:21,160 b, c, d, e, f, h, g-- which are out of order-- 737 00:45:21,160 --> 00:45:30,690 the parity of the number of inversions is odd. 738 00:45:35,220 --> 00:45:38,440 And the proof will be by induction. 739 00:45:38,440 --> 00:45:40,750 And invariant proofs are always by induction. 740 00:45:46,790 --> 00:45:50,100 And the inductive hypothesis-- and this 741 00:45:50,100 --> 00:45:52,270 is very typical in a proof by using 742 00:45:52,270 --> 00:46:11,910 invariants-- is, so P of n is after any sequence of n moves 743 00:46:11,910 --> 00:46:17,260 from the start state-- in fact, just the rest of this 744 00:46:17,260 --> 00:46:18,020 is what it is. 745 00:46:25,700 --> 00:46:29,280 All right, so our inductive hypothesis is P of n, 746 00:46:29,280 --> 00:46:33,510 after any sequence of n moves-- so n is the number of moves 747 00:46:33,510 --> 00:46:37,510 you took to get there-- from the start state, 748 00:46:37,510 --> 00:46:41,550 the parity of the number of inversions is odd. 749 00:46:41,550 --> 00:46:44,180 That is the inductive hypothesis. 750 00:46:44,180 --> 00:46:45,680 This is the invariant. 751 00:46:45,680 --> 00:46:47,380 And they become one and the same. 752 00:46:47,380 --> 00:46:50,960 And the parameter n is the number of moves you've taken. 753 00:46:50,960 --> 00:46:53,625 And that's how you set up a proof using an invariant. 754 00:46:53,625 --> 00:46:55,774 It always looks just like this. 755 00:47:16,550 --> 00:47:19,220 OK, so we're doing a proof by induction. 756 00:47:19,220 --> 00:47:22,720 We've got the inductive hypothesis. 757 00:47:22,720 --> 00:47:24,837 What's the next step? 758 00:47:24,837 --> 00:47:25,670 AUDIENCE: Base case. 759 00:47:25,670 --> 00:47:26,545 PROFESSOR: Base case. 760 00:47:32,456 --> 00:47:34,830 And in these circumstances, where the proof by invariant, 761 00:47:34,830 --> 00:47:37,590 the base case is always 0. 762 00:47:37,590 --> 00:47:40,020 We haven't made any moves yet. 763 00:47:40,020 --> 00:47:41,860 Now in this case, if we haven't made moves, 764 00:47:41,860 --> 00:47:48,870 the number of inversions in the start state now is 1. 765 00:47:48,870 --> 00:47:55,380 That means the parity is odd, and the hypothesis 766 00:47:55,380 --> 00:47:56,230 is satisfied. 767 00:47:56,230 --> 00:48:00,650 P of 0 is true, because in any sequence of zero moves, 768 00:48:00,650 --> 00:48:02,092 after this-- i.e. 769 00:48:02,092 --> 00:48:03,800 in this state-- you've got one inversion. 770 00:48:03,800 --> 00:48:06,602 That's odd. 771 00:48:06,602 --> 00:48:08,815 The last step is the inductive step. 772 00:48:16,690 --> 00:48:22,510 And here we need to show for any n bigger or equal to 0, 773 00:48:22,510 --> 00:48:29,980 we need to show P of n implies p of n plus 1 is true-- 774 00:48:29,980 --> 00:48:32,990 the standard thing. 775 00:48:32,990 --> 00:48:35,770 So let's look at P n plus 1. 776 00:48:35,770 --> 00:48:38,260 That's talking about where we are 777 00:48:38,260 --> 00:48:42,550 after a sequence of n plus 1 moves in the puzzle, 778 00:48:42,550 --> 00:48:45,610 from the start state. 779 00:48:45,610 --> 00:48:58,790 So let's consider any sequence of n plus 1 moves. 780 00:48:58,790 --> 00:49:00,545 And call these moves-- label them 781 00:49:00,545 --> 00:49:05,394 by M1 all the way to M n plus 1. 782 00:49:05,394 --> 00:49:06,560 Those are the moves we made. 783 00:49:09,080 --> 00:49:13,680 Now, by the inductive hypothesis, because of P n, 784 00:49:13,680 --> 00:49:17,720 we know that after the first n moves, the parity is still odd. 785 00:49:17,720 --> 00:49:20,170 That's what P n says. 786 00:49:20,170 --> 00:49:20,980 That's P n. 787 00:49:20,980 --> 00:49:24,774 After any sequence of n moves from here, 788 00:49:24,774 --> 00:49:26,690 the parity of the number of inversions is odd. 789 00:49:29,490 --> 00:49:31,460 So we could say by the inductive hypothesis, 790 00:49:31,460 --> 00:49:48,450 or we could say by P n, we know that the parity after moves 791 00:49:48,450 --> 00:49:54,340 M1 out to M n is odd. 792 00:50:00,130 --> 00:50:05,240 Now, by Corollary One-- do we still have Corollary One? 793 00:50:05,240 --> 00:50:06,724 [INAUDIBLE] 794 00:50:06,724 --> 00:50:07,640 AUDIENCE: [INAUDIBLE]. 795 00:50:07,640 --> 00:50:10,140 PROFESSOR: [INAUDIBLE], yeah, good, we've got Corollary One. 796 00:50:10,140 --> 00:50:14,650 During any move, the parity doesn't change. 797 00:50:14,650 --> 00:50:19,190 That says from after the nth move to after the n plus 1st 798 00:50:19,190 --> 00:50:22,141 move-- one extra move-- doesn't change the parity. 799 00:50:22,141 --> 00:50:22,890 So it's still odd. 800 00:50:40,600 --> 00:50:50,080 So next, by Corollary One, we know 801 00:50:50,080 --> 00:50:59,010 that the parity of the number of inversions 802 00:50:59,010 --> 00:51:01,840 does not change during M n plus 1. 803 00:51:14,744 --> 00:51:25,710 Therefore, this implies that the parity after all n plus 1 804 00:51:25,710 --> 00:51:35,340 moves-- these guys-- is odd. 805 00:51:35,340 --> 00:51:37,180 It started odd. 806 00:51:37,180 --> 00:51:39,150 It stayed odd after the first n. 807 00:51:39,150 --> 00:51:41,580 It stayed odd during the n plus 1st. 808 00:51:41,580 --> 00:51:43,940 So it's odd. 809 00:51:43,940 --> 00:51:48,780 And that's exactly the statement of P n plus 1. 810 00:51:48,780 --> 00:51:50,740 So we've completed the induction. 811 00:51:50,740 --> 00:51:53,247 We've shown that P n implies P n plus 1. 812 00:51:56,450 --> 00:52:01,241 All right, so now, any questions so far on this? 813 00:52:01,241 --> 00:52:01,989 Yeah. 814 00:52:01,989 --> 00:52:03,947 AUDIENCE: What's the difference between a lemma 815 00:52:03,947 --> 00:52:05,300 and a corollary? 816 00:52:05,300 --> 00:52:07,440 PROFESSOR: Really, there's not a lot of difference. 817 00:52:07,440 --> 00:52:09,450 Corollary usually is something that's 818 00:52:09,450 --> 00:52:12,870 a simple consequence of something else. 819 00:52:12,870 --> 00:52:16,734 And the corollary had a pretty short proof. 820 00:52:16,734 --> 00:52:19,150 Usually when you see corollary, that's not a 10-page proof 821 00:52:19,150 --> 00:52:19,770 there. 822 00:52:19,770 --> 00:52:22,410 A lemma is something that you're going 823 00:52:22,410 --> 00:52:25,010 to use as a tool for a bigger thing, often 824 00:52:25,010 --> 00:52:27,060 a theorem or another lemma. 825 00:52:27,060 --> 00:52:29,970 In fact, now we're going to get to the theorem, which 826 00:52:29,970 --> 00:52:32,820 is sort of the final thing-- the thing we're really after. 827 00:52:32,820 --> 00:52:34,315 And that's sort of the big deal. 828 00:52:34,315 --> 00:52:35,690 And now the proof will be simple, 829 00:52:35,690 --> 00:52:38,512 because we've done all these lemmas and corollaries. 830 00:52:38,512 --> 00:52:39,345 Any other questions? 831 00:52:42,230 --> 00:52:44,840 All right. 832 00:52:44,840 --> 00:52:49,170 In fact, the theorem is up here, right? 833 00:52:49,170 --> 00:52:52,040 There is no sequence of legal moves to invert g and h. 834 00:52:52,040 --> 00:52:53,950 In other words, the students were screwed. 835 00:52:53,950 --> 00:52:57,060 They couldn't do it fairly. 836 00:52:57,060 --> 00:52:58,400 So let's prove the theorem now. 837 00:53:28,590 --> 00:53:39,030 The parity of the number of inversions 838 00:53:39,030 --> 00:53:42,520 in the desired state-- i.e. 839 00:53:42,520 --> 00:53:51,050 in order-- the target state-- is even. 840 00:53:51,050 --> 00:53:52,160 Nothing's out of order. 841 00:53:52,160 --> 00:53:55,320 There's zero inversions. 842 00:53:55,320 --> 00:54:07,030 By Lemma Four, the desired state cannot be reached from 843 00:54:07,030 --> 00:54:26,450 the start state, because its parity is odd, 844 00:54:26,450 --> 00:54:27,750 using legal moves. 845 00:54:27,750 --> 00:54:28,420 So we're done. 846 00:54:28,420 --> 00:54:30,290 So the proof of the theorem-- by now, 847 00:54:30,290 --> 00:54:34,200 it's short, because we did four lemmas, a corollary, and lots 848 00:54:34,200 --> 00:54:34,790 of argument. 849 00:54:38,850 --> 00:54:43,010 Could you have solved the puzzle if I allow the blank to be 850 00:54:43,010 --> 00:54:46,680 somewhere else at the end? 851 00:54:46,680 --> 00:54:48,250 Is the puzzle solvable then? 852 00:54:51,180 --> 00:54:52,250 No. 853 00:54:52,250 --> 00:54:52,790 Why not? 854 00:54:55,770 --> 00:54:58,105 Doesn't impact the parity at all, so you can't do that. 855 00:55:04,450 --> 00:55:06,300 Again, the idea here-- and you'll 856 00:55:06,300 --> 00:55:08,850 get some practice in homework-- is 857 00:55:08,850 --> 00:55:12,140 you're looking for a property that holds at the beginning, 858 00:55:12,140 --> 00:55:15,400 is preserved by every step, but is not 859 00:55:15,400 --> 00:55:19,190 present in the target state. 860 00:55:19,190 --> 00:55:22,980 Now actually, this puzzle was enormously popular 861 00:55:22,980 --> 00:55:25,260 in the late 1880s. 862 00:55:25,260 --> 00:55:29,260 In fact there was $1,000 prize offered for anybody 863 00:55:29,260 --> 00:55:31,640 who could solve the larger version. 864 00:55:31,640 --> 00:55:34,310 Back then, it was the 15 puzzle, which you can still 865 00:55:34,310 --> 00:55:37,740 buy today-- same problem on a 4 by 4 grid-- 866 00:55:37,740 --> 00:55:39,150 exactly the same problem. 867 00:55:39,150 --> 00:55:40,470 A pair is out of order. 868 00:55:40,470 --> 00:55:42,430 You've got to get them in order. 869 00:55:42,430 --> 00:55:44,510 You can't do it. 870 00:55:44,510 --> 00:55:46,460 Now, the proof you can't do it is 871 00:55:46,460 --> 00:55:50,210 a little harder-- same idea-- one extra idea 872 00:55:50,210 --> 00:55:52,570 in it-- one extra lemma. 873 00:55:52,570 --> 00:55:54,080 And that's for homework. 874 00:55:54,080 --> 00:55:56,700 So you'll go through and see exactly the structure 875 00:55:56,700 --> 00:55:59,360 with one extra little trick it. 876 00:55:59,360 --> 00:56:02,177 But back then, I guess most people didn't-- of course, 877 00:56:02,177 --> 00:56:04,010 most people didn't realize it wasn't doable. 878 00:56:04,010 --> 00:56:06,250 So they could offer this price safely. 879 00:56:06,250 --> 00:56:11,130 $1,000 then is probably worth a quarter million dollars today. 880 00:56:11,130 --> 00:56:13,440 Any questions on the eight puzzle? 881 00:56:13,440 --> 00:56:15,624 Yeah. 882 00:56:15,624 --> 00:56:19,261 AUDIENCE: The inductive steps-- when 883 00:56:19,261 --> 00:56:23,064 you said, "by inductive hypothesis," [INAUDIBLE] parity 884 00:56:23,064 --> 00:56:27,465 after, shouldn't the first term be M0? 885 00:56:27,465 --> 00:56:28,340 PROFESSOR: Let's see. 886 00:56:28,340 --> 00:56:31,250 No, the first move is M1. 887 00:56:31,250 --> 00:56:33,410 The second is M2. 888 00:56:33,410 --> 00:56:36,859 Now, when I talk about zero moves, 889 00:56:36,859 --> 00:56:38,400 that means no moves are taking place. 890 00:56:38,400 --> 00:56:39,970 I'm still in the start state. 891 00:56:39,970 --> 00:56:42,920 So a move is a transition between states. 892 00:56:42,920 --> 00:56:44,160 So you could have state 0. 893 00:56:44,160 --> 00:56:45,556 That's the start state. 894 00:56:45,556 --> 00:56:49,685 State one would be the move after move one. 895 00:56:49,685 --> 00:56:50,810 Have I got that right here? 896 00:56:50,810 --> 00:56:56,550 So the inductive step, I need to show P0 zero implies P1. 897 00:56:56,550 --> 00:56:59,070 P1 implies P2, and so forth. 898 00:56:59,070 --> 00:57:03,620 And P n is the parity of inversions after n moves. 899 00:57:06,200 --> 00:57:07,670 So you could have state s0. 900 00:57:07,670 --> 00:57:12,835 We didn't label the states here, but you could have state s0. 901 00:57:12,835 --> 00:57:13,817 Yeah. 902 00:57:13,817 --> 00:57:17,499 AUDIENCE: So in this problem, we assume that everything should 903 00:57:17,499 --> 00:57:20,830 be defined as rows or columns. 904 00:57:20,830 --> 00:57:25,454 How do we know when the assumptions are valid? 905 00:57:25,454 --> 00:57:26,870 PROFESSOR: That's a good question. 906 00:57:26,870 --> 00:57:31,071 OK, so really, there's two cases. 907 00:57:31,071 --> 00:57:32,570 To be really precise, we should have 908 00:57:32,570 --> 00:57:35,510 argued there's only two types of moves, a row move and a column 909 00:57:35,510 --> 00:57:36,037 move. 910 00:57:36,037 --> 00:57:38,620 And in fact, if you look at what can move into a blank square, 911 00:57:38,620 --> 00:57:40,919 there's four guys that can do it-- the guy above, 912 00:57:40,919 --> 00:57:43,460 the guy to the right, the guy to the left, and the guy below. 913 00:57:43,460 --> 00:57:45,549 Two of those are row moves, two are columns. 914 00:57:45,549 --> 00:57:47,590 So that's right-- to really pin down the details, 915 00:57:47,590 --> 00:57:50,696 we should have checked those are the only two possible moves. 916 00:57:50,696 --> 00:57:53,320 And if there was a third kind of move that I hadn't considered, 917 00:57:53,320 --> 00:57:55,860 this proof would be bogus. 918 00:57:55,860 --> 00:57:58,290 That's a good question. 919 00:57:58,290 --> 00:57:59,141 Any other questions? 920 00:58:02,230 --> 00:58:04,880 OK. 921 00:58:04,880 --> 00:58:07,142 Now, I think probably, you see why 922 00:58:07,142 --> 00:58:08,350 the invariants are important. 923 00:58:08,350 --> 00:58:12,290 But say that someday, you're building software 924 00:58:12,290 --> 00:58:14,762 to run a nuclear reactor. 925 00:58:14,762 --> 00:58:16,470 Now, there's a certain state you'd really 926 00:58:16,470 --> 00:58:19,530 like to avoid-- meltdown. 927 00:58:19,530 --> 00:58:21,310 And you'd like to be able to prove 928 00:58:21,310 --> 00:58:25,220 that, in any sequence of moves that happen in your reactor 929 00:58:25,220 --> 00:58:28,800 program, you never reach the meltdown state. 930 00:58:28,800 --> 00:58:31,160 Well you'd use invariants to do that. 931 00:58:31,160 --> 00:58:34,950 Or if you're building software for an airplane, 932 00:58:34,950 --> 00:58:37,400 you'd like to never reach the crash state. 933 00:58:37,400 --> 00:58:39,860 Or if you're building a radiation device, 934 00:58:39,860 --> 00:58:44,330 you never want to get in the state that fries the patient. 935 00:58:44,330 --> 00:58:48,425 So this is an important notion. 936 00:58:48,425 --> 00:58:49,800 So for the rest of the day, we're 937 00:58:49,800 --> 00:58:52,470 going to talk about a different kind of induction 938 00:58:52,470 --> 00:58:55,390 called strong induction. 939 00:58:55,390 --> 00:58:58,020 It's very similar to ordinary induction, 940 00:58:58,020 --> 00:59:02,970 but it's a little easier to use when solving certain problems. 941 00:59:02,970 --> 00:59:05,820 Now like regular induction, strong induction 942 00:59:05,820 --> 00:59:07,908 can be expressed with an axiom. 943 00:59:12,490 --> 00:59:14,594 So let me show you the strong induction axiom. 944 00:59:44,420 --> 00:59:46,420 You have a predicate, P n, like before. 945 00:59:54,570 --> 01:00:04,840 If P0 is true-- your base case-- and for all n, 946 01:00:04,840 --> 01:00:10,330 it's not P n implies P n plus 1, it's P0 and P1 947 01:00:10,330 --> 01:00:19,430 and dot, dot, dot, and P n are all true, then P n plus 1. 948 01:00:19,430 --> 01:00:29,242 If this is true for all n, then P n is true for all n. 949 01:00:38,410 --> 01:00:41,470 Now, the only difference between strong induction 950 01:00:41,470 --> 01:00:46,380 and ordinary induction that we did last time is this part. 951 01:00:49,460 --> 01:00:52,220 In ordinary induction, you're showing 952 01:00:52,220 --> 01:00:54,830 that P n implies P n plus 1. 953 01:00:54,830 --> 01:00:58,360 In strong induction, you're showing that all these facts 954 01:00:58,360 --> 01:01:02,880 put together imply P n plus 1. 955 01:01:02,880 --> 01:01:04,810 Now, to show implication, remember, 956 01:01:04,810 --> 01:01:08,234 you get to assume that all these things are true. 957 01:01:08,234 --> 01:01:10,150 So you know how in ordinary induction, we say, 958 01:01:10,150 --> 01:01:13,890 "assume P n is true and you're going to prove P n plus 1?" 959 01:01:13,890 --> 01:01:17,440 In strong induction, you get to say, "assume P n is true, 960 01:01:17,440 --> 01:01:20,070 P n minus 1 is true, dot, dot, dot, P1 is true, 961 01:01:20,070 --> 01:01:21,840 and P0 is true. 962 01:01:21,840 --> 01:01:24,650 You get to assume a lot more. 963 01:01:24,650 --> 01:01:26,810 So it's a stronger proof technique, 964 01:01:26,810 --> 01:01:30,520 because it allows you to do more-- or so you would think. 965 01:01:30,520 --> 01:01:34,162 Now in fact, any proof you can do with strong induction, 966 01:01:34,162 --> 01:01:35,620 you can do with ordinary induction. 967 01:01:35,620 --> 01:01:36,990 It just might be harder. 968 01:01:36,990 --> 01:01:38,600 So you can't prove any more with it, 969 01:01:38,600 --> 01:01:40,300 but it makes your proofs much easier. 970 01:01:40,300 --> 01:01:42,133 And we're going to do an example in a minute 971 01:01:42,133 --> 01:01:44,320 where the proof is much easier by getting 972 01:01:44,320 --> 01:01:47,330 to assume all of these things are true in order 973 01:01:47,330 --> 01:01:50,880 to prove P n plus 1. 974 01:01:50,880 --> 01:01:53,990 Are there any questions about the difference here 975 01:01:53,990 --> 01:01:57,150 with strong induction-- that now you get to assume all these 976 01:01:57,150 --> 01:02:01,910 are true as part of the inductive step? 977 01:02:01,910 --> 01:02:02,410 All right. 978 01:02:04,930 --> 01:02:07,410 Our first example of a strong induction 979 01:02:07,410 --> 01:02:10,210 is going to be a simple game. 980 01:02:10,210 --> 01:02:13,380 We've got a stack of eight blocks here. 981 01:02:13,380 --> 01:02:15,680 Now, in this game, what you're going to do 982 01:02:15,680 --> 01:02:21,490 is divide the stack into two sub-stacks. 983 01:02:21,490 --> 01:02:25,470 So I just took eight, and split it into three and five. 984 01:02:25,470 --> 01:02:30,390 For that move, you get 15 points-- 3 times 5. 985 01:02:30,390 --> 01:02:31,490 Let's write that down. 986 01:02:45,370 --> 01:02:47,450 OK, so this is called the Unstacking Game. 987 01:02:54,810 --> 01:03:02,140 And in the first move, we went 8 split to 5 and 3. 988 01:03:02,140 --> 01:03:03,940 And that's worth 15 points. 989 01:03:06,850 --> 01:03:12,100 Now in the next move, I'm going to split the stack of five 990 01:03:12,100 --> 01:03:14,160 into four and one. 991 01:03:14,160 --> 01:03:16,760 And for that, you get 4 points-- 4 times 1. 992 01:03:21,230 --> 01:03:26,610 And I keep on going until I have a stacks of height one. 993 01:03:26,610 --> 01:03:29,270 And the last move, I'll be splitting a two into two ones. 994 01:03:29,270 --> 01:03:30,810 That'll give me one point. 995 01:03:30,810 --> 01:03:35,080 Then I add up all the points, and that's your score. 996 01:03:35,080 --> 01:03:38,630 And the goal is to get the most number of points 997 01:03:38,630 --> 01:03:41,200 when you add up the entire score. 998 01:03:41,200 --> 01:03:45,730 Now, just so this game is clear, we're going to play it. 999 01:03:45,730 --> 01:03:48,049 And I'm going to raise the stakes here. 1000 01:03:48,049 --> 01:03:49,590 What we're going to do is we're going 1001 01:03:49,590 --> 01:03:51,980 to have a competition between three members 1002 01:03:51,980 --> 01:03:55,610 of the class and the TAs. 1003 01:03:55,610 --> 01:04:00,020 Now, if the class team wins-- they get more points-- 1004 01:04:00,020 --> 01:04:02,720 we're going to give everybody in the class candy. 1005 01:04:02,720 --> 01:04:06,340 And I've got lots of candy here. 1006 01:04:06,340 --> 01:04:09,668 If the TAs beat you, they get the candy. 1007 01:04:09,668 --> 01:04:11,610 AUDIENCE: What if it's a tie? 1008 01:04:11,610 --> 01:04:13,679 PROFESSOR: We'll figure that out. 1009 01:04:13,679 --> 01:04:14,720 We'll come to that later. 1010 01:04:14,720 --> 01:04:16,140 But you want to win this thing. 1011 01:04:16,140 --> 01:04:18,216 So I need some volunteers from the class 1012 01:04:18,216 --> 01:04:19,340 who think they can do well. 1013 01:04:19,340 --> 01:04:21,030 Yeah, come on down. 1014 01:04:21,030 --> 01:04:23,740 You two guys come on down. 1015 01:04:23,740 --> 01:04:25,000 All right, TAs come on up. 1016 01:04:30,030 --> 01:04:31,760 Now, I want you to make some noise 1017 01:04:31,760 --> 01:04:35,796 if you think your three class reps here can beat the TAs. 1018 01:04:35,796 --> 01:04:38,102 [CHEERS AND APPLAUSE] 1019 01:04:38,102 --> 01:04:40,970 All right, how many people-- make some noise you 1020 01:04:40,970 --> 01:04:42,540 think the TAs are going to win. 1021 01:04:42,540 --> 01:04:43,212 AUDIENCE: Ooh. 1022 01:04:43,212 --> 01:04:44,420 PROFESSOR: Ooh, that's nasty. 1023 01:04:44,420 --> 01:04:47,180 It must've been a rough recitation last week 1024 01:04:47,180 --> 01:04:48,930 on Wednesday. 1025 01:04:48,930 --> 01:04:50,884 All right, so let's see. 1026 01:04:50,884 --> 01:04:52,800 I think we're going to let the class go first. 1027 01:04:52,800 --> 01:04:54,160 This is your stack. 1028 01:04:54,160 --> 01:04:56,270 Now think about what move you want to make first, 1029 01:04:56,270 --> 01:04:57,750 because that matters. 1030 01:04:57,750 --> 01:05:00,630 And you guys can give them some advice if you want, 1031 01:05:00,630 --> 01:05:02,887 as to the move they should make first. 1032 01:05:02,887 --> 01:05:04,470 And I'm going to keep score over here. 1033 01:05:08,820 --> 01:05:11,070 Oh, OK, they went for the maximum move. 1034 01:05:11,070 --> 01:05:11,580 That's good. 1035 01:05:11,580 --> 01:05:16,160 They realized 4 times 4 is 16-- very good. 1036 01:05:16,160 --> 01:05:19,705 So let's write that up here. 1037 01:05:19,705 --> 01:05:23,380 You're Off to a good start. 1038 01:05:23,380 --> 01:05:25,370 In fact, that's the maximum number of points 1039 01:05:25,370 --> 01:05:28,720 for the first move, I think-- good job. 1040 01:05:32,320 --> 01:05:36,490 All right, so here's the class here. 1041 01:05:36,490 --> 01:05:37,640 And here are the TAs. 1042 01:05:40,620 --> 01:05:48,135 And the class went 8 into 4 by 4, and they got 16. 1043 01:05:51,030 --> 01:05:55,340 Now, the TAs are working hard here, as you can see. 1044 01:05:55,340 --> 01:05:56,890 And they've got a move. 1045 01:05:56,890 --> 01:05:59,910 That's a pretty pathetic first move for the TAs. 1046 01:05:59,910 --> 01:06:03,230 Looking good for the candy for you guys. 1047 01:06:03,230 --> 01:06:06,980 They got 7 points for the TAs. 1048 01:06:06,980 --> 01:06:09,672 Class, what would you like to do for your next move? 1049 01:06:09,672 --> 01:06:10,588 AUDIENCE: [INAUDIBLE]. 1050 01:06:16,220 --> 01:06:19,274 PROFESSOR: You can't start over now-- too late for that. 1051 01:06:19,274 --> 01:06:22,000 [SIDE CONVERSATION] 1052 01:06:22,000 --> 01:06:24,140 A lot of people counting on you guys. 1053 01:06:24,140 --> 01:06:27,830 [SIDE CONVERSATION] 1054 01:06:27,830 --> 01:06:29,480 Oh, no, no, one at a time. 1055 01:06:29,480 --> 01:06:30,990 No, just one. 1056 01:06:30,990 --> 01:06:33,866 One stack gets split-- either one. 1057 01:06:33,866 --> 01:06:35,540 AUDIENCE: [INAUDIBLE]. 1058 01:06:35,540 --> 01:06:37,200 PROFESSOR: There you go. 1059 01:06:37,200 --> 01:06:39,668 Oh, well, what do you do now? 1060 01:06:39,668 --> 01:06:42,656 [SIDE CONVERSATION] 1061 01:06:42,656 --> 01:06:45,146 AUDIENCE: Their strategy's obviously better than ours. 1062 01:06:45,146 --> 01:06:46,142 AUDIENCE: Yeah, but we've figured it out already. 1063 01:06:46,142 --> 01:06:46,640 AUDIENCE: We're going to lose. 1064 01:06:46,640 --> 01:06:48,931 PROFESSOR: The TAs are convinced they're going to lose. 1065 01:06:48,931 --> 01:06:52,279 Three and one, OK, good, interesting. 1066 01:06:52,279 --> 01:06:53,320 So we have three and one. 1067 01:06:53,320 --> 01:06:56,110 That gives you 3 points. 1068 01:06:56,110 --> 01:06:58,000 All right, TAs, we need a move. 1069 01:07:02,090 --> 01:07:08,000 All right, so they've gone six and one-- 6 points. 1070 01:07:08,000 --> 01:07:13,330 Class, you think you're dead already? 1071 01:07:13,330 --> 01:07:17,130 So you've gotten three and one now, again, for 3. 1072 01:07:17,130 --> 01:07:18,160 So you're up to 22. 1073 01:07:18,160 --> 01:07:20,570 You're way ahead-- 22 to 13. 1074 01:07:20,570 --> 01:07:23,307 All right, TAs. 1075 01:07:23,307 --> 01:07:24,890 They look a little disorganized to me. 1076 01:07:24,890 --> 01:07:25,694 What do you think? 1077 01:07:25,694 --> 01:07:26,610 AUDIENCE: [INAUDIBLE]. 1078 01:07:29,190 --> 01:07:31,315 PROFESSOR: Another one-- you can tell where they're 1079 01:07:31,315 --> 01:07:32,970 headed here-- five and one. 1080 01:07:32,970 --> 01:07:33,792 They have 5 points. 1081 01:07:33,792 --> 01:07:34,500 They're up to 18. 1082 01:07:34,500 --> 01:07:37,300 They're 4 behind you. 1083 01:07:37,300 --> 01:07:39,146 All right, class. 1084 01:07:39,146 --> 01:07:43,640 All right, you got 2 points. 1085 01:07:43,640 --> 01:07:53,290 TAs-- you really think they know how to do this best? 1086 01:07:53,290 --> 01:07:53,854 I don't know. 1087 01:07:53,854 --> 01:07:54,770 AUDIENCE: [INAUDIBLE]. 1088 01:08:02,380 --> 01:08:04,890 PROFESSOR: Oh, big change in strategy there. 1089 01:08:08,500 --> 01:08:10,520 All that thinking, and that's what we got. 1090 01:08:10,520 --> 01:08:13,371 OK, 4 points. 1091 01:08:13,371 --> 01:08:13,870 Class. 1092 01:08:20,029 --> 01:08:22,939 All right, they pick up 2 more here. 1093 01:08:22,939 --> 01:08:27,620 The three just got split into two and one for 2 points. 1094 01:08:27,620 --> 01:08:28,370 How are you doing? 1095 01:08:28,370 --> 01:08:32,729 You've got 19, 22, 24, up to 26. 1096 01:08:32,729 --> 01:08:37,010 13, 18, 22-- you're still doing good. 1097 01:08:37,010 --> 01:08:38,180 TAs are behind. 1098 01:08:38,180 --> 01:08:40,221 Let's see what they've got up their sleeves here. 1099 01:08:43,210 --> 01:08:45,950 All right, they definitely have a strategy going here. 1100 01:08:45,950 --> 01:08:49,109 That's 3 points. 1101 01:08:49,109 --> 01:08:53,029 Ooh, there's not much option left for you guys. 1102 01:08:53,029 --> 01:08:53,851 Yeah. 1103 01:08:53,851 --> 01:08:54,813 [SIDE CONVERSATION] 1104 01:08:54,813 --> 01:08:57,699 AUDIENCE: Choose the right. 1105 01:08:57,699 --> 01:08:59,149 AUDIENCE: Air blocks. 1106 01:08:59,149 --> 01:09:01,964 PROFESSOR: No, no, no, that'll be a 0. 1107 01:09:05,240 --> 01:09:08,200 All right, that gave you a point-- two 1108 01:09:08,200 --> 01:09:11,580 went to one and one-- 1 point. 1109 01:09:11,580 --> 01:09:13,710 Not a lot of choice for you guys either, I guess. 1110 01:09:13,710 --> 01:09:15,418 There's only one way to split that stack. 1111 01:09:18,330 --> 01:09:22,010 All right, 2 points, and your final move 1112 01:09:22,010 --> 01:09:25,979 for the class and all the candy. 1113 01:09:25,979 --> 01:09:29,132 You get 1 more point. 1114 01:09:29,132 --> 01:09:30,340 Let's see what your total is. 1115 01:09:30,340 --> 01:09:34,670 You've got 22, 24, 26, 27, 28. 1116 01:09:34,670 --> 01:09:37,700 And the TAs are going to get one last move for the TAs. 1117 01:09:41,220 --> 01:09:44,339 All right, and you got 2, 1, 1, 2. 1118 01:09:44,339 --> 01:09:45,130 That's interesting. 1119 01:09:45,130 --> 01:09:55,682 1, 2, 3, 4, 5, 6, 7-- 7 times 8 over 2-- no, that's not right. 1120 01:09:55,682 --> 01:09:58,140 Did I do that right? 1121 01:09:58,140 --> 01:10:01,800 Oh, 28-- we got a tie. 1122 01:10:01,800 --> 01:10:04,160 Oh, geez. 1123 01:10:04,160 --> 01:10:05,660 I tell you what-- I'll give you guys 1124 01:10:05,660 --> 01:10:08,132 one more chance to start over. 1125 01:10:08,132 --> 01:10:08,840 You've seen that. 1126 01:10:08,840 --> 01:10:10,937 You've got to beat them. 1127 01:10:10,937 --> 01:10:11,520 You tied them. 1128 01:10:11,520 --> 01:10:12,840 You've got to beat them. 1129 01:10:12,840 --> 01:10:14,360 One more chance here. 1130 01:10:14,360 --> 01:10:16,472 [SIDE CONVERSATION] 1131 01:10:16,472 --> 01:10:17,680 You got to beat them, though. 1132 01:10:17,680 --> 01:10:18,574 You got 28. 1133 01:10:18,574 --> 01:10:19,490 You already tied them. 1134 01:10:19,490 --> 01:10:22,596 They came from behind and tied you. 1135 01:10:22,596 --> 01:10:25,380 You've got to beat them. 1136 01:10:25,380 --> 01:10:27,730 You got off to a good start, but then they caught up. 1137 01:10:27,730 --> 01:10:37,720 [SIDE CONVERSATION] 1138 01:10:37,720 --> 01:10:41,210 Now, your class reps had an interesting thought here. 1139 01:10:41,210 --> 01:10:44,325 They ask, is it possible that any strategy gives 28? 1140 01:10:47,160 --> 01:10:49,590 Hmm. 1141 01:10:49,590 --> 01:10:51,110 I wouldn't do that to you, would I? 1142 01:10:51,110 --> 01:10:53,082 [LAUGHTER] 1143 01:10:53,082 --> 01:10:56,670 Yeah, probably. 1144 01:10:56,670 --> 01:10:57,545 Any ideas? 1145 01:10:57,545 --> 01:11:01,110 Can you beat 28? 1146 01:11:01,110 --> 01:11:02,520 They're already eating the candy. 1147 01:11:06,770 --> 01:11:10,370 In fact, you can't beat 28. 1148 01:11:10,370 --> 01:11:12,310 And you can't do worse than 28, either. 1149 01:11:12,310 --> 01:11:14,399 Because every strategy gives 28. 1150 01:11:14,399 --> 01:11:16,690 So I guess we're going to have to throw it to the class 1151 01:11:16,690 --> 01:11:20,270 to vote who should get the candy. 1152 01:11:20,270 --> 01:11:23,174 So if you think your reps really should win this 1153 01:11:23,174 --> 01:11:25,090 and you should get the candy, make some noise. 1154 01:11:25,090 --> 01:11:28,400 [CHEERS AND APPLAUSE] 1155 01:11:28,400 --> 01:11:31,871 If you think your TAs should get the candy make some noise. 1156 01:11:31,871 --> 01:11:34,460 [CHEERS AND APPLAUSE] 1157 01:11:34,460 --> 01:11:36,342 All right, so you get the candy. 1158 01:11:36,342 --> 01:11:37,800 Here, help pass out the candy here. 1159 01:11:37,800 --> 01:11:39,970 We've got plenty of bags and baskets. 1160 01:11:39,970 --> 01:11:43,430 Take it all up on both sides, and pass it out. 1161 01:11:43,430 --> 01:11:47,430 [SIDE CONVERSATION] 1162 01:12:46,930 --> 01:12:50,180 OK, is everybody getting some candy up there? 1163 01:12:50,180 --> 01:12:51,680 We should have enough for everybody, 1164 01:12:51,680 --> 01:12:53,888 unless somebody got really hungry down here in front. 1165 01:12:59,170 --> 01:13:01,340 OK, so while you're doing that, let's 1166 01:13:01,340 --> 01:13:02,590 try to prove this theorem. 1167 01:13:16,130 --> 01:13:21,830 So the theorem is that all strategies for the n-block game 1168 01:13:21,830 --> 01:13:25,460 produce the same score. 1169 01:13:25,460 --> 01:13:26,765 It wasn't a coincidence for 8. 1170 01:13:31,900 --> 01:13:36,070 And the score, we'll call it S of n for the n-block game. 1171 01:13:36,070 --> 01:13:41,420 So for example, we're trying to show that S of 8 was 28. 1172 01:13:45,760 --> 01:13:47,380 So what strategy do you think we're 1173 01:13:47,380 --> 01:13:48,505 going to use for the proof? 1174 01:13:49,146 --> 01:13:50,270 AUDIENCE: Strong induction. 1175 01:13:50,270 --> 01:13:51,784 PROFESSOR: Strong induction-- so you 1176 01:13:51,784 --> 01:13:53,950 want to write that down-- proof by strong induction. 1177 01:14:02,110 --> 01:14:07,430 What's the next step in a proof by any kind of induction? 1178 01:14:07,430 --> 01:14:08,650 AUDIENCE: Base case. 1179 01:14:08,650 --> 01:14:11,230 PROFESSOR: Base case-- not yet. 1180 01:14:11,230 --> 01:14:12,230 AUDIENCE: The predicate. 1181 01:14:12,230 --> 01:14:15,880 PROFESSOR: The predicate-- what's the predicate here? 1182 01:14:15,880 --> 01:14:19,460 All right, so for the inductive hypothesis, 1183 01:14:19,460 --> 01:14:24,118 the predicate-- any guesses as to what P of n is going to be? 1184 01:14:24,118 --> 01:14:26,330 AUDIENCE: [INAUDIBLE]. 1185 01:14:26,330 --> 01:14:27,288 PROFESSOR: What's that? 1186 01:14:27,288 --> 01:14:31,070 AUDIENCE: n should be 2n minus 1 by 2. 1187 01:14:31,070 --> 01:14:33,280 PROFESSOR: Yeah, that's part of it, 1188 01:14:33,280 --> 01:14:36,680 but we're going to use this as a predicate to start with. 1189 01:14:36,680 --> 01:14:38,882 You've gone a step ahead there. 1190 01:14:38,882 --> 01:14:41,090 So I'm going to start with this as being a predicate, 1191 01:14:41,090 --> 01:14:43,150 because I'm trying to show they're all the same. 1192 01:14:43,150 --> 01:14:45,400 And I haven't figured out what the scores going to be. 1193 01:14:45,400 --> 01:14:47,970 But I think you're already on a good track here for what 1194 01:14:47,970 --> 01:14:50,410 the score is going to be. 1195 01:14:50,410 --> 01:14:51,948 Now we do the base case. 1196 01:14:58,430 --> 01:15:02,770 So we take n equals 1-- the one-block game. 1197 01:15:02,770 --> 01:15:05,130 S of 1 is 0. 1198 01:15:05,130 --> 01:15:06,170 We never took a move. 1199 01:15:06,170 --> 01:15:07,080 We never got a score. 1200 01:15:07,080 --> 01:15:08,150 There was only one block. 1201 01:15:08,150 --> 01:15:10,560 We ended before we started. 1202 01:15:10,560 --> 01:15:13,680 So that's OK. 1203 01:15:13,680 --> 01:15:15,235 And now we have the inductive step. 1204 01:15:18,660 --> 01:15:29,510 And here we get to assume P1, P2, all the way up to P n, 1205 01:15:29,510 --> 01:15:31,610 to prove P n plus 1. 1206 01:15:36,020 --> 01:15:41,791 And so now we look at n plus 1 blocks, 1207 01:15:41,791 --> 01:15:43,040 because that's we're starting. 1208 01:15:48,210 --> 01:15:51,890 So we have n plus 1, and we split it somehow. 1209 01:15:51,890 --> 01:15:53,500 And it could be any split. 1210 01:15:53,500 --> 01:15:57,700 We might have K on one side, then n plus 1 minus K 1211 01:15:57,700 --> 01:16:01,727 on the other side for any K between 1 and n. 1212 01:16:05,630 --> 01:16:08,660 And let's figure out our score for that scenario. 1213 01:16:12,600 --> 01:16:15,170 Well, we get the product of these numbers 1214 01:16:15,170 --> 01:16:18,060 for the first step. 1215 01:16:18,060 --> 01:16:24,100 We get K times n plus 1 minus K for the first step. 1216 01:16:24,100 --> 01:16:27,750 And then as we recurse, and we split up 1217 01:16:27,750 --> 01:16:31,300 that block of K blocks, how many points do we 1218 01:16:31,300 --> 01:16:34,030 get for splitting that all the way down? 1219 01:16:34,030 --> 01:16:34,900 AUDIENCE: P of K. 1220 01:16:34,900 --> 01:16:37,191 PROFESSOR: P of K, because that's the induction. 1221 01:16:37,191 --> 01:16:39,315 We assume that as part of the induction hypothesis. 1222 01:16:42,700 --> 01:16:45,080 And how many points do we get for splitting 1223 01:16:45,080 --> 01:16:46,260 this stack all the way down? 1224 01:16:48,940 --> 01:16:55,590 Yeah, P of n plus 1 minus K. 1225 01:16:55,590 --> 01:16:57,330 And you see why strong induction's 1226 01:16:57,330 --> 01:17:00,310 coming in handy here? 1227 01:17:00,310 --> 01:17:02,990 For the TA's strategy, K would be 1. 1228 01:17:02,990 --> 01:17:05,099 We know P of 1 is 0. 1229 01:17:05,099 --> 01:17:06,890 And you would just need ordinary induction. 1230 01:17:06,890 --> 01:17:08,760 This would be P of n. 1231 01:17:08,760 --> 01:17:11,300 But for a general strategy, it could be any split. 1232 01:17:11,300 --> 01:17:13,110 So we need to have all these assumed here. 1233 01:17:13,110 --> 01:17:18,330 It makes it much easier when using strong induction. 1234 01:17:18,330 --> 01:17:20,310 All right, so this is our total score 1235 01:17:20,310 --> 01:17:23,180 for the game for n plus 1 blocks. 1236 01:17:23,180 --> 01:17:28,240 And we're trying to show it just depends on n, 1237 01:17:28,240 --> 01:17:33,149 and that it doesn't depend on K. Does that depend on K? 1238 01:17:38,030 --> 01:17:40,210 Looks like it to me, right? 1239 01:17:40,210 --> 01:17:44,020 I got K in every single term. 1240 01:17:44,020 --> 01:17:44,740 So I'm not there. 1241 01:17:44,740 --> 01:17:45,240 I'm stuck. 1242 01:17:47,720 --> 01:17:48,939 You see why I'm stuck? 1243 01:17:48,939 --> 01:17:51,230 Because I'd like to be able to say that the score I get 1244 01:17:51,230 --> 01:17:54,120 for the n plus one block game-- this 1245 01:17:54,120 --> 01:17:58,520 is S n plus 1-- is the same for any sequence of moves. 1246 01:17:58,520 --> 01:18:02,260 It doesn't even depend on K. But I can't do that. 1247 01:18:02,260 --> 01:18:05,310 What do you do when you're stuck with an induction proof? 1248 01:18:05,310 --> 01:18:06,460 What's one of the tricks? 1249 01:18:06,460 --> 01:18:07,584 AUDIENCE: Make it stronger. 1250 01:18:07,584 --> 01:18:09,800 PROFESSOR: Make it stronger, which 1251 01:18:09,800 --> 01:18:13,360 means I get a stronger induction hypothesis. 1252 01:18:13,360 --> 01:18:17,030 Now, somebody gave me one up there before. 1253 01:18:17,030 --> 01:18:19,196 How could I strengthen my induction hypothesis here? 1254 01:18:22,052 --> 01:18:23,960 AUDIENCE: [INAUDIBLE]. 1255 01:18:23,960 --> 01:18:27,320 PROFESSOR: Give the formula for S n-- that 1256 01:18:27,320 --> 01:18:28,360 would make it stronger. 1257 01:18:28,360 --> 01:18:30,140 I tell you what it is. 1258 01:18:30,140 --> 01:18:32,760 What's a good guess for the formula here? 1259 01:18:32,760 --> 01:18:33,700 AUDIENCE: Factorial. 1260 01:18:33,700 --> 01:18:41,580 PROFESSOR: Factorial-- Well, is S of 8 equal 8 factorial? 1261 01:18:41,580 --> 01:18:44,234 No, not so good. 1262 01:18:44,234 --> 01:18:46,631 [SIDE CONVERSATION] 1263 01:18:46,631 --> 01:18:48,130 AUDIENCE: n equals n minus 1 over 2. 1264 01:18:48,130 --> 01:18:51,510 PROFESSOR: Yeah, that's a better guess-- 1265 01:18:51,510 --> 01:18:56,160 equals n times n minus 1 over 2. 1266 01:18:56,160 --> 01:18:59,750 And in fact, what's 8 times 7 over 2? 1267 01:18:59,750 --> 01:19:00,330 It's 28. 1268 01:19:00,330 --> 01:19:01,770 It works here. 1269 01:19:01,770 --> 01:19:02,770 Let's check another one. 1270 01:19:02,770 --> 01:19:04,520 What's S of 2? 1271 01:19:07,171 --> 01:19:07,670 AUDIENCE: 1. 1272 01:19:07,670 --> 01:19:12,740 PROFESSOR: 1-- well, 2 times 1 over 2-- it works. 1273 01:19:12,740 --> 01:19:14,690 What's S of 3? 1274 01:19:17,600 --> 01:19:21,130 2 the first move, then 1 more. 1275 01:19:21,130 --> 01:19:26,340 3-- 3 times 2 over 2 is 3-- looks good. 1276 01:19:26,340 --> 01:19:28,430 So now I've got a stronger induction hypothesis. 1277 01:19:28,430 --> 01:19:30,220 Not only is it always the same, it 1278 01:19:30,220 --> 01:19:33,710 is that number is your score. 1279 01:19:33,710 --> 01:19:35,190 Let's see if that works. 1280 01:19:35,190 --> 01:19:38,000 Let's plug that in now. 1281 01:19:38,000 --> 01:19:40,560 So base case-- let's check it out-- 1282 01:19:40,560 --> 01:19:47,520 is 1 times 1 minus 1 over 2 equal to 0. 1283 01:19:47,520 --> 01:19:49,750 Yes. 1284 01:19:49,750 --> 01:19:53,040 Let's plug it in here now. 1285 01:19:53,040 --> 01:19:58,570 P of K would be now K, K minus 1 over 2. 1286 01:19:58,570 --> 01:20:08,220 This would be n plus 1 minus K, n minus K over 2 plus this one 1287 01:20:08,220 --> 01:20:08,720 here. 1288 01:20:12,140 --> 01:20:15,850 All right, I've got to add all these things up, and see 1289 01:20:15,850 --> 01:20:19,473 if it equals that expression for n plus 1. 1290 01:20:19,473 --> 01:20:20,435 Let's do that. 1291 01:20:23,330 --> 01:20:29,780 All right, I get 2 K n plus 2 K minus 2 K squared. 1292 01:20:29,780 --> 01:20:34,920 I'm putting all this over 2-- one giant mess over 2 here-- 1293 01:20:34,920 --> 01:20:43,120 plus K squared minus K plus n squared. 1294 01:20:43,120 --> 01:20:52,940 Well, let's write it just as n plus 1 times n, minus K n, 1295 01:20:52,940 --> 01:20:57,860 minus K, minus K n, all over 2. 1296 01:20:57,860 --> 01:20:59,770 And now let's cancel. 1297 01:20:59,770 --> 01:21:04,420 Two K n's here cancel K n, K n. 1298 01:21:04,420 --> 01:21:12,310 2K cancels K and K. 2K squared minus 2 K squared 1299 01:21:12,310 --> 01:21:14,070 cancels K squared. 1300 01:21:14,070 --> 01:21:20,970 And I forgot, plus K squared from here and here. 1301 01:21:20,970 --> 01:21:25,040 So I'm left with n plus 1 times n over 2. 1302 01:21:25,040 --> 01:21:26,450 That is S n plus 1. 1303 01:21:29,080 --> 01:21:30,770 And the K disappears. 1304 01:21:30,770 --> 01:21:34,740 We've established, now, the stronger induction hypothesis. 1305 01:21:34,740 --> 01:21:38,980 So not only did we prove that every set of unstackings 1306 01:21:38,980 --> 01:21:40,960 gives you the same score. 1307 01:21:40,960 --> 01:21:46,010 We proved the score is, for n blocks, n times n minus 1 1308 01:21:46,010 --> 01:21:46,570 over 2. 1309 01:21:49,787 --> 01:21:51,620 That's was pretty good for strong induction. 1310 01:21:51,620 --> 01:21:53,710 It lets you do some pretty powerful things. 1311 01:21:53,710 --> 01:21:56,820 OK, very good, that's it for today.