prove the impossible lecture 6: sep 19 (based on slides in mit 6.042) 1234 5678 9101112 131415 1234...

43
Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 2 3 4 5 6 7 8 9 10 11 12 13 15 14

Upload: jonas-warner

Post on 22-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Prove the Impossible

Lecture 6: Sep 19 (based on slides in MIT 6.042)

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15

1 2 3 4

5 6 7 8

9 10 11 12

13 15 14

Page 2: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Domino Puzzle

An 8x8 chessboard, 32 pieces of dominos

Can we fill the chessboard?

Page 3: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Domino Puzzle

An 8x8 chessboard, 32 pieces of dominos

Easy!

Page 4: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Domino Puzzle

An 8x8 chessboard with two holes, 31 pieces of dominos

Can we fill the chessboard?

Easy!

Page 5: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Domino Puzzle

An 8x8 chessboard with two holes, 31 pieces of dominos

Can we fill the chessboard?

Easy??

Page 6: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Domino Puzzle

An 4x4 chessboard with two holes, 7 pieces of dominos

Can we fill the chessboard?

Impossible!

Page 7: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Domino Puzzle

An 8x8 chessboard with two holes, 31 pieces of dominos

Can we fill the chessboard?

Then what??

Page 8: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Another Chessboard Problem

?

A rook can only move along a diagonal

Can a rook move from its current position to the question mark?

Page 9: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Another Chessboard Problem

?

A rook can only move along a diagonal

Can a rook move from its current position to the question mark?

Impossible!

Why?

Page 10: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Another Chessboard Problem

?

1. The rook is in a blue

position.

2. A blue position can only

move to a blue position by

diagonal moves.

3. The question mark is in a

white position.

4. So it is impossible for the

rook to go there.

Invariant!

This is a very simple example of the invariant method.

Page 11: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Domino Puzzle

An 8x8 chessboard with two holes, 31 pieces of dominos

Can we fill the chessboard?

Page 12: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Domino Puzzle

1. Each domino will occupy one

white square and one blue

square.

2. There are 32 blue squares

but only 30 white squares.

3. So it is impossible to fill the

chessboard using only 31

dominos.

Invariant!

This is a simple example of the invariant method.

Page 13: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Invariant Method

1. Find properties (the invariants) that are

satisfied throughout the whole process.

2. Show that the target do not satisfy the properties.

3. Conclude that the target is not achievable.

In the rook example, the invariant is the colour of the position of the rook.

In the domino example, the invariant is that

any placement of dominos will occupy the same

number of blue positions and white positions.

Page 14: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

The Possible

We just proved that if we take out two squares of the same colour, then it is impossible to finish.

What if we take out two squares of different colours?Would it be always possible to finish then?

Yes??

Page 15: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Prove the Possible

Yes??

Page 16: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Prove the Possible

The secret.

Page 17: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Prove the Possible

The secret.

Page 18: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Fifteen Puzzle

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15

Move: can move a square adjacent to the empty square

to the empty square.

Page 19: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Fifteen Puzzle

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15

1 2 3 4

5 6 7 8

9 10 11 12

13 15 14

Initial configuration Target configuration

Is there a sequence of moves that allows you to start

from the initial configuration to the target

configuration?

Page 20: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Invariant Method

1. Find properties (the invariants) that are

satisfied throughout the whole process.

2. Show that the target do not satisfy the properties.

3. Conclude that the target is not achievable.

What is an invariant in this game??

This is usually the hardest part of the proof.

Page 21: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Hint

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15

1 2 3 4

5 6 7 8

9 10 11 12

13 15 14

Initial configuration Target configuration

((1,2,3,…,14,15),(4,4)) ((1,2,3,…,15,14),(4,4))

Hint: the two states have different parity.

Page 22: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Parity

Given a sequence, a pair is “out-of-order” if the first element is larger.

For example, the sequence (1,2,4,5,3) has two out-of-order pairs, (4,3) and (5,3).

Given a state S = ((a1,a2,…,a15),(i,j))

Parity of S = (number of out-of-order pairs + i) mod 2

row number of the empty square

Page 23: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Hint

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15

1 2 3 4

5 6 7 8

9 10 11 12

13 15 14

Initial configuration Target configuration

((1,2,3,…,14,15),(4,4)) ((1,2,3,…,15,14),(4,4))

Clearly, the two states have different parity.

Parity of S = (number of out-of-order pairs + i) mod 2

Page 24: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Invariant Method

1. Find properties (the invariants) that are

satisfied throughout the whole process.

2. Show that the target do not satisfy the properties.

3. Conclude that the target is not achievable.

Invariant = parity of state

Claim: Any move will preserve the parity of the state.

Proving the claim will finish the impossibility proof.

Parity is even

Parity is odd

Page 25: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Proving the Invariant

Claim: Any move will preserve the parity of the state.

Parity of S = (number of out-of-order pairs + i) mod 2

? ? ? ?

? a ?

? ? ? ?

? ? ? ?

? ? ? ?

? a ?

? ? ? ?

? ? ? ?

Horizontal movement does not change anything…

Page 26: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Proving the Invariant

Claim: Any move will preserve the parity of the state.

Parity of S = (number of out-of-order pairs + i) mod 2

? ? ? ?

? a b1 b2

b3 ? ?

? ? ? ?

? ? ? ?

? b1 b2

b3 a ? ?

? ? ? ?

If there are (0,1,2,3) out-of-order pairs in the current state,

there will be (3,2,1,0) out-of-order pairs in the next state.

Row number has changed by 1

So the parity stays the same! We’ve proved the claim.

Difference

is 1 or 3.

Page 27: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Fifteen Puzzle

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15

15 14 13 12

11 10 9 8

7 6 5 4

3 2 1

Initial configuration Target configuration

Is there a sequence of moves that allows you to start

from the initial configuration to the target

configuration?

This is a standard example of the invariant method.

Page 28: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Checker

x=0

Start with any configuration with all men on or below the x-axis.

Page 29: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Checker

x=0

Move: jump through your adjacent neighbour, but then your neighbour will disappear.

Page 30: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Checker

x=0

Move: jump through your adjacent neighbour, but then your neighbour will disappear.

Page 31: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Checker

x=0

Goal: Find an initial configuration with least number of men to jump up to level k.

Page 32: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

K=1

x=0

2 men.

Page 33: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

K=2

x=0

Page 34: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

K=2

x=0

4 men.

Now we have reduced to the k=1 configuration, but one level higher.

Page 35: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

K=3

x=0

This is the configuration for k=2, so jump two level higher.

Page 36: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

K=3

x=0

8 men.

Page 37: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

K=4

x=0

Page 38: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

K=4

x=0

Page 39: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

K=4

x=0

Page 40: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

K=4

x=0

Page 41: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

K=4

x=0

Now we have reduced to the k=3 configuration, but one level higher

20 men!

Page 42: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

K=5

a. 39 or below

b. 40-50 men

c. 51-70 men

d. 71- 100 men

e. 101 – 1000 men

f. 1001 or above

None of the above (but f is closest), it is impossible!

This is a tricky example of the invariant method.

Excellent project idea

Page 43: Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042) 1234 5678 9101112 131415 1234 5678 9101112 131514

Classwork 1

October 3 (in class)

1. Logic.

2. Sets, functions.

3. Proof by cases, contradiction.

4. Proof by inductions.

5. Invariant method.

True or false, multiple choice, short question, long question.

A very useful method