1 / 32

INHERENT LIMITATIONS OF COMPUTER PROGRAMS

CSci 4011. INHERENT LIMITATIONS OF COMPUTER PROGRAMS. RICE ’ S THEOREM. Let P be a language of Turing machine encodings. IF P satisfies the following properties :. For all TMs M 1 and M 2 , where L(M 1 ) = L(M 2 ), 〈M 1 〉  P if and only if 〈M 2 〉  P.

niel
Télécharger la présentation

INHERENT LIMITATIONS OF COMPUTER PROGRAMS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSci 4011 INHERENT LIMITATIONS OF COMPUTER PROGRAMS

  2. RICE’S THEOREM Let P be a language of Turing machine encodings. IF P satisfies the following properties: For all TMs M1 and M2, where L(M1) = L(M2), 〈M1〉  P if and only if 〈M2〉  P There exist TMs 〈MIN〉  P and 〈MOUT〉  P (i.e. P is a “nontrivialproperty of the r.e. languages.”) THEN P is undecidable. EXTREMELY POWERFUL

  3. EXAMPLES Aε = { 〈M〉 | M is a TM and L(M) = {ε} } CFTM = {〈M〉 | M is a TM and L(M) is context-free} OLTM = {〈M〉 | M is a TM and accepts only odd length strings} Use Rice’s Theorem to prove that Aε , CFTM, and OLTM are undecidable.

  4. Let EH = { 〈M〉 | M is a TM and ∃w. M(w) halts } Rice’s Theorem does not apply to EH: Let M1(s) = “reject.”, M2(s) = “loop forever.” Then L(M1) = L(M2) but 〈M1〉∈ EH and 〈M2〉  EH. EH is undecidable. Proof: HALTTM ≤m EH: ƒ(〈M,w〉) = “PMw(s): if (s  w): loop forever. else: return M(s).” WITH GREAT POWER COMES GREAT RESPONSIBILITY!

  5. GREAT RESPONSIBILITY Prove that Rice’s Theorem does not apply to: Let ULTM = { 〈M〉 | M is a TM with a useless state } WRITE-2-1s = { 〈M〉 | M is a TM that writes exactly two ones to its tape on some input} *state q is useless if for all s, M(s) is never in state q

  6. ((lambda (x)        (list x (list (quote quote) x))) (quote          (lambda (x)            (list x (list (quote quote) x))))) Print the next sentence twice, the second time in quotes. “Print the next sentence twice, the second time in quotes.” Can we make a TM that does the same? WARNING: HEADACHES AHEAD

  7. Q Pw Theorem: There is a computable q : Σ*  Σ*, where for any string w, q(w) is the description of a TM Pw that on any input, prints out w and then accepts s w w

  8. CM A TM THAT MAKES CANNIBALS s P〈M〉 〈M〉 M M(〈M〉)

  9. CM P〈CM〉 A TM THAT PRINTS ITSELF s P〈CM〉 w CM SELF Run the “cannibal maker” on itself!

  10. SELF-REFERENCE UNDECIDABILITY There are problems that no computer can solve INCOMPLETENESS There are true theorems that have no proof

  11. R T THE RECURSION THEOREM Theorem: Let T be a Turing machine that computes a function t : Σ* Σ* Σ*. There is a Turing machine R that computes a function r :Σ* Σ*, where for every w r(w) = t(〈R〉, w) (a,b) t(a,b) w t(〈R〉,w)

  12. s CM T P’〈M〉 , w 〈M,s〉 M M(〈M〉,s) Proof: (a,b) t(a,b) 〈M〉 CM’ 〈M,w〉

  13. s P’〈CM’→T〉 CM’ T , w CM’ T T t(〈P’→CM’→T〉,s) Proof: (a,b) t(a,b) 〈M,w〉 CM’ P’〈CM’→T〉 w t(〈R〉,w)

  14. A Turing machine can obtain its own description and then go on to compute with it • Design TM t(M,w) that assumes M is code for t(w) 2. Use recursion theorem to get TM R(w) = t(〈R〉,w)

  15. Theorem: ATM is undecidable Proof (using the recursion theorem): Assume H decides ATM Construct machine B such that on input w: 1. Obtains, via the recursion theorem, its own description B 2. Runs H on 〈B,w〉 and flips the output Running B on input w does the opposite of what H says it should!

  16. INCOMPLETENESS There are truestatements that have no proof

  17. GREAT LOGICIANS OF THE TWENTIETH CENTURY James T. Kirk Kurt Gödel “This sentence is a lie.” “This sentence has no proof.” Like Gödel, we will build a formal statement that is true but unprovable

  18. STATEMENTS We want to express mathematical statements, eg: “If x < y and y < z then x < z” ∀ x,y,z [ (x < y) ∧(y < z) → (x < z) ] “There are infinitely many prime numbers” ∀q∃p∀x,y [ p > q ∧ (x,y > 1 → xy p) ]

  19. STATEMENTS We can make a formal grammar for statements: Σ = { ∨, ∧, ¬, [, ], (, ), ∀, ∃, x, R, ;} S →Q [ F ] Q →∀X Q | ∃X Q | ∀X | ∃X F →A | F ∧ F | F ∨ F |¬F | (F) A → RA | R(L) X →xX | x L →X | X; L A statement is a string from this grammar with: nofree variables: if xi appears in F, it appears in Q well-formedrelations: each appearance of Ri has the same number of arguments.

  20. STATEMENTS ∀x1∃x2∃x3[ R1(x1) ∧ R2(x1;x2;x3) ] ∀x1 ∃x2[ R1(x1;x2) ∨ R1(x2;x1) ] ∃x [ R(x) ] NOT STATEMENTS R1(x) ∨¬R2(x) ∀x1[ R(x1; x2) ] ∀x1∃x2[ R(x1) ∧ R(x1;x2) ]

  21. TRUTH & MODELS A modelM is a k-tuple (U, P1, …, Pk) where: U is the universe of values each xi can have P1 … Pk are relations over U M assigns “meaning” or “truth” to a statement: Ri(u1,u2,…) is true iff (u1,u2…) ∈Pi ∀xSis true iff for every x ∈U, S is true ∃xSis true iff for some x ∈U, S is true. ∧,∨,¬ have the usual meanings.

  22. EXAMPLE Let M = (ℝ, {(x,y,z) : x+y=z}). Then: “∀xƎy [ R(y,y,x) ]” is true. “Ǝy∀x [ R(y,y,x) ]” is false. “∀y ∃x [ R(y,x) ]” is ill-formed.

  23. EXAMPLE Let M = (ℕ, {(x,y) : x≤y}, {(x,y,z) : z = x⨉y} ). Then: “∀x ∀y [ R1(y,x) ∨ R1(x,y) ]” is true. “∃y ∀x [ R1(x,y) ]” is false. “∃y ∀x [ R1(y,x,x) ]” is ill-formed.

  24. LANGUAGE & THEORY Let M= (U, P1, …, Pk) be a model. The language of M, L(M) is the set of well-formed statements under M. The theory of M, Th(M) is the set of true statements in L(M).

  25. PROOFS …are sequences of statements that “logically follow” from each other. For example S follows from T in first-order logic if: S is a tautology; or S is an axiom; or S = ∀x T ( where x  T); or S ≡ and T ≡ () ∧ (⇒ ); etc… In general, a logic is a decidable subset of S ⨉ S A sequence S1…Sm where for each i, (Sj<i, Si) ∈ or (ε, Si) ∈, is a proof of Smin logic .

  26. Given a logic  and a model M, define the set Provable(M) = { S ∈L(M): S has a proof in  } Theorem: Provable(M) is Turing recognizable. Proof: Since a proof is just a string, we can check if S is provable by checking all possible proofs:

  27. defis_provable(S): for π in {0,1,00,01,10,11,100,…}: (S1,…,Sm) = parse_as_stmt_list(π) S0 = None is_proof = True for i in{1,…,m}: follows[i] = S[i] ∈L(M) and (S[:i],S[i]) ∈. is_proof = is_proof and follows[i] if (is_proof and (S[m] == S)): return True

  28. INCOMPLETENESS I Theorem: For every TM M and string w, there is a computable formula M,w(x) 2 L(N,+,⨉) such that ∃x M,w(x) is true iff M(w) accepts. Proof: We make a sentence that says “x encodes an accepting computation history of M on w:” (x mod bλ = q0w) ∧ ∀i [ (u = x div biλmod bλ ) ∧ (v = x div b(i+1)λ mod bλ)  (u ⇒Mv) ] Ǝλ Ǝj [ x div bj mod b = qaccept ] ∧

  29. INCOMPLETENESS II Theorem: For every TM M and string w, there is a computable formula M,w(x)L(ℕ,+,) such that ƎxM,w(x) is true iff M(w) accepts. Corollary: Th(ℕ, +, ⨉) is undecidable. Proof: Suppose Th(ℕ,+,) was decidable. Then we could write a program accepts to decide ATM as follows: def accepts(M,w): if “Ǝx M,w(x)” Th(ℕ,+, ): return True else: return False

  30. INCOMPLETENESS III Theorem: For every TM M and string w, there is a computable formula M,w(x)L(ℕ,+,) such that Ǝx M,w(x) is true iff M(w) accepts. Corollary: Th(ℕ, +, ⨉) is undecidable. Corollary: There is a sentence in Th(ℕ,+,⨉) that is not provable. Proof: Suppose Th(ℕ,+,⨉) ⊆ Provable(ℕ,+,⨉). Then for all 〈M,w〉, either “∃x M,w(x)”∈Provable or “∀x¬M,w(x)”∈Provable. This gives an algorithm for ATM!

  31. accepts(M,w): In parallel: accept if is_provable(“∃x M,w(x)”) accepts reject if is_provable(“∀x¬M,w(x)”) accepts accepts(M,w) works if  is: sound: you cannot prove “false” in . complete: Every true  is provable in . This gives “Gödel’s incompleteness theorem:” every logic for (ℕ,+,⨉) is unsound or incomplete.

  32. THIS SLIDE HAS NO PROOF Theorem: the statement ψK,ε≝“∀x ¬K,ε(x)” is true but not provable, where: • K(w) = • Use recursion theorem to obtain code for K • Use code for K to construct K,w(x). • Run is_provable(“∀x ¬K,w(x)”) Proof: Suppose that K(ε) accepts. If  is sound, then K(ε) cannot accept. Thus is_provable(ψK,ε) must loop forever without finding a proof. But this means ψK,ε is true: K(ε) does not accept!

More Related