Review Reductions L (M,x)

advertisement
IN210 − lecture 4
Review
L
LH
LH
• show LH unsolvable by diagonalization
• show L unsolvable by reduction
Reductions
(M,x)
MR
M’
YES
YES
NO
NO
ML
MH
M’:
Simulate M on input x;
Do <ACTION>;
Autumn 1999
1 of 13
IN210 − lecture 4
Example
Theorem 1 Equivalence of programs (Turing
machines) is undecidable.
Proof:
(M,x)
M’
MR
YES
YES
NO
NO
ME
M’’
MH
M’:
Simulate M on input x;
Accept;
M”:
Accept;
• M 00 accepts all inputs.
• M and x are constants to M 0.
• M 0 accepts all inputs if and only if M halts
on input x.
Autumn 1999
2 of 13
IN210 − lecture 4
Insights
Theorem 2 (Rice; its basic message) Most
“interesting” properties of programs (TMs) are
undecidable.
But what about the unsolvable problems that
are not related to programs/TMs?
Today
• A technique (reduction) for proving
unsolvability of non-TM problems
• Important insights — physiognomy of
unsolvable problems
Question: How to come out of the world of
TMs and into the world of general problems?
Answer: View the Turing machine
computation as pattern matching.
Autumn 1999
3 of 13
IN210 − lecture 4
.....
.....
.....
.....
.....
b b b
b b b
b b b
b b b
h
b b Y b
q3
b b b b
q2
b 0 b b
q1
1 0 b b
s
b b 0 1 0 b b
.....
.....
time
(steps)
.....
.....
.....
configuration (tape,
state, r/w head)
Turing machine rules (δ) become templates:
q1
1
b
δ(s, 0) = (q1, b, R) is
and s
s
b 0 1
0 1 0
Y
q1
Z
b
but also
and s
s and
s
X Y 0
Y 0 Z
0 Z W
for all X, Y, Z and W ∈ {1, 0, b}.
Y
We also have
for all X, Y, Z ∈ {1, 0, b}.
X Y Z
Autumn 1999
4 of 13
IN210 − lecture 4
Halting configuration
• row with square h
α
• finitely many rows (matrix is bounded in
vertical direction)
An unsolvable Tiling problem
Input: A finite set of tiles with one designated
tile (which must be placed by the entrance
door). The tiles cannot be rotated or flipped.
Tiling:
Y es!
←→
N o!
←→
...
Question: Is the set of tiles complete? (Given
an unlimited supply of each tile, can any
room be tiled?)
The Tiling problem (LT ) is unsolvable
because we can make the reduction
LH C 7−→ LT
Autumn 1999
5 of 13
..
..
..
..
..
..
IN210 − lecture 4
b
b
b
b
q
2
q’2 q’ 0
2
b
..
..
.. I0
b
b
b
b
I0 I 0
b
b
b
b
b
b
s
0
s
0
q
1
1
q
1
q’ q’ 1
1 1
I0 I0
1
I1 I1
1
I2 I2
0
0
b
b
0
0
b
b
I 3 I3
..
..
I3 ..
• Tiles for rules of Turing machine M :
b
s
0
q’
1
and
q1
q’ 1
1
for δ(s, 0) = (q1, b, R)
1
• Tiles for tape symbols “far away” from
1
b
read/write head:
and
, etc.
1
b
• Designated tile: I 0
s
0
I1
• Tiles for input string x: I1
1
I2 , etc.
• We can tile forever (tile any room) if and
only if M doesn’t halt on input x!
Autumn 1999
6 of 13
IN210 − lecture 4
An unsolvable grammar (language
definition) problem
Grammar G = (T, N, R)
T , set of terminal symbols
N , set of nonterminal symbols, containing
the start symbol S
R , set of derivation rules:
S → (S)
S → ()S
S→
R1
R2
R3
A derivation of the string ()() :
R1
R3
S ` (S) ` ()S ` ()(S) ` ()()
R1
R2
G
G
G
G
The language defined by G is the set of all
strings that are derived by G.
In context-free grammars the left-hand side
of each rule consists of exactly one
non-terminal.
Autumn 1999
7 of 13
IN210 − lecture 4
Example
G = (T, N, R)
T = {Mark, Ann, I, love, you, very, much}
N = {S, A, B}
R=
S → Mark A Ann
A → I love you B much
B → very B
B→
Autumn 1999
8 of 13
IN210 − lecture 4
General grammars
• The left-hand side of each rule can have
both non-terminals (at least one) and
terminals
• A Turing machine M with input x can
easily be encoded as derivation rules:
— TM rule δ(S, 0) = (q1, b, R):
s 1 → b q1
1
0
s 0 → b q1
0
0
etc. (“box symbols” are non-terminals)
— Derivation rule for input string (’010’):
S → B s0 1 0 E
— Rules for inserting and removing blanks
— Rule for removing the last non-terminal:
h →h
Y
• Reduction LH 7−→ LG:
M halts for input x if and only if the string
“h” can be derived by grammar G.
Question: Programming language syntax is
defined by contex-free grammars, and not by
the more powerful general grammars. Why?
Autumn 1999
9 of 13
IN210 − lecture 4
Can machines think?
Example: Theorem proving in a formal
system
(Theorem)
(x + y)2 ≡ x2 + 2xy + y 2
(a + b)(c + d) ≡ a(c + d) + b(c + d)
..
(Rules/axioms)
ab ≡ ba
Question: Can algorithms prove/verify
theorems?
Answer: Not if the rules can encode a Turing
machine . . . But algorithms can accept
theorems.
Algorithms can also enumerate theorems.
Example: Theoremhood in first-order logic is
undecidable (IN 394)
Question: What about automatic program
correctness proving?
Autumn 1999
10 of 13
IN210 − lecture 4
Closing remarks on
unsolvability
L
LH
Two kinds of reductions:
• to Turing machine questions
• to general questions
The reductions give us a tool for proving
undecidability and insight into the
nature/physiognomy of unsolvable problems.
Autumn 1999
11 of 13
IN210 − lecture 4
Complexity
Unsolvable
Horrible (intractable)
Nice (tractable)
• Horrible problems are solvable by
algorithms that take billions of years to
produce a solution.
• Nice problems are solvable by “proper”
algorithms.
• We want techniques and insights
Complexity ←→ resources: time, space
l
complexity classes:
P(olynomial time), NP-complete,
Co-NP-complete, Exponential time,
PSPACE, . . .
Autumn 1999
12 of 13
IN210 − lecture 4
...
Goal
EXP TIME
PSPACE
Co
NP
NP
P
Map of classes
= complete or "hardest"
problems in a class
Autumn 1999
13 of 13
Download