Download presentation
Presentation is loading. Please wait.
Published byDorothy Ross Modified over 8 years ago
1
Lecture 25 Undecidability Topics: Recursively Enumerable Languages Recursive languages The halting problem Post Correspondence Problem Problem reductions December 1, 2008 CSCE 355 Foundations of Computation
2
– 2 – CSCE 355 Fall 2008 Last Time: Turing Machines: IDs and moves, ExamplesNew: Test 2 Hello Programs: Can one program tell what a program will do? Recursively Enumerable Languages Recursive languages The halting problem Post Correspondence Problem Problem reductions Loose Ends Homework graded Sample Exam – emailed this week Graduating Seniors – Student Evaluations
3
– 3 – CSCE 355 Fall 2008 What is computable? Hello Programs: Can one program tell what a program will do?
4
– 4 – CSCE 355 Fall 2008 Hello World Programs 1.HelloWorld.rb 2.HelloFermat.rb 3.HelloWorldDetecter1.rb 4.HelloWorldDetecter2.rb 5.HelloWorldDetecter3.rb
5
– 5 – CSCE 355 Fall 2008 HelloWorld0.rb puts "Hello World!"
6
– 6 – CSCE 355 Fall 2008 Fermat’s Last Theorem Conjecture from 1637 "I have a truly marvellous proof of this proposition which this margin is too narrow to contain.“proof proved by Andrew Wiles in 1995 (358 years later) Andrew WilesAndrew Wiles But for discussion assume still not proven. http://en.wikipedia.org/wiki/Fermat%27s_Last_Theorem
7
– 7 – CSCE 355 Fall 2008 HelloFermat.rb n = 3; total = 3 ## Fermat’s Last Theorem Checker as helloWorld foundSolution = 0 while foundSolution = 0 1.upto(total-2) do |x| 1.upto(total-2) do |x| 1.upto(total-x-1) do |y| z = total-x-y z = total-x-y if (x**n + y**n == z**n) if (x**n + y**n == z**n) puts "Hello World!" foundSolution = 1 end; end;end; total = total+1 total = total+1 puts "total=#{total}" puts "total=#{total}"end;
8
– 8 – CSCE 355 Fall 2008 Questions on HelloFermat.rb Will it print “Hello World!” ? Is it possible to modify the ruby interpreter to tell if it will print “Hello World!” ?
9
– 9 – CSCE 355 Fall 2008 http://iti.zcu.cz/domazlice08/
10
– 10 – CSCE 355 Fall 2008 HelloWorldTester.rb Write ruby simulator “HelloWorldTester.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!”
11
– 11 – CSCE 355 Fall 2008 HelloWorldTester.rb (figure 8.3) To simplify Input will just be “I” Program will just be “P” HelloWorldTester will just be H Hello World! tester.rb H Input Program yes no H I P yes no
12
– 12 – CSCE 355 Fall 2008 HelloWorldTester1.rb (figure 8.4) Modify the original HelloWorld tester H so that when it would have printed “no” it now prints “Hello World!” Note this new program H1 behaves just like H except when H prints no. H1 I P yes Hello World!
13
– 13 – CSCE 355 Fall 2008 HelloWorldTester2.rb (figure 8.5) Interested in programs that read other programs as their input Now Modify H1 to get H2 Treat P as both the program and its input “operate P on itself as the data” Note on H2’s behavior If P would print “Hello World!” then H2 prints yes Else if P would not print it then H2 prints “Hello World!” H2 P yes Hello World!
14
– 14 – CSCE 355 Fall 2008 What does H2 do when run on itself ? (figure 8.6) But now consider P = H2 Note on H2’s behavior now is If H2 would print “Hello World!” then H2 prints yes Else if H2 would not print it then H2 prints “Hello World!” H2 yes Hello World!
15
– 15 – 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
16
– 16 – CSCE 355 Fall 2008 Distinguished sets of prefixes IDEA again: Let S = { a 1, a 2, …, a n } Then choose two arbitrary prefixes say a i and a j Then let z = b i, In this case a i b i is in L, but a j b i is not in L so L distinguishes the two prefixes Thus L is not regular.
17
– 17 – CSCE 355 Fall 2008 Mistakes Let S = { a 1, a 2, …, a n } choose two prefixes a i and a j 1.Not letting k=j or k=0 in z = b j c k 2.Not error but not needed: i>j, i-j j, i-j < n 3.Show S1 and S2 are not regular therefore S1 union S2 is not regular. 4.S = { a 1 b 1 c 1, a 2 b 2 c 2, …, a n b n c n } or other sets in the language
18
– 18 – CSCE 355 Fall 2008 Pumping Lemma {a i b j c k | i=j or i=k}
19
– 19 – CSCE 355 Fall 2008 Mistakes: Pumping Lemma {a i b j c k | i=j or i=k} Given n choose w independent of n. Arbitrary w, no real choice. a i b i c i with no relation expressed between i and n. Two separate cases a i b 0 c i and a i b i c 0.
20
– 20 – CSCE 355 Fall 2008 Homework 1.*8.2.1b 2.****8.2.3
21
– 21 – CSCE 355 Fall 2008 Language accepted by TM M = (Q, Σ, Γ, δ, q 0, B, F) L(M) = {w in Σ * | q 0 w ├* α p β for some p in F}
22
– 22 – CSCE 355 Fall 2008 Recursively Enumerable Languages
23
– 23 – CSCE 355 Fall 2008 Recursive languages
24
– 24 – CSCE 355 Fall 2008 The halting problem Enumerating the binary strings ε, 0, 1, 00, 01, 10, 11, … Codes for Turing Machines in binary, i.e., Σ = {0,1} Number states, Q, | Σ |, Σ, | Γ |, Γ, δ, … 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 D1 = left, D2=right Enumerating Turing Machines TM 0, TM 1, TM 2, …
25
– 25 – CSCE 355 Fall 2008 Diagonalization Arguments Real numbers
26
– 26 – CSCE 355 Fall 2008 Post Correspondence Problem
27
– 27 – CSCE 355 Fall 2008 Problem reductions
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.