Breakfast Bytes

Download Report

Transcript Breakfast Bytes

Breakfast Bytes
Easy, Hard, and Impossible
Elaine Rich
Easy
Tic Tac Toe
Hard
Chess
The Turk
Unveiled in 1770.
Searching for the Best Move
A
B
E
(8)
F
(-6)
C
G
(0)
H
(0)
I
(2)
D
J
(5)
K
L
M
(-4) (10) (5)
How Much Computation Does it Take?
• Middle game branching factor  35
• Lookahead required to play master level chess  8
• 358 
• Seconds in a year 
• Seconds since Big Bang 
2,000,000,000,000
31,536,000
300,000,000,000,000,000
The Turk
Still fascinates people.
A Modern
Reconstruction
Built by John Gaughan. First
displayed in 1989. Controlled
by a computer. Uses the
Turk’s original chess board.
Chess Today
In 1997, Deep Blue beat Garry
Kasparov.
Seems Hard But Really Easy
Nim
At your turn, you must choose a pile, then remove as
many sticks from the pile as you like.
The player who takes the last stick(s) wins.
Nim
Now let’s try:
Oops, now there are a lot of possibilities to try.
Decimal Numbers
10000
89
1000
100
10
1
8
9
Decimal Numbers
10000
89
587
1000
100
10
1
8
9
Decimal Numbers
10000
1000
100
89
567
34765
5
10
1
8
9
6
7
Decimal Numbers
10000
1000
100
89
567
34765
3
4
5
7
10
1
8
9
6
8
7
5
Binary Numbers
16
5
8
4
2
1
Binary Numbers
16
5
9
8
4
2
1
1
0
1
Binary Numbers
16
8
5
9
21
1
4
2
1
1
0
1
0
0
1
Binary Numbers
16
8
5
9
21
3
1
1
0
4
2
1
1
0
1
0
1
0
0
1
1
Binary Numbers
16
8
5
9
21
3
16
1
1
0
4
2
1
1
0
1
0
1
0
0
1
1
1
1
Binary Numbers
16
8
4
2
1
1
0
1
1
1
0
0
1
1
0
0
0
0
1
0
1
1
1
0
5
9
21
3
16
Nim
My turn:
10
10
11
11
For the current player:
• Guaranteed loss if last row is all 0’s.
• Guaranteed win otherwise.
(2)
(2)
(3)
Nim
My turn:
100
010
101
011
For the current player:
• Guaranteed loss if last row is all 0’s.
• Guaranteed win otherwise.
(4)
(2)
(5)
Nim
Your turn:
100
001
101
000
For the current player:
• Guaranteed loss if last row is all 0’s.
• Guaranteed win otherwise.
(4)
(1)
(5)
Impossible
An Interesting Puzzle
List 1
1
2
3
b
babbb
ba
4
bbbaa
2
List 1
babbb
List 2
ba
List 2
bbb
ba
a
babbb
An Interesting Puzzle
List 1
1
2
3
b
babbb
ba
4
bbbaa
2
1
List 1
babbbb
List 2
babbb
List 2
bbb
ba
a
babbb
An Interesting Puzzle
List 1
1
2
3
b
babbb
ba
4
bbbaa
2
1
List 2
bbb
ba
a
babbb
1
List 1
babbbbb
List 2
babbbbbb
An Interesting Puzzle
List 1
1
2
3
b
babbb
ba
4
bbbaa
2
1
List 2
bbb
ba
a
babbb
1 3
List 1
babbbbbba
List 2
babbbbbba
The Post Correspondence Problem
List 1
List 2
1
11
011
2
01
0
3
001
110
The Post Correspondence Problem
List 1
1
2
3
ab
ab
aa
List 2
a
ba
baa
The Post Correspondence Problem
List 1
1
2
3
ba
abb
bab
List 2
bab
bb
abb
The Post Correspondence Problem
List 1
1
2
3
1101
0110
1
List 2
1
11
110
What is a Program?
What is a Program?
A procedure that can be performed by a computer.
The Post Correspondence Problem
A program to solve this problem:
Until a solution or a dead end is found do:
If dead end, halt and report no.
Generate the next candidate solution.
Test it. If it is a solution, halt and report yes.
So, if there are say 4 rows in the table, we’ll try:
1
2
3
4
1,1
1,2
1,3
1,4
2,1 ……
1,1,1 ….
1,5
The Post Correspondence Problem
A program to solve this problem:
Until a solution or a dead end is found do:
If dead end, halt and report no.
Generate the next candidate solution.
Test it. If it is a solution, halt and report yes.
So, if there are say 4 rows in the table, we’ll try:
1
2
3
4
1,1
1,2
1,3
1,4
1,5
2,1 ……
1,1,1 ….
But what if there is no solution?
A Tiling Problem
A Tiling Problem
A Tiling Problem
A Tiling Problem
A Tiling Problem
A Tiling Problem
A Tiling Problem
A Tiling Problem
A Tiling Problem
A Tiling Problem
Another Tiling Problem
Another Tiling Problem
Another Tiling Problem
Programs Debug Programs
Given an arbitrary program, can it be guaranteed to halt?
read name
if name = “Elaine”
then print “You win!!”
else print “You lose ”
Programs Debug Programs
Given an arbitrary program, can it be guaranteed to halt?
read number
set result to 1
set counter to 2
until counter > number do
set result to result * counter
add 1 to counter
print result
Programs Debug Programs
Given an arbitrary program, can it be guaranteed to halt?
read number
set result to 1
set counter to 2
until counter > number do
set result to result * counter
add 1 to counter
Suppose number = 5:
print result
result
number counter
1
5
2
2
5
3
6
5
4
24
5
5
120
5
6
Programs Debug Programs
Given an arbitrary program, can it be guaranteed to halt?
read number
set result to 1
set counter to 2
until counter > number do
set number to number* counter
add 1 to counter
Suppose number = 5:
print result
result
number counter
1
5
2
1
10
3
1
30
4
1
120
5
1
600
6
Programs Debug Programs
Given an arbitrary program, can it be guaranteed to halt?
read number
until number = 1 do
if number is even then set number to number/2
if number is odd then set number to 3number + 1
Suppose number is 7:
Programs Debug Programs
Given an arbitrary program, can it be guaranteed to halt?
read number
until number = 1 do
if number is even then set number to number/2
if number is odd then set number to 3number + 1
Collatz Conjecture: This program (which solves the 3x+1
problem) always halts.
We can try it on big numbers:
http://math.carleton.ca/%7Eamingare/mathzone/3n+1.html
The Impossible
The halting problem cannot be solved.
We can prove that no program can ever be written that
can look at arbitrary other programs and decide whether
or not they always halt.
Which is Amazing
Given the things programs can do.
Which is Amazing
Given the things programs can do.
http://www.bdi.com/content/sec.php?section=BigDog
Which is Amazing
Given the things programs can do.
http://pc.watch.impress.co.jp/docs/2003/1218/sony_06.wmv