CSCE 355 Foundations of Computation Lecture 25 Undecidability
CSCE 355 Foundations of Computation Lecture 25 Undecidability Topics: n Recursively Enumerable Languages n Recursive languages The halting problem Post Correspondence Problem reductions n n n December 1, 2008
Last Time: n Turing Machines: IDs and moves, Examples New: n n n n Test 2 Hello Programs: Can one program tell what a program will do? Recursively Enumerable Languages Recursive languages The halting problem Post Correspondence Problem reductions Loose Ends n n – 2– Homework graded Sample Exam – emailed this week Graduating Seniors – Student Evaluations CSCE 355 Fall 2008
What is computable? • – 3– Hello Programs: Can one program tell what a program will do? CSCE 355 Fall 2008
Hello World Programs 1. Hello. World. rb 2. Hello. Fermat. rb 3. Hello. World. Detecter 1. rb 4. Hello. World. Detecter 2. rb 5. Hello. World. Detecter 3. rb – 4– CSCE 355 Fall 2008
Hello. World 0. rb puts "Hello World!" – 5– CSCE 355 Fall 2008
Fermat’s Last Theorem • Conjecture from 1637 n "I have a truly marvellous proof of this proposition which this margin is too narrow to contain. “ • proved by Andrew Wiles in 1995 (358 years later) • But for discussion assume still not proven. – 6– http: //en. wikipedia. org/wiki/Fermat%27 s_Last_Theorem CSCE 355 Fall 2008
Hello. Fermat. rb n = 3; total = 3 ## Fermat’s Last Theorem Checker as hello. World found. Solution = 0 while found. Solution = 0 1. upto(total-2) do |x| 1. upto(total-x-1) do |y| z = total-x-y if (x**n + y**n == z**n) puts "Hello World!" found. Solution = 1 end; total = total+1 puts "total=#{total}" –end; 7– CSCE 355 Fall 2008
Questions on Hello. Fermat. rb • Will it print “Hello World!” ? • Is it possible to modify the ruby interpreter to tell if it will print “Hello World!” ? – 8– CSCE 355 Fall 2008
– 9– http: //iti. zcu. cz/domazlice 08/ CSCE 355 Fall 2008
Hello. World. Tester. rb • Write ruby simulator “Hello. World. Tester. rb” that will test 1. Read a ruby program prog. rb and its input “I” 2. Simulate the program on that input 3. Print “yes” if the first thing “prog. rb” would print when run on Input would be “Hello World!” • Assumptions 1. All I/O is character based 2. Only using the function puts 3. Assume “print Hello World!” means the first characters printed are “Hello World!” – 10 – CSCE 355 Fall 2008
Hello. World. Tester. rb (figure 8. 3) Input Program Hello World! tester. rb H yes no • To simplify n Input will just be “I” n Program will just be “P” Hello. World. Tester will just be H n I P – 11 – H yes no CSCE 355 Fall 2008
Hello. World. Tester 1. rb (figure 8. 4) I P H 1 yes Hello World! • Modify the original Hello. World tester H so that when it would have printed “no” it now prints “Hello World!” • Note this new program H 1 behaves just like H except when H prints no. – 12 – CSCE 355 Fall 2008
Hello. World. Tester 2. rb (figure 8. 5) P H 2 yes Hello World! • Interested in programs that read other programs as their input • Now Modify H 1 to get H 2 • Treat P as both the program and its input “operate P on itself as the data” • Note on H 2’s behavior n n – 13 – If P would print “Hello World!” then H 2 prints yes Else if P would not print it then H 2 prints “Hello World!” CSCE 355 Fall 2008
What does H 2 do when run on itself ? (figure 8. 6) H 2 yes Hello World! • But now consider P = H 2 • Note on H 2’s behavior now is n n – 14 – If H 2 would print “Hello World!” then H 2 prints yes Else if H 2 would not print it then H 2 prints “Hello World!” CSCE 355 Fall 2008
Contradiction • So assuming writing a program H that can tell whether another arbitrary program will print “Hello World!” is impossible • So some problems are not solvable by computers. • Godel’s Incompleteness Theorem – 15 – CSCE 355 Fall 2008
Distinguished sets of prefixes • IDEA again: • Let S = { a 1, a 2, … , an} • Then choose two arbitrary prefixes say ai and aj • Then let z = bi, • In this case ai bi is in L, but aj bi is not in L so L distinguishes the two prefixes • Thus L is not regular. – 16 – CSCE 355 Fall 2008
Mistakes Let S = { a 1, a 2, … , an} choose two prefixes ai and aj 1. Not letting k=j or k=0 in z = bjck 2. Not error but not needed: i>j, i-j < n 3. Show S 1 and S 2 are not regular therefore S 1 union S 2 is not regular. 4. S = { a 1 b 1 c 1, a 2 b 2 c 2, … , anbncn} or other sets in the language – 17 – CSCE 355 Fall 2008
Pumping Lemma {aibjck | i=j or i=k} – 18 – CSCE 355 Fall 2008
Mistakes: Pumping Lemma {aibjck | i=j or i=k} • Given n choose w independent of n. • Arbitrary w, no real choice. • aibici with no relation expressed between i and n. • Two separate cases aib 0 ci and aibic 0. – 19 – CSCE 355 Fall 2008
Homework 1. *8. 2. 1 b 2. ****8. 2. 3 – 20 – CSCE 355 Fall 2008
Language accepted by TM M = (Q, Σ, Γ, δ, q 0 , B, F) • L(M) = {w in Σ* | q 0 w ├* αpβ – 21 – for some p in F} CSCE 355 Fall 2008
Recursively Enumerable Languages – 22 – CSCE 355 Fall 2008
Recursive languages – 23 – CSCE 355 Fall 2008
The halting problem • Enumerating the binary strings n ε, 0, 1, 00, 01, 10, 11, … • Codes for Turing Machines in binary, i. e. , Σ = {0, 1} n Number states, Q, |Σ|, Σ , |Γ |, Γ, δ, … n q 1 always denotes the start state q 2 only accepting state X 1 – the symbol 0 X 2 – the symbol 1 X 3 – the symbol Blank D 1 = left, D 2=right n n n • Enumerating Turing Machines n – 24 – TM 0, TM 1, TM 2, … CSCE 355 Fall 2008
Diagonalization Arguments • Real numbers – 25 – CSCE 355 Fall 2008
Post Correspondence Problem – 26 – CSCE 355 Fall 2008
Problem reductions – 27 – CSCE 355 Fall 2008
- Slides: 27