Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 23 Turing Machines Topics: Pumping Lemma for CFL Example Chomsky hierarchy What’s Computable ? Turing Machines November 24, 2008 CSCE 355 Foundations.

Similar presentations


Presentation on theme: "Lecture 23 Turing Machines Topics: Pumping Lemma for CFL Example Chomsky hierarchy What’s Computable ? Turing Machines November 24, 2008 CSCE 355 Foundations."— Presentation transcript:

1 Lecture 23 Turing Machines Topics: Pumping Lemma for CFL Example Chomsky hierarchy What’s Computable ? Turing Machines November 24, 2008 CSCE 355 Foundations of Computation

2 – 2 – CSCE 355 Fall 2008 Last Time: Chomsky normal form Pumping Lemma for Context Free LanguagesNew: Chomsky Hierarchy

3 – 3 – CSCE 355 Fall 2008 Pumping Lemma for CFLs Let L be a CFL. Then there exists a constant n such that if z is a string in L of length at least n, then we can write z = uvwxy such that 1. |vwx| =< n 2.|vx| > 0 3.uv i wx i y is in L for all i >= 0.

4 – 4 – CSCE 355 Fall 2008 Idea behind proof  Assume CNF (or do for L(G)-{ε})  Consider Parse Tree  Sufficiently long string z, means the parse tree must be sufficiently big.

5 – 5 – CSCE 355 Fall 2008 Example L = {ww | w in {0,1}* }  Given L as above, suppose we chose n for the Pumping Lemma (for CFLs).  Choose z =  Consider arbitrary partition of z = uvwxy satisfying 1. | vwx| =< n 2. |vx| > 0  Then show …

6 – 6 – CSCE 355 Fall 2008 Example continued

7 – 7 – CSCE 355 Fall 2008 Chomsky Hierarchy http://en.wikipedia.org/wiki/Chomsky_hierarchy GrammarLanguagesAutomatonProduction rules (constraints) Type-0Recursively enumerableTuring machine α  β no restrictions Type-1Context-sensitiveLinear-bounded non- deterministic Turing machine αAβ  αγβ Type-2Context-freeNon-deterministic pushdown automaton pushdown automaton A  α Type-3RegularDFA A  a or A  aB

8 – 8 – CSCE 355 Fall 2008 Chomsky Hierarchy Venn Diagram

9 – 9 – CSCE 355 Fall 2008 Alan Turing  British Mathematician  Led team that cracked Enigma (German Code)  Formalized concept of algorithms – model “any possible computation”  Turing Test AI  References http://www.turing.org.uk/turing/ http://www-groups.dcs.st- and.ac.uk/~history/Biographies/Turing.html http://www-groups.dcs.st- and.ac.uk/~history/Biographies/Turing.html http://www-groups.dcs.st- and.ac.uk/~history/Extras/Turing_running.html http://www-groups.dcs.st- and.ac.uk/~history/Extras/Turing_running.html

10 – 10 – CSCE 355 Fall 2008 What is computable?

11 – 11 – CSCE 355 Fall 2008 Hello World Programs 1.HelloWorld.rb 2.HelloFermat.rb 3.HelloWorldDetecter1.rb 4.HelloWorldDetecter2.rb 5.HelloWorldDetecter3.rb

12 – 12 – CSCE 355 Fall 2008 HelloWorld0.rb puts "Hello World!"

13 – 13 – 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

14 – 14 – 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;

15 – 15 – 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!” ?

16 – 16 – CSCE 355 Fall 2008 http://iti.zcu.cz/domazlice08/

17 – 17 – 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!”

18 – 18 – 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

19 – 19 – 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!

20 – 20 – 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!

21 – 21 – 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!

22 – 22 – 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

23 – 23 – CSCE 355 Fall 2008 Turing Machines  Model of “any possible computation” i.e. an algorithm  Finite State Control + “infinite tape” for memory

24 – 24 – CSCE 355 Fall 2008 Formal Definition of Turing Machine M = (Q, Σ, Γ, δ, q 0, B, F)  Q  Σ  Γ  δ : Q x Γ  Q x Γ x {L, R} δ (q, X) = (p, Y, D)  q 0  B – blank symbol in Γ but not in Σ  F

25 – 25 – CSCE 355 Fall 2008 Instantaneous Descriptors  What do we need to describe to characterize the state of a Turing Machine? State Contents of the tape Where the read/write head is located  So an instantaneous descriptor looks like X 1 X 2 …X i-1 q X i X i+1, … X n  exceptions

26 – 26 – CSCE 355 Fall 2008 Moves of the Turing Machine  ID1 ├ ID2  ID1 ├* ID2

27 – 27 – CSCE 355 Fall 2008 Example figure 8.9

28 – 28 – CSCE 355 Fall 2008 Homework 1.8.2.1b


Download ppt "Lecture 23 Turing Machines Topics: Pumping Lemma for CFL Example Chomsky hierarchy What’s Computable ? Turing Machines November 24, 2008 CSCE 355 Foundations."

Similar presentations


Ads by Google