MELJUN P. CORTES,
MBA,MPA,BSCS,ACS
CSC 3130: Automata theory and formal languages

Fall 2008

Variants of Turing Machines
...
Recognizing versus deciding
The language recognized by a TM is the set of
all inputs that make it reach qacc
accept

rejec...
Turing Machines
state control

input
0 1 0
infinite tape

…

Why is this a universal model of computation?
The Church-Turing Thesis
All arguments [for the CT Thesis] which can be given are
bound to be, fundamentally, appeals to i...
Variant 1: The multitape Turing
Machine
state control

tape 1 0

1

tape 2 0

1

tape 3 1

0

0

…
…

0

…

The transition...
Variant I: The multitape Turing
Machine
Multitape Turing Machines recognize the same
languages as single-tape Turing Machi...
Variant I: The multitape Turing
Machine
For every transition in M, do following in S:
Until you find the last #,
Find the ...
Variant 2: The random access
machine meaning
program
instruction

PC 0
R0

0

R1

2
0

registers

0

M

0
1
2
3
4
5

0

R2...
Variant 2: The random access
machine meaning
instruction

PC 01
23
45
R0
R1

0-7
-14
0-7

R2

0

M

0-7
0

0
1
2
3
4
5

0
...
Variant 2: The random access
machine
Random assess machines recognize the same
languages as Turing Machines

Simulating a ...
Simulating a TM on a RAM
program

q0

/2R
1

q1

M

…

6
7
8
9
10

qacc

1

2

1

0
1
2
3

…

save R1
read R1
add -1
jzero...
Simulating a RAM on a Turing
Machine
The configuration of a RAM consists of




PC
R0

Program counter
Contents of regi...
Simulating a RAM on a Turing
Machine
The TM has a simulation tape and a
scratch tape
(14,3,-7,5,(0,2),(2,1),(3,2))
The sim...
Simulating a RAM on a Turing
Machine
(14,3,-7,5,(0,2),(2,1),(3,2))
c

Example: load R1

1. Copy R1 to scratch tape

s

-7
...
Variant 3: Nondeterministic
Turing Machine
N
0

1

0

…

