1 00:00:00,080 --> 00:00:02,430 The following content is provided under a Creative 2 00:00:02,430 --> 00:00:03,810 Commons license. 3 00:00:03,810 --> 00:00:06,060 Your support will help MIT OpenCourseWare 4 00:00:06,060 --> 00:00:10,150 continue to offer high quality educational resources for free. 5 00:00:10,150 --> 00:00:12,690 To make a donation or to view additional materials 6 00:00:12,690 --> 00:00:16,600 from hundreds of MIT courses, visit MIT OpenCourseWare 7 00:00:16,600 --> 00:00:17,305 at ocw.mit.edu. 8 00:00:26,650 --> 00:00:28,820 ERIK DEMAINE: Welcome back to 6.890. 9 00:00:28,820 --> 00:00:33,160 Today will be our last lecture about pure 3SAT, so to speak, 10 00:00:33,160 --> 00:00:35,440 and we'll be focusing in particular on circuit 11 00:00:35,440 --> 00:00:37,240 SAT today. 12 00:00:37,240 --> 00:00:39,620 But before we get started with more reductions, 13 00:00:39,620 --> 00:00:46,390 I want to highlight two styles of 3SAT proofs that we've seen. 14 00:00:46,390 --> 00:00:49,030 This is orthogonal to the circuit perspective 15 00:00:49,030 --> 00:00:51,350 versus logic perspective. 16 00:00:54,110 --> 00:00:56,740 And I think it's interesting to highlight the two 17 00:00:56,740 --> 00:00:58,920 different approaches. 18 00:00:58,920 --> 00:01:04,450 So approach one I'm going to call dual rail logic. 19 00:01:04,450 --> 00:01:05,950 These are not the usual names. 20 00:01:05,950 --> 00:01:07,260 We're making up names here. 21 00:01:07,260 --> 00:01:11,140 There aren't really names for these types of reductions. 22 00:01:11,140 --> 00:01:14,825 And the other type I'm going to call binary logic. 23 00:01:18,180 --> 00:01:25,590 These names come from actual circuit stuff, real hardware. 24 00:01:25,590 --> 00:01:28,930 So for example, all the Nintendo proofs we saw 25 00:01:28,930 --> 00:01:31,780 are in the style of what I would call dual rail 26 00:01:31,780 --> 00:01:35,770 logic because the variables have two outputs. 27 00:01:35,770 --> 00:01:38,120 And the idea is that this one is activated 28 00:01:38,120 --> 00:01:40,080 when x is set to true. 29 00:01:40,080 --> 00:01:42,130 This one is activated when not x is set to true 30 00:01:42,130 --> 00:01:45,050 or x is set to false. 31 00:01:45,050 --> 00:01:47,240 Never should both of them be activated. 32 00:01:47,240 --> 00:01:49,310 So you have a separate rail, separate line 33 00:01:49,310 --> 00:01:51,180 for the true case, and a separate line 34 00:01:51,180 --> 00:01:54,110 for the false case. 35 00:01:54,110 --> 00:01:57,520 And this is usually called the variable gadget that does that. 36 00:02:11,430 --> 00:02:14,100 And I'm going to make up some more terminology. 37 00:02:14,100 --> 00:02:21,050 I'll call this semi-wires to distinguish from wires. 38 00:02:21,050 --> 00:02:28,560 So over here in the binary logic case, 39 00:02:28,560 --> 00:02:30,470 this is sort of a half of a distinction. 40 00:02:30,470 --> 00:02:31,470 It's a semi-distinction. 41 00:02:40,380 --> 00:02:43,660 This is my attempt to unify things slightly. 42 00:02:50,140 --> 00:02:53,000 So the idea is that these semi-wires, either they 43 00:02:53,000 --> 00:02:57,020 get activated, or they don't get activated at all. 44 00:02:57,020 --> 00:03:00,570 In the unactivated case, nothing happens to them. 45 00:03:00,570 --> 00:03:03,360 So they're not really interesting. 46 00:03:03,360 --> 00:03:05,160 In the binary logic case, the idea 47 00:03:05,160 --> 00:03:08,649 is that the wire gadget is active in all situations, 48 00:03:08,649 --> 00:03:10,440 but it can be active in two different ways. 49 00:03:10,440 --> 00:03:12,690 You can either set it to the true state 50 00:03:12,690 --> 00:03:14,240 or you can set it to the false state, 51 00:03:14,240 --> 00:03:18,080 and it represents both sort of in one wire. 52 00:03:18,080 --> 00:03:20,640 Now, this distinction is going to get a little bit of egg. 53 00:03:20,640 --> 00:03:24,090 But we saw an example of this kind of proof 54 00:03:24,090 --> 00:03:25,850 when we were talking about crease pattern, 55 00:03:25,850 --> 00:03:28,610 flat foldability, and p hardness. 56 00:03:28,610 --> 00:03:31,130 The wire was the pleat, and the pleat 57 00:03:31,130 --> 00:03:33,210 could be folded one way or the other. 58 00:03:33,210 --> 00:03:36,370 But either way, the information is right here, 59 00:03:36,370 --> 00:03:40,180 and the same wire gets put into this gadget 60 00:03:40,180 --> 00:03:42,400 whether you're true or false. 61 00:03:42,400 --> 00:03:45,890 Whereas over here you're connecting to this clause 62 00:03:45,890 --> 00:03:51,060 only the true half wire or semi-wire goes to this clause. 63 00:03:51,060 --> 00:03:55,160 The false one goes to this clause and to this clause. 64 00:03:55,160 --> 00:03:57,720 So there's a distinction between here 65 00:03:57,720 --> 00:03:59,419 where the wire's been split in half, 66 00:03:59,419 --> 00:04:00,960 and here where it's all in one place, 67 00:04:00,960 --> 00:04:05,961 and the wire goes to the gadget whether it's a true or false. 68 00:04:05,961 --> 00:04:09,600 I think that's what I wanted to say. 69 00:04:09,600 --> 00:04:12,830 My main intent here is to highlight what kind of gadgets 70 00:04:12,830 --> 00:04:14,470 you need. 71 00:04:14,470 --> 00:04:18,320 So we have a wire gadget on this side, 72 00:04:18,320 --> 00:04:20,399 a variable gadget on this side. 73 00:04:20,399 --> 00:04:27,880 For binary logic you also need a splitter or a split gadget 74 00:04:27,880 --> 00:04:29,190 to make copies of the wire. 75 00:04:34,080 --> 00:04:35,850 So the idea is you have one wire coming 76 00:04:35,850 --> 00:04:38,280 in, there's some magic split gadget which 77 00:04:38,280 --> 00:04:42,370 makes two wires or three wires, whatever, coming out. 78 00:04:42,370 --> 00:04:44,760 So then you can repeat split however many times 79 00:04:44,760 --> 00:04:47,600 that variable occurs. 80 00:04:47,600 --> 00:04:50,160 You can make a copy. 81 00:04:50,160 --> 00:04:53,800 In the non-monotone versions of 3SAT 82 00:04:53,800 --> 00:05:00,800 you may also need a negation or not gadget. 83 00:05:00,800 --> 00:05:04,260 If you need negation, then you'll need a negation gadget. 84 00:05:04,260 --> 00:05:09,000 In some cases you also need a terminator gadget 85 00:05:09,000 --> 00:05:10,095 in this perspective. 86 00:05:15,060 --> 00:05:23,160 A terminator gadget is just the end of a wire, you might say. 87 00:05:23,160 --> 00:05:25,570 So if you want to just not use a wire, 88 00:05:25,570 --> 00:05:28,240 then you would put a terminator gadget. 89 00:05:28,240 --> 00:05:30,980 And the idea of the terminator gadget is it leaves it free, 90 00:05:30,980 --> 00:05:34,520 leaves the wire free to choose true or false. 91 00:05:34,520 --> 00:05:38,837 Now, sometimes you can get away without a terminator gadget. 92 00:05:38,837 --> 00:05:40,420 For example, if each of your variables 93 00:05:40,420 --> 00:05:44,944 occurs exactly four times, then you can just use two splitters, 94 00:05:44,944 --> 00:05:46,610 make four copies, and then connect those 95 00:05:46,610 --> 00:05:50,340 directly to the clauses, maybe with some negations. 96 00:05:50,340 --> 00:05:52,340 So in that case, you wouldn't need a terminator. 97 00:05:52,340 --> 00:05:53,860 Over here we're using a terminator 98 00:05:53,860 --> 00:05:55,984 in a certain sense, which is the edge of the paper. 99 00:05:55,984 --> 00:05:59,380 If a wire goes to the edge of the paper it becomes free. 100 00:05:59,380 --> 00:06:01,344 So that's sort of the terminator gadget here. 101 00:06:01,344 --> 00:06:02,760 Though we didn't make explicit, it 102 00:06:02,760 --> 00:06:05,435 was part of this overall plan. 103 00:06:09,260 --> 00:06:15,710 In both cases, in one and two, you probably 104 00:06:15,710 --> 00:06:21,790 need something like a turn gadget 105 00:06:21,790 --> 00:06:23,720 and maybe a crossover gadget. 106 00:06:30,070 --> 00:06:32,380 We've seen these in various forms. 107 00:06:32,380 --> 00:06:36,210 In this case, the turn gadget was very explicit. 108 00:06:36,210 --> 00:06:38,530 I mean it was also a splitter and also in negator, 109 00:06:38,530 --> 00:06:40,610 but in particular, it changed the angle, 110 00:06:40,610 --> 00:06:43,470 and we needed that in order to take this truth value 111 00:06:43,470 --> 00:06:48,936 and send it up to clause and aim everything right. 112 00:06:48,936 --> 00:06:50,310 And in general, if you were doing 113 00:06:50,310 --> 00:06:52,410 any kind of embedding into two dimensions, 114 00:06:52,410 --> 00:06:53,910 you're probably going to need a turn 115 00:06:53,910 --> 00:06:58,480 gadget so you can move your wires or semi-wires around. 116 00:06:58,480 --> 00:07:00,800 A lot of the time people might call this also a wire, 117 00:07:00,800 --> 00:07:02,590 so that's why. 118 00:07:02,590 --> 00:07:04,720 But I think it's useful to have a word 119 00:07:04,720 --> 00:07:08,170 to distinguish these kinds of wires which are only 120 00:07:08,170 --> 00:07:10,650 active or inactive, versus the wires which are always 121 00:07:10,650 --> 00:07:12,110 active but in two possible states. 122 00:07:14,710 --> 00:07:19,170 Hopefully that clarifies or makes more explicit the types 123 00:07:19,170 --> 00:07:22,810 of proofs we've seen so far. 124 00:07:22,810 --> 00:07:25,700 Now, today we're going to do a couple of circuit SAT 125 00:07:25,700 --> 00:07:29,030 proofs, which all of this applies to circuit SAT proofs, 126 00:07:29,030 --> 00:07:31,290 as well as SAT and 1 and 3SAT and that'll 127 00:07:31,290 --> 00:07:34,230 equals SAT, that'll equal 3SAT. 128 00:07:34,230 --> 00:07:37,060 Circuit SAT you're going to have-- I 129 00:07:37,060 --> 00:07:39,570 guess in principle you could do it dual rail 130 00:07:39,570 --> 00:07:41,700 logic or binary logic, although usually we 131 00:07:41,700 --> 00:07:47,040 probably think of them in this capacity in binary logic. 132 00:07:47,040 --> 00:07:49,840 And you're going to have wires. 133 00:07:49,840 --> 00:07:51,260 You still need splits because you 134 00:07:51,260 --> 00:07:53,300 need to be able to take the output of a gate 135 00:07:53,300 --> 00:07:56,750 and send it to multiple other gates. 136 00:07:56,750 --> 00:07:58,480 In addition to a not gadget, you're 137 00:07:58,480 --> 00:08:04,350 going to want some other universal logic gate. 138 00:08:04,350 --> 00:08:06,380 So we're going to talk about that in a bit 139 00:08:06,380 --> 00:08:07,525 after we see some examples. 140 00:08:10,730 --> 00:08:16,530 Our first example is called Akari or Light Up. 141 00:08:16,530 --> 00:08:23,010 This is another Nikoli puzzle like Sudoku and Numberlink 142 00:08:23,010 --> 00:08:24,770 we saw last time. 143 00:08:24,770 --> 00:08:29,440 So here's a sample input and a sample output. 144 00:08:29,440 --> 00:08:32,500 Ignore the black dots there. 145 00:08:32,500 --> 00:08:35,240 So you're given a grid. 146 00:08:35,240 --> 00:08:37,049 There's blank squares and there's 147 00:08:37,049 --> 00:08:39,940 obstacle squares where you're not allowed to put anything. 148 00:08:39,940 --> 00:08:43,110 Some of the obstacle squares may have a number between 0 and 4 149 00:08:43,110 --> 00:08:43,919 on them. 150 00:08:43,919 --> 00:08:47,940 And that number represents how many, among the four neighbors, 151 00:08:47,940 --> 00:08:50,570 edge neighbors of that square, how many of them 152 00:08:50,570 --> 00:08:52,640 should have a light? 153 00:08:52,640 --> 00:08:55,510 These blue circles are lights. 154 00:08:55,510 --> 00:08:58,590 OK, so like this one has zero lights in those four positions, 155 00:08:58,590 --> 00:09:02,670 this one has two, this one has four, that's forced, and so on. 156 00:09:02,670 --> 00:09:06,680 A lot of the cells are free, but whether you're lit or not. 157 00:09:06,680 --> 00:09:10,040 And then the rules are so you can 158 00:09:10,040 --> 00:09:12,050 think of a light as a rook in chess, 159 00:09:12,050 --> 00:09:15,240 so it can see everything horizontally in the same row, 160 00:09:15,240 --> 00:09:17,790 up to obstacles, and in the same column up to obstacles. 161 00:09:17,790 --> 00:09:22,510 So this guy, for example, lights this portion and this portion. 162 00:09:22,510 --> 00:09:27,650 This guy lights that portion, and the thing here, and so on. 163 00:09:27,650 --> 00:09:30,460 And the goal is, first of all, to light the entire board, 164 00:09:30,460 --> 00:09:35,480 so that's why it's all green, it's all lit in that way. 165 00:09:35,480 --> 00:09:39,020 And no two lights should like each other, because then it's 166 00:09:39,020 --> 00:09:40,086 too bright I guess. 167 00:09:40,086 --> 00:09:41,580 I don't know. 168 00:09:41,580 --> 00:09:44,650 So no two rooks can attack each other 169 00:09:44,650 --> 00:09:48,290 would be another perspective. 170 00:09:48,290 --> 00:09:49,610 I think those are the rules. 171 00:09:49,610 --> 00:09:52,650 So you've got to satisfy the number constraint. 172 00:09:52,650 --> 00:09:55,290 You can only place lights in the blank squares. 173 00:09:55,290 --> 00:09:58,470 You have to light everything, and they can't see each other. 174 00:09:58,470 --> 00:10:00,140 So this is a valid solution. 175 00:10:00,140 --> 00:10:02,490 This is puzzle one on the Nikoli website, 176 00:10:02,490 --> 00:10:04,337 and there's a ton more if you want to play. 177 00:10:04,337 --> 00:10:05,878 AUDIENCE: So you're saying they can't 178 00:10:05,878 --> 00:10:08,039 be in the same NOR column? 179 00:10:08,039 --> 00:10:10,080 PROFESSOR: I mean they can be in the same column, 180 00:10:10,080 --> 00:10:12,660 but they have to be separated by an obstacle. 181 00:10:12,660 --> 00:10:15,850 So they can't see each other within a sort of sub-column 182 00:10:15,850 --> 00:10:20,040 or within a sub-row as given by the obstacles. 183 00:10:20,040 --> 00:10:21,110 Cool. 184 00:10:21,110 --> 00:10:22,950 So that's the problem, and now we're 185 00:10:22,950 --> 00:10:26,120 going to prove that it's NP-complete. 186 00:10:26,120 --> 00:10:28,610 This is the nice proof because it's relatively simple 187 00:10:28,610 --> 00:10:32,180 and it illustrates a kind of circuit SAT and style 188 00:10:32,180 --> 00:10:34,390 reduction. 189 00:10:34,390 --> 00:10:38,030 So for starters, and I would say most SAT proofs, 190 00:10:38,030 --> 00:10:40,100 a good starting point is a wire gadget. 191 00:10:40,100 --> 00:10:42,900 You want to think about can I make some construction that 192 00:10:42,900 --> 00:10:45,280 has ideally exactly two solutions, one 193 00:10:45,280 --> 00:10:47,910 to represent true, one to represent false. 194 00:10:47,910 --> 00:10:51,840 So here are a variety of ways to do wires. 195 00:10:51,840 --> 00:10:53,960 And this is a fairly flexible kind of game. 196 00:10:53,960 --> 00:10:56,030 The basic one looks like this. 197 00:10:56,030 --> 00:10:59,120 Most of things are going to be obstacles to tie it down, make 198 00:10:59,120 --> 00:11:01,080 it easy to separate gadgets. 199 00:11:01,080 --> 00:11:03,617 But here we have two blanks squares, a one, 200 00:11:03,617 --> 00:11:05,450 two blank squares, a one, two blank squares. 201 00:11:05,450 --> 00:11:07,820 That's sort of a simple kind of wire 202 00:11:07,820 --> 00:11:12,830 because you know from this one, either x or x prime is a light. 203 00:11:12,830 --> 00:11:14,510 Exactly one of them is. 204 00:11:14,510 --> 00:11:16,860 So that forces alternation. 205 00:11:16,860 --> 00:11:18,580 Done. 206 00:11:18,580 --> 00:11:19,110 Why? 207 00:11:19,110 --> 00:11:21,865 Because if we choose x, we can't choose x prime because then 208 00:11:21,865 --> 00:11:24,690 they're in the same sub-row and all the way down the chain. 209 00:11:24,690 --> 00:11:27,160 So in general, if x is true, the idea 210 00:11:27,160 --> 00:11:28,710 is that the x's are the lights. 211 00:11:28,710 --> 00:11:32,250 If x is false, then the x primes are the lights. 212 00:11:32,250 --> 00:11:34,970 Now, that's a basic wire. 213 00:11:34,970 --> 00:11:37,340 But part of the wires we need a turn gadget. 214 00:11:37,340 --> 00:11:41,030 So this is a 90 degree turn. 215 00:11:41,030 --> 00:11:43,500 Just check that this is still lit. 216 00:11:43,500 --> 00:11:46,500 If these guys could not see each other, I think this is black. 217 00:11:46,500 --> 00:11:48,710 It's also OK. 218 00:11:48,710 --> 00:11:50,260 The alternation's forced by the one. 219 00:11:50,260 --> 00:11:53,430 But some flexibility. 220 00:11:53,430 --> 00:11:57,130 And let's see. 221 00:11:57,130 --> 00:11:59,620 The other fun thing you could do is spread out the x and x 222 00:11:59,620 --> 00:11:59,910 prime. 223 00:11:59,910 --> 00:12:01,284 If you put a bunch of zeroes here 224 00:12:01,284 --> 00:12:03,370 to force that there's no lights here, 225 00:12:03,370 --> 00:12:05,470 because this has to be lit again, one of these 226 00:12:05,470 --> 00:12:08,400 has to be active, and the ones force an alternation. 227 00:12:08,400 --> 00:12:13,480 So this is helpful because if our wires just look like this, 228 00:12:13,480 --> 00:12:16,050 and this will come up again today, 229 00:12:16,050 --> 00:12:19,880 then you're forced to be congruent to zero mod three. 230 00:12:19,880 --> 00:12:23,470 First your width has to be a multiple of 3. 231 00:12:23,470 --> 00:12:24,610 And this can be an issue. 232 00:12:24,610 --> 00:12:27,290 If you have a bunch of gadgets each of the different sizes-- 233 00:12:27,290 --> 00:12:29,920 maybe one is 5 by 5, another 3 by 3, 234 00:12:29,920 --> 00:12:32,162 and other fun prime numbers, then 235 00:12:32,162 --> 00:12:34,120 you might have trouble actually getting gadgets 236 00:12:34,120 --> 00:12:36,120 to meet edge on. 237 00:12:36,120 --> 00:12:37,660 Maybe there's a gap of one or two 238 00:12:37,660 --> 00:12:39,520 or something between the gadgets. 239 00:12:39,520 --> 00:12:41,600 But if you have a set up where you 240 00:12:41,600 --> 00:12:47,590 can adjust the wire lengths to be any integer, that's good. 241 00:12:47,590 --> 00:12:49,030 You can do this most of the time, 242 00:12:49,030 --> 00:12:51,140 but then when you're getting close to the gate, 243 00:12:51,140 --> 00:12:53,080 if you're off by one or two or three, 244 00:12:53,080 --> 00:12:56,950 you just make it a little bit longer and you're all set. 245 00:12:56,950 --> 00:13:00,340 AUDIENCE: The unfilled one can also just 246 00:13:00,340 --> 00:13:02,936 have a crossover gadget then? 247 00:13:02,936 --> 00:13:03,810 PROFESSOR: Ah, sorry? 248 00:13:03,810 --> 00:13:05,226 AUDIENCE: Since you have nothing-- 249 00:13:05,226 --> 00:13:08,377 it's very natural to have a crossover gadget by putting 250 00:13:08,377 --> 00:13:09,690 two of them orthongonal. 251 00:13:09,690 --> 00:13:10,150 PROFESSOR: Oh yeah. 252 00:13:10,150 --> 00:13:12,316 You can make a crossover gadget easy in this set up. 253 00:13:12,316 --> 00:13:13,820 I think that is a future slide. 254 00:13:16,470 --> 00:13:17,840 So we'll do crossover in a bit. 255 00:13:17,840 --> 00:13:22,770 Let's start with-- yeah, you can very easily do crossover. 256 00:13:22,770 --> 00:13:24,976 We won't need a crossover here. 257 00:13:24,976 --> 00:13:27,390 That's what I mean. 258 00:13:27,390 --> 00:13:29,092 So we definitely need splitting, though. 259 00:13:29,092 --> 00:13:30,550 In general, whenever you have wires 260 00:13:30,550 --> 00:13:32,091 you've got to be able to make copies, 261 00:13:32,091 --> 00:13:34,700 because if your variable only appears in two places, 262 00:13:34,700 --> 00:13:39,800 3SAT is easy, our circuit SAT is probably easy. 263 00:13:39,800 --> 00:13:43,530 So here is a splitter. 264 00:13:43,530 --> 00:13:46,990 This is the main mechanism. 265 00:13:46,990 --> 00:13:49,180 I guess these ones and this two. 266 00:13:49,180 --> 00:13:51,800 So these ones force an alternation 267 00:13:51,800 --> 00:13:52,850 between here and here. 268 00:13:52,850 --> 00:13:55,310 These have to be opposites of each other. 269 00:13:55,310 --> 00:14:00,350 And then the two-- so if both of the x's are present, 270 00:14:00,350 --> 00:14:02,120 if this is absent, then these two 271 00:14:02,120 --> 00:14:03,830 have to be present by the ones. 272 00:14:03,830 --> 00:14:06,040 And so by this two, that's all there is, 273 00:14:06,040 --> 00:14:07,260 and therefore this is absent. 274 00:14:07,260 --> 00:14:08,676 So these guys have to be the same. 275 00:14:08,676 --> 00:14:10,700 These guys have to be opposite. 276 00:14:10,700 --> 00:14:14,230 And conversely, if this is present by these ones, 277 00:14:14,230 --> 00:14:16,490 these have to be absent, and by this two, 278 00:14:16,490 --> 00:14:18,530 this has to be present. 279 00:14:18,530 --> 00:14:20,356 So this is almost sort of a-- well, 280 00:14:20,356 --> 00:14:21,730 you could also put some ones here 281 00:14:21,730 --> 00:14:24,650 I guess if you felt like it. 282 00:14:24,650 --> 00:14:27,510 Anyway, if you think about the parity 283 00:14:27,510 --> 00:14:32,810 here, when we're represent a signal coming into a gadget, 284 00:14:32,810 --> 00:14:36,810 there's x on the left and x prime on the right. 285 00:14:36,810 --> 00:14:40,350 So that means coming out here there's not x prime on the left 286 00:14:40,350 --> 00:14:44,290 and x on the right, so this actually a negated copy of x. 287 00:14:44,290 --> 00:14:47,600 And up here with some turns, we have a regular copy 288 00:14:47,600 --> 00:14:48,809 of x and a regular copy of x. 289 00:14:48,809 --> 00:14:50,974 This is actually a fairly common thing that happens. 290 00:14:50,974 --> 00:14:53,310 When you try to split maybe you also get a negated copy, 291 00:14:53,310 --> 00:14:55,550 or instead you get a negated copy. 292 00:14:55,550 --> 00:14:57,110 This is actually great because it 293 00:14:57,110 --> 00:14:58,685 kills two birds with one stone. 294 00:14:58,685 --> 00:15:00,060 You could use this as a splitter. 295 00:15:00,060 --> 00:15:03,500 It kind of makes 3D copies of your signal. 296 00:15:03,500 --> 00:15:06,480 But you could also use it just as a negation gadget, as 297 00:15:06,480 --> 00:15:08,540 a not gate. 298 00:15:08,540 --> 00:15:13,080 I think I have a slide of those done explicitly. 299 00:15:13,080 --> 00:15:13,580 Yeah. 300 00:15:13,580 --> 00:15:17,230 So here we're effectively using a terminator gadget. 301 00:15:17,230 --> 00:15:20,369 We're saying, well, we could throw away this negated copy 302 00:15:20,369 --> 00:15:22,160 because we already have two positive copies 303 00:15:22,160 --> 00:15:23,820 and that's enough for a splitter. 304 00:15:23,820 --> 00:15:28,980 So if we just end this wire here, great, we've got a split. 305 00:15:28,980 --> 00:15:32,620 Or if we throw away the two copies of x and we just 306 00:15:32,620 --> 00:15:36,850 want the negated copy of x, then ends up looking like this. 307 00:15:36,850 --> 00:15:40,710 So we get a split gadget and a not gate 308 00:15:40,710 --> 00:15:42,280 essentially for free out of this. 309 00:15:42,280 --> 00:15:44,290 You could just present this gadget 310 00:15:44,290 --> 00:15:46,410 and say, oh, I also have terminators, 311 00:15:46,410 --> 00:15:48,210 and then you know that you get these. 312 00:15:48,210 --> 00:15:51,070 But for fun, he drew them and I'll show you them. 313 00:15:51,070 --> 00:15:55,340 I won't show you them in future proofs. 314 00:15:55,340 --> 00:15:55,840 Cool. 315 00:15:55,840 --> 00:15:57,155 So let's see, what do we have? 316 00:15:57,155 --> 00:15:59,300 We've got a wire. 317 00:15:59,300 --> 00:16:00,130 We've got a split. 318 00:16:00,130 --> 00:16:00,900 We've got a not. 319 00:16:00,900 --> 00:16:03,290 We've got a terminator. 320 00:16:03,290 --> 00:16:07,760 We need some kind of clause or some kind of logic gate. 321 00:16:07,760 --> 00:16:10,210 And then possibly we also need a crossover. 322 00:16:10,210 --> 00:16:10,990 We have turns. 323 00:16:14,970 --> 00:16:18,530 Next up is a gate. 324 00:16:18,530 --> 00:16:20,220 It's sort of a mega gate. 325 00:16:20,220 --> 00:16:24,860 I'm guessing McPhail tried various little configurations 326 00:16:24,860 --> 00:16:26,890 and then found one that did interesting things. 327 00:16:26,890 --> 00:16:30,290 It actually does two interesting things at once. 328 00:16:30,290 --> 00:16:33,710 So we have x coming in on the left and y coming in 329 00:16:33,710 --> 00:16:36,820 on the right, so both of them have this x prime and y 330 00:16:36,820 --> 00:16:39,780 prime, then negated copies. 331 00:16:39,780 --> 00:16:43,240 And then we've got some fun stuff in here. 332 00:16:43,240 --> 00:16:45,430 So let's start with maybe the bottom, 333 00:16:45,430 --> 00:16:48,200 which is supposed to be an OR of x and y. 334 00:16:48,200 --> 00:16:51,832 So let's say that they are both false, for example. 335 00:16:51,832 --> 00:16:54,290 And in general, we're going to have to check all the cases, 336 00:16:54,290 --> 00:16:55,870 but I won't do all of them. 337 00:16:55,870 --> 00:16:57,710 So let's say this is absent. 338 00:16:57,710 --> 00:17:00,165 This is absent, meaning the it's lit from the other end. 339 00:17:00,165 --> 00:17:02,540 AUDIENCE: If it's false it means that x prime is present. 340 00:17:02,540 --> 00:17:02,980 ERIK DEMAINE: Oh, right. 341 00:17:02,980 --> 00:17:03,480 Sorry. 342 00:17:03,480 --> 00:17:06,230 If they're both false-- I though it was good-- then 343 00:17:06,230 --> 00:17:10,800 both of these are present, and therefore, we're 344 00:17:10,800 --> 00:17:12,849 going to get hopefully that this one's absent 345 00:17:12,849 --> 00:17:16,280 because the OR of false and false is false. 346 00:17:16,280 --> 00:17:19,060 So the claim would be that A prime and B 347 00:17:19,060 --> 00:17:21,560 prime must be activated. 348 00:17:21,560 --> 00:17:22,976 AUDIENCE: If they weren't then you 349 00:17:22,976 --> 00:17:25,397 couldn't light both A and B. 350 00:17:25,397 --> 00:17:26,230 ERIK DEMAINE: Right. 351 00:17:26,230 --> 00:17:29,230 These are at best OR'd together. 352 00:17:29,230 --> 00:17:31,020 At most, one of these is present. 353 00:17:31,020 --> 00:17:33,930 These regions both need to be lit. 354 00:17:33,930 --> 00:17:39,010 So we're going to need at least one of them 355 00:17:39,010 --> 00:17:41,450 to be on, but once one of them is on, 356 00:17:41,450 --> 00:17:44,580 we know that z is absent, and then the other one must be on. 357 00:17:44,580 --> 00:17:46,480 Right, this too. 358 00:17:46,480 --> 00:17:48,430 Good. 359 00:17:48,430 --> 00:17:53,410 And then we should up here get x NOR. 360 00:17:53,410 --> 00:17:56,660 So when these were both false and present, 361 00:17:56,660 --> 00:17:59,970 these were present, these are absent, 362 00:17:59,970 --> 00:18:01,880 and therefore, this is present. 363 00:18:01,880 --> 00:18:05,310 And the x OR of zero and zero is zero. 364 00:18:05,310 --> 00:18:09,120 The x NOR is 1, so that's good. 365 00:18:09,120 --> 00:18:10,730 So in general, you check all the cases 366 00:18:10,730 --> 00:18:12,260 and confirm this is the case. 367 00:18:12,260 --> 00:18:16,470 Again, by putting terminators on here, we can get either x OR y, 368 00:18:16,470 --> 00:18:22,820 or x NOR-- x NOR y-- it sounds funny. 369 00:18:22,820 --> 00:18:23,665 That's great. 370 00:18:26,520 --> 00:18:29,580 This is the one that we really care about. 371 00:18:29,580 --> 00:18:34,040 The OR gate-- well, so different answers to this. 372 00:18:34,040 --> 00:18:40,370 But you should know, and we'll talk more about this later, 373 00:18:40,370 --> 00:18:46,800 NAND-- or let's say NAND gate is universal. 374 00:18:50,320 --> 00:18:52,565 And a NOR gate by itself is universal. 375 00:18:55,700 --> 00:18:57,930 They're just good things you should know. 376 00:18:57,930 --> 00:18:59,950 They go back at least 50 years. 377 00:19:02,580 --> 00:19:04,360 AUDIENCE: What does universal mean? 378 00:19:04,360 --> 00:19:07,160 ERIK DEMAINE: So universal means that from those-- 379 00:19:07,160 --> 00:19:08,830 if you're just given a bunch of NANDs, 380 00:19:08,830 --> 00:19:13,020 then you can construct any logical get you want. 381 00:19:13,020 --> 00:19:15,040 I will talk about that more in a moment. 382 00:19:15,040 --> 00:19:16,820 So this OR is particularly interesting 383 00:19:16,820 --> 00:19:20,930 because we already have NOT, and so from OR and NOT 384 00:19:20,930 --> 00:19:23,534 we can make NOR-- it's just the NOT of the OR. 385 00:19:23,534 --> 00:19:27,220 And so from that, we should be able to make anything. 386 00:19:27,220 --> 00:19:29,120 Which is great, except for one thing 387 00:19:29,120 --> 00:19:30,700 which is the crossover gadget. 388 00:19:30,700 --> 00:19:33,810 So in the case of Light Up, crossover gadget 389 00:19:33,810 --> 00:19:35,070 is easy to construct. 390 00:19:35,070 --> 00:19:39,220 But because we have x OR anyway, we 391 00:19:39,220 --> 00:19:44,070 can use this fun fact that-- this is the symbol for x OR. 392 00:19:44,070 --> 00:19:49,030 If you have x OR gadgets, you can make a crossover gadget 393 00:19:49,030 --> 00:19:50,590 for free. 394 00:19:50,590 --> 00:19:53,310 So this communicates x to x, y to y. 395 00:19:53,310 --> 00:19:54,620 There's four cases. 396 00:19:54,620 --> 00:19:56,610 I won't check all of them. 397 00:19:56,610 --> 00:19:59,430 But that's cool because we have x NOR, 398 00:19:59,430 --> 00:20:01,420 we can negate it and get x OR. 399 00:20:01,420 --> 00:20:05,480 And then we can take three of them, plugging them together, 400 00:20:05,480 --> 00:20:07,920 and we get a rather complicated crossover gadget 401 00:20:07,920 --> 00:20:08,974 if I expanded it out. 402 00:20:08,974 --> 00:20:11,390 There is a simpler one, but we don't care about simplicity 403 00:20:11,390 --> 00:20:11,890 here. 404 00:20:11,890 --> 00:20:15,160 These are just constants, and we just care about polynomial. 405 00:20:15,160 --> 00:20:19,403 So that's Light Up as empty heart. 406 00:20:19,403 --> 00:20:20,986 AUDIENCE: Do we need crossover gadgets 407 00:20:20,986 --> 00:20:22,230 in general for circuit SAT? 408 00:20:22,230 --> 00:20:24,900 Is planner circuit SAT hard? 409 00:20:24,900 --> 00:20:26,900 ERIK DEMAINE: Please wait. 410 00:20:26,900 --> 00:20:27,580 Yeah. 411 00:20:27,580 --> 00:20:30,069 This is something-- well, yeah. 412 00:20:30,069 --> 00:20:32,110 I want to talk about that after the next example. 413 00:20:32,110 --> 00:20:32,820 AUDIENCE: OK. 414 00:20:32,820 --> 00:20:35,320 ERIK DEMAINE: Which we'll get to an answer to that question. 415 00:20:35,320 --> 00:20:37,930 Which as far as I know hasn't been explicitly raised before, 416 00:20:37,930 --> 00:20:43,230 but the answer is basically, you don't need crossover gadgets, 417 00:20:43,230 --> 00:20:46,510 and for all the cases I can think. 418 00:20:46,510 --> 00:20:50,540 So that was Light Up is NP hard. 419 00:20:50,540 --> 00:20:53,419 It's also in NP because a certificate is just where do 420 00:20:53,419 --> 00:20:54,210 you put the lights. 421 00:20:54,210 --> 00:20:56,920 There's only polynomial number of places to put them, 422 00:20:56,920 --> 00:20:58,141 and checking it is easy. 423 00:20:58,141 --> 00:20:58,640 Cool. 424 00:20:58,640 --> 00:21:00,880 So NP-complete. 425 00:21:00,880 --> 00:21:03,690 Oh, here's for fun an overall construction, 426 00:21:03,690 --> 00:21:05,180 which McPhail worked out. 427 00:21:05,180 --> 00:21:09,690 So putting all the pieces together and possibly using-- I 428 00:21:09,690 --> 00:21:11,380 think here there's maybe no crossovers. 429 00:21:13,920 --> 00:21:17,290 So in general, with Circuit SAT you can construct sort 430 00:21:17,290 --> 00:21:19,050 of any Boolean formula you want once you 431 00:21:19,050 --> 00:21:23,050 have a universal set of gates. 432 00:21:23,050 --> 00:21:27,130 But yeah, you can work through details here. 433 00:21:27,130 --> 00:21:29,570 It's easy to convert between AND and OR 434 00:21:29,570 --> 00:21:32,310 just by negating the inputs by De Morgan. 435 00:21:32,310 --> 00:21:40,520 So you've got x OR y is NOT x and NOT y or vice versa. 436 00:21:40,520 --> 00:21:42,190 So as long as you've got NOT an OR 437 00:21:42,190 --> 00:21:45,900 you can construct AND and vice versa by negating things 438 00:21:45,900 --> 00:21:48,150 appropriately. 439 00:21:48,150 --> 00:21:53,800 So that's what he's doing here for getting some ORs and so on. 440 00:21:53,800 --> 00:21:56,900 And because there's two copies of x-- well, 441 00:21:56,900 --> 00:21:59,220 x is sort of getting split here. 442 00:21:59,220 --> 00:22:00,850 I guess you didn't have to split x. 443 00:22:00,850 --> 00:22:03,262 You could just connect directly. 444 00:22:03,262 --> 00:22:04,970 This is a pretty nice clean construction. 445 00:22:04,970 --> 00:22:08,682 It could actually make decent resize puzzles with it. 446 00:22:08,682 --> 00:22:11,448 AUDIENCE: So you end up with the wire carrying the formula 447 00:22:11,448 --> 00:22:13,367 just by doing all these combinations? 448 00:22:13,367 --> 00:22:14,200 ERIK DEMAINE: Right. 449 00:22:14,200 --> 00:22:15,146 AUDIENCE: And then what do you do? 450 00:22:15,146 --> 00:22:16,354 ERIK DEMAINE: Ah, good point. 451 00:22:16,354 --> 00:22:17,070 Thank you. 452 00:22:17,070 --> 00:22:21,470 There was one more point to this picture, which is this zero. 453 00:22:21,470 --> 00:22:26,750 This should be an OR of x false, and this OR or this AND 454 00:22:26,750 --> 00:22:30,610 and blah, blah, blah, which is this thing. 455 00:22:30,610 --> 00:22:32,490 AUDIENCE: So if that wire's carrying true, 456 00:22:32,490 --> 00:22:34,690 then you don't need to put a light next to the zero, 457 00:22:34,690 --> 00:22:36,320 otherwise you would have to, and that means 458 00:22:36,320 --> 00:22:37,420 the puzzle can't be solved. 459 00:22:37,420 --> 00:22:38,253 ERIK DEMAINE: Right. 460 00:22:38,253 --> 00:22:40,339 So for this puzzle to be solvable, 461 00:22:40,339 --> 00:22:41,880 we better not put a light here, which 462 00:22:41,880 --> 00:22:44,540 means it has to be here, which corresponds to this formula 463 00:22:44,540 --> 00:22:48,887 being true, I think, if I got that parity right. 464 00:22:48,887 --> 00:22:49,470 Or either way. 465 00:22:49,470 --> 00:22:53,680 You could put a one there and force there to be a light. 466 00:22:53,680 --> 00:22:55,820 So this makes the puzzle feasible if and only 467 00:22:55,820 --> 00:22:57,310 if this formula's feasible. 468 00:22:57,310 --> 00:22:58,810 Because the wires are unconstrained, 469 00:22:58,810 --> 00:23:03,500 except by setting this thing equal to one. 470 00:23:03,500 --> 00:23:06,590 So this is a special kind of terminator, you might say. 471 00:23:06,590 --> 00:23:08,240 A true terminator. 472 00:23:08,240 --> 00:23:10,410 You want to force the thing to be true in the end. 473 00:23:10,410 --> 00:23:11,785 That's usually pretty easy to do. 474 00:23:11,785 --> 00:23:14,010 Terminator's usually one of the simplest gadgets 475 00:23:14,010 --> 00:23:14,680 to worry about. 476 00:23:14,680 --> 00:23:16,200 But yeah, you do need it. 477 00:23:16,200 --> 00:23:19,020 For circuit SAT you need-- let's add that. 478 00:23:25,160 --> 00:23:29,379 Circuit SAT you need let's say a true terminator. 479 00:23:29,379 --> 00:23:30,920 There are other ways you could do it. 480 00:23:37,040 --> 00:23:37,790 Cool. 481 00:23:37,790 --> 00:23:42,150 Other questions about Akari? 482 00:23:42,150 --> 00:23:42,840 All right. 483 00:23:42,840 --> 00:23:45,030 So our next topic is Mine Sweeper. 484 00:23:45,030 --> 00:23:46,311 This is from our poster. 485 00:23:46,311 --> 00:23:48,060 We did Super Mario Brothers, and Bruce Lee 486 00:23:48,060 --> 00:23:51,450 did Rush Hour, so Mine Sweeper's the last one on the poster. 487 00:23:51,450 --> 00:23:54,950 Let's prove it hard. 488 00:23:54,950 --> 00:23:58,097 We're actually going to cover two proofs about Mine Sweeper, 489 00:23:58,097 --> 00:24:00,180 because there are sort of two natural problems you 490 00:24:00,180 --> 00:24:01,490 might ask about it. 491 00:24:01,490 --> 00:24:05,530 The first problem is consistency. 492 00:24:05,530 --> 00:24:08,940 So this is I give you a set up, I'm 493 00:24:08,940 --> 00:24:11,380 going to give you a partially solved board that you're not 494 00:24:11,380 --> 00:24:13,400 given the x levels. 495 00:24:13,400 --> 00:24:16,370 So just a regular instance of Mine Sweeper. 496 00:24:16,370 --> 00:24:19,610 Maybe you're told where some of the bombs are. 497 00:24:19,610 --> 00:24:22,120 It won't actually matter, because all the bombs that I'll 498 00:24:22,120 --> 00:24:24,481 draw here are drivable from this-- 499 00:24:24,481 --> 00:24:26,230 I should mention the rules of Mine Sweeper 500 00:24:26,230 --> 00:24:27,760 just in case you haven't played. 501 00:24:27,760 --> 00:24:30,250 Anyone not played Mine Sweeper? 502 00:24:30,250 --> 00:24:32,020 I'm not willing to admit it. 503 00:24:32,020 --> 00:24:35,260 The numbers here representing, among all your vertex 504 00:24:35,260 --> 00:24:38,664 neighbors, all eight neighbors, how many of them are bombs. 505 00:24:38,664 --> 00:24:41,080 You don't want to click on the bombs because then you die. 506 00:24:41,080 --> 00:24:43,350 So your goal is from this partial information, 507 00:24:43,350 --> 00:24:45,114 these blank squares represent zeros. 508 00:24:45,114 --> 00:24:46,530 From this partial information, you 509 00:24:46,530 --> 00:24:49,800 want to figure out where the bombs must be. 510 00:24:49,800 --> 00:24:54,050 And here's a very familiar looking wire. 511 00:24:57,890 --> 00:25:00,860 We can't just have obstacles that are wild cards. 512 00:25:00,860 --> 00:25:02,780 So we have to put numbers if we don't 513 00:25:02,780 --> 00:25:04,555 want there to be bombs there. 514 00:25:04,555 --> 00:25:06,930 That makes the gadgets quite a bit trickier to work with. 515 00:25:06,930 --> 00:25:08,710 But this looks pretty similar. 516 00:25:08,710 --> 00:25:11,850 We've got these ones, which force an alternation. 517 00:25:11,850 --> 00:25:14,900 Exactly one of these two is a bomb, so if x is present, 518 00:25:14,900 --> 00:25:17,600 x prime is absent and vice versa. 519 00:25:17,600 --> 00:25:20,610 And then this one forces-- I guess actually this one 520 00:25:20,610 --> 00:25:22,930 forces these to be opposite. 521 00:25:22,930 --> 00:25:25,690 So that forces the alternation down the line. 522 00:25:25,690 --> 00:25:28,040 So again, there are exactly two solutions to this wire 523 00:25:28,040 --> 00:25:31,660 gadget for where the bombs could be. 524 00:25:31,660 --> 00:25:33,490 And so the Mine Sweeper consistency problem 525 00:25:33,490 --> 00:25:36,840 is I give you some picture involving these things, 526 00:25:36,840 --> 00:25:41,015 and I want to know is there a solution-- is there 527 00:25:41,015 --> 00:25:42,640 a placement of the bombs that satisfies 528 00:25:42,640 --> 00:25:44,830 all of these constraints? 529 00:25:44,830 --> 00:25:50,640 Now, you might ask why is that the problem we care about? 530 00:25:50,640 --> 00:25:54,340 And one reason if you're playing Mine Sweeper, 531 00:25:54,340 --> 00:25:56,570 you'd like to know, for example, could there 532 00:25:56,570 --> 00:25:59,350 be a bomb at this position? 533 00:25:59,350 --> 00:26:02,080 So could there be a bomb at this position? 534 00:26:02,080 --> 00:26:05,190 I could solve that problem, potentially, 535 00:26:05,190 --> 00:26:09,950 if I could solve Mine Sweeper consistency by saying, 536 00:26:09,950 --> 00:26:12,520 let's put a bomb there as part of the partial information. 537 00:26:12,520 --> 00:26:14,750 Is that consistent with everything else? 538 00:26:14,750 --> 00:26:17,310 So add a bomb to the partial information. 539 00:26:17,310 --> 00:26:20,320 Is that a consistent configuration? 540 00:26:20,320 --> 00:26:22,430 So if I could solve Mine Sweeper consistency, 541 00:26:22,430 --> 00:26:24,020 I could play Mine Sweeper very well 542 00:26:24,020 --> 00:26:26,137 by just testing which are bombable positions. 543 00:26:26,137 --> 00:26:27,970 If they're not, possible to be a bomb there. 544 00:26:27,970 --> 00:26:29,940 Actually click there and get more information 545 00:26:29,940 --> 00:26:31,470 and cook until done. 546 00:26:31,470 --> 00:26:33,920 Now, maybe you could solve Mine Sweeper in a different way 547 00:26:33,920 --> 00:26:35,150 than using consistency. 548 00:26:35,150 --> 00:26:38,190 But one way to solve it would be consistency. 549 00:26:38,190 --> 00:26:38,690 Question? 550 00:26:38,690 --> 00:26:41,300 AUDIENCE: By consistency you don't mean unique solution. 551 00:26:41,300 --> 00:26:43,550 ERIK DEMAINE: I do not mean unique solution, right. 552 00:26:43,550 --> 00:26:43,790 Yeah. 553 00:26:43,790 --> 00:26:45,390 So when you actually want to solve the game, 554 00:26:45,390 --> 00:26:47,210 you'd like there to be a unique solution. 555 00:26:47,210 --> 00:26:49,590 That's a problem we will get to in a moment. 556 00:26:49,590 --> 00:26:52,065 AUDIENCE: So a blank board, unfilled information 557 00:26:52,065 --> 00:26:53,800 is consistent. 558 00:26:53,800 --> 00:26:54,550 ERIK DEMAINE: Yes. 559 00:26:54,550 --> 00:26:57,980 Completely blank board is consistent. 560 00:26:57,980 --> 00:26:59,380 And it wouldn't be interesting. 561 00:26:59,380 --> 00:27:01,060 As you're playing, you imagine you've 562 00:27:01,060 --> 00:27:03,210 gathered some information, you add a bomb. 563 00:27:03,210 --> 00:27:04,956 You want to say is this consistent. 564 00:27:04,956 --> 00:27:06,705 It says yes, like you're in a blank board. 565 00:27:06,705 --> 00:27:08,496 And you're like could there be a bomb here. 566 00:27:08,496 --> 00:27:10,060 Of course there could be. 567 00:27:10,060 --> 00:27:11,460 Then that's not a safe move. 568 00:27:11,460 --> 00:27:16,250 So if you could solve this, you could identify safe moves. 569 00:27:16,250 --> 00:27:19,310 Turns out you can't solve it, so it doesn't directly help you. 570 00:27:19,310 --> 00:27:20,230 Yeah. 571 00:27:20,230 --> 00:27:23,282 AUDIENCE: So there doesn't always exist a safe move. 572 00:27:23,282 --> 00:27:25,490 ERIK DEMAINE: There doesn't always exist a safe move. 573 00:27:25,490 --> 00:27:28,910 AUDIENCE: What good is it, kind of, 574 00:27:28,910 --> 00:27:30,859 to know whether [INAUDIBLE]. 575 00:27:30,859 --> 00:27:31,650 ERIK DEMAINE: Yeah. 576 00:27:31,650 --> 00:27:33,890 I would say consistency is the wrong problem 577 00:27:33,890 --> 00:27:36,130 to solve for Mine Sweeper. 578 00:27:36,130 --> 00:27:38,290 But it was the first problem solved. 579 00:27:38,290 --> 00:27:42,290 The gadgets are relatively easy, which is 580 00:27:42,290 --> 00:27:44,560 going to be fairly complicated. 581 00:27:44,560 --> 00:27:46,830 And then we'll get to the right problem for if you 582 00:27:46,830 --> 00:27:47,959 wanted to solve the puzzle. 583 00:27:47,959 --> 00:27:49,750 At this point it's an interesting question. 584 00:27:49,750 --> 00:27:51,374 You just want to know is it consistent. 585 00:27:51,374 --> 00:27:54,057 Did the computer cheat would be one other perspective. 586 00:27:54,057 --> 00:27:56,140 Or you could imagine some adversarial Mine Sweeper 587 00:27:56,140 --> 00:27:58,655 where you only decide the bombs as the person is playing. 588 00:28:02,210 --> 00:28:05,260 So here, just even telling whether your opponent 589 00:28:05,260 --> 00:28:08,410 is cheating is hard. 590 00:28:08,410 --> 00:28:11,400 So that's another perspective. 591 00:28:11,400 --> 00:28:13,920 Let's finish this proof. 592 00:28:13,920 --> 00:28:16,830 We have a terminator, which is actually a little bit 593 00:28:16,830 --> 00:28:17,540 tricky here. 594 00:28:17,540 --> 00:28:19,680 You can't just end with ones because that would 595 00:28:19,680 --> 00:28:21,280 force this guy to be a bomb. 596 00:28:21,280 --> 00:28:23,090 So you end with these threes, which 597 00:28:23,090 --> 00:28:26,970 force-- these guys are already bombs because of this picture, 598 00:28:26,970 --> 00:28:30,590 and then exactly one of those will still have to be a bomb. 599 00:28:30,590 --> 00:28:32,290 And then we have a splitter. 600 00:28:32,290 --> 00:28:34,880 It's a similar picture to Akari. 601 00:28:34,880 --> 00:28:38,030 We have this two, which forces exactly to two of these 602 00:28:38,030 --> 00:28:40,055 to be present, and these ones force alternation. 603 00:28:43,090 --> 00:28:47,520 Now, I'm orienting these arrows for the splitter 604 00:28:47,520 --> 00:28:54,400 and defining true to be when the pointy end of the arrow 605 00:28:54,400 --> 00:28:56,730 is present. 606 00:28:56,730 --> 00:28:59,000 So that means this is actually a negated copy, 607 00:28:59,000 --> 00:29:01,509 and these are unnegated copies. 608 00:29:01,509 --> 00:29:03,050 But that's only from the orientation. 609 00:29:03,050 --> 00:29:06,040 This gadget's actually symmetric, fourfold. 610 00:29:06,040 --> 00:29:08,370 But if you put these arrows in, which 611 00:29:08,370 --> 00:29:11,450 you would do if you were actually following a circuit, 612 00:29:11,450 --> 00:29:13,830 their circuits are directed acyclic graphs remember. 613 00:29:13,830 --> 00:29:17,270 So this is negation, which is good because it gives us a NOT, 614 00:29:17,270 --> 00:29:18,690 it also gives us a split. 615 00:29:18,690 --> 00:29:21,830 You can also end these two things and get a turn. 616 00:29:21,830 --> 00:29:23,300 So great, three gadgets in one. 617 00:29:26,870 --> 00:29:28,750 So we already have NOT. 618 00:29:28,750 --> 00:29:30,740 This is another way to do NOT. 619 00:29:30,740 --> 00:29:34,770 And it's interesting here because with Akari we 620 00:29:34,770 --> 00:29:39,600 could stretch wires to any length, any integer length 621 00:29:39,600 --> 00:29:41,360 that's sufficiently long. 622 00:29:41,360 --> 00:29:46,224 Here, we're forced in this modulo three picture, normally. 623 00:29:46,224 --> 00:29:47,890 But when we do something like a negation 624 00:29:47,890 --> 00:29:49,670 here we get kind of messed up. 625 00:29:49,670 --> 00:29:52,520 We're no longer in the same position modulo three. 626 00:29:52,520 --> 00:29:56,790 We should be off by one I believe. 627 00:29:56,790 --> 00:30:01,240 So the idea is if you do two negations in a row, 628 00:30:01,240 --> 00:30:04,840 then you can end up shifting by exactly two 629 00:30:04,840 --> 00:30:07,630 and still have the same signal. 630 00:30:07,630 --> 00:30:11,220 So you can see here we have xx bar, 631 00:30:11,220 --> 00:30:17,980 but down here we have it shifted two positions over. 632 00:30:17,980 --> 00:30:22,210 Or I guess it's more impressive over here, so x bar x. 633 00:30:22,210 --> 00:30:24,800 And normally this would repeat in this kind of pattern. 634 00:30:27,450 --> 00:30:30,031 So it actually shifted by one position. 635 00:30:30,031 --> 00:30:30,530 Good. 636 00:30:30,530 --> 00:30:32,440 That's actually what I want. 637 00:30:32,440 --> 00:30:39,550 So see the pattern here, here, here, here, and shift by one. 638 00:30:39,550 --> 00:30:42,480 Yeah, or two the other direction. 639 00:30:42,480 --> 00:30:43,580 OK, so that's good. 640 00:30:43,580 --> 00:30:46,460 That lets me adjust my wire length. 641 00:30:46,460 --> 00:30:49,760 These are also often called shift gadgets. 642 00:30:49,760 --> 00:30:51,700 They just let you shift by one. 643 00:30:51,700 --> 00:30:54,242 And whenever you have gadgets that force certain modulo 644 00:30:54,242 --> 00:30:56,200 constraints, just having the ability to add one 645 00:30:56,200 --> 00:30:58,430 is great because then you can break all switch constraints. 646 00:30:58,430 --> 00:31:00,388 You no longer have to live in a mod three grid, 647 00:31:00,388 --> 00:31:03,120 whatever, if you don't want to. 648 00:31:03,120 --> 00:31:04,330 So this is important. 649 00:31:04,330 --> 00:31:09,370 In general-- I'll add it to the list here. 650 00:31:09,370 --> 00:31:11,590 When you're dealing with wires you 651 00:31:11,590 --> 00:31:13,290 may need some kind of shift gadget that 652 00:31:13,290 --> 00:31:18,820 lets you fix parity issues, or in this case, a mod three 653 00:31:18,820 --> 00:31:21,310 parity. 654 00:31:21,310 --> 00:31:24,550 OK, here is a more complicated gadget, 655 00:31:24,550 --> 00:31:25,990 which I will not go through. 656 00:31:25,990 --> 00:31:26,980 It looks scary. 657 00:31:26,980 --> 00:31:29,200 It's not actually a ton going on. 658 00:31:29,200 --> 00:31:31,470 It's a lot of gadgets we've already seen. 659 00:31:31,470 --> 00:31:33,860 It uses a slight-- I've mentioned a turn gadget. 660 00:31:33,860 --> 00:31:35,990 This is another way to do a turn. 661 00:31:35,990 --> 00:31:38,190 There's a few redundant gadgets in this paper 662 00:31:38,190 --> 00:31:39,950 because it's fun to make gadgets, 663 00:31:39,950 --> 00:31:43,280 so I want to have more. 664 00:31:43,280 --> 00:31:45,590 So there's, for example, just a turn gadget here. 665 00:31:45,590 --> 00:31:46,907 There's a splitter here. 666 00:31:46,907 --> 00:31:47,740 Another turn gadget. 667 00:31:47,740 --> 00:31:52,240 This is reflectionally symmetric around the x-axis. 668 00:31:52,240 --> 00:31:54,140 There's basically just a turn here, 669 00:31:54,140 --> 00:31:58,250 so x is just getting copied and negated into here. 670 00:31:58,250 --> 00:32:00,190 z is getting copied and negated into here. 671 00:32:02,790 --> 00:32:07,090 This is the output value, which is getting copied around 672 00:32:07,090 --> 00:32:07,760 into here. 673 00:32:07,760 --> 00:32:10,430 And then a little bit of magic happens here and here 674 00:32:10,430 --> 00:32:12,180 to get these to interact in the right way. 675 00:32:12,180 --> 00:32:15,170 And it's essentially just checking cases 676 00:32:15,170 --> 00:32:19,330 to see that this computes an AND of these two inputs. 677 00:32:22,040 --> 00:32:24,642 But a little bit complicated. 678 00:32:24,642 --> 00:32:26,350 AUDIENCE: Is coming up with these gadgets 679 00:32:26,350 --> 00:32:29,280 harder than checking them? 680 00:32:29,280 --> 00:32:30,960 ERIK DEMAINE: Good question. 681 00:32:30,960 --> 00:32:31,700 It's unclear. 682 00:32:31,700 --> 00:32:32,890 Often when you're designing things, 683 00:32:32,890 --> 00:32:35,110 you have a lot more control, and it could potentially 684 00:32:35,110 --> 00:32:39,990 be easier to design hard problems than to check them. 685 00:32:39,990 --> 00:32:42,230 Because we know it's NP-complete to check this, 686 00:32:42,230 --> 00:32:44,857 in a certain sense. 687 00:32:44,857 --> 00:32:47,190 I mean, of course, in this case there's only four cases, 688 00:32:47,190 --> 00:32:49,550 so it's not really that hard. 689 00:32:49,550 --> 00:32:51,200 But yeah, when you're designing things 690 00:32:51,200 --> 00:32:53,594 you have in mind a certain connectivity structure, 691 00:32:53,594 --> 00:32:55,260 and then it's a matter of getting things 692 00:32:55,260 --> 00:32:58,530 to resolve in the grid and not have things overlapping and so 693 00:32:58,530 --> 00:33:02,450 on, which is a different kind of constraint. 694 00:33:02,450 --> 00:33:04,040 I might say it's a more fun one. 695 00:33:04,040 --> 00:33:07,354 I would call designing these puzzles meta puzzles, and to me 696 00:33:07,354 --> 00:33:08,020 that's more fun. 697 00:33:08,020 --> 00:33:10,470 But of course, I'm a theoretical computer scientist. 698 00:33:10,470 --> 00:33:13,910 That's why we're here. 699 00:33:13,910 --> 00:33:17,090 Anyway, fun to answer that question. 700 00:33:19,720 --> 00:33:21,130 So here's a fun thing. 701 00:33:21,130 --> 00:33:26,355 I hadn't seen this paper before by Goldschlager in 1977. 702 00:33:26,355 --> 00:33:28,230 They were worried about p completeness, which 703 00:33:28,230 --> 00:33:29,870 we haven't talked about yet. 704 00:33:29,870 --> 00:33:32,200 But in particular, they gave these two pictures. 705 00:33:32,200 --> 00:33:35,550 This one we've seen. 706 00:33:35,550 --> 00:33:39,480 If you have an x OR gadget, you can construct a crossover. 707 00:33:39,480 --> 00:33:41,870 Now, we don't have an XOR gadget in this case, 708 00:33:41,870 --> 00:33:44,920 but we have an AND gadget or a NAND gadget. 709 00:33:44,920 --> 00:33:48,930 This is the funny way of writing NAND, NOT of an AND. 710 00:33:48,930 --> 00:33:52,240 And if you have NAND gadgets you can construct an XOR. 711 00:33:52,240 --> 00:33:54,770 So if you plug this picture into each of these three 712 00:33:54,770 --> 00:33:59,270 pictures you get a kind of ugly thing, but it's planar 713 00:33:59,270 --> 00:34:01,100 and it implements a crossover. 714 00:34:01,100 --> 00:34:05,640 Which means if you have NAND, you get planarity for free. 715 00:34:05,640 --> 00:34:12,530 So I'm going to call this planar circuit SAT. 716 00:34:19,870 --> 00:34:22,870 It's like catch, this, I think is also a made-up term. 717 00:34:22,870 --> 00:34:24,469 I haven't seen it in the literature. 718 00:34:24,469 --> 00:34:27,510 Because it's a little bit vague what it could mean. 719 00:34:27,510 --> 00:34:34,230 But let's say we're given a planar directed 720 00:34:34,230 --> 00:34:35,515 acyclic circuit. 721 00:34:40,719 --> 00:34:47,885 And let's say all gates are NAND. 722 00:34:50,509 --> 00:34:51,550 Then this is NP-complete. 723 00:34:58,604 --> 00:34:59,520 AUDIENCE: [INAUDIBLE]. 724 00:35:02,231 --> 00:35:03,230 ERIK DEMAINE: Ah, right. 725 00:35:03,230 --> 00:35:04,090 Sorry. 726 00:35:04,090 --> 00:35:05,980 And at the end you want it to be true. 727 00:35:05,980 --> 00:35:07,180 Thank you. 728 00:35:07,180 --> 00:35:11,293 So you have let's say the sources are unconstrained. 729 00:35:16,070 --> 00:35:18,410 So those represent the variables. 730 00:35:18,410 --> 00:35:23,086 And there's a sync, which is set to one. 731 00:35:23,086 --> 00:35:24,710 And we could say there's just one sync. 732 00:35:24,710 --> 00:35:28,000 So you have some starting points. 733 00:35:28,000 --> 00:35:31,500 Those are completely free to choose true or false. 734 00:35:31,500 --> 00:35:34,740 And then at the end you have a sync. 735 00:35:34,740 --> 00:35:37,580 I guess it just has one thing probably coming into it. 736 00:35:37,580 --> 00:35:39,670 Wouldn't make sense otherwise. 737 00:35:39,670 --> 00:35:41,706 And we set this to be one. 738 00:35:41,706 --> 00:35:43,330 So that's just like satisfying formula, 739 00:35:43,330 --> 00:35:48,530 but drawn as a Boolean circuit, and it's planar. 740 00:35:48,530 --> 00:35:50,770 Now, we're going to see more versions of planar SAT 741 00:35:50,770 --> 00:35:55,050 next class, but this one as far as I know is newish. 742 00:35:55,050 --> 00:35:57,070 It's essentially argued in this paper. 743 00:35:57,070 --> 00:35:59,590 Say, hey look-- this paper was not 744 00:35:59,590 --> 00:36:04,450 talking about NP-completeness, but the K paper says, 745 00:36:04,450 --> 00:36:07,130 hey, we've got these two things, so as long 746 00:36:07,130 --> 00:36:09,560 as you have NAND you've got crossovers for free. 747 00:36:09,560 --> 00:36:12,630 So you don't have to worry about planarity, which is good news. 748 00:36:12,630 --> 00:36:15,680 So no crossover gadget needed. 749 00:36:15,680 --> 00:36:16,547 There is one. 750 00:36:16,547 --> 00:36:18,380 It's actually not that hard in Mine Sweeper, 751 00:36:18,380 --> 00:36:21,740 but it's nicer when you don't have to do it. 752 00:36:21,740 --> 00:36:23,230 Questions? 753 00:36:23,230 --> 00:36:24,953 I guess I did talk about termination. 754 00:36:27,960 --> 00:36:29,660 We do need a true terminator here 755 00:36:29,660 --> 00:36:31,090 because we're doing circuit SAT. 756 00:36:31,090 --> 00:36:33,490 That's really easy. 757 00:36:33,490 --> 00:36:35,770 In fact, this would do it. 758 00:36:35,770 --> 00:36:38,440 Just ending with all ones means, in fact, 759 00:36:38,440 --> 00:36:41,790 if there's zeroes out here, that means this has to be a bomb. 760 00:36:41,790 --> 00:36:43,840 And so that sets it to one. 761 00:36:43,840 --> 00:36:48,070 So there's a true terminator for Mine Sweeper consistency. 762 00:36:48,070 --> 00:36:50,410 But as we've seen in various ways, 763 00:36:50,410 --> 00:36:53,190 Mine Sweeper consistency is probably not 764 00:36:53,190 --> 00:36:58,490 what we want to actually play the game. 765 00:36:58,490 --> 00:37:01,210 The algorithm I gave you is one way 766 00:37:01,210 --> 00:37:04,250 to think about playing the game where you add a thing 767 00:37:04,250 --> 00:37:06,370 and you check for consistency. 768 00:37:06,370 --> 00:37:08,810 That's also a little bit weird where 769 00:37:08,810 --> 00:37:11,156 you're assuming that the input is consistent, 770 00:37:11,156 --> 00:37:12,530 and then you add one bomb and you 771 00:37:12,530 --> 00:37:14,488 want to see whether that makes it inconsistent. 772 00:37:14,488 --> 00:37:16,340 That's a special case of this instance. 773 00:37:16,340 --> 00:37:18,439 Maybe not as hard as the general picture. 774 00:37:18,439 --> 00:37:20,480 Everything was consistent up until the moment you 775 00:37:20,480 --> 00:37:23,140 added one new bomb information. 776 00:37:23,140 --> 00:37:26,930 These pictures don't look exactly like that. 777 00:37:26,930 --> 00:37:31,200 Another thing I want to point out in these gadgets 778 00:37:31,200 --> 00:37:37,210 is let's say the number of x and x bars is not the same. 779 00:37:37,210 --> 00:37:41,080 Maybe this negation, this equal numbers of x and x 780 00:37:41,080 --> 00:37:43,770 bars over here, but there's one extra x bar. 781 00:37:43,770 --> 00:37:46,330 What that means is local to this picture, 782 00:37:46,330 --> 00:37:51,810 the number of bombs that get used varies. 783 00:37:51,810 --> 00:37:55,630 There's either one, two, three, four bombs if you choose x, 784 00:37:55,630 --> 00:37:57,960 or there's five bombs if you choose x bar. 785 00:37:57,960 --> 00:38:00,330 And one of the minor things in Mine Sweeper 786 00:38:00,330 --> 00:38:04,830 is that the total number of bombs is given to you as input. 787 00:38:04,830 --> 00:38:08,330 So that actually also kind of messes things up. 788 00:38:08,330 --> 00:38:10,970 Anyway, luckily, this problem was solved. 789 00:38:10,970 --> 00:38:14,460 It was actually independently solved by multiple people. 790 00:38:14,460 --> 00:38:19,620 It's claimed in Bob Hearn's PhD thesis, though never 791 00:38:19,620 --> 00:38:21,360 got fully written up. 792 00:38:21,360 --> 00:38:25,230 And then it got published, so no reason to write it up anymore. 793 00:38:25,230 --> 00:38:28,010 So here is their proof. 794 00:38:28,010 --> 00:38:29,600 Both this proof and the previous one 795 00:38:29,600 --> 00:38:32,650 appeared in Mathematical Intelligencer. 796 00:38:32,650 --> 00:38:35,130 So they draw the gadgets slightly differently, 797 00:38:35,130 --> 00:38:37,560 and so far everything looks about the same. 798 00:38:37,560 --> 00:38:41,370 They're not going to use a phase changer in this form at least. 799 00:38:41,370 --> 00:38:43,900 So they're going to draw the wire gadget like this, 800 00:38:43,900 --> 00:38:45,820 and the idea is that you would copy it, 801 00:38:45,820 --> 00:38:48,130 you get things mod three, that will turn out 802 00:38:48,130 --> 00:38:49,409 to be OK for them. 803 00:38:49,409 --> 00:38:51,450 But what they really want is that in each diagram 804 00:38:51,450 --> 00:38:54,210 there are equal number of x and x bars. 805 00:38:54,210 --> 00:38:54,800 Why? 806 00:38:54,800 --> 00:38:56,410 And also what are they proving? 807 00:38:56,410 --> 00:39:02,800 So this is what they call the Mine Sweeper inference problem. 808 00:39:07,230 --> 00:39:11,090 But it's also what you might just call Mine Sweeper. 809 00:39:11,090 --> 00:39:12,937 I want to solve this puzzle. 810 00:39:12,937 --> 00:39:14,520 What does it mean to solve the puzzle? 811 00:39:14,520 --> 00:39:16,728 Well, it means you're given this partial information. 812 00:39:16,728 --> 00:39:18,780 You want to know am I done? 813 00:39:18,780 --> 00:39:19,840 Did I solve it? 814 00:39:19,840 --> 00:39:20,510 Can I solve it? 815 00:39:20,510 --> 00:39:22,330 Can I figure out where all the bombs are? 816 00:39:22,330 --> 00:39:26,470 This is like there being a unique solution. 817 00:39:26,470 --> 00:39:30,410 So I want to conclude that, OK, I can figure out 818 00:39:30,410 --> 00:39:32,530 where all the bombs are. 819 00:39:32,530 --> 00:39:37,400 So can you figure everything out? 820 00:39:47,840 --> 00:39:53,230 So again, the reduction is from something like circuit SAT. 821 00:39:53,230 --> 00:39:56,365 It's going to be a reduction from circuit unSAT. 822 00:40:04,820 --> 00:40:07,180 Unsatisfiability. 823 00:40:07,180 --> 00:40:10,570 So satisfiability you want to set the variables 824 00:40:10,570 --> 00:40:13,522 so that the outcome is true. 825 00:40:13,522 --> 00:40:15,730 You might say, well, I could try to set the variables 826 00:40:15,730 --> 00:40:16,990 so the outcome is false. 827 00:40:16,990 --> 00:40:18,810 That's the same problem. 828 00:40:18,810 --> 00:40:19,700 That won't change. 829 00:40:19,700 --> 00:40:21,910 Just put a NOT at the end. 830 00:40:21,910 --> 00:40:26,620 Unsatisfiability means that you cannot satisfy this formula. 831 00:40:26,620 --> 00:40:29,020 There's no way to set the variables to make 832 00:40:29,020 --> 00:40:31,870 the output true. 833 00:40:31,870 --> 00:40:39,410 There does not exist choices for the x ANDs, such 834 00:40:39,410 --> 00:40:46,420 that some f of xi's equals 1. 835 00:40:46,420 --> 00:40:50,099 If we do some-- who knows, this is called De Morgan? 836 00:40:50,099 --> 00:40:50,640 Probably not. 837 00:41:06,650 --> 00:41:10,790 Another fun fact is NOT there exists, 838 00:41:10,790 --> 00:41:14,280 NOT is the same thing as for all or however you 839 00:41:14,280 --> 00:41:16,000 want to write it. 840 00:41:16,000 --> 00:41:19,100 So if we put this negation over to here, 841 00:41:19,100 --> 00:41:21,730 this turns into universal quantifiers. 842 00:41:21,730 --> 00:41:25,030 These are extensial quantifiers to for alls. 843 00:41:25,030 --> 00:41:27,000 So this is quite a different problem. 844 00:41:27,000 --> 00:41:30,920 3SAT is about do there exist settings for these n variables 845 00:41:30,920 --> 00:41:33,360 such that this comes out to be true. 846 00:41:33,360 --> 00:41:36,600 Now we're saying no matter how you set the variables, 847 00:41:36,600 --> 00:41:40,019 this comes out to be true or false I guess. 848 00:41:40,019 --> 00:41:41,310 But again, that doesn't matter. 849 00:41:41,310 --> 00:41:44,062 You can just put the negation inside f if you wanted to. 850 00:41:44,062 --> 00:41:45,770 So the key difference here is we switched 851 00:41:45,770 --> 00:41:46,950 the quantify direction. 852 00:41:46,950 --> 00:41:49,200 This is such a big difference that this problem is not 853 00:41:49,200 --> 00:41:52,830 NP-complete, unless NP equals coNP. 854 00:41:52,830 --> 00:41:54,720 This problem is coNP complete. 855 00:42:03,870 --> 00:42:09,830 Recall coNP are the problems where you can always given 856 00:42:09,830 --> 00:42:10,670 no certificate. 857 00:42:10,670 --> 00:42:13,170 Whenever the answer is no, I can give you a short proof 858 00:42:13,170 --> 00:42:14,230 that the answer is no. 859 00:42:14,230 --> 00:42:18,060 How would I tell you that the answer to this question is no? 860 00:42:18,060 --> 00:42:19,880 I would give you a satisfying assignment. 861 00:42:19,880 --> 00:42:23,600 I'd give you xa to xn, where f ends up being 1, 862 00:42:23,600 --> 00:42:24,930 then you know this is not true. 863 00:42:24,930 --> 00:42:27,260 It's very hard to prove yes here. 864 00:42:27,260 --> 00:42:30,960 I mean you might have to check all possible exponentially many 865 00:42:30,960 --> 00:42:33,240 assignments to the xi's. 866 00:42:33,240 --> 00:42:35,420 Of course, we don't know whether that's possible. 867 00:42:35,420 --> 00:42:36,650 That's coNP completeness. 868 00:42:36,650 --> 00:42:43,120 It's the same NP versus p problem, but negated. 869 00:42:43,120 --> 00:42:44,050 Cool. 870 00:42:44,050 --> 00:42:47,580 So claim is Mine Sweeper inference is coNP-complete. 871 00:42:47,580 --> 00:42:49,620 And in general, the proper statement 872 00:42:49,620 --> 00:42:52,910 is Mine Sweeper is coNP-complete. 873 00:42:52,910 --> 00:42:56,530 Mine Sweeper consistency is NP-complete, 874 00:42:56,530 --> 00:42:59,420 but Mine Sweeper the game, I want to solve the game, 875 00:42:59,420 --> 00:43:00,700 is coNP-complete. 876 00:43:00,700 --> 00:43:01,540 Cool? 877 00:43:01,540 --> 00:43:05,500 This will be one of the few cases where coNP arises for us. 878 00:43:07,941 --> 00:43:08,440 Yeah. 879 00:43:08,440 --> 00:43:10,320 AUDIENCE: Where does coNP lie on this? 880 00:43:10,320 --> 00:43:11,827 We don't know? 881 00:43:11,827 --> 00:43:13,660 ERIK DEMAINE: In my one-dimensional diagram, 882 00:43:13,660 --> 00:43:16,170 you can think of NP and coNP lying in the same space, 883 00:43:16,170 --> 00:43:17,900 but maybe like in a parallel universe. 884 00:43:21,210 --> 00:43:22,320 I think. 885 00:43:22,320 --> 00:43:30,340 People always draw this picture, NP, coNP. 886 00:43:30,340 --> 00:43:33,290 P is here, and this is NP intersect coNP. 887 00:43:33,290 --> 00:43:38,140 And some people think that's the same thing as P. Who knows. 888 00:43:38,140 --> 00:43:41,950 So there are parallel universes, one about positive problems, 889 00:43:41,950 --> 00:43:45,240 one about negative problems. 890 00:43:45,240 --> 00:43:49,256 But in some sense, equal complexity. 891 00:43:49,256 --> 00:43:50,880 In this class we think about reductions 892 00:43:50,880 --> 00:43:52,088 as being one call reductions. 893 00:43:52,088 --> 00:43:53,530 You take your problem, you map it 894 00:43:53,530 --> 00:43:57,080 so that the output when you solve this new problem 895 00:43:57,080 --> 00:44:00,640 has exactly the same solution to the original problem. 896 00:44:00,640 --> 00:44:03,080 If you instead think about multi-call reductions 897 00:44:03,080 --> 00:44:05,870 where you can make calls to an oracle that solved the target 898 00:44:05,870 --> 00:44:08,450 problem multiple times and then do stuff with it-- 899 00:44:08,450 --> 00:44:10,450 you could, for example, call that thing, 900 00:44:10,450 --> 00:44:12,630 then negate the answer and return that. 901 00:44:12,630 --> 00:44:17,280 In that universe NP and coNP become the same thing. 902 00:44:17,280 --> 00:44:19,380 Or NP-completeness and coNP-completeness, 903 00:44:19,380 --> 00:44:21,580 which are about reductions, become the same thing. 904 00:44:21,580 --> 00:44:23,900 So that's the only thing holding them apart 905 00:44:23,900 --> 00:44:26,620 is that we're not allowed to negate the answer. 906 00:44:26,620 --> 00:44:28,336 So I view them as almost the same, 907 00:44:28,336 --> 00:44:30,960 but obviously they're different and you have to distinguish one 908 00:44:30,960 --> 00:44:31,420 from the other. 909 00:44:31,420 --> 00:44:33,570 But in terms of difficulty they're about the same. 910 00:44:33,570 --> 00:44:36,010 The difference between NP and coNP versus p space 911 00:44:36,010 --> 00:44:39,360 is totally different, or x time, or the other things 912 00:44:39,360 --> 00:44:41,470 in my one-dimensional diagram. 913 00:44:41,470 --> 00:44:41,970 Yeah? 914 00:44:41,970 --> 00:44:45,237 AUDIENCE: Would p equals NP imply p equals coNP? 915 00:44:45,237 --> 00:44:46,820 ERIK DEMAINE: If p equals NP, then I'm 916 00:44:46,820 --> 00:44:54,590 pretty sure NP equals coNP, because in polynomial time 917 00:44:54,590 --> 00:44:57,470 you can do-- yeah. p is closed under a complement, 918 00:44:57,470 --> 00:45:00,090 because you can solve the problem then negate. 919 00:45:00,090 --> 00:45:02,620 So I should say NP and coNP are different. 920 00:45:02,620 --> 00:45:05,650 But NP-complete and coNP-complete are very close, 921 00:45:05,650 --> 00:45:07,670 let's say. 922 00:45:07,670 --> 00:45:10,390 There's sort of dual-- for every problem over here, 923 00:45:10,390 --> 00:45:12,790 the corresponding problem over here is like the hardest, 924 00:45:12,790 --> 00:45:15,420 and they're sort of symmetric or something. 925 00:45:18,470 --> 00:45:19,090 All right. 926 00:45:19,090 --> 00:45:21,430 Phew. 927 00:45:21,430 --> 00:45:23,380 Back to Mine Sweeper. 928 00:45:23,380 --> 00:45:26,130 So here is the coNP-completeness. 929 00:45:26,130 --> 00:45:28,190 We have wires just like before, but I'm 930 00:45:28,190 --> 00:45:29,920 drawing them differently. 931 00:45:29,920 --> 00:45:33,190 Because part of the issue here is we 932 00:45:33,190 --> 00:45:35,410 are told how many bombs there are, 933 00:45:35,410 --> 00:45:38,090 and we don't want that information to help us. 934 00:45:38,090 --> 00:45:40,470 So we want every diagram to have an equal number 935 00:45:40,470 --> 00:45:42,116 of, say, x and x bars. 936 00:45:42,116 --> 00:45:43,740 So if we set it with x or set it with x 937 00:45:43,740 --> 00:45:46,790 bar, we use exactly the same number of bombs, 938 00:45:46,790 --> 00:45:49,990 Which means knowing what gadgets are glued together 939 00:45:49,990 --> 00:45:52,410 we can just add up how many bombs each one has. 940 00:45:52,410 --> 00:45:55,879 That will be the total number of bombs given to the puzzle. 941 00:45:55,879 --> 00:45:57,920 And that shouldn't give you any extra information 942 00:45:57,920 --> 00:45:59,544 because all of these pictures will have 943 00:45:59,544 --> 00:46:01,710 equal number of x's and x bars. 944 00:46:01,710 --> 00:46:06,830 So here we have wire, terminator, and turn. 945 00:46:06,830 --> 00:46:09,340 Pretty similar to before, but now checking 946 00:46:09,340 --> 00:46:12,090 that everything has equal number of x's and x bars. 947 00:46:12,090 --> 00:46:15,997 I think this turn, for example-- no, 948 00:46:15,997 --> 00:46:17,330 that one happens to be balanced. 949 00:46:17,330 --> 00:46:18,955 Some of these gadgets are not balanced. 950 00:46:18,955 --> 00:46:21,520 This one almost certainly. 951 00:46:21,520 --> 00:46:23,360 OK. 952 00:46:23,360 --> 00:46:30,150 So in this case, they construct a NOT gate and an OR gate. 953 00:46:30,150 --> 00:46:32,870 And then they also build a shifter. 954 00:46:32,870 --> 00:46:34,430 This is a different kind of shifter. 955 00:46:37,540 --> 00:46:41,690 It still has width and multiple of 3, but we're taking the wire 956 00:46:41,690 --> 00:46:43,990 and shifting it perpendicular by one unit. 957 00:46:43,990 --> 00:46:46,240 With turns you can simulate the other type of shifter, 958 00:46:46,240 --> 00:46:49,440 but this turns out to be the only one that they need. 959 00:46:49,440 --> 00:46:53,250 So let's talk about that first, let's say. 960 00:46:53,250 --> 00:47:00,270 So if x is set by this two and this bomb, this one is not set. 961 00:47:00,270 --> 00:47:02,300 This four already has three of them, 962 00:47:02,300 --> 00:47:03,849 so it effectively becomes a one. 963 00:47:03,849 --> 00:47:05,890 So then these two have to be opposites from each. 964 00:47:05,890 --> 00:47:08,750 This is sort of where the shift happens. 965 00:47:08,750 --> 00:47:11,725 And then because we have to deal with these bombs that 966 00:47:11,725 --> 00:47:12,480 are left over. 967 00:47:12,480 --> 00:47:14,270 Let's put some more in. 968 00:47:14,270 --> 00:47:17,550 And then this is five, so there's already four here, 969 00:47:17,550 --> 00:47:19,730 and so that forces an alternation there. 970 00:47:19,730 --> 00:47:21,900 So same idea, but with some bombs 971 00:47:21,900 --> 00:47:26,562 added in to fill the space, let's say. 972 00:47:26,562 --> 00:47:31,620 Got to do a one here, and a one here, a one there. 973 00:47:31,620 --> 00:47:32,370 This is a problem. 974 00:47:32,370 --> 00:47:34,684 I can't put a one here. 975 00:47:34,684 --> 00:47:36,350 That would force this guy to be present. 976 00:47:36,350 --> 00:47:38,245 So that's probably why that bomb is there, 977 00:47:38,245 --> 00:47:40,370 because we don't want to have to say how many bombs 978 00:47:40,370 --> 00:47:41,940 are adjacent to this corner. 979 00:47:41,940 --> 00:47:43,790 With regular wires you don't have corners. 980 00:47:43,790 --> 00:47:45,010 Good. 981 00:47:45,010 --> 00:47:47,740 But when you're doing a shift you have sort of corner. 982 00:47:47,740 --> 00:47:50,640 Same thing with the turn gadget that we already saw. 983 00:47:50,640 --> 00:47:51,360 OK. 984 00:47:51,360 --> 00:47:54,310 I think NOT is also pretty intelligible, 985 00:47:54,310 --> 00:47:55,910 but it's fairly complicated. 986 00:47:55,910 --> 00:48:00,310 It essentially involves making another copy of the signal 987 00:48:00,310 --> 00:48:03,590 just so we get an equal number of x's and x bars. 988 00:48:03,590 --> 00:48:06,665 Because we saw in the previous reduction with a NOT gate, 989 00:48:06,665 --> 00:48:08,720 we had this one isolated guy. 990 00:48:08,720 --> 00:48:10,450 That would be like this one. 991 00:48:10,450 --> 00:48:13,650 And so if you just have this picture, yeah, 992 00:48:13,650 --> 00:48:15,090 it would negate things. 993 00:48:15,090 --> 00:48:17,240 And again, this is designed to be mod three, 994 00:48:17,240 --> 00:48:23,929 so there's three, six-- that's hard to do-- nine, 12, 15. 995 00:48:23,929 --> 00:48:26,220 So things are nicely aligned on the mod three boundary, 996 00:48:26,220 --> 00:48:29,160 but they end up with these three dudes. 997 00:48:29,160 --> 00:48:30,510 They end up flipping the signal. 998 00:48:30,510 --> 00:48:33,179 Here's x, here's also x, which is like the reverse 999 00:48:33,179 --> 00:48:34,220 because it's on the left. 1000 00:48:36,810 --> 00:48:39,310 But this would have an unequal number of x's and x bars. 1001 00:48:39,310 --> 00:48:41,710 There's too many x's in this row. 1002 00:48:41,710 --> 00:48:45,510 So we end up splitting off a negated copy here, basically, 1003 00:48:45,510 --> 00:48:46,580 to balance things out. 1004 00:48:46,580 --> 00:48:48,371 And now if you count all the x's and x bars 1005 00:48:48,371 --> 00:48:50,600 they should be equal. 1006 00:48:50,600 --> 00:48:51,840 Cool. 1007 00:48:51,840 --> 00:48:54,380 And then they build an OR gate. 1008 00:48:54,380 --> 00:48:58,480 So it's again, looks fairly complicated. 1009 00:48:58,480 --> 00:49:00,490 Probably pretty simple in essence, 1010 00:49:00,490 --> 00:49:03,140 but I don't feel like checking all those cases. 1011 00:49:03,140 --> 00:49:07,825 What is annoying is that this thing is not mod three aligned. 1012 00:49:07,825 --> 00:49:11,600 Mod three aligned would be here or here, 1013 00:49:11,600 --> 00:49:14,030 with the output always in the middle finger. 1014 00:49:14,030 --> 00:49:15,570 But instead it's here. 1015 00:49:15,570 --> 00:49:17,690 And so they used the shift gadget over here 1016 00:49:17,690 --> 00:49:19,780 to offset that by one, and similarly 1017 00:49:19,780 --> 00:49:22,130 in all three pictures. 1018 00:49:22,130 --> 00:49:24,970 And then you get an OR gate with proper alignment. 1019 00:49:24,970 --> 00:49:27,820 Everything works out in mod three. 1020 00:49:27,820 --> 00:49:29,440 OK. 1021 00:49:29,440 --> 00:49:31,630 Cool. 1022 00:49:31,630 --> 00:49:35,900 So we have NOT and we have OR, therefore we have NOR, 1023 00:49:35,900 --> 00:49:40,980 and therefore we can build any logical gate we want. 1024 00:49:40,980 --> 00:49:45,620 An so we have turns, we have shifts that we need, 1025 00:49:45,620 --> 00:49:48,035 we have NOT, we have-- did we do split? 1026 00:49:48,035 --> 00:49:50,892 I think we did split on the previous-- nope, 1027 00:49:50,892 --> 00:49:52,190 we didn't do split. 1028 00:49:52,190 --> 00:49:54,810 OK, then let's do split. 1029 00:49:54,810 --> 00:49:57,790 So we need to copy our wires. 1030 00:49:57,790 --> 00:50:01,990 This is a more complicated version of the previous split. 1031 00:50:01,990 --> 00:50:04,670 Again, with an extra thing thrown in. 1032 00:50:04,670 --> 00:50:06,310 Like this is not needed. 1033 00:50:06,310 --> 00:50:09,790 You don't have to put this here, but it adds an extra x bar. 1034 00:50:09,790 --> 00:50:13,520 So there's actually two of those things. 1035 00:50:13,520 --> 00:50:16,150 And so together that offsets all the extra x copies 1036 00:50:16,150 --> 00:50:17,560 that are on the inside. 1037 00:50:17,560 --> 00:50:20,200 And so that forces, again, equal number of bombs, 1038 00:50:20,200 --> 00:50:23,700 whether it's x or x bar chosen. 1039 00:50:23,700 --> 00:50:26,220 So we can just count how many bombs 1040 00:50:26,220 --> 00:50:29,410 are needed in this picture. 1041 00:50:29,410 --> 00:50:30,400 Cool. 1042 00:50:30,400 --> 00:50:32,340 This is, again, a symmetric version. 1043 00:50:32,340 --> 00:50:36,850 So if you're thinking of, let's say, this as the input, 1044 00:50:36,850 --> 00:50:40,980 and these two as the output, than negation happened. 1045 00:50:40,980 --> 00:50:42,800 So if you don't want negation to happen, 1046 00:50:42,800 --> 00:50:44,270 just put a big NOT gate there. 1047 00:50:47,190 --> 00:50:49,992 And in this case they give a crossover gadget. 1048 00:50:49,992 --> 00:50:51,450 In particular because it's not that 1049 00:50:51,450 --> 00:50:56,330 hard to give a crossover gadget, but it's also not necessary. 1050 00:50:56,330 --> 00:50:58,760 So you could do crossover explicitly, 1051 00:50:58,760 --> 00:51:06,170 but in fact, I just looked on Wikipedia earlier today. 1052 00:51:06,170 --> 00:51:09,910 We already know that planar circuit SAT with NAND gates 1053 00:51:09,910 --> 00:51:10,900 is hard. 1054 00:51:10,900 --> 00:51:12,294 So can we build NAND? 1055 00:51:12,294 --> 00:51:14,960 And so I looked up in Wikipedia, how you build NAND out of NORs. 1056 00:51:14,960 --> 00:51:16,320 And the answer is this. 1057 00:51:16,320 --> 00:51:17,790 And that's planar. 1058 00:51:17,790 --> 00:51:19,220 So we're done. 1059 00:51:19,220 --> 00:51:22,790 You take this picture, you plug it into each of these guys. 1060 00:51:22,790 --> 00:51:24,520 And you take that picture and you plug it 1061 00:51:24,520 --> 00:51:26,330 into each of these guys. 1062 00:51:26,330 --> 00:51:28,700 Make sure to preserve planarity all the way through. 1063 00:51:28,700 --> 00:51:29,870 It does. 1064 00:51:29,870 --> 00:51:34,040 And then from-- I should know that's you construct NAND out 1065 00:51:34,040 --> 00:51:34,540 of NOR. 1066 00:51:34,540 --> 00:51:40,820 It's exactly from De Morgan law, because this is just negation. 1067 00:51:40,820 --> 00:51:42,596 So cool thing is all these constructions 1068 00:51:42,596 --> 00:51:43,970 preserve planarity which means we 1069 00:51:43,970 --> 00:51:46,740 can add to our definition of planar circuit SAT. 1070 00:51:46,740 --> 00:51:53,370 All gates are NAND or all gates are NOR. 1071 00:51:56,730 --> 00:52:01,620 This is nice because when you're solving next p set or whatever, 1072 00:52:01,620 --> 00:52:05,470 you can just take planar circuit SAT, 1073 00:52:05,470 --> 00:52:07,980 if you happen to construct a NAND gate you're done. 1074 00:52:07,980 --> 00:52:10,190 If you happen to construct an OR gate you're done. 1075 00:52:10,190 --> 00:52:11,270 No crossover needed. 1076 00:52:11,270 --> 00:52:14,950 You'll still need turns, and maybe a shift, 1077 00:52:14,950 --> 00:52:17,350 and maybe a terminator. 1078 00:52:17,350 --> 00:52:20,990 You won't need NOT if you build NAND or NOR. 1079 00:52:20,990 --> 00:52:24,250 You'll need a split, but you don't need a crossover anymore. 1080 00:52:24,250 --> 00:52:25,730 This is cool. 1081 00:52:25,730 --> 00:52:28,240 As far as I know a new result, but I mean obviously implicit 1082 00:52:28,240 --> 00:52:31,250 in all of these things. 1083 00:52:31,250 --> 00:52:31,750 Yeah. 1084 00:52:31,750 --> 00:52:34,900 AUDIENCE: Do you know if there's any sub-problem, I guess, 1085 00:52:34,900 --> 00:52:37,930 is that where you don't have universal gates 1086 00:52:37,930 --> 00:52:43,060 and you can't be planar and get it so hard? 1087 00:52:43,060 --> 00:52:44,070 So maybe you can-- 1088 00:52:44,070 --> 00:52:45,320 ERIK DEMAINE: Oh, interesting. 1089 00:52:45,320 --> 00:52:46,861 AUDIENCE: You can split wires and you 1090 00:52:46,861 --> 00:52:50,542 have a variable that has the negation of it coming out, 1091 00:52:50,542 --> 00:52:51,625 but that's all you can do. 1092 00:52:51,625 --> 00:52:52,600 No other NOT gates. 1093 00:52:56,930 --> 00:52:59,130 ERIK DEMAINE: My guess is that all such problems are 1094 00:52:59,130 --> 00:53:01,090 polynomially solvable, but maybe that's something 1095 00:53:01,090 --> 00:53:01,965 we could think about. 1096 00:53:04,800 --> 00:53:06,280 Certainly plausible that you don't 1097 00:53:06,280 --> 00:53:08,710 need to be able to construct all Boolean formulas in order 1098 00:53:08,710 --> 00:53:09,800 to be hard. 1099 00:53:09,800 --> 00:53:14,380 But my vague sense/experience playing around 1100 00:53:14,380 --> 00:53:17,260 with weird other gates, most of them 1101 00:53:17,260 --> 00:53:19,170 are all equivalent to splits if they're not 1102 00:53:19,170 --> 00:53:21,990 universal-- something like a split. 1103 00:53:21,990 --> 00:53:24,610 Maybe with some like five operand operator, 1104 00:53:24,610 --> 00:53:26,080 you could do something cool. 1105 00:53:26,080 --> 00:53:30,490 But usually they degenerate to other split-like things 1106 00:53:30,490 --> 00:53:34,090 or clause-like things. 1107 00:53:34,090 --> 00:53:36,880 But if you don't have both, you don't get enough to be hard. 1108 00:53:36,880 --> 00:53:38,380 We should prove a theorem like that, 1109 00:53:38,380 --> 00:53:42,530 but I would guess that you need something like this. 1110 00:53:42,530 --> 00:53:44,910 Now these are not the only universal gate sets. 1111 00:53:44,910 --> 00:53:50,170 I think in a moment I will have a-- if you are curious 1112 00:53:50,170 --> 00:53:52,569 about more of what universal gate sets are, 1113 00:53:52,569 --> 00:53:54,110 these are usually called functionally 1114 00:53:54,110 --> 00:53:56,266 complete or functional completeness. 1115 00:53:56,266 --> 00:53:57,640 If you look at that on Wikipedia, 1116 00:53:57,640 --> 00:53:59,380 this is an excerpt from Wikipedia, 1117 00:53:59,380 --> 00:54:03,140 you see NAND and NOR are the only, among arity two 1118 00:54:03,140 --> 00:54:06,539 operators, so you have two inputs, one output. 1119 00:54:06,539 --> 00:54:08,080 NAND and NOR are the only things that 1120 00:54:08,080 --> 00:54:09,630 by themselves are universal. 1121 00:54:09,630 --> 00:54:13,140 But once you allow two different gates you can do other things. 1122 00:54:13,140 --> 00:54:15,740 So these are particularly interesting. 1123 00:54:15,740 --> 00:54:19,260 This is false I think. 1124 00:54:19,260 --> 00:54:23,310 It's called [INAUDIBLE], and this is called top, it's true. 1125 00:54:23,310 --> 00:54:26,504 And so these are slightly unusual ways for me 1126 00:54:26,504 --> 00:54:27,670 to think about writing them. 1127 00:54:27,670 --> 00:54:30,960 Here we have, of course, AND and NOT. 1128 00:54:30,960 --> 00:54:34,710 But this is right implication, which 1129 00:54:34,710 --> 00:54:37,230 is like not the left thing or the right thing. 1130 00:54:37,230 --> 00:54:38,710 We talked about that in the past. 1131 00:54:38,710 --> 00:54:41,020 That by itself is not enough, because you can just 1132 00:54:41,020 --> 00:54:42,160 follow implication chains. 1133 00:54:42,160 --> 00:54:45,876 But if you also have false, that is universal. 1134 00:54:45,876 --> 00:54:48,290 So that's kind of funny. 1135 00:54:48,290 --> 00:54:52,690 And this is XOR I think. 1136 00:54:52,690 --> 00:54:56,430 XOR is the same as saying that the two things are different. 1137 00:54:56,430 --> 00:54:58,462 And this is XNOR. 1138 00:54:58,462 --> 00:55:00,170 So those by themselves are not universal, 1139 00:55:00,170 --> 00:55:02,461 but if you have some other kind of one-way implication, 1140 00:55:02,461 --> 00:55:05,890 then that gives you any logical formulas. 1141 00:55:05,890 --> 00:55:09,040 Now, whether these in the planar version are hard, I don't know. 1142 00:55:09,040 --> 00:55:13,370 But I know that Ds in the planar version are hard. 1143 00:55:13,370 --> 00:55:15,474 OK, back to Mine Sweeper. 1144 00:55:15,474 --> 00:55:17,640 They drew a picture of how everything fits together, 1145 00:55:17,640 --> 00:55:20,142 so it's maybe nice to have the big picture. 1146 00:55:20,142 --> 00:55:22,350 But let's in particular think about what the decision 1147 00:55:22,350 --> 00:55:26,005 question is and make sure-- I mean I claim this is coNP 1148 00:55:26,005 --> 00:55:28,630 and then we're doing unSATs, but we should actually check that. 1149 00:55:28,630 --> 00:55:30,810 At this point we've just simulated a circuit. 1150 00:55:30,810 --> 00:55:33,490 We haven't thought about what we're trying to solve overall. 1151 00:55:33,490 --> 00:55:37,920 Now, we want to know whether we can derive everything. 1152 00:55:37,920 --> 00:55:41,712 So we compute our formula and then the output is here. 1153 00:55:41,712 --> 00:55:43,420 And at this point there's just a terminal 1154 00:55:43,420 --> 00:55:46,030 there saying I don't know what it is. 1155 00:55:46,030 --> 00:55:47,805 Different from the previous proof. 1156 00:55:47,805 --> 00:55:51,040 The previous proof said that should be one at the end, 1157 00:55:51,040 --> 00:55:53,460 and then you have to figure out how to fill in the things. 1158 00:55:53,460 --> 00:55:56,900 Now we're saying, I don't know what's there. 1159 00:55:56,900 --> 00:55:59,200 Can you figure out what's there? 1160 00:55:59,200 --> 00:56:01,960 And if it's the case that no matter how 1161 00:56:01,960 --> 00:56:06,280 you set the variables you always get false, 1162 00:56:06,280 --> 00:56:09,320 then you know what this wire looks like. 1163 00:56:09,320 --> 00:56:10,420 You know that it's false. 1164 00:56:10,420 --> 00:56:12,260 And in fact, you can figure out everything. 1165 00:56:12,260 --> 00:56:13,635 If you know what all the XI's are 1166 00:56:13,635 --> 00:56:15,650 you can just run through the circuit. 1167 00:56:15,650 --> 00:56:19,200 So you can figure out the entire diagram. 1168 00:56:19,200 --> 00:56:21,070 But in general, just asking the question, 1169 00:56:21,070 --> 00:56:22,870 can I figure out this square? 1170 00:56:22,870 --> 00:56:24,860 Is there a bomb or not? 1171 00:56:24,860 --> 00:56:27,350 In order for there not to be a bomb, 1172 00:56:27,350 --> 00:56:30,800 you would have to solve this problem. 1173 00:56:30,800 --> 00:56:32,690 You need to determine that no matter 1174 00:56:32,690 --> 00:56:36,020 how you set the things you end up with a zero. 1175 00:56:36,020 --> 00:56:39,860 Or the adjacent position it would be the opposite. 1176 00:56:39,860 --> 00:56:42,010 So conversely, what I really care about-- that 1177 00:56:42,010 --> 00:56:43,720 was the wrong direction. 1178 00:56:43,720 --> 00:56:46,240 I'm given a circuit unSAT instance. 1179 00:56:46,240 --> 00:56:48,235 I want to turn it into a Mine Sweeper instance. 1180 00:56:48,235 --> 00:56:55,410 So I do that, and then the question is-- get this right-- 1181 00:56:55,410 --> 00:56:58,960 can you derive whether there is a bomb in this square? 1182 00:56:58,960 --> 00:57:03,270 Can you determine that there must be a bomb in this square, 1183 00:57:03,270 --> 00:57:04,130 for example? 1184 00:57:04,130 --> 00:57:07,160 That would be a slightly cleaner version. 1185 00:57:07,160 --> 00:57:12,090 And that will be true, if and only if no matter what you do, 1186 00:57:12,090 --> 00:57:13,420 there's a bomb in that square. 1187 00:57:13,420 --> 00:57:15,680 Which is like saying no matter what you do, 1188 00:57:15,680 --> 00:57:18,210 this formula comes out to zero. 1189 00:57:18,210 --> 00:57:20,230 So any kind of inference question like that 1190 00:57:20,230 --> 00:57:25,550 is going to require you to solve this problem, 1191 00:57:25,550 --> 00:57:27,430 or rather, this problem can be reduced 1192 00:57:27,430 --> 00:57:30,820 to any inference problem like that. 1193 00:57:30,820 --> 00:57:35,150 It's easy to get backwards here, so hope I got it all right. 1194 00:57:35,150 --> 00:57:37,350 And that's coNP completeness. 1195 00:57:37,350 --> 00:57:40,257 Reductions look the same for coNP. 1196 00:57:40,257 --> 00:57:41,840 We just start with different problems. 1197 00:57:45,320 --> 00:57:46,870 Cool. 1198 00:57:46,870 --> 00:57:52,380 So that was Mine Sweeper and functional completeness. 1199 00:57:52,380 --> 00:57:54,900 I have one more-- well, sort of two more proofs. 1200 00:57:54,900 --> 00:57:59,830 Only one that I will talk about in detail for Candy Crush 1201 00:57:59,830 --> 00:58:04,850 and soon enough, Bejeweled. 1202 00:58:04,850 --> 00:58:07,740 But let's think about Candy Crush is the modern version. 1203 00:58:07,740 --> 00:58:11,510 I'm guessing you've all played, but in case not, 1204 00:58:11,510 --> 00:58:12,260 please don't play. 1205 00:58:12,260 --> 00:58:14,830 It's very addictive. 1206 00:58:14,830 --> 00:58:16,850 But on the slides we're allowed to. 1207 00:58:16,850 --> 00:58:22,540 So you have a grid of colors, colored candies. 1208 00:58:22,540 --> 00:58:26,530 And a move in this game is to take two candies 1209 00:58:26,530 --> 00:58:29,190 and switch their order. 1210 00:58:29,190 --> 00:58:31,620 I guess in this picture I did these two. 1211 00:58:31,620 --> 00:58:34,380 If you switch these two you get this picture. 1212 00:58:34,380 --> 00:58:38,270 And the mechanics of the game, the physics or whatever, 1213 00:58:38,270 --> 00:58:40,950 is whenever you have three or more candies 1214 00:58:40,950 --> 00:58:45,300 of the same color in a row or column, or in a row, 1215 00:58:45,300 --> 00:58:47,040 then they disappear. 1216 00:58:47,040 --> 00:58:48,455 And anything above them falls. 1217 00:58:48,455 --> 00:58:50,682 So like this red candy ends up there. 1218 00:58:50,682 --> 00:58:52,640 In this case, there were no more candies above. 1219 00:58:52,640 --> 00:58:55,098 In the real game usually there's always more candies above. 1220 00:58:55,098 --> 00:58:59,210 But if we're in a small game this won't-- if we're in a big 1221 00:58:59,210 --> 00:59:00,930 game and looking at a small window, 1222 00:59:00,930 --> 00:59:03,430 we know everything about what will fall. 1223 00:59:03,430 --> 00:59:06,356 AUDIENCE: Do you need to make them fall or do they 1224 00:59:06,356 --> 00:59:07,730 automatically fall once you get-- 1225 00:59:07,730 --> 00:59:09,313 ERIK DEMAINE: They automatically fall. 1226 00:59:09,313 --> 00:59:11,700 Yeah, so they are forced to fall. 1227 00:59:11,700 --> 00:59:13,380 It's all I get to do is make this move 1228 00:59:13,380 --> 00:59:15,060 and then stuff happens. 1229 00:59:15,060 --> 00:59:17,050 So I make this move and then anything 1230 00:59:17,050 --> 00:59:20,329 that-- any three in a rows or more disappear. 1231 00:59:20,329 --> 00:59:22,120 And then if that makes more three in a rows 1232 00:59:22,120 --> 00:59:23,800 they will disappear and so on. 1233 00:59:23,800 --> 00:59:25,940 And my hands are off at that point. 1234 00:59:25,940 --> 00:59:28,640 Once the chain reactions are finished-- 1235 00:59:28,640 --> 00:59:30,660 not all games work this way, but Candy Crush 1236 00:59:30,660 --> 00:59:31,980 happens to work this way. 1237 00:59:31,980 --> 00:59:34,750 Once these things are finished, then I can do another exchange. 1238 00:59:34,750 --> 00:59:38,340 And when I do an exchange I must make three in a row. 1239 00:59:38,340 --> 00:59:40,895 I can't just swap these two guys. 1240 00:59:40,895 --> 00:59:41,770 It's not interesting. 1241 00:59:41,770 --> 00:59:44,320 AUDIENCE: What if it's like a T pattern or like non-linear? 1242 00:59:47,342 --> 00:59:48,300 ERIK DEMAINE: Yeah, OK. 1243 00:59:48,300 --> 00:59:49,800 In this picture we'll never have Ts. 1244 00:59:49,800 --> 00:59:52,360 It will always be three in a row, and never a four in a row. 1245 00:59:52,360 --> 00:59:55,370 With four in a row, magical striped candies happen 1246 00:59:55,370 --> 00:59:57,980 and you don't want to know. 1247 00:59:57,980 --> 01:00:01,430 So potentially you can get up to five in a row with these rows, 1248 01:00:01,430 --> 01:00:03,860 but in these reductions that won't happen. 1249 01:00:03,860 --> 01:00:06,850 So we don't care what the rules say there. 1250 01:00:06,850 --> 01:00:08,560 We're only going to get three in a rows. 1251 01:00:08,560 --> 01:00:11,130 There is a weird catch in this proof. 1252 01:00:11,130 --> 01:00:15,530 I'm going to mention two proofs from 2014, so all very recent. 1253 01:00:15,530 --> 01:00:17,810 I guess the game isn't that old. 1254 01:00:17,810 --> 01:00:22,170 And in this proof we're going to assume if-- in general, there 1255 01:00:22,170 --> 01:00:25,400 may be multiple three in a rows at once. 1256 01:00:25,400 --> 01:00:28,090 And the proof is going to assume that they are resolved bottom 1257 01:00:28,090 --> 01:00:31,890 to top, so you do the bottom-most one first, things 1258 01:00:31,890 --> 01:00:35,170 fall, then you do the next one, things fall, do the next one, 1259 01:00:35,170 --> 01:00:36,410 things fall. 1260 01:00:36,410 --> 01:00:38,100 That's not how the actual game works. 1261 01:00:38,100 --> 01:00:42,510 In the game, they all disappear simultaneously 1262 01:00:42,510 --> 01:00:43,840 and then stuff falls. 1263 01:00:43,840 --> 01:00:45,670 OK, but ignore that for the moment. 1264 01:00:45,670 --> 01:00:47,412 The next proof will change the model. 1265 01:00:47,412 --> 01:00:49,620 OK, this is a much easier one to think about and draw 1266 01:00:49,620 --> 01:00:50,720 the pictures. 1267 01:00:50,720 --> 01:00:55,310 So in that model, here's a variable gadget. 1268 01:00:55,310 --> 01:00:58,310 The starting point's the same, picture top and bottom. 1269 01:00:58,310 --> 01:01:00,170 And the idea is either you exchange 1270 01:01:00,170 --> 01:01:02,920 these two to make three, or you exchange 1271 01:01:02,920 --> 01:01:04,550 these two to make three. 1272 01:01:04,550 --> 01:01:07,900 And the consequence is either the right column falls by three 1273 01:01:07,900 --> 01:01:09,560 or the middle column falls by three. 1274 01:01:09,560 --> 01:01:11,930 And that's all you can do local to this gadget. 1275 01:01:11,930 --> 01:01:13,107 So that's easy. 1276 01:01:13,107 --> 01:01:14,440 Things are going to get messier. 1277 01:01:17,620 --> 01:01:21,100 OK, so you have this picture, variable gadget for XI. 1278 01:01:21,100 --> 01:01:25,360 Above it I'm going to make one of these two gadgets. 1279 01:01:25,360 --> 01:01:27,887 Actually, both of them, but one at a time. 1280 01:01:27,887 --> 01:01:29,470 So in fact, it will actually look kind 1281 01:01:29,470 --> 01:01:31,380 of like this, stacked on top of the variable which 1282 01:01:31,380 --> 01:01:32,070 is down here. 1283 01:01:32,070 --> 01:01:33,410 So variables down here. 1284 01:01:33,410 --> 01:01:38,415 Either the center column falls or the right column falls. 1285 01:01:38,415 --> 01:01:41,160 Now, the idea is this is going to eventually connect 1286 01:01:41,160 --> 01:01:43,650 to a clause, and this variable-- I should 1287 01:01:43,650 --> 01:01:45,220 say this is not for circuit SAT, this 1288 01:01:45,220 --> 01:01:48,600 is from 3SAT-- regular old 3SAT. 1289 01:01:48,600 --> 01:01:51,252 So that variable appears in a clause 1290 01:01:51,252 --> 01:01:52,960 either in positive form or negative form. 1291 01:01:52,960 --> 01:01:54,160 Positive, use this gadget. 1292 01:01:54,160 --> 01:01:56,080 Negative, use this gadget. 1293 01:01:56,080 --> 01:02:00,540 So in the positive case, if this falls by three 1294 01:02:00,540 --> 01:02:04,470 we get this picture, and then these disappear, 1295 01:02:04,470 --> 01:02:06,520 and so this guy falls one more. 1296 01:02:06,520 --> 01:02:08,810 And the idea is that's going to trigger something off 1297 01:02:08,810 --> 01:02:09,380 to the right. 1298 01:02:09,380 --> 01:02:12,060 That will be next slide. 1299 01:02:12,060 --> 01:02:14,130 That will be the wire gadget. 1300 01:02:14,130 --> 01:02:18,030 If the center column fell by three, nothing would happen. 1301 01:02:18,030 --> 01:02:20,680 The purples-- so I should mention how 1302 01:02:20,680 --> 01:02:22,170 these gadgets are constructed. 1303 01:02:22,170 --> 01:02:25,890 There's a four color sort of checkerboard pattern 1304 01:02:25,890 --> 01:02:27,220 in odd rows. 1305 01:02:27,220 --> 01:02:29,400 It's alternating orange, green, orange, green. 1306 01:02:29,400 --> 01:02:32,540 In even rows it's alternating red, yellow, red, yellow. 1307 01:02:32,540 --> 01:02:35,270 And then in a few places we're going to put the purple ones, 1308 01:02:35,270 --> 01:02:37,130 because purple's best. 1309 01:02:37,130 --> 01:02:40,940 And all the action is going to be in the purple candies. 1310 01:02:40,940 --> 01:02:43,900 These guys are just out there-- and the real game 1311 01:02:43,900 --> 01:02:44,670 has six colors. 1312 01:02:44,670 --> 01:02:45,920 We're only using five of them. 1313 01:02:45,920 --> 01:02:47,204 So cool. 1314 01:02:47,204 --> 01:02:48,620 These guys are just sort of filler 1315 01:02:48,620 --> 01:02:50,700 to make sure nothing else happens. 1316 01:02:50,700 --> 01:02:55,730 But still things fall vertically in a nice controlled way. 1317 01:02:55,730 --> 01:03:00,640 OK, so if these fall by three, the purples 1318 01:03:00,640 --> 01:03:02,210 don't align so nothing happens. 1319 01:03:02,210 --> 01:03:04,840 In this case, if the center one falls by three 1320 01:03:04,840 --> 01:03:07,660 we get alignment, and that falls by one. 1321 01:03:07,660 --> 01:03:10,030 So great. 1322 01:03:10,030 --> 01:03:16,430 Also note, these gadgets stack somewhat nicely. 1323 01:03:16,430 --> 01:03:20,170 In that other than this three gap-- in reality, 1324 01:03:20,170 --> 01:03:21,760 more candies will fill in here. 1325 01:03:21,760 --> 01:03:23,790 I drew it this way so you could see how 1326 01:03:23,790 --> 01:03:26,020 much the columns actually fall. 1327 01:03:26,020 --> 01:03:28,490 Remember, this all sort of happens in one move. 1328 01:03:28,490 --> 01:03:32,690 So this falls, these clear, then this will clear, 1329 01:03:32,690 --> 01:03:35,240 and stuff happens. 1330 01:03:35,240 --> 01:03:35,890 It's annoying. 1331 01:03:35,890 --> 01:03:40,100 So, so far everything's good because each of these 1332 01:03:40,100 --> 01:03:44,550 has fallen by one in addition to the original three. 1333 01:03:44,550 --> 01:03:49,535 But in this case, this follows by an extra one, 1334 01:03:49,535 --> 01:03:51,915 and I think you need to add an extra candy here. 1335 01:03:51,915 --> 01:03:54,450 I'm a little unclear in the details on how to do that. 1336 01:03:54,450 --> 01:03:58,540 It's mentioned in the paper, but without details. 1337 01:03:58,540 --> 01:04:01,242 Anyway, in the end we will have a bunch of these 1338 01:04:01,242 --> 01:04:02,450 stacked on top of each other. 1339 01:04:02,450 --> 01:04:05,085 Each time the variable occurs in various clauses 1340 01:04:05,085 --> 01:04:06,460 we're going to have some positive 1341 01:04:06,460 --> 01:04:07,800 and some negative ones. 1342 01:04:07,800 --> 01:04:11,190 And we want the same variable trigger-- ah, that's right. 1343 01:04:11,190 --> 01:04:14,060 There will be-- well, OK. 1344 01:04:14,060 --> 01:04:14,560 Yeah. 1345 01:04:14,560 --> 01:04:17,270 I'm going to leave it like that. 1346 01:04:17,270 --> 01:04:22,270 So at this point we have a purple thing triggering 1347 01:04:22,270 --> 01:04:23,280 something to the right. 1348 01:04:23,280 --> 01:04:24,780 So now I'm going to show you how that part works. 1349 01:04:24,780 --> 01:04:25,870 This is the wire. 1350 01:04:25,870 --> 01:04:27,444 So the wire itself is like this. 1351 01:04:27,444 --> 01:04:29,610 And the idea is that when there's a purple one here, 1352 01:04:29,610 --> 01:04:31,750 a chain reaction happens. 1353 01:04:31,750 --> 01:04:33,160 And it happens in this way. 1354 01:04:33,160 --> 01:04:37,850 As soon as there's a purple candy here, this clears, 1355 01:04:37,850 --> 01:04:39,900 which makes these two fall by one, 1356 01:04:39,900 --> 01:04:42,800 which clears that, which makes this fall by one, 1357 01:04:42,800 --> 01:04:45,790 and triggers the next thing. 1358 01:04:45,790 --> 01:04:51,330 This one, some stacking happens. 1359 01:04:51,330 --> 01:04:52,260 Let's see. 1360 01:04:52,260 --> 01:04:56,910 So overall, I think this one is actually better behaved. 1361 01:04:56,910 --> 01:05:00,340 This falls by one here and then two. 1362 01:05:00,340 --> 01:05:02,870 So overall these columns fell by two. 1363 01:05:02,870 --> 01:05:05,500 This column has fallen so far by one, 1364 01:05:05,500 --> 01:05:07,349 but it's about to fall by a second one, 1365 01:05:07,349 --> 01:05:09,140 because this will always trigger something. 1366 01:05:09,140 --> 01:05:11,700 And so these do stack nicely, because you always 1367 01:05:11,700 --> 01:05:13,430 clear exactly two columns. 1368 01:05:13,430 --> 01:05:16,490 The worry is that the gadget above it will be skewed. 1369 01:05:19,579 --> 01:05:21,120 Let me give you one more gadget, then 1370 01:05:21,120 --> 01:05:23,370 I'll tell you-- no, actually, I think 1371 01:05:23,370 --> 01:05:26,450 at this point I should tell you how things fit together, 1372 01:05:26,450 --> 01:05:29,060 which is this picture. 1373 01:05:35,450 --> 01:05:41,765 So we have variables down here in the lower left. 1374 01:05:47,960 --> 01:05:51,105 Then let's worry about one thing at a time. 1375 01:05:55,140 --> 01:05:57,485 These are the connection gadgets. 1376 01:06:00,460 --> 01:06:03,390 I don't think I told you their name. 1377 01:06:03,390 --> 01:06:06,380 But they are your connector gadgets. 1378 01:06:06,380 --> 01:06:08,350 This is making a 90 degree turn. 1379 01:06:08,350 --> 01:06:10,070 From the falling action we're going 1380 01:06:10,070 --> 01:06:12,710 to get a purple in a particular position, which 1381 01:06:12,710 --> 01:06:14,755 causes rightward motion. 1382 01:06:14,755 --> 01:06:21,760 And then the wires that you saw basically go in some angle 1383 01:06:21,760 --> 01:06:22,470 off to the right. 1384 01:06:27,924 --> 01:06:29,590 I want these all to be non-intersecting. 1385 01:06:33,410 --> 01:06:36,830 And there's sort of two of them. 1386 01:06:36,830 --> 01:06:41,490 There's going to be the true case and the false case. 1387 01:06:41,490 --> 01:06:44,370 And then way over here somewhere, 1388 01:06:44,370 --> 01:06:51,930 we're going to have a clause where these wires all attach. 1389 01:06:51,930 --> 01:06:53,770 And then above it we're going to have 1390 01:06:53,770 --> 01:07:01,540 a reward where you get tons of points, and et cetera. 1391 01:07:01,540 --> 01:07:05,155 So let me tell you what happens next. 1392 01:07:07,760 --> 01:07:11,500 It's a fun way to draw the picture. 1393 01:07:11,500 --> 01:07:14,420 So above these we'll have some other connections. 1394 01:07:17,035 --> 01:07:19,480 I should not do it in the same pattern. 1395 01:07:19,480 --> 01:07:20,930 I should not do it like that. 1396 01:07:20,930 --> 01:07:21,590 Yeah, sure. 1397 01:07:21,590 --> 01:07:23,582 Connection, connection. 1398 01:07:27,890 --> 01:07:31,910 OK, again, diagonal lines. 1399 01:07:31,910 --> 01:07:33,270 Great. 1400 01:07:33,270 --> 01:07:34,080 Not quite diagonal. 1401 01:07:34,080 --> 01:07:35,030 It's an angle. 1402 01:07:35,030 --> 01:07:36,572 We have a clause. 1403 01:07:36,572 --> 01:07:37,530 Everything connects up. 1404 01:07:37,530 --> 01:07:40,730 Above the clause is a reward. 1405 01:07:43,810 --> 01:07:51,360 And then I move boards, and that's the picture. 1406 01:07:51,360 --> 01:07:53,280 And above the variables, we just keep 1407 01:07:53,280 --> 01:07:57,510 adding more connections connected to some clauses. 1408 01:07:57,510 --> 01:08:01,470 And there's not just three variables, of course. 1409 01:08:01,470 --> 01:08:04,910 There's n variables down here, and we use some, three of them, 1410 01:08:04,910 --> 01:08:06,530 and then connect that off to a clause. 1411 01:08:06,530 --> 01:08:10,360 And they're all just stacked-- I happen to draw the clauses 1412 01:08:10,360 --> 01:08:11,360 one on top of the other. 1413 01:08:11,360 --> 01:08:13,100 That shouldn't happen. 1414 01:08:13,100 --> 01:08:14,980 So there's some extra space here. 1415 01:08:14,980 --> 01:08:17,240 This is more over to the right. 1416 01:08:17,240 --> 01:08:19,374 So that none of them will interact with each other. 1417 01:08:19,374 --> 01:08:20,040 That's the goal. 1418 01:08:23,670 --> 01:08:29,689 Except there's some issues, like notice this wire gadget, 1419 01:08:29,689 --> 01:08:31,979 notice dual rail logic. 1420 01:08:31,979 --> 01:08:34,825 Either this is active or this is active. 1421 01:08:34,825 --> 01:08:36,200 And we hope that not both of them 1422 01:08:36,200 --> 01:08:38,325 are active, although that can actually happen here. 1423 01:08:38,325 --> 01:08:40,350 I'll get to that. 1424 01:08:40,350 --> 01:08:44,609 So when this activates, notice this goes 1425 01:08:44,609 --> 01:08:47,300 on top of a variable gadget. 1426 01:08:47,300 --> 01:08:49,310 Now, a wire by itself is kind of good. 1427 01:08:49,310 --> 01:08:52,410 We've seen it removes two things from every spot. 1428 01:08:52,410 --> 01:08:56,500 So things don't shift too much. 1429 01:08:56,500 --> 01:09:00,149 And furthermore, we should hope that either this activates 1430 01:09:00,149 --> 01:09:01,060 or this activates. 1431 01:09:01,060 --> 01:09:02,850 So this will shift by a consistent amount 1432 01:09:02,850 --> 01:09:04,670 in either case. 1433 01:09:04,670 --> 01:09:10,109 But the wire may get messed up because the variable actually 1434 01:09:10,109 --> 01:09:13,260 removes three things from one of the columns. 1435 01:09:13,260 --> 01:09:21,130 So we need a better wire gadget, which looks like this. 1436 01:09:21,130 --> 01:09:22,420 This is a super wire gadget. 1437 01:09:22,420 --> 01:09:23,520 It's really cool. 1438 01:09:23,520 --> 01:09:27,399 It works no matter how you use it, kind of. 1439 01:09:27,399 --> 01:09:29,670 So this is what it looks like in general. 1440 01:09:29,670 --> 01:09:31,330 And this is regular use. 1441 01:09:31,330 --> 01:09:34,529 So as before, if we trigger this, 1442 01:09:34,529 --> 01:09:38,760 then this triggers, and this guy falls by one, just like before. 1443 01:09:38,760 --> 01:09:41,450 But now also, if there's a variable down here 1444 01:09:41,450 --> 01:09:44,310 and this column falls by three-- or sorry. 1445 01:09:44,310 --> 01:09:47,500 If this column falls by three, so the same picture, 1446 01:09:47,500 --> 01:09:52,195 the things fell by three, still everything works out. 1447 01:09:52,195 --> 01:09:54,390 These two fall. 1448 01:09:54,390 --> 01:09:56,690 These two fall but they meet a different dude. 1449 01:09:56,690 --> 01:10:00,380 But there were a bunch of guys to meet up with, so it's fine. 1450 01:10:00,380 --> 01:10:05,620 And I clearly drew the output in the wrong place. 1451 01:10:05,620 --> 01:10:07,561 The output should be here I think. 1452 01:10:07,561 --> 01:10:08,060 Yeah. 1453 01:10:08,060 --> 01:10:11,600 So in this picture the output was here, 1454 01:10:11,600 --> 01:10:13,120 also it shifted by one. 1455 01:10:13,120 --> 01:10:16,550 In this picture the output is here, not up there. 1456 01:10:16,550 --> 01:10:18,340 So in both cases it triggers. 1457 01:10:18,340 --> 01:10:20,840 And finally if the middle column fell by three 1458 01:10:20,840 --> 01:10:24,840 before this gadget activated, then this, 1459 01:10:24,840 --> 01:10:28,360 again, triggers this time with this guy being different. 1460 01:10:28,360 --> 01:10:31,360 Instead of this one matching, this one's matching. 1461 01:10:31,360 --> 01:10:36,220 That still triggers these guys and this is still the output. 1462 01:10:36,220 --> 01:10:38,374 So this is a different wire gadget 1463 01:10:38,374 --> 01:10:40,040 that works in three different scenarios, 1464 01:10:40,040 --> 01:10:42,050 depending on what happened below it. 1465 01:10:42,050 --> 01:10:43,290 So that's good news. 1466 01:10:43,290 --> 01:10:47,590 That lets us do this type of wire. 1467 01:10:47,590 --> 01:10:50,160 And in general, we're going to have a chain reaction all 1468 01:10:50,160 --> 01:10:56,090 the way down here until we get to the clause from bottom 1469 01:10:56,090 --> 01:10:57,020 to top. 1470 01:10:57,020 --> 01:10:58,750 And this we'll resolve. 1471 01:10:58,750 --> 01:11:02,996 And let me show you the clause. 1472 01:11:02,996 --> 01:11:06,490 I think details are a little bit messy. 1473 01:11:06,490 --> 01:11:10,340 There's a little locking mechanism here. 1474 01:11:10,340 --> 01:11:13,980 But basically the idea is all of these things come 1475 01:11:13,980 --> 01:11:16,570 in, x1, x1 bar, x2, x2 bar. 1476 01:11:16,570 --> 01:11:20,390 All of the half wires or semi-wires. 1477 01:11:20,390 --> 01:11:24,270 And so we expect one of these to activate. 1478 01:11:24,270 --> 01:11:27,830 Maybe you don't do that, but that would be weird, 1479 01:11:27,830 --> 01:11:30,190 and you won't end up satisfying the clause. 1480 01:11:30,190 --> 01:11:36,310 So if this one activates, then these align, and you're happy. 1481 01:11:36,310 --> 01:11:38,902 In general, if you can get this column to fall, 1482 01:11:38,902 --> 01:11:41,110 you're going to be happy, because above this thing is 1483 01:11:41,110 --> 01:11:42,090 this reward gadget. 1484 01:11:42,090 --> 01:11:45,940 And if this column falls by one, you get a million points. 1485 01:11:45,940 --> 01:11:49,270 And every clause has its own reward of a million points, 1486 01:11:49,270 --> 01:11:53,010 and million here is like n squared or something. 1487 01:11:53,010 --> 01:11:54,634 So you really want to get these. 1488 01:11:54,634 --> 01:11:56,800 And the only way to do it is to satisfy the clauses. 1489 01:11:56,800 --> 01:11:58,330 The only way to get all the point 1490 01:11:58,330 --> 01:12:01,010 is satisfy all the clauses. 1491 01:12:01,010 --> 01:12:05,030 Now, the goal in this game, I didn't mention, 1492 01:12:05,030 --> 01:12:07,800 is to maximize the number of points you can get 1493 01:12:07,800 --> 01:12:09,520 for a given number of moves. 1494 01:12:09,520 --> 01:12:13,640 Usually in Candy Crush you have a limited number of moves. 1495 01:12:13,640 --> 01:12:16,350 So the idea is you're just going to have enough moves to set 1496 01:12:16,350 --> 01:12:18,130 each of the variables right. 1497 01:12:18,130 --> 01:12:20,250 If you end up setting one of the wires directly-- 1498 01:12:20,250 --> 01:12:22,490 you can trigger any wire by doing a little flip. 1499 01:12:22,490 --> 01:12:24,830 You can say I'll trigger this one wire. 1500 01:12:24,830 --> 01:12:27,470 But that will satisfy, at most, one clause. 1501 01:12:27,470 --> 01:12:28,930 Whereas if you do it on a variable, 1502 01:12:28,930 --> 01:12:30,905 you're going to satisfy a bunch of clauses, 1503 01:12:30,905 --> 01:12:33,760 and that's clearly better. 1504 01:12:33,760 --> 01:12:37,440 So that's a bit of an argument you need to make. 1505 01:12:37,440 --> 01:12:39,120 It doesn't help enough. 1506 01:12:39,120 --> 01:12:43,860 You could even set this wire and this wire, an xy or an x bar 1507 01:12:43,860 --> 01:12:44,360 wire. 1508 01:12:44,360 --> 01:12:49,280 But the claim is that will never buy 1509 01:12:49,280 --> 01:12:54,140 you as much as setting an entire variable, 1510 01:12:54,140 --> 01:12:56,550 and here's the reason why. 1511 01:12:56,550 --> 01:12:59,012 I drew this picture simply to say 1512 01:12:59,012 --> 01:13:01,470 for every clause we're going to have this picture connected 1513 01:13:01,470 --> 01:13:02,680 to some variables. 1514 01:13:02,680 --> 01:13:04,950 In fact, every time you have a clause, 1515 01:13:04,950 --> 01:13:08,110 you make a million copies of the clause. 1516 01:13:08,110 --> 01:13:10,070 And million is like n. 1517 01:13:10,070 --> 01:13:12,670 So that it's really worth setting the var-- 1518 01:13:12,670 --> 01:13:15,654 every variable appears in millions of clauses. 1519 01:13:15,654 --> 01:13:17,320 So you really want to set the variables. 1520 01:13:17,320 --> 01:13:19,480 If you just satisfy one measly clause 1521 01:13:19,480 --> 01:13:22,470 and get one measly million points, it's not worth it. 1522 01:13:22,470 --> 01:13:25,960 But if you can get a million times a million points, whoa, 1523 01:13:25,960 --> 01:13:29,430 a trillion points. 1524 01:13:29,430 --> 01:13:31,840 So that's why you should only set variables, not 1525 01:13:31,840 --> 01:13:33,731 set wires directly. 1526 01:13:33,731 --> 01:13:34,230 OK. 1527 01:13:37,540 --> 01:13:40,010 I think I have roughly covered this proof, except I 1528 01:13:40,010 --> 01:13:41,770 didn't go up the chain. 1529 01:13:41,770 --> 01:13:46,044 Here, setting x1 bar doesn't do much except setting one 1530 01:13:46,044 --> 01:13:48,460 or the other of these ends up shifting all of these things 1531 01:13:48,460 --> 01:13:51,150 by one, which ends of clearing this, which shifts 1532 01:13:51,150 --> 01:13:53,750 all of these columns by one. 1533 01:13:53,750 --> 01:13:56,370 And basically things look really spread out here, 1534 01:13:56,370 --> 01:13:58,180 but as you work your way up, they're 1535 01:13:58,180 --> 01:14:00,110 coming more and more into alignment. 1536 01:14:00,110 --> 01:14:03,630 The idea is as long as things resolve from bottom to top, 1537 01:14:03,630 --> 01:14:11,215 you-- it doesn't-- then first you figure out whether x1 1538 01:14:11,215 --> 01:14:12,090 satisfies the clause. 1539 01:14:12,090 --> 01:14:14,590 If it doesn't, it sets things up for x2. 1540 01:14:14,590 --> 01:14:16,370 And then maybe x2 satisfies the clause. 1541 01:14:16,370 --> 01:14:18,260 If it doesn't, it sets things up for x3 here. 1542 01:14:18,260 --> 01:14:19,810 They're spread out even more. 1543 01:14:19,810 --> 01:14:22,360 But by the time you've done these things below, 1544 01:14:22,360 --> 01:14:24,020 that thing will be ready. 1545 01:14:27,470 --> 01:14:30,080 So that was the first proof. 1546 01:14:30,080 --> 01:14:34,660 The second proof-- sorry, before interlude. 1547 01:14:34,660 --> 01:14:37,570 Candy Crush is based on a variety of games. 1548 01:14:37,570 --> 01:14:40,590 Most famous is Bejeweled, but there is a long history 1549 01:14:40,590 --> 01:14:44,010 of-- even Tetris is in there. 1550 01:14:44,010 --> 01:14:46,610 There's a long history of match three games. 1551 01:14:46,610 --> 01:14:48,600 And pretty much all of these are NP-complete. 1552 01:14:48,600 --> 01:14:50,266 I don't know the details of all of them, 1553 01:14:50,266 --> 01:14:54,300 but there's this paper by three authors a little bit later 1554 01:14:54,300 --> 01:14:57,390 in the year that proves basically all of these games 1555 01:14:57,390 --> 01:15:00,692 are NP-complete, even when you're not given a move limit. 1556 01:15:00,692 --> 01:15:01,650 So this is interesting. 1557 01:15:01,650 --> 01:15:03,970 And Bejeweled, the goal is just to maximize your score. 1558 01:15:03,970 --> 01:15:06,386 You don't necessarily have a limit on the number of moves, 1559 01:15:06,386 --> 01:15:08,530 unlike Candy Crush. 1560 01:15:08,530 --> 01:15:11,890 And also in some levels candy Crush is like that. 1561 01:15:11,890 --> 01:15:14,902 So here it was very crucial that we only had enough moves 1562 01:15:14,902 --> 01:15:16,110 to trigger all the variables. 1563 01:15:16,110 --> 01:15:18,852 We didn't want to be able to do other things. 1564 01:15:18,852 --> 01:15:20,560 So here's a different proof, and I'm just 1565 01:15:20,560 --> 01:15:24,737 going to give the high level picture, basically. 1566 01:15:24,737 --> 01:15:26,570 This is cool, because even just figuring out 1567 01:15:26,570 --> 01:15:31,400 whether you get this one gem, this one candy is hard. 1568 01:15:31,400 --> 01:15:33,660 In order to do so, you have to line up 1569 01:15:33,660 --> 01:15:37,070 all of these things for each clause. 1570 01:15:37,070 --> 01:15:40,850 And here's the reduction from exactly one of 3SAT. 1571 01:15:40,850 --> 01:15:43,480 So only if exactly one of the variables 1572 01:15:43,480 --> 01:15:46,659 get set correctly does this shift to the right level, 1573 01:15:46,659 --> 01:15:49,200 and only when all of these are shifted to the right level can 1574 01:15:49,200 --> 01:15:52,107 you trigger this wire to go all the way here and get that guy. 1575 01:15:52,107 --> 01:15:53,690 And it's the only way to get that guy. 1576 01:15:53,690 --> 01:15:54,780 You can't do it directly. 1577 01:15:54,780 --> 01:15:57,250 It can only be triggered from the left-hand side. 1578 01:15:57,250 --> 01:15:58,976 And there's also a sequencer over here, 1579 01:15:58,976 --> 01:16:00,350 which forces all of the variables 1580 01:16:00,350 --> 01:16:03,770 to get set before this happens. 1581 01:16:03,770 --> 01:16:06,720 So it's a little tricky, because you don't want it to be, 1582 01:16:06,720 --> 01:16:09,490 you could say half of them, and then trigger this, 1583 01:16:09,490 --> 01:16:12,220 and then things happen to align in a cheating way. 1584 01:16:12,220 --> 01:16:15,270 The details are complicated, but they actually 1585 01:16:15,270 --> 01:16:18,290 implemented their reduction. 1586 01:16:18,290 --> 01:16:19,870 So this is it. 1587 01:16:19,870 --> 01:16:25,290 Now, as it says here, there are 4,000 rows above and 2,000 rows 1588 01:16:25,290 --> 01:16:25,790 below. 1589 01:16:25,790 --> 01:16:28,470 So it's a large construction. 1590 01:16:28,470 --> 01:16:30,560 And this is for this formula. 1591 01:16:30,560 --> 01:16:34,410 [LAUGHTER] 1592 01:16:34,410 --> 01:16:37,440 I can clean it up a little bit, remove the-- again, 1593 01:16:37,440 --> 01:16:39,710 there's a background checkerboard pattern here. 1594 01:16:39,710 --> 01:16:44,730 So if I generate instance then things are little bit cleaner. 1595 01:16:44,730 --> 01:16:47,200 And I think highlighted in red are the moves you can make. 1596 01:16:47,200 --> 01:16:48,960 So here's the first variable. 1597 01:16:48,960 --> 01:16:51,790 You could either-- let's do the simple one first-- 1598 01:16:51,790 --> 01:16:56,750 move this guy with this one, and then trigger, trigger, trigger. 1599 01:16:56,750 --> 01:16:59,210 All this happens without you able to do anything. 1600 01:16:59,210 --> 01:17:02,670 And that will move some stuff up top. 1601 01:17:02,670 --> 01:17:10,460 Or we can move this one here, and then this is fun. 1602 01:17:10,460 --> 01:17:13,480 The variable goes down and it just 1603 01:17:13,480 --> 01:17:17,580 keeps-- it goes down, basically, to where the x1 bar is, 1604 01:17:17,580 --> 01:17:21,430 down here, and then it triggers that guy, and maybe that guy 1605 01:17:21,430 --> 01:17:23,310 also. 1606 01:17:23,310 --> 01:17:24,563 And that one. 1607 01:17:24,563 --> 01:17:25,469 And-- 1608 01:17:25,469 --> 01:17:28,670 [LAUGHTER] 1609 01:17:28,670 --> 01:17:30,970 Just lots of stuff happens. 1610 01:17:30,970 --> 01:17:32,820 Anyway, eventually we'll get down to x2 1611 01:17:32,820 --> 01:17:35,640 and we'll be able to set it one way or the other. 1612 01:17:35,640 --> 01:17:37,942 So the details are obviously a little bit complicated, 1613 01:17:37,942 --> 01:17:39,400 but clearly they've been explicitly 1614 01:17:39,400 --> 01:17:41,608 worked out because they can even play the game, which 1615 01:17:41,608 --> 01:17:44,030 is pretty awesome. 1616 01:17:44,030 --> 01:17:46,490 Anyway, and they also have the greatest URL, 1617 01:17:46,490 --> 01:17:48,142 candycrush.isnphard.com. 1618 01:17:48,142 --> 01:17:53,410 We should try to get other things not as nphard.com. 1619 01:17:53,410 --> 01:17:55,120 That is Candy Crush and Bejeweled 1620 01:17:55,120 --> 01:17:59,117 and all of its friends are NP hard. 1621 01:17:59,117 --> 01:18:00,700 That's it, unless there are questions. 1622 01:18:03,510 --> 01:18:07,950 So we've just started to scratch the surface on the idea 1623 01:18:07,950 --> 01:18:10,520 that planar graphs are hard, and next class we'll 1624 01:18:10,520 --> 01:18:12,950 see planar versions of 3SAT and one and 3SAT. 1625 01:18:12,950 --> 01:18:16,780 If we weren't using here, this is using a non-planar thing. 1626 01:18:16,780 --> 01:18:19,490 So that helps with a lot of proofs, especially 1627 01:18:19,490 --> 01:18:22,320 ones that happen in the plane. 1628 01:18:22,320 --> 01:18:24,340 So we've seen it with planar circuit SAT. 1629 01:18:24,340 --> 01:18:27,440 But next we'll do planar and 3SAT, planar one and 3SAT, 1630 01:18:27,440 --> 01:18:29,440 planar not all equal SAT, those kinds of things. 1631 01:18:29,440 --> 01:18:34,600 And again, be able to avoid crossovers, which is nice. 1632 01:18:34,600 --> 01:18:36,150 Cool.