1 / 23

CSC 3130: Automata theory and formal languages

Fall 2008. The Chinese University of Hong Kong. CSC 3130: Automata theory and formal languages. Variants of Turing Machines. Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130. Recognizing versus deciding. Looping is an undesirable behavior so we say Such TM are called deciders.

cybille
Download Presentation

CSC 3130: Automata theory and formal languages

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. Fall 2008 The Chinese University of Hong Kong CSC 3130: Automata theory and formal languages Variants of Turing Machines Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130

  2. Recognizing versus deciding • Looping is an undesirable behavior so we say • Such TM are called deciders The language recognized by a TM is the set ofall inputs that make it reach qacc accept reject loop A TM decides language Lif it recognizes L anddoes not loop on any input

  3. Turing Machines state control input … infinite tape 0 1 0 Why is this a universal model of computation?

  4. The Church-Turing Thesis All arguments [for the CT Thesis] which can be given are bound to be, fundamentally, appeals to intuition, and for this reason rather unsatisfactory mathematically. The arguments which I shall use are of three kinds: 1. A direct appeal to intuition 2. A proof of the equivalence of two definitions (In case the new definition has greater intuitive appeal) 3. Giving examples of large classes of numbers which are computable. 1936: “On Computable Numbers, with an Application to the Entscheidungsproblem” Section 9. The extent of the computable numbers

  5. Variant 1: The multitape Turing Machine • The transition may depend on the contents of all the cells • Different tape heads can be moved independently state control … tape 1 … … tape 2 tape 3 0 0 1 0 1 1 0 0

  6. Variant I: The multitape Turing Machine Multitape Turing Machines recognize the same languages as single-tape Turing Machines … … M G = {0, 1, ☐} … 1 0 0 0 1 1 0 0 S …    # 0 1 0 # 0 1 # 1 0 0 # G’ = {0, 1, ☐, 0, 1, ☐, #}   

  7. Variant I: The multitape Turing Machine • For every transition in M, do following in S: Until you find the last #, Find the next dotted symbol Update this symbol according to transition in M Move the dot according to transition in M If there is no space to move the dot, Move everything to the right of the dot to make space first Move head of S to beginning of tape S …    # 0 1 0 # 0 1 # 1 0 0 # G’ = {0, 1, ☐, 0, 1, ☐, #}   

  8. Variant 2: The random access machine instruction meaning • It has registers that can store arbitrary values, aprogram counter, and a random-access memory programcounter PC 0 0 1 2 3 4 5 load -7R0 := -7 write R3M[R3] := R0 store R5R5 := R0 add R5R0 := R0 + R5 jpos 3 if R0 > 0 then PC := 3 accept registers R0 0 R1 0 R2 0 … M 2 1 2 2 0 memory 1 2 3 4 0

  9. Variant 2: The random access machine instruction meaning • The instructions are indexed by the program counter PC 0 1 2 0 1 2 3 4 5 load -7R0 := -7 write R2M[R2] := R0 save R1R1 := R0 add R1R0 := R0 + R1 jzero 3 if R0 = 0 then PC := 3 accept 3 4 5 R0 0 -7 -14 R1 0 -7 R2 0 … M 0 0 0 0 0 -7 1 2 3 4 0

  10. Variant 2: The random access machine • Simulating a Turing Machine on a RAM: Random assess machines recognize the same languages as Turing Machines M … 1 2 1 head PC tape R0 2 … M 1 2 1 0 0

  11. Simulating a TM on a RAM program 0 save R1handle for state q0 0 1 2 3 6 7 8 9 10 save R1save head positionread R1read tape contents x add -1 jzero 6if x = 1 goto line 6 load 2 new value of cell write R1 write in memory load R1 recall head position add 1 move head to right jump 30 go to state q1 M … q1 1/2R … q0 qacc … … 30 save R1handle for state q1 1 2 1 … 200 accepthandle for state qacc

  12. Simulating a RAM on a Turing Machine • The configuration of a RAM consists of • Program counter • Contents of registers • Indices and contents of all nonempty memory cells PC 14 configuration = (14, 3, -7, 5, (0, 2), (2, 1), (3, 2)) R0 3 R1 -7 R2 5 … M 2 0 1 2 0 0 1 2 3 4

  13. Simulating a RAM on a Turing Machine • The TM has a simulation tape and a scratch tape • The simulation tape stores RAM configuration • The TM has a set of states corresponding to eachprogram instruction of the RAM • The TM tape is updates according to RAM instruction M (14,3,-7,5,(0,2),(2,1),(3,2))

  14. Simulating a RAM on a Turing Machine • Example: load R1 c (14,3,-7,5,(0,2),(2,1),(3,2)) s 1. Copy R1 to scratch tape -7 c (14,-,-7,5,(0,2),(2,1),(3,2)) 2. Write R1 to conf tape s -7 . c Make more spaceas needed (14,-,-7,5,(0,2),(2,1),(3,2)) . c (14,-,-7,5,(0,2),(2,1),(3,2) ) . c (14,- ,-7,5,(0,2),(2,1),(3,2)) c (14,-7,-7,5,(0,2),(2,1),(3,2)) 3. Erase scratch tape

  15. Variant 3: Nondeterministic Turing Machine • The transition function is nondeterministic: • The language recognized by N are those strings that can lead N to end in qacc N … 0 1 0 d: (Q – {qacc, qrej})   → subsets of (Q  G  {L, R})

  16. Equivalence of NTM and TM • Let us look more deeply into NTMs Nondeterministic Turing Machines recognize the same languages as Turing Machines Nondeterministic choices can be numbered q5 ➀ 1/2R q3 The first m steps of the computation are then fully specified by a sequenceof m numbers q6 1/1L ➁ 1/1R ➂

  17. Simulating a nondeterministic TM input tape N M … 0 1 0 simulation tape … 0 1 0 … address tape 0 1 0 … 1 3 2 2 k = maximum number ofnondeterministic choices in any state G’ = G ∪ {1,..., k} Address tape specifies nondeterministic choices of N First, input is copied from input tape to simulation tape Then, M simulates N using address tape data

  18. How to use the address tape input tape N M … 0 1 0 simulation tape … 0 1 0 … address tape 0 1 0 … 1 3 2 2 Suppose N accepts x when nondeterminism =11221321 Then we want to make sure the address tape contains the string 11221321 at some point in its execution To ensure this we try all possibilities for the address tape

  19. Simulating a nondeterministic TM input tape x Description of M: … 0 1 0 Initially: x = input of Na is empty For all possible strings a: Copy x to z. Simulate N on input z using a as the nondeterminism If a specifies an invalid choice or simulation runs out of choices, abandon simulation. If N enters its accept state, accept and halt. If N enters its reject state, abandon simulation. simulation tape z … 0 1 0 address tape a … 1 3 2 2

  20. Correctness of simulation • If N accepts x: Eventually, M will encounter the correct a Description of M: For all possible strings a: Copy x to z. Simulate N on input z using a as the nondeterminism If a specifies an invalid choice or simulation runs out of choices, abandon simulation. If N enters its accept state, accept and halt. If N enters its reject state, abandon simulation. So M will accept Provided that all previoussimulations halt!

  21. Correctness of simulation • Claim: Simulation step always halts (never loops) Description of M: For all possible strings a: Copy x to z. Simulate N on input z using a as the nondeterminism If a specifies an invalid choice orsimulation runs out of choices, abandon simulation. If N enters its accept state, accept and halt. If N enters its reject state, abandon simulation. Since a is finite, the simulation will eventuallyrun out of choices

  22. Correctness of simulation • If N does not accept x, then for every a: Description of M: Either N will loop, so simulation runs out of choices For all possible strings a: Copy x to z. Simulate Non input z using a as the nondeterminism If a specifies an invalid choice or simulation runs out of choices, abandon simulation. If N enters its accept state, accept and halt. If N enters its reject state, abandon simulation. Or N rejects, so simulation isabandoned anyway In either case, simulation fails, so M loops forever!

  23. Context-free languages are recognizable • Corollary • In fact If L is context-free, then it is recognizable by a TM If L is context-free, then it is decided by some TM

More Related