The transition function is nondeterministic:
δ: (Q – {qacc, qrej}...
Equivalence of NTM and TM
Nondeterministic Turing Machines recognize
the same languages as Turing Machines

Let us look mo...
Simulating a nondeterministic
TM
input tape
N

M

0
0

0

1

0

0

1

simulation tape
…
0

3

address tape
…
2 2

…

k = m...
How to use the address tape
N

M

0
0

0

1

0

1

0

1

simulation tape
…
0

3

address tape
…
2 2

…
1

input tape
…

Su...
Simulating a nondeterministic
TM
input tape x
Description of M:
0

1

0

…

simulation tape z
Initially:
…
0 1 0
x = input...
Correctness of simulation
If N accepts x:
Description of M:

Eventually, M will
encounter
the correct a

For all possible ...
Correctness of simulation
Claim: Simulation step always halts (never
Description of M:
loops)

For all possible strings a:...
Correctness of simulation
If N does not accept x, then for every a:
Description of M:

For all possible strings a: Either ...
Context-free languages are
recognizable
Corollary
If L is context-free, then it is recognizable by a TM

In fact

If L is ...
Upcoming SlideShare
Loading in...5
×

MELJUN CORTES Automata Theory (Automata16)

98
-1

Published on

MELJUN CORTES Automata Theory (Automata16)

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
98
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

MELJUN CORTES Automata Theory (Automata16)

  1. 1. MELJUN P. CORTES, MBA,MPA,BSCS,ACS CSC 3130: Automata theory and formal languages Fall 2008 Variants of Turing Machines MELJUN CORTES
  2. 2. Recognizing versus deciding The language recognized by a TM is the set of all inputs that make it reach qacc accept reject loop Looping is an undesirable behavior so we say A TM decides language L if it recognizes L and does not loop on any input  Such TM are called deciders
  3. 3. Turing Machines state control input 0 1 0 infinite tape … Why is this a universal model of computation?
  4. 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. 5. Variant 1: The multitape Turing Machine state control tape 1 0 1 tape 2 0 1 tape 3 1 0 0 … … 0 … The transition may depend on the contents of all the cells Different tape heads can be moved independently
  6. 6. Variant I: The multitape Turing Machine Multitape Turing Machines recognize the same languages as single-tape Turing Machines 0 S 0 1 1 M 1 0 0 0  # 0 1 Γ = {0, 1, ☐} … … … 0 # 0 1  # 1  0 … 0 # Γ’ = {0, 1, ☐, 0, 1, ☐, #}   
  7. 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 # Γ’ = {0, 1, ☐, 0, 1, ☐, #}   
  8. 8. Variant 2: The random access machine meaning program instruction PC 0 R0 0 R1 2 0 registers 0 M 0 1 2 3 4 5 0 R2 counter 1 1 2 2 load -7 write R3 store R5 add R5 jpos 3 accept 2 3 0 4 R0 := -7 M[R3] := R0 R5 := R0 R0 := R0 + R5 if R0 > 0 then PC := 3 … memory It has registers that can store arbitrary values, a program counter, and a random-access memory
  9. 9. Variant 2: The random access machine meaning instruction PC 01 23 45 R0 R1 0-7 -14 0-7 R2 0 M 0-7 0 0 1 2 3 4 5 0 1 0 2 load -7 write R2 save R1 add R1 jzero 3 accept 0 3 0 4 R0 := -7 M[R2] := R0 R1 := R0 R0 := R0 + R1 if R0 = 0 then PC := 3 … The instructions are indexed by the program counter
  10. 10. Variant 2: The random access machine Random assess machines recognize the same languages as Turing Machines Simulating a Turing Machine on a RAM: M head PC R0 2 M 1 2 1 1 2 1 ape t 0 0 … …
  11. 11. Simulating a TM on a RAM program q0 /2R 1 q1 M … 6 7 8 9 10 qacc 1 2 1 0 1 2 3 … save R1 read R1 add -1 jzero 6 … save head state q0 handle for position read tape contents x if 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 … 30 save R1 … 200 accept handle for state q1 handle for state qacc
  12. 12. Simulating a RAM on a Turing Machine The configuration of a RAM consists of    PC R0 Program counter Contents of registers Indices and contents of all nonempty memory 14 cells configuration = 3 R1 -7 R2 5 M 2 0 (14, 3, -7, 5, (0, 2), (2, 1), (3, 2)) 0 1 1 2 2 3 0 4 …
  13. 13. Simulating a RAM on a Turing Machine The TM has a simulation tape and a scratch tape (14,3,-7,5,(0,2),(2,1),(3,2)) The simulation tape stores RAM M configuration The TM has a set of states corresponding to each
  14. 14. Simulating a RAM on a Turing Machine (14,3,-7,5,(0,2),(2,1),(3,2)) c Example: load R1 1. Copy R1 to scratch tape s -7 2. Write R1 to conf tape c s (14,-,-7,5,(0,2),(2,1),(3,2)) -7 3. Erase scratch tape c . (14,-,-7,5,(0,2),(2,1),(3,2)) c . (14,-,-7,5,(0,2),(2,1),(3,2) ) c Make more space as needed . (14,- ,-7,5,(0,2),(2,1),(3,2)) c (14,-7,-7,5,(0,2),(2,1),(3,2))
  15. 15. Variant 3: Nondeterministic Turing Machine N 0 1 0 … The transition function is nondeterministic: δ: (Q – {qacc, qrej}) × Γ → subsets of (Q × Γ × {L, R}) The language recognized by N are those strings that can lead N to end in qacc
  16. 16. Equivalence of NTM and TM Nondeterministic Turing Machines recognize the same languages as Turing Machines Let us look more deeply into NTMs ➀ q3 1/2R q5 1/1L ➁ 1/1R ➂ q6 Nondeterministic choices can be numbered The first m steps of the computation are then fully specified by a sequence of m numbers
  17. 17. Simulating a nondeterministic TM input tape N M 0 0 0 1 0 0 1 simulation tape … 0 3 address tape … 2 2 … k = maximum number of nondeterministic choices in any state 1 … 1 Γ’ = Γ ∪ {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. 18. How to use the address tape N M 0 0 0 1 0 1 0 1 simulation tape … 0 3 address tape … 2 2 … 1 input tape … 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. 19. Simulating a nondeterministic TM input tape x Description of M: 0 1 0 … simulation tape z Initially: … 0 1 0 x = input of N address tape a a is empty … 1 3 2 2 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.
  20. 20. Correctness of simulation If N accepts x: Description of M: Eventually, M will encounter the correct a 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 So M abandon simulation. simulation runs out of choices, will accept If N enters its accept state, accept and halt. If N enters its reject state, abandon simulation. Provided that all previous simulations halt!
  21. 21. Correctness of simulation Claim: Simulation step always halts (never Description of M: loops) 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. Since a is finite, the simulation will eventually run out of choices
  22. 22. Correctness of simulation If N does not accept x, then for every a: Description of M: For all possible strings a: Either N will loop, so simulation Copy x to z. runs out of nondeterminism Simulate N on input z using a as thechoices If a specifies an invalidOr N rejects, so simulation is choice or simulation runs out abandoned abandon simulation. of choices, anyway If N enters its accept state, accept and halt. If N enters its reject state, abandon simulation. In either case, simulation fails, so M loops forever!
  23. 23. Context-free languages are recognizable Corollary If L is context-free, then it is recognizable by a TM In fact If L is context-free, then it is decided by some TM
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×