# INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

## Presentation on theme: "INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011."— Presentation transcript:

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

SET THEORY 101 A function ƒ : A → B is: 1-1 (or injective) if onto (or surjective) if bijective if it is 1-1 and onto. ƒ(x)=ƒ(y) ⇔ x=y ∀ y Ǝ x: y = ƒ(x) 1-1 then |A| |B| onto then |A| |B| bijective then |B| |A|. ƒ can help us count. If ƒ is: ≤ ≥ =

Let S be any set and (S) be the power set of S Theorem: There is no onto map from S to P(S) Proof: Assume, for a contradiction, that there is an onto map ƒ : S  (S) Let D ƒ = { x  S | x  ƒ(x) } If D ƒ = ƒ(y) then y  D ƒ if and only if y  D ƒ We construct an D ƒ ⊆ S that cannot be the output, ƒ(y), for any y  S. D ƒ is called the diagonal set for ƒ.

x y 1 ∈ ƒ(x)?y 2 ∈ ƒ(x)?y 3 ∈ ƒ(x)?y 4 ∈ ƒ(x)? … y1y1 YNYY y2y2 NYNY y3y3 NNNN y4y4 YNNY  Y Y Y N (y i ∈ D) ≡ (y i ∉ ƒ(y i ))

The process of constructing a counterexample by “contradicting the diagonal” is called DIAGONALIZATION

No matter what, (S) always has more elements than S

THE CHURCH-TURING THESIS L is recognized by a program for some computer* ⇔ L is recognized by a TM * The computer must be “reasonable”

There are languages over {0,1} that are not decidable If we believe the Church-Turing Thesis, this means there are problems that computers inherently cannot solve. We proved this using a “simple” counting argument: There are more Languages than Turing Machines.

Turing Machines Languages over {0,1}

Not all languages over {0,1} are decidable Turing Machines Strings of 0s and 1s Sets of strings of 0s and 1s Languages over {0,1} S(S) OK, but what does an undecidable language look like?

THE DIAGONAL LANGUAGE D TM = { 〈 M 〉 | M does not accept 〈 M 〉 } is undecidable. T M 1 ∈ L(T)?M 2 ∈ L(T)?M 3 ∈ L(T)?M 4 ∈ L(T)? … M1M1 YNYY M2M2 NYNY M3M3 NNNN M4M4 YNNY  Y Y Y N *Note: Hypothetical. May not correspond to an actual encoding *

Programs can “accept” their code as input: \$ grep grep /tmp/example.pl < { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/10/2810603/slides/slide_12.jpg", "name": "Programs can accept their code as input: \$ grep grep /tmp/example.pl <

A TM = { 〈 M,w 〉 | M is a TM that accepts string w } THE ACCEPTANCE PROBLEM Theorem: A TM is Turing-recognizable but NOT decidable A TM is Turing-recognizable: Define TM U as follows: On input 〈 M,w 〉, U runs M on w. If M ever accepts: accept. If M ever rejects: reject. If M(w) loops forever: U( 〈 M,w 〉 ) loops forever.

A TM = { 〈 M,w 〉 | M is a TM that accepts string w } A TM is undecidable:(proof by contradiction) Assume TM acceptsInput decides A TM acceptsInput(M,w) = Acceptif M(w) accepts Reject otherwise Construct a new TM LLPF as follows: on input 〈 M 〉 run acceptsInput (M, 〈 M 〉 ) and output the opposite LLPF( M ) = Rejectif M accepts M Accept if M does not accept M LLPF

M1M1 M2M2 M3M3 M4M4 : M1M1 M2M2 M3M3 M4M4 … accept reject OUTPUT OF acceptsInput(M,N)* accept reject LLPF reject accept reject accept ? *Note: Hypothetical. May not correspond to an actual encoding

Theorem: A TM is Turing-recognizable (r.e.) but NOT decidable Theorem:  A TM is not even Turing-recognizable! Proof: Suppose ¬A TM is recognized by TM V. We know A TM is recognized by U. Build Z to decide A TM : run V(M,w) and U(M,w) in parallel. If V accepts, reject; if U accepts, accept.

A language is called Turing-recognizable, semi-decidable, or recursively enumerable if some TM recognizes it A language is called decidable or recursive if some TM decides it recursive languages r.e. languages all languages

HALT TM = { 〈 M,w 〉 | M is a TM that halts on string w } Theorem: HALT TM is undecidable THE HALTING PROBLEM Proof: Assume, for a contradiction, that TM haltsOnInput decides HALT TM haltsOnInput(M,w) = Acceptif M(w) halts Reject if M(w) loops We construct the machine liarLiar as follows: liarLiar( 〈 M 〉 ): if haltsOnInput(M, 〈 M 〉 ): return liarLiar( 〈 M 〉 ) else: return true. liarLiar( 〈 liarLiar 〉 ) halts iff liarLiar( 〈 liarLiar 〉 ) loops!

We can also prove that A TM is undecidable by “reusing” the proof that D TM is undecidable. Theorem. If A TM is decidable, then so is D TM. Proof: Suppose we have a program, acceptsInput, that decides A TM, e.g. acceptsInput(M,w) returns true if 〈 M,w 〉  A TM and returns false otherwise. We can build a TM notDiagonal to decide ¬D TM : Theorem. If HALT TM is decidable, then so is A TM. Proof: acceptsInput(M,w) = let M’ = M with q reject replaced by q loop. return haltsOnInput(M’,w) notDiagonal( 〈 M 〉 ) = return acceptsInput(M, 〈 M 〉 )