Professional Documents
Culture Documents
Turing Machines 1 PDF
Turing Machines 1 PDF
CS154 FINITE
STATE
q10
CONTROL
Turing Machines
AI N P U T
INFINITE TAPE
0 → 0, R → , R 0 → 0, R → , R
qaccept qaccept
0 → 0, R 0 → 0, R
→ , R → , R
qreject 0 → 0, R 0 → 0, R
→ , L → , L
Language = {0}
1
Definition: A Turing Machine is a 7-tuple
T = (Q, Σ, Γ, δ, q0, qaccept, qreject), where: Turing Machine Configurations
Q is a finite set of states
q7
Σ is the input alphabet, where ∉ Σ
Γ is the tape alphabet, where ∈ Γ and Σ ⊆ Γ
δ : Q × Γ → Q × Γ × {L, R}
1 1 0 1 0 0 0 1 1 0
q0 ∈ Q is the start state
qaccept ∈ Q is the accept state corresponds to the configuration:
qreject ∈ Q is the reject state, and qreject ≠ qaccept
11010q700110
2
x → x, L
n C = {aibjck | k = i*j, and i, j, k ≥ 1}
{ 02 | n ≥ 0 } 0 → 0, L
q2
PSEUDOCODE:
→ , R
→ , L
x → x, R 1. If the input doesn’t match a*b*c*, reject.
x → x, R 2. Move the head back to the leftmost symbol.
q0 q1 q3 3. Cross off an a, scan to the right until b.
0 → , R 0 → x, R Sweep between b’s and c’s, crossing off one of
x → x, R each until all b’s are crossed off.
→ , R 0 → 0, R If all c’s get crossed off while doing this, reject.
→ , R 0 → x, R
4. Uncross all the b’s.
If there’s another a left, then repeat stage 3.
qreject qaccept q4
If all a’s are crossed out,
x → x, R Check if all c’s are crossed off.
→ , R If yes, then accept, else reject.
aabbbcccccc
xabbbcccccc FINITE
STATE
k
xayyyzzzccc CONTROL
xabbbzzzccc
xxyyyzzzzzz
δ : Q × Γk → Q × Γk × {L,R}k
Theorem: Every Multitape Turing Machine can be Theorem: Every Multitape Turing Machine can be
transformed into a single tape Turing Machine transformed into a single tape Turing Machine
1 0 0 1 0 0
FINITE FINITE
STATE STATE
CONTROL CONTROL
FINITE FINITE
STATE . . . STATE . . .
1 0 0 # # # 1 0 0 # # #
CONTROL CONTROL
3
Theorem: Every Multitape Turing Machine can be Theorem: Every Multitape Turing Machine can be
transformed into a single tape Turing Machine transformed into a single tape Turing Machine
1 0 0 1 0 0
FINITE FINITE
STATE STATE
CONTROL CONTROL
FINITE FINITE
STATE . . . STATE . . .
1 0 0 # # # 1 0 0 # # #
CONTROL CONTROL
Similarly, we can encode DFAs and NFAs ADFA = { (D, w) | D is a DFA that accepts string w }
as bit strings. Theorem: ADFA is decidable
Proof Idea: Directly simulate D on w!
So we can define the following languages:
ANFA = { (N, w) | N is an NFA that accepts string w }
ADFA = { (B, w) | B is a DFA that accepts string w }
Theorem: ANFA is decidable. (Why?)
ANFA = { (B, w) | B is an NFA that accepts string w }
ATM = { (C, w) | C is a TM that accepts string w } ATM = { (M, w) | M is a TM that accepts string w }
4
Universality of Turing Machines
Theorem: There is a universal Turing machine U The Church-Turing Thesis
that can take as input
- the code of an arbitrary TM M
- an input string w, Everyone’s
such that U(M, w) accepts iff M(w) accepts. Intuitive Notion = Turing Machines
of Algorithms
This is a fundamental property:
Turing machines can run their own code!
This thesis is tested every time you write
Note that DFAs/NFAs do not have this property. a program that does something!
That is, ADFA is not regular.