0% found this document useful (0 votes)
18 views27 pages

lec8

The document discusses Universal Turing Machines, which are capable of simulating any other Turing machine by taking their description and input data. It outlines various types of Turing machines, including standard, multi-track, and bi-directional tapes, as well as the encoding of Turing machines and their transitions. The document also explains the phases of how a Universal Turing Machine operates, including validation, initialization, and simulation of the input Turing machine.

Uploaded by

vvedang1382
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views27 pages

lec8

The document discusses Universal Turing Machines, which are capable of simulating any other Turing machine by taking their description and input data. It outlines various types of Turing machines, including standard, multi-track, and bi-directional tapes, as well as the encoding of Turing machines and their transitions. The document also explains the phases of how a Universal Turing Machine operates, including validation, initialization, and simulation of the input Turing machine.

Uploaded by

vvedang1382
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Universal Turing Machines

Sides based on material by Kani, Erickson, Chekuri, et. al.

All mistakes are my own! - Ivan Abraham (Fall 2024)


Turing Machine
… b b a a a a … Input/Output Tape

q1

• Input written on (in nite) one sided


Reading and Writing Head tape.
(moves in both directions)
• Special blank characters.
• Finite state control (similar to DFA).
q3 …

q2 qn
• Read character under head, write
character out, move the head right
q1 q0
or left (or stay).

Finite control

2







fi
Turing Machine
Transition function

δ : Q × Γ → Q × Γ × {L, R, S}

current symbol new symbol Direction to


state scanned state to write move on tape

From state q, on reading a:

• go to state p
• write b δ(q, a) = (p, b, L)
• move head Left
• Missing transitions lead to hell state.
“Blue screen of death.” “Machine crashes.
3







Turing machine variants
Equivalent Turing Machines

Several variations of a Turing machine:

• Standard Turing machine (single in nite tape)


• Multi-track tapes
• Bi-in nite tape (from last lecture)
• Multiple heads
• Multiple heads and tapes

4

fi
fi
Turing machine variants
Multi-track Tapes

Suppose we have a TM with multiple tracks:


1 1 0 0 0 0 … Tape 0
0 1 0 1 1 0 … Tape 1
0 1 0 0 1 1 … Tape 2
H1

Is there an equivalent single-track TM?


4 7 0 2 3 1 … Input/ Output
Tape
H1

New transition function: δ : Q × Γ1 × Γ2 × Γ3 → Q × Γ1 × Γ2 × Γ3 × {−1, + 1}


5




Turing machine variants
In nite Bi-directional Tape

Suppose we have a TM with tape that is bi-in nite:


… -2 -1 0 +1 +2 +3 … Input/ Output
Tape
H1

Is there an equivalent one-sided TM?

0 +1 +2 +3 +4 +5 +6 … Positive index track


-1 -2 -3 -4 -5 -6 … Negative index track
H1
* Marker Symbol indicates transition

Can model as multiple tapes.


6



fi
fi
Turing machine variants
In nite Bi-directional Tape

Suppose we have a TM with tape that is bi-in nite:


… -2 -1 0 +1 +2 +3 … Input/ Output
Tape
H1

Is there an equivalent one-sided TM?

⇌ 0 1 -1 2 -2 3 -3 4 … Input/ Output Tape


H1
* Marker Symbol tracks/indicates which index we look at

Or as single tape interleaved with positive and negative indexes.

7




fi
fi
Turing machine variants
Multiple Read/Write Heads

Suppose we have a TM with multiple heads:


1 1 0 0 0 0 … Input/ Output Tape
H1 H2 H3

What does the transition function for the equivalent nominal TM look like?

8




Turing machine variants
Multiple Read/Write Heads

Suppose we have a TM with multiple heads:


1 1 0 0 0 0 … Input/ Output Tape 1
H1

0 0 0 1 1 1 … Input/ Output Tape 2


H2

0 0 1 1 0 0 … Input/ Output Tape 3


H3

What does the transition function for the equivalent nominal TM look like?

9




Determinism in Turing Machines

10

Determinism in Turing Machines
Deterministic vs Non-Deterministic

Deterministic Non-Deterministic

accept


f(n) f(n)
… reject
accept or
reject
accept

11



Power of NTM vs. DTM?
A DTM can simulate a NTM in the following ways:

• Multiplicity of con guration of states


1. Have the store multiple con gurations of the NTM.
2. At every timestep, process each con guration. Add con gurations
to the set if multiple paths exist.

• Multiple Tapes - Can simulate NTM with 3-tape DTM:


1. First tape holds original input
2. Second used to simulate a particular computation of NTM
3. Third tape encodes path in NTM computation tree.
12

fi
fi
fi
fi
Universal Turing Machine
Introduction

A single Turing Machine Mu that can compute anything computable


Takes as input:

• the description of some other TM M


