0% found this document useful (0 votes)
36 views57 pages

Turing Variations

The document discusses variations of the Turing machine model including machines with multiple tapes, nondeterministic transitions, and the ability for the head to stay in place. It proves that each of these variations is equivalent in computational power to the standard Turing machine by describing how one model can simulate the other.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views57 pages

Turing Variations

The document discusses variations of the Turing machine model including machines with multiple tapes, nondeterministic transitions, and the ability for the head to stay in place. It proves that each of these variations is equivalent in computational power to the standard Turing machine by describing how one model can simulate the other.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 57

Variations

of the
Turing Machine

1
The Standard Model
Infinite Tape
 aababbcac a

Read-Write Head (Left or Right)

Control Unit

Deterministic

2
Variations of the Standard Model

Turing machines with: • Stay-Option


• Semi-Infinite Tape
•Multidimensional
•Multitape
• Nondeterministic

Different Turing Machine Classes


3
Same Power of two machine classes- Equivalent:
both classes accept the
same set of languages

We will prove:
each new class has the same power
with Standard Turing Machine

(accept Turing-Recognizable Languages)

4
Same Power of two classes means:

for any machine M1 of first class


there is a machine M 2 of second class

such that: L( M1 )  L( M 2 )

and vice-versa

5
Simulation: A standard technique for showing
the equivance of machine classes.
Simulate the machine of one class
with a machine of the other class
Second Class
First Class Simulation Machine
Original Machine M2
M1 M1

simulates M1
6
Configurations in the Original Machine M1
have corresponding configurations
in the Simulation Machine M 2

M1
Original Machine: d0  d1    d n

  
Simulation Machine: d 0  d1    d n
M2
7
Accepting Configuration

Original Machine: df

Simulation Machine: d f

the Simulation Machine


and the Original Machine
accept the same strings
L( M1 )  L( M 2 )
8
Turing Machines with Stay-Option

The head can stay in the same position

 aababbcac a

Left, Right, Stay

L,R,S: possible head moves


9
Example: Time 1
 aababbcac a
q1
Time 2
 b ab abb c ac a
q2

q1 a  b, S q2
10
Theorem: Stay-Option machines
have the same power with
Standard Turing machines

Proof: 1. Stay-Option Machines


simulate Standard Turing machines

2. Standard Turing machines


simulate Stay-Option machines
11
1. Stay-Option Machines
simulate Standard Turing machines

Trivial: any standard Turing machine


is also a Stay-Option machine

12
2. Standard Turing machines
simulate Stay-Option machines

We need to simulate the stay head option


For each transition with the S option, introduce
a new state, and two transitions
 One transition moves the head right, and
transits to the new state.
 The next transition moves the head back to
left, and transits to the previous state.

13
Stay-Option Machine

a  b, S
q1 q2

Simulation in Standard Machine

a  b, L x  x, R
q1 q2

For every possible tape symbol x


14
For other transitions nothing changes
Stay-Option Machine

a  b, L
q1 q2

Simulation in Standard Machine

a  b, L
q1 q2

Similar for Right moves


15
example of simulation

Stay-Option Machine:
q1 a  b, S q2 aaba  baba 
1 2
q1 q2

Simulation in Standard Machine:


aaba  baba  baba 
1 2 3
q1 q2 q2

END OF PROOF
16
Multiple Track Tape
A useful trick to perform more
complicated simulations

One Tape
  a b a b  track 1
  b a c d  track 2

One head
One symbol ( a, b)

17
  a b a b  track 1
  b a c d  track 2

q1

  a c a b  track 1
  b d c d  track 2

q2

(b, a )  (c, d ), L
q1 q2
18
Multi-tape Turing Machine

A multi-tape Turing Machine is like an


ordinary TM
There are k tapes
 Each tape has its own independent
read/write head.
The only fundamental difference from the
ordinary TM is δ– the state transition
function.
19
 : Q    Q    {L, R} , k : the number of tapes.
k k k

 (qi , a1 ,..., ak )  (q j , b1 ,..., bk , L, R, L,..., L).

