inherent limitations of computer programs csci 4011

40
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

Upload: emely-weatherall

Post on 29-Mar-2015

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

INHERENT LIMITATIONS OF COMPUTER PROGRAMS

CSci 4011

Page 2: 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.

Page 3: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

QUIZ 3x a ƒ(x)?∈ b ƒ(x)?∈ c ƒ(x)?∈

a no yes no

b yes no yes

c no no yes

D Yes Yes No

Page 4: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

QUIZ 3

b → R

→ ☐ R

qa?aba☐to_endba

Page 5: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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 }

Page 6: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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

Page 7: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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.

Page 8: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

A

B

ƒ

ƒ

MAPPING REDUCIBILITY

w A ƒ(w) B

Σ* Σ*

Page 9: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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)

Page 10: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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.

Page 11: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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∈

Page 12: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

THE PCP GAME

ba

a

a

ab

b

bcb

b

a

ba

a

a

ab

Page 13: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

a

aa

aaa

a

a

c

a

aa

c

a

aaa

a

a

aa

Page 14: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

a

ab

ca

a

b

ca

a

ab

abc

c

a

ab

b

ca

ca

a

abc

c

Page 15: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

ca

a

acc

ca

abc

ab

Page 16: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

aab

aa

acc

a

b

b

c

a

caa

a

b

b

Page 17: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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!

Page 18: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

THE FPCP GAME

… is just like the PCP game except that a match has to start with the first tile

Page 19: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

a

aa

aaa

a

a

c

a

aa

c

a

aaa

a

a

aa

FPCP

Page 20: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

ba

a

a

ab

b

bcb

b

a

FPCP

Page 21: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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.

Page 22: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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:

Page 23: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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.

Page 24: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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,

Page 25: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

M accepts w if and only if there exists an accepting computation

history that starts with C1=q0w

Page 26: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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

Page 27: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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# ... #

Page 28: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

Given 〈 M,w 〉 , we will construct an instance P of FPCP

in 7 steps

Page 29: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

STEP 1

Put #

#q0w1w2…wn#into P

Page 30: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

#

#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.

Page 31: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

STEP 2

If (q,a) = (p,b,R) then addqa

bp

STEP 3

If (q,a) = (p,b,L) then addcqa

pcbfor all c Γ

Page 32: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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

Page 33: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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

Page 34: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

STEP 4

adda

a

STEP 5

add#

#

for all a Γ

#

#

Page 35: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

#

#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

#

#

Page 36: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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###

Page 37: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

STEP 7

addqacc##

#

STEP 6

addaqacc

qacc

qacca

qacc

for all a Γ

Page 38: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

#

#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#

Page 39: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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 #

#

Page 40: INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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