Presentation is loading. Please wait.

Presentation is loading. Please wait.

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

Similar presentations


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

1 INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

2 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 There exist TMs 〈 M IN 〉  P and 〈 M OUT 〉  P THEN P is undecidable. EXTREMELY POWERFUL (i.e. P is a “nontrivial property of the r.e. languages.”)

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

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

5 GREAT RESPONSIBILITY WRITE-2-1s = { 〈 M 〉 | M is a TM that writes exactly two ones to its tape on some input} Prove that Rice’s Theorem does not apply to: Let UL TM = { 〈 M 〉 | M is a TM with a useless state } *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 Theorem: There is a computable q : Σ*  Σ*, where for any string w, q(w) is the description of a TM P w that on any input, prints out w and then accepts Q w PwPw s w

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

9 A TM THAT PRINTS ITSELF CM P 〈 CM 〉 w s 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 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) T (a,b)t(a,b) R w t( 〈 R 〉,w)

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

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

14 A Turing machine can obtain its own description and then go on to compute with it 1.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: A TM is undecidable Proof (using the recursion theorem): Assume H decides A TM 1. Obtains, via the recursion theorem, its own description B Construct machine B such that on input w: 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 true statements that have no proof

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

18 STATEMENTS We want to express mathematical statements, eg: “There are infinitely many prime numbers” “If x < y and y < z then x < z” ∀ x,y,z [ (x < y) ∧ (y < z) → (x < z) ] ∀ 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: no free variables: if x i appears in F, it appears in Q well-formed relations: each appearance of R i has the same number of arguments.

20 STATEMENTS ∀ x 1 ∃ x 2 ∃ x 3 [ R 1 (x 1 ) ∧ R 2 (x 1 ;x 2 ;x 3 ) ] ∀ x 1 ∃ x 2 [ R 1 (x 1 ;x 2 ) ∨ R 1 (x 2 ;x 1 ) ] ∃ x [ R(x) ] NOT STATEMENTS R 1 (x) ∨ ¬R 2 (x) ∀ x 1 [ R(x 1 ; x 2 ) ] ∀ x 1 ∃ x 2 [ R(x 1 ) ∧ R(x 1 ;x 2 ) ]

21 TRUTH & MODELS M assigns “meaning” or “truth” to a statement: A model M is a k-tuple (U, P 1, …, P k ) where: U is the universe of values each x i can have P 1 … P k are relations over U R i (u 1,u 2,…) is true iff (u 1,u 2 …) ∈ P i ∀ xS is true iff for every x ∈ U, S is true ∃ xS is 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 “ Ǝ y ∀ x [ R(y,y,x) ]” is “ ∀ y ∃ x [ R(y,x) ]” is ill-formed. true. false.

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

24 LANGUAGE & THEORY 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 ). Let M = (U, P 1, …, P k ) be a model.

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 S 1 …S m where for each i, (S j<i, S i ) ∈  or (ε, S i ) ∈ , is a proof of S m in 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 def is_provable(S): for π in {0,1,00,01,10,11,100,…}: (S 1,…,S m ) = parse_as_stmt_list(π) S 0 = 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 λ = q 0 w) ∧∀i [ (u = x div b iλ mod b λ ) ∧ (v = x div b (i+1)λ mod b λ )  (u ⇒ M v) ] ∧ Ǝ j [ x div b j mod b = q accept ]

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 A TM as follows: def accepts(M,w): if “ Ǝ x  M,w (x)”  Th( ℕ,+,  ): return True else: return False

30 INCOMPLETENESS III 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 A TM ! 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.

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) = 1.Use recursion theorem to obtain code for K 2.Use code for K to construct  K,w (x). 3.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!


Download ppt "INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011."

Similar presentations


Ads by Google