Read as:
If the TM is in state qi and
the heads are reading symbols a1 through ak,
Then the machine goes to state qj, and
the heads write symbols b1 through bk, and
Move in the specified directions.

20
Multi-tape Turing Machines

Control unit
(state machine)

Tape 1 Tape 2
 a b c   e f g 
Input string

21
Tape 1 Time 1 Tape 2
 a b c   e f g 
q1 q1

Tape 1 Time 2 Tape 2


 a g c   e d g 
q2 q2

(b, f )  ( g , d ), L, R
q1 q2
22
Theorem: Multi-tape machines
have the same power with
Standard Turing machines

Proof: 1. Multi-tape machines


simulate Standard Turing machines

2. Standard Turing machines


simulate Multi-tape machines
23
1. Multi-tape machines simulate
Standard Turing Machines:

Trivial: Use just one tape

24
2. Standard Turing machines simulate
Multi-tape machines:

Standard machine:
• Uses a multi-track tape to simulate
the multiple tapes

• A tape of the Multi-tape machine


corresponds to a pair of tracks

25
Multi-tape Machine
Tape 1 Tape 2
 a b c   e f g h 

Standard machine with four track tape


a b c Tape 1
0 1 0 head position
e f g h Tape 2
0 0 1 0 head position
26
Reference point
a b c Tape 1
#
# 0 1 0 head position
# e f g h Tape 2
# 0 0 1 0 head position

Repeat for each state transition:


1. Return to reference point
2. Find current symbol in Tape 1
3. Find current symbol in Tape 2
4. Make transition
END OF PROOF
27
Nondeterministic Turing Machines

…are just like standard TMs, except:

1. The machine may proceed according


to several possibilities.
 : Q  Γ → Pow(Q  Γ  {L,R})

2. The machine accepts a string if there


exists a path from start configuration to
an accepting configuration.

28
Nondeterministic Turing Machines

q2 Choice 1
a  b, L

q1

a  c, R q3 Choice 2

Allows Non Deterministic Choices

29
Time 0

 a b c 
Time 1
q1
Choice 1
q2  b b c 
a  b, L
q2
q1
Choice 2
a  c, R q3  c b c 
q3 30
A computation of a Nondeterministic TM
is a tree, where each branch of the tree
looks like a computation of an ordinary
TM.

If a single branch reaches the accepting


state, the Nondeterministic TM accepts,
even if other branches reach the rejecting
state.

31
Deterministic Non-Deterministic
Computation Computation

reject

accept or reject accept


The machine accepts a string if there exists a
path from start configuration to an accepting
configuration.
Input string w is accepted if
there is a computation:

q0 w  x q f y

Initial configuration Final Configuration

Any accept state

There is a computation:

33
Theorem: Nondeterministic machines
have the same power with
Standard Turing machines

Proof: 1. Nondeterministic machines


simulate Standard Turing machines

2. Standard Turing machines


simulate Nondeterministic machines
34
1. Nondeterministic Machines simulate
Standard (deterministic) Turing Machines

Trivial: every deterministic machine


is also nondeterministic

35
2. Standard (deterministic) Turing machines
simulate Nondeterministic machines:
Proof Idea:
• Show that we can simulate an NTM N
with DTM D.

Note: in this simulation D tries all possible


branches of N’s computation. If D ever
finds the accept state on one of these
branches then it accepts. Otherwise D
simulation will not terminate.
36
 N’s computation on an input w is a tree,
N(w).
 Each branch of N(w) represents one of the
branches of the nondeterminism.
 Each node of N(w) is a configuration of N.
 The root of N(w) is the start configuration.

Note: D searches N(w) for an accepting


configuration.

37
Design D to explore the tree by using a
breadth-first search.

This strategy explores all branches at the


same depth before going to explore any
branch at the next depth. Hence, this
method guarantees that D will visit every
node of N(w) until it encounters an accepting
configuration.

38
D has three tapes,

1.Tape 1 (called input tape) always contains


