inherent limitations of computer programs csci 4011
TRANSCRIPT
INHERENT LIMITATIONS OF COMPUTER PROGRAMS
CSci 4011
QUIZ 3The Turing Machine M decides the language L if:
M accepts all w L and rejects all w L.∈ ∉
The language L is Turing-recognizable if:
There is a TM that recognizes L (accepts all and only the strings in L).
The language L is undecidable if:
There is no TM that decides it.
QUIZ 3x a ƒ(x)?∈ b ƒ(x)?∈ c ƒ(x)?∈
a no yes no
b yes no yes
c no no yes
D Yes Yes No
QUIZ 3
b → R
→ ☐ R
qa?aba☐to_endba
UNDECIDABLE PROBLEMS
DTM = { 〈 M 〉 | M is a TM that does not accept 〈 M 〉 }Theorem. DTM is undecidable.
Proof. Suppose machine N decides DTM. ThenN accepts 〈 N 〉 ⇔ 〈 N 〉 DTM ⇔ N does not accept 〈 N 〉
ATM = { 〈 M,w 〉 | M is a TM that accepts on input w }Theorem. If ATM is decidable, so is DTM.Proof. If ¬ATM is decided by the program nAcceptwe can decide DTM by calling nAccept(M, 〈 M 〉 ).
Theorem. If HALTTM is decidable, then so is ATM.HALTTM = { 〈 M,w 〉 | M is a TM that halts on input w }
In most cases, we show that a language is undecidable by showing that if it is decidable, then so is ATM.
We reduce deciding ATM to deciding the language in question
MAPPING REDUCIBILITY
ƒ : Σ* Σ* is a computable function if some Turing machine M, for any input w, halts with just ƒ(w) on its tape
A language A is mapping reducible to language B, written A m B, if there is a computable function ƒ : Σ* Σ*, where for every w,
w A ƒ(w) B
ƒ is called a reduction from A to B.
A
B
ƒ
ƒ
MAPPING REDUCIBILITY
w A ƒ(w) B
Σ* Σ*
Theorem: If A m B and B is decidable, then A is decidable
Proof: Let BSolver be a program to decide B and let ƒ be a reduction from A to B
We build a machine ASolver that decides A:
ASolver(w):
1. Let s = ƒ(w)
2. Return BSolver(s)
Corollary: If A m B and A is undecidable, then B is undecidable
Proof: Suppose, for contradiction, that BSolver decides B and let ƒ be a reduction from A to B.
The same machine ASolver decides A:
ASolver(w):
1. Let s = ƒ(w)
2. Return BSolver(s)
Since A is undecidable the program BSolver must not exist. Thus B is undecidable.
Theorem: If A ≤m B and B ≤m C, then A ≤m C
Proof: Let ƒ : A B and g : B C be computable functions, where
w A ⇔ ƒ(w) B, x B ⇔ g(x) C
We build a computable mapping h by setting h(w) = g(ƒ(w)).
h is a reduction from A to C:
h is computable, since ƒ and g are computable.
w A ∈ ⇔ ƒ(w) ∈ B ⇔ g(ƒ(w)) = h(w) C∈
THE PCP GAME
ba
a
a
ab
b
bcb
b
a
ba
a
a
ab
a
aa
aaa
a
a
c
a
aa
c
a
aaa
a
a
aa
a
ab
ca
a
b
ca
a
ab
abc
c
a
ab
b
ca
ca
a
abc
c
ca
a
acc
ca
abc
ab
aab
aa
acc
a
b
b
c
a
caa
a
b
b
POST CORRESPONDENCE PROBLEMGiven a collection of tiles, is there a match?
PCP = { P | P is a set of tiles with a match }
PCP is undecidable!
THE FPCP GAME
… is just like the PCP game except that a match has to start with the first tile
a
aa
aaa
a
a
c
a
aa
c
a
aaa
a
a
aa
FPCP
ba
a
a
ab
b
bcb
b
a
FPCP
Theorem: PCP is “harder than” FPCP. That is: FPCP ≤m PCP
Proof. We will show a reduction that converts a FPCP instance F into a PCP instance P, so that P has a PCP matchiff F has a FPCP match.
To convert an FPCP isntance into a PCP instance:
If u = u1u2…un, we define:
u = u1 u2 u3 … un
u = u1 u2 u3 … un
u = u1 u2 u3 … un
t1
b1
…t2
b2
tk
bk
t1
b1
t1
b1
t2
b2
tk
bk
…
FPCP:
PCP:
Theorem: FPCP is undecidable
Proof: We will show that ATM ≤m FPCP.
Given a pair 〈 M,w 〉 we will construct a set oftiles that has a match iff M accepts w.
The match will correspond to an acceptingcomputation history of M on w.
COMPUTATION HISTORIES
An accepting computation history is a sequence of configurations C1,C2,…,Ck, where
An rejecting computation history is a sequence of configurations C1,C2,…,Ck, where
1. C1 is the start configuration,
2. Ck is a rejecting configuration,
3. Each Ci follows from Ci-1
3. Each Ci follows from Ci-1
2. Ck is an accepting configuration,
1. C1 is the start configuration,
M accepts w if and only if there exists an accepting computation
history that starts with C1=q0w
0 → , R
→ , R
qacceptqreject
0 → x, R
x → x, R → , R
x → x, R
0 → 0, Lx → x, L
x → x, R
→ , L → , R
0 → x, R0 → 0, R
→ , Rx → x, R
{ 0 | n ≥ 0 }2n
q0 q1
q2
q3
q4
0 → , R
→ , R
qacceptqreject
0 → x, R
x → x, R → , R
x → x, R
0 → 0, Lx → x, L
x → x, R
→ , L → , R
0 → x, R0 → 0, R
→ , Rx → x, R
{ 0 | n ≥ 0 }2n
q0 q1
q2
q3
q4
q00000
q1000
xq300
x0q40
x0xq3
x0q2x
xq20x
q2x0x
q2x0x
:#q00000#q1000#xq300#x0q40#x0xq3# ... #
Given 〈 M,w 〉 , we will construct an instance P of FPCP
in 7 steps
STEP 1
Put #
#q0w1w2…wn#into P
#
#q0w1w2…wn#
matching C1 on top adds C2 on the bottom.
IDEA FOR STEP 2-5:
Add tiles so that:
#
#C1#
C1#
C2#
C2#
C3#
Ci#
Ci+1#
matching C2 on top adds C3 on the bottom.
matching Ci on top adds Ci+1 on the bottom.
…
STEP 2
If (q,a) = (p,b,R) then addqa
bp
STEP 3
If (q,a) = (p,b,L) then addcqa
pcbfor all c Γ
0 → , R
→ , R
qacceptqreject
0 → x, R
x → x, R → , R
x → x, R
0 → 0, Lx → x, L
x → x, R
→ , L → , R
0 → x, R0 → 0, R
→ , Rx → x, R
{ 0 | n ≥ 0 }2n
q0 q1
q2
q3
q4
0 → , R
→ , R
qacceptqreject
0 → x, R
x → x, R → , R
x → x, R
0 → 0, Lx → x, L
x → x, R
→ , L → , R
0 → x, R0 → 0, R
→ , Rx → x, R
{ 0 | n ≥ 0 }2n
q0 q1
q2
q3
q4#
#q00000#
q00
q1
q10
xq3
…0q3
q20
xq3
q2x
q3
q2
0q20
q200
xq20
q2x0
q20
q20
STEP 4
adda
a
STEP 5
add#
#
for all a Γ
#
#
#
#q00000# q1
q00
xq3
q10
q20
0q3 xq3
q2x q2
q3
0q20
q200
xq20
q2x0
q20
q20
xq1
q1x q0x
xqr
q0
qr qa
q1 q2
q1
q3x
xq3
q30
0q4
q40
xq3
q4x
xq4
q4
qr
0q3x
q20x q2xx
xq3x q3x
q2x
x
x
#
#
0
0
#
#
#
#q00000#
xq3
q10 0
0
0
0
#
#q00000# q1
q00
0
0
0
0
0
0
#
#
How do we get the match to stop?
##C1#
C1#C2#
C2#C3#
Ci#Ci+1#
xqiay#xbqaccy#
… … xbqaccy#
?
Let qacc “eat up” one tape cell per step
xbqaccy#xqaccy#
xqaccy#xqacc#
xqacc#qacc#
qacc###
STEP 7
addqacc##
#
STEP 6
addaqacc
qacc
qacca
qacc
for all a Γ
#
#q00000# q1
q00
xq3
q10
q20
0q3 xq3
q2x q2
q3
0q20
q200
xq20
q2x0
q20
q20
xq1
q1x q0x
xqr
q0
qr qa
q1 q2
q1
q3x
xq3
q30
0q4
q40
xq3
q4x
xq4
q4
qr
0q3x
q20x q2xx
xq3x q3x
q2x
x
x
#
#
0
0
#
# 0
0qacc
0
qacc0
x
qaccx
x
xqacc
x
qacc
x
qacc
#
#q00000#
0 → 0, R
→ , R
qaccept
qreject
0 → 0, R
→ , Rq0 q1
0q1
q00
0qrej
q10
qrej
q0 q1
qacc
0
0
#
#
#
#q00#
#
# qacc
qacc
qacc
0qacc
qacc
qacc
qacc
qacc0
#
#q00# 0q1
q00 #
#
0
0
q1
qacc
#
#
0
0 qacc
qacc
#
qacc##
#
# qacc
0qacc #
#
Given 〈 M,w 〉 , we can construct an instance of FPCP that has a
match if and only if M accepts w
Since ATM is undecidable, so is PCP
That is, ATM ≤m FPCP.
Since FPCP ≤m PCP, we get:ATM ≤m PCP