• data w for M to run on
Outputs:

• results of running M(w)

13






Universal Turing Machine
Some notation

M: Turing machine
⟨M⟩: a string uniquely describing M (we will see that it can be thought of as a
number)

w: An input string.
⟨M, w⟩: A unique string encoding both M and input w.

L(Mu) = {⟨M, w⟩ is a TM and M accepts w}

14








Universal Turing Machine
Introduction

We want to construct a Turing machine such that:

L (Mu) = {⟨M, w⟩ ∣ M accepts w}


Mu is a stored-program computer. It reads ⟨M, w⟩, parses it as a program M
and data w, and executes M on data w.

In other words, Mu simulates the run of M on w.

15











Universal Turing Machine
Coding of TMs
Lemma: If a language L over alphabet {0,1} is accepted by some TM M, then there
is a one-tape TM M′ that accepts L, such that

• Γ = {0,1,B}
• states numbered 1,...,k
• q1 is a unique start state
• q3 is a unique halt/accept state
• q3 is a unique halt/reject state
Note: To represent a TM, we need only list its set of transitions - everything else is
implicit by the above.

16












Listing Transition

• Use the following order:


δ (q1,0), δ (q1,1), δ (q1, B), δ (q2,0), δ (q2,1), δ (q2, B), …
…δ (qk,0), δ (qk,1), δ (qk, B)
• Use the following encoding:
111 t1 11 t2 11 t3 11 . . . 11 t3k 111
where ti is the encoding of transition i as given on the next slide.

17






Encoding a transition

Recall transition looks like δ(q, a) = (p, b, L). So, encode as


< state > 1 < input > 1 < new state > 1 < new-symbol > 1 < direction >
where
i
• state qi represented by 0
• 0,1,B represented by 0, 00, 000
• L, R, S represented by 0, 00, 000
δ (q3,1) = (q4,0,R) represented by 000 1 00 1 0000 1 0 1 00
⏟ ⏟ ⏟ ⏟ ⏟
q3 1 q4 0 R
18











Example
Typical TM code:

11101010000100100110100100000101011 . . . . . 11 . . . . . . . 11 . . . . . . . 111
• Begins, ends with 111
• Transitions separated by 11
• Fields within transition separated by 1
• Individual elds represented by 0s

19


fi



TMs are (binary) numbers

• Every TM is encoded by a unique element of ℕ


• Convention: elements of ℕ that do not correspond to any TM encoding
represent the “null TM” that accepts nothing.

• Thus, every TM is a number, and vice versa


• Let < M > mean the number that encodes M
• Conversely, let Mn be the TM with encoding n.

20







How Mu works
Con guration

Three tapes

• Tape 1: holds input M and w demarcated with #; never changes


• Tape 2: simulates M’s single tape
• Tape 3: holds M’s current state

1 1 1 t1 1 1 t2 1 1 … t3k 1 1 1 # w

Input M Input w
21







fi





Universal Turing Machine
How Mu works: Phase 1 (validate)

• Check if Tape 1 holds a valid TM by examining < M >


• There should be no more than three consecutive ones.
• The beginning and ending must be enclosed in 111’s.
i j
• Substring 110 | 0 1 does not appear twice.
• Appropriate number of zeros and ones between 1’s demarcating transition
code
11000010100000100001...
• Etc.
22







Universal Turing Machine
How Mu works - Phase 2 (initialize)

• Copy w to Tape 2
• Write 0 on Tape 3 indicating it is in the start state
• If at any time, Tape 3 holds 00 (or 000), then halt and accept (or reject)

11101010000100100110100100000101011 . . . . . . 111 # 100110 Tape 1


Code for M

$100110 Tape 2
Current contents of M’s tape

$0 Tape 3
Current state of M
23










Universal Turing Machine
How Mu works - Phase 3 (simulation)

• Repeatedly simulate the steps of M


i
• Example: If tape 3 holds 0 and tape 2 is scanning 1, then search for substring
i
110 1001 on tape 1.

11101010000100100110100100000101011 . . . . . . 111 # 100110 Tape 1


Code for M

$100110 Tape 2
Current contents of M’s tape

$0 Tape 3
Current state of M
24











Universal Turing Machine
How Mu works - Phase 3 - (simulation, after a single move)

• Check if 00 or 000 is on tape 3; if so, halt and accept or reject


• Otherwise, simulate the next move by searching for pattern. In this example,
the next pattern = 1100000101
move tape 2 head to the right

11101010000100100110100100000101011 . . . . . . 111 # 100110


Code for M copy new state 00000 to tape 3

$000110
Current contents of M’s tape write a 0 under tape 2’s head

$00000
Current state of M
25









Examples
https://rosettacode.org/wiki/Universal_Turing_machine#Python

26

Universal Turing Machine
Examples

• See:

27

You might also like