the input (and the code of N) and is never
altered.
2.Tape 2 (called simulation tape) maintains
a copy of the N’s tape on some branch of
its nondeterministic Computation
3.Tape 3 (called address tape) keeps track
of D’s location in N’s nondeterministic
computation tree.
39
input tape
(never altered )
0 1 ............
D x x#0 1 x B ...... simulation tape
1 2 1 ...... address tape
0
number of states

......
01 bq

10
... q bb 11 ... b
Address Tape
 Every node in N(w) can have at most b children,
where b is the size of the largest set of possible
choices given by N’s transition function.

 Hence, to every node we assign an address that


is a string in the alphabet ∑ b = {1,2,...,b}.

 Example: we assign the address 231 to the node


reached by starting at the root, going to its
second child and then going to that node’s third
child and then going to that node’s first child.
41
 Each symbol in a node address tells us which
choice to make next when simulating a step in one
branch in N’s nondeterministic computation.
 Sometimes a symbol may not correspond to any
choice if too few choices are available for a
configuration. In that case the address is invalid
and doesn’t correspond to any node.
 Tape 3 contains a string over ∑b which
represents a branch of N’s computation from the
root to the node addressed by that string, unless
the address is invalid.
 The empty string Ɛ is the address of the root.

42
The Description of D
1. Initially tape 1 contains w and tape 2 and 3 are
empty.
2. Copy tape 1 over tape 2
3. Use tape 2 to simulate N with input w on one branch
of its nondeterministic computation.
 Before each step of N, consult the next symbol on tape 3
determine which choice to make among those allowed by N’s
transition function.
 If no more symbols remain on tape 3 or if this nondeterministic
choice is invalid, abort this branch by going to stage 4.
 If a rejecting configuration is reached go to stage 4; if an
accepting configuration is encountered, accept the input.
4. Replace the string on tape 3 with the next string as if
it is a counter and go to stage 2.

43
A Universal Turing Machine

44
A limitation of Turing Machines:

Turing Machines are “hardwired”

they execute
only one program
Question: Can we build a programmable TM that accepts
as input a (M: Turing machine, w: input string) pair and
outputs whatever M would output when started up on w?

Answer: Yes, it’s called the Universal Turing Machine.


45
Universal Turing Machine

Attributes:

• Reprogrammable machine

• Simulates any other Turing Machine

46
Universal Turing Machine
simulates any Turing Machine M

Input of Universal Turing Machine:

Description of transitions of M
Input string of M

47
To define the Universal Turing Machine U
we need to:

1. Define an encoding scheme that can be


used to describe to U as (M, w) pair
• <M, w>, many ways of encoding …
2.Describe the operation of U given input
<M , w >

48
Tape 1
Three tapes

Description of M

Universal
Tape 2
Turing
Machine
Tape Contents of M

Tape 3

State of M 49
Tape 1

Description of M

We describe Turing machine M


as a string of symbols:

We encode M as a string of symbols

50
Alphabet Encoding

Symbols: a b c d 

Encoding: 1 11 111 1111

51
State Encoding

States: q1 q2 q3 q4 

Encoding: 1 11 111 1111

Head Move Encoding

Move: L R

Encoding: 1 11
52
Transition Encoding

Transition:  (q1, a )  (q2 , b, L)

Encoding: 1 0 1 0 11 0 11 0 1

separator

53
Turing Machine Encoding

Transitions:
 (q1, a )  (q2 , b, L)  (q2 , b)  (q3 , c, R )

Encoding:
1 0 1 0 11 0 11 0 1 00 11 0 1 10 111 0 111 0 11
separator
54
Tape 1 contents of Universal Turing Machine:

binary encoding
of the simulated machine M

Tape 1
1 0 1 0 11 0 11 0 10011 0 1 10 111 0 111 0 1100 

55
How it works

Initialization of U :

1. U is started with input <M, w> on its


first tape.
2.Copy <M> on to tape 2.
3. U writes in the third tape the
encoding of the initial state of M.

56
Simulate the steps of M :

1. Until M would halt do:


 Scan tape 2 for a quintuple that
matches the current state, input pair.
Perform the associated action, by
changing tapes 1 and 3.
If no matching quintuple found, halt.
Else loop.
2. Report the same result M would report.

57

You might also like