SlideShare a Scribd company logo
1 of 26
Download to read offline
Turing Machines
Sipser Chapter 3, pages 165-176
Intro to Turing Machines
• A Turing Machine (TM) has finite-state control (like PDA), and
an infinite read-write tape. The tape serves as both input and
unbounded storage device.
• The tape is divided into cells, and each cell holds one symbol
from the tape alphabet.
• There is a special blank symbol B. At any instant, all but
finitely many cells hold B.
• Tape head sees only one cell at any instant. The contents of
this cell and the current state determine the next move of the
TM.
1 1 0 2 B B B B B B B
The tape extends
to infinity on the
right with all
Blanks (B)
state
0 1 2
1 L,2,3
2
3
4
State = 1
…
Moves
• A move consists of:
– replacing the contents of the scanned cell
– repositioning of the tape head to the nearest cell
on the left, or on the right
– changing the state
• The input alphabet is a subset of the tape alphabet. Initially,
the tape holds a string of input symbols (the input), starting
on the left of the tape, with in infinite sequence of blanks to
the right (after the input). The initial position of the head is
the leftmost symbol.
Formal Definition
• A TM is a 7-tuple M=(Q,Σ,Γ,δ,q0,qaccept,qreject), where
1. Q is a finite set of states
2. Σ is the input alphabet (does not contain B the blank symbol)
3. Γ is the tape alphabet, where
1. Σ ⊆ Γ (the input alphabet is a subset of the tape alphabet)
2. B ∈Γ (Blank is in the tape alphabet)
4. q0 ∈ Q is the start state
5. Qaccept ∈ Q is the accepting state
6. Qreject ∈ Q is the rejecting state
7. δ : Q × Γ → Q × Γ × {L,R} is a partial function.
The value of δ (q,X) is either undefined, or is a triple consisting of the new state,
the replacement symbol, and direction (left/right) for the head motion.
Example
• Here is a TM that checks its third symbol is 0,
accepts if so, and runs forever, if not (note it
never rejects).
• M=({p,q,r,s,t,d},{0,1,},{0,1,B},p,s,d)
• δ(p,X) = (q,X,R) for X=0,1
• δ(q,X) = (r,X,R) for X=0,1
• δ(r,0) = (s,0,L)
• δ(r,1) = (t,1,R)
• δ(t,X) = (t,X,R) for X=0,1,B
δ(p,X) = (q,X,R) for X=0,1
δ(q,X) = (r,X,R) for X=0,1
δ(r,0) = (s,0,L)
δ(r,1) = (t,1,R)
δ(t,X) = (t,X,R) for X=0,1,B
Transisition Diagrams for TM
• Pictures of TM can be
drawn like those for
PDA's. Here's the TM
of the example
below.
Implicit Assumptions
• Input is placed on tape in contiguous block of
cells (all the way to the left)
• All other cells to the right are blank: ‘B’
• Tape head positioned at Left of input block
• There is one start state
• The text uses a single accepting and rejecting
state, an alternative is to have many such states.
These are equivalent, why?
Example 2: { anbm | n,m ≥ 0}
states = 0,1,H
tape alphabet = a,b,^
input alphabet = a,b
start = 0
blank = ‘^'
accepting = H
rejecting = R
delta = (0,^,^,S,H)
(0,a,a,R,0)
(0,b,b,R,1)
(1,b,b,R,1)
(1,^,^,S,H)
Example 3: { anbncn | n ≥ 0}
delta =
(0,a,X,R,1) Replace a by X and scan right
(0,Y,Y,R,0) Scan right over Y
(0,Z,Z,R,4) Scan right over Z, but make final check
(0,^,^,S,H) Nothing left, so its success
(1,a,a,R,1) Scan right looking for b, skip over a
(1,b,Y,R,2) Replace b by y, and scan right
(1,Y,Y,R,1) scan right over Y
(2,c,Z,L,3) Scan right looking for c, replacxe it by Z
(2,b,b,R,2) scan right skipping over b
(2,Z,Z,R,2) scan right skipping over Z
(3,a,a,L,3) scan left looking for X, skipping over a
(3,b,b,L,3) scan left looking for X, skipping over b
(3,X,X,R,0) Found an X, move right one cell
(3,Y,Y,L,3) scan left over Y
(3,Z,Z,L,3) scan left over Z
(4,Z,Z,R,4) Scan right looking for ^, skip over Z
(4,^,^,S,H) Found what we’re looking for, success!
tape alphabet = a,b,c,^,X,Y,Z
input alphabet = a,b,c
start = 0
blank = ‘^ '
final = H
aabbcc
Xabbcc
XaYbcc
XaYbZc
XXYbZc
XXYYZc
XXYYZZ
Details
• There are 3 level of details we might use to describe TM’s
1. Give the complete formal description
• the states, alphabet, transition, etc
2. Implementation description
• Partition the states into stages, Use English to describe how
each stage move the head and stores data on the tape
• Each stage performs one function.
• Describe how we move between stages
• No details of states or transition function
3. High level description
• Use English to describe an algorithm
• Don’t mention how to describe tape or moves
Example Implementation level
• { 02^n | n ≥ 0}
• Stages
1. Sweep left to right across the tape. Crossing off
every other 0
2. If in stage 1, the tape conatined a single 0, accept
3. If in stage 1, the tape contained more than a single
0, and the number of 0’s was odd, reject
4. Return the head to the left-hand end of the tape
5. Goto stage 1.
What is important
• We seek to convince the student that Turing
machines are a powerful tool to describe
algorithms
• The full set of details is often too complex to
describe completely, because the details do
not add to our understanding.
• But, we could use our high level descriptions
to complete the formal description if we
desired.
Turing machines with output
• A Turing machine can compute an output by
leaving an answer on the tape when it halts.
• We must specify the form of the output when
the machine halts.
Adding two to a number in unary
TM Q {0, 1, H, R}
Sigma {1}
Gamma {1, ^}
Delta 0 1 -> (1, R, 0)
0 ^ -> (1, R, 1)
1 ^ -> (1, S, H)
q0 0
Accept H
Reject R
Blank ^
Adding 1 to a Binary Number
TM Q {0, 1, 2, H, R}
Sigma {1, 0, ^}
Gamma {1, 0, ^}
Delta 0 0 -> (0, R, 0)
0 1 -> (1, R, 0)
0 ^ -> (^, L, 1)
1 0 -> (1, L, 2)
1 1 -> (0, L, 1)
1 ^ -> (1, S, H)
2 0 -> (0, L, 2)
2 1 -> (1, L, 2)
2 ^ -> (^, R, H)
q0 0
Accept H
Reject R
Blank ^
^1011^
^1010^
^1000^
^1100^
An equality Test
delta =
(0,1,^,R,1)
(0,^,^,R,4)
(0,#,#,R,4)
(1,1,1,R,1)
(1,^,^,L,2)
(1,#,#,R,1)
(2,1,^,L,3)
(2,#,1,S,H)
(3,1,1,L,3)
(3,^,^,R,0)
(3,#,#,L,3)
(4,1,1,S,H)
(4,^,^,S,H)
(4,#,#,R,4)
states = 0,1,2,3,4,H
tape alphabet = 1,0,#,^
input alphabet = 1,0,#
start = 0
blank = ‘^'
final = H
Configurations (Sipser pg. 140)
• configurations for TM's are strings of the form α q β , where
α, β ∈ Γ* and q ∈ Q. (Assume that Q and Γ* are disjoint sets,
guaranteeing unique parsing of configurations.)
• The string α represents the tape contents to the left of the
head.
• The string β represents the non-blank tape contents to the
right of the head, including the currently scanned cell.
• Adding or deleting a few blank symbols at the beginning or
end of an confiuration results in an equivalent configuartion.
Both represent the same instant in the execution of a TM.
Sipser terminology
• Other authors call configurations
instantaneous descriptions
• Starting Configuration
• Accepting Configuration
• Rejecting Configuration
Both of these
are halting
configurations
Relating configurations
• TM's transitions induce the relation |- between configurations.
• Let ω =X1. . . Xi-1 q Xi . . . Xk be an configuration.
• If δ(q,Xi) is undefined, then there are no configurations ω '
such that ω |- ω '.
• If δ(q,Xi)=(p,Y,R) then
ω |- ω ' holds for ω ' = X1. . . Xi-1 Y p Xi+1. . . Xk
• Similarly, if δ(q,X_i)=(p,Y,L)
then ω |- ω’ holds for ω’ =X1. . . pXi-1YXi+1 . . . Xk
• When ω |- ω’ Sipser says: “ ω yields ω’ ”
Note
• If, in the first case, we have i=k, (that is we are at the
end of the non-blank portion of the tape to the right)
then we need to use the equivalent representation
• ω = X1 . . . Xk-1 q Xk B
• for our formula to make sense. Similarly, we add a B
to the beginning of ω whenever necessary.
Example
• Here is the sequence of
configurations of our example
machine, showing its execution
with the given input 0101:
• p0101 |- 0q101 |-01r01 |- 0s101
• The machine halts, since there are
no moves from the state s. When
the input is 0111, the machine
goes forever, as follows:
• p0111 |- 0q111 |- 01r11 |- 011t1
|- 0111t |- 0111Bt |- 0111BBt |- …
The Language of a TM
• We define the language of the TM M to be the set L(M) of all
strings w ∈ Σ*
• such that: Q0 w |-* α qaccept β
• for any α, β
• Languages accepted by TM's are call recursively enumerable
(RE). Sipser calls this Turing-recognizable
• Example. For our example machine, we have L(M)=
(0+1)(0+1)0(0+1)*
• If the machine recognizes some language, and also halts for all
inputs. We say the language is Turing-decidable.
Acceptance by Halting
• Some text books define an alternative way of defining a
language associated with a TM M. (But not Sipser, though
the idea is still interesting).
• We denote it H(M), and it consists of strings that cause
the TM to halt. Precisely, a string w ∈ Σ* belongs to H(M)
• iff q0 w |-* α p X β
• where δ(p,X) is undefined.
• Example. For our example machine, we have
• H(M)= ε + 0 + 1 + (0+1)(0+1) + (0+1)(0+1)0(0+1)*
Equivalence of
Acceptance by Final State and Halting
• How would we prove such an equivalence?
• 1. Construct a TM that accepts by Halting from
an ordinary one.
• 2. Construct an ordinary TM from one that
accepts by halting.

More Related Content

Similar to TuringMachines.pdf

Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
ankitamakin
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
ankitamakin
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
Srimatre K
 
Matrix 2 d
Matrix 2 dMatrix 2 d
Matrix 2 d
xyz120
 
Winter 8 Tutorial TM.pptx
Winter 8 Tutorial TM.pptxWinter 8 Tutorial TM.pptx
Winter 8 Tutorial TM.pptx
HarisPrince
 

Similar to TuringMachines.pdf (20)

Turing Machines (TM)
Turing Machines (TM)Turing Machines (TM)
Turing Machines (TM)
 
Automata Theory - Turing machine
Automata Theory - Turing machineAutomata Theory - Turing machine
Automata Theory - Turing machine
 
TuringMachines.ppt
TuringMachines.pptTuringMachines.ppt
TuringMachines.ppt
 
TuringMachines-myppt.pptx
TuringMachines-myppt.pptxTuringMachines-myppt.pptx
TuringMachines-myppt.pptx
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 
CSE680-07QuickSort.pptx
CSE680-07QuickSort.pptxCSE680-07QuickSort.pptx
CSE680-07QuickSort.pptx
 
Chapter No. 8 Root Locus of control System
Chapter No. 8 Root Locus of control SystemChapter No. 8 Root Locus of control System
Chapter No. 8 Root Locus of control System
 
TOC Introduction
TOC Introduction TOC Introduction
TOC Introduction
 
Second Order Active RC Blocks
Second Order Active RC BlocksSecond Order Active RC Blocks
Second Order Active RC Blocks
 
Time series Modelling Basics
Time series Modelling BasicsTime series Modelling Basics
Time series Modelling Basics
 
Signals and Systems Assignment Help
Signals and Systems Assignment HelpSignals and Systems Assignment Help
Signals and Systems Assignment Help
 
time_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdftime_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdf
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conq
 
Matrix 2 d
Matrix 2 dMatrix 2 d
Matrix 2 d
 
EC8352-Signals and Systems - Laplace transform
EC8352-Signals and Systems - Laplace transformEC8352-Signals and Systems - Laplace transform
EC8352-Signals and Systems - Laplace transform
 
Lecture7x.ppt
Lecture7x.pptLecture7x.ppt
Lecture7x.ppt
 
Turing machine
Turing machineTuring machine
Turing machine
 
Winter 8 Tutorial TM.pptx
Winter 8 Tutorial TM.pptxWinter 8 Tutorial TM.pptx
Winter 8 Tutorial TM.pptx
 

More from viswanath kani (8)

ContextFreeGrammars (1).pptx
ContextFreeGrammars (1).pptxContextFreeGrammars (1).pptx
ContextFreeGrammars (1).pptx
 
Unit2 Toc.pptx
Unit2 Toc.pptxUnit2 Toc.pptx
Unit2 Toc.pptx
 
Unit -I Toc.pptx
Unit -I Toc.pptxUnit -I Toc.pptx
Unit -I Toc.pptx
 
Pushdown Automaton (1).ppt
Pushdown Automaton (1).pptPushdown Automaton (1).ppt
Pushdown Automaton (1).ppt
 
UNIT 2.pdf
UNIT 2.pdfUNIT 2.pdf
UNIT 2.pdf
 
UNIT 1.pdf
UNIT 1.pdfUNIT 1.pdf
UNIT 1.pdf
 
toc_model_qp2-.pdf
toc_model_qp2-.pdftoc_model_qp2-.pdf
toc_model_qp2-.pdf
 
Bio fuel
Bio fuelBio fuel
Bio fuel
 

Recently uploaded

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 

Recently uploaded (20)

Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

TuringMachines.pdf

  • 2. Intro to Turing Machines • A Turing Machine (TM) has finite-state control (like PDA), and an infinite read-write tape. The tape serves as both input and unbounded storage device. • The tape is divided into cells, and each cell holds one symbol from the tape alphabet. • There is a special blank symbol B. At any instant, all but finitely many cells hold B. • Tape head sees only one cell at any instant. The contents of this cell and the current state determine the next move of the TM.
  • 3. 1 1 0 2 B B B B B B B The tape extends to infinity on the right with all Blanks (B) state 0 1 2 1 L,2,3 2 3 4 State = 1 …
  • 4. Moves • A move consists of: – replacing the contents of the scanned cell – repositioning of the tape head to the nearest cell on the left, or on the right – changing the state • The input alphabet is a subset of the tape alphabet. Initially, the tape holds a string of input symbols (the input), starting on the left of the tape, with in infinite sequence of blanks to the right (after the input). The initial position of the head is the leftmost symbol.
  • 5. Formal Definition • A TM is a 7-tuple M=(Q,Σ,Γ,δ,q0,qaccept,qreject), where 1. Q is a finite set of states 2. Σ is the input alphabet (does not contain B the blank symbol) 3. Γ is the tape alphabet, where 1. Σ ⊆ Γ (the input alphabet is a subset of the tape alphabet) 2. B ∈Γ (Blank is in the tape alphabet) 4. q0 ∈ Q is the start state 5. Qaccept ∈ Q is the accepting state 6. Qreject ∈ Q is the rejecting state 7. δ : Q × Γ → Q × Γ × {L,R} is a partial function. The value of δ (q,X) is either undefined, or is a triple consisting of the new state, the replacement symbol, and direction (left/right) for the head motion.
  • 6. Example • Here is a TM that checks its third symbol is 0, accepts if so, and runs forever, if not (note it never rejects). • M=({p,q,r,s,t,d},{0,1,},{0,1,B},p,s,d) • δ(p,X) = (q,X,R) for X=0,1 • δ(q,X) = (r,X,R) for X=0,1 • δ(r,0) = (s,0,L) • δ(r,1) = (t,1,R) • δ(t,X) = (t,X,R) for X=0,1,B
  • 7. δ(p,X) = (q,X,R) for X=0,1 δ(q,X) = (r,X,R) for X=0,1 δ(r,0) = (s,0,L) δ(r,1) = (t,1,R) δ(t,X) = (t,X,R) for X=0,1,B Transisition Diagrams for TM • Pictures of TM can be drawn like those for PDA's. Here's the TM of the example below.
  • 8. Implicit Assumptions • Input is placed on tape in contiguous block of cells (all the way to the left) • All other cells to the right are blank: ‘B’ • Tape head positioned at Left of input block • There is one start state • The text uses a single accepting and rejecting state, an alternative is to have many such states. These are equivalent, why?
  • 9. Example 2: { anbm | n,m ≥ 0} states = 0,1,H tape alphabet = a,b,^ input alphabet = a,b start = 0 blank = ‘^' accepting = H rejecting = R delta = (0,^,^,S,H) (0,a,a,R,0) (0,b,b,R,1) (1,b,b,R,1) (1,^,^,S,H)
  • 10. Example 3: { anbncn | n ≥ 0} delta = (0,a,X,R,1) Replace a by X and scan right (0,Y,Y,R,0) Scan right over Y (0,Z,Z,R,4) Scan right over Z, but make final check (0,^,^,S,H) Nothing left, so its success (1,a,a,R,1) Scan right looking for b, skip over a (1,b,Y,R,2) Replace b by y, and scan right (1,Y,Y,R,1) scan right over Y (2,c,Z,L,3) Scan right looking for c, replacxe it by Z (2,b,b,R,2) scan right skipping over b (2,Z,Z,R,2) scan right skipping over Z (3,a,a,L,3) scan left looking for X, skipping over a (3,b,b,L,3) scan left looking for X, skipping over b (3,X,X,R,0) Found an X, move right one cell (3,Y,Y,L,3) scan left over Y (3,Z,Z,L,3) scan left over Z (4,Z,Z,R,4) Scan right looking for ^, skip over Z (4,^,^,S,H) Found what we’re looking for, success! tape alphabet = a,b,c,^,X,Y,Z input alphabet = a,b,c start = 0 blank = ‘^ ' final = H
  • 12. Details • There are 3 level of details we might use to describe TM’s 1. Give the complete formal description • the states, alphabet, transition, etc 2. Implementation description • Partition the states into stages, Use English to describe how each stage move the head and stores data on the tape • Each stage performs one function. • Describe how we move between stages • No details of states or transition function 3. High level description • Use English to describe an algorithm • Don’t mention how to describe tape or moves
  • 13. Example Implementation level • { 02^n | n ≥ 0} • Stages 1. Sweep left to right across the tape. Crossing off every other 0 2. If in stage 1, the tape conatined a single 0, accept 3. If in stage 1, the tape contained more than a single 0, and the number of 0’s was odd, reject 4. Return the head to the left-hand end of the tape 5. Goto stage 1.
  • 14. What is important • We seek to convince the student that Turing machines are a powerful tool to describe algorithms • The full set of details is often too complex to describe completely, because the details do not add to our understanding. • But, we could use our high level descriptions to complete the formal description if we desired.
  • 15. Turing machines with output • A Turing machine can compute an output by leaving an answer on the tape when it halts. • We must specify the form of the output when the machine halts.
  • 16. Adding two to a number in unary TM Q {0, 1, H, R} Sigma {1} Gamma {1, ^} Delta 0 1 -> (1, R, 0) 0 ^ -> (1, R, 1) 1 ^ -> (1, S, H) q0 0 Accept H Reject R Blank ^
  • 17. Adding 1 to a Binary Number TM Q {0, 1, 2, H, R} Sigma {1, 0, ^} Gamma {1, 0, ^} Delta 0 0 -> (0, R, 0) 0 1 -> (1, R, 0) 0 ^ -> (^, L, 1) 1 0 -> (1, L, 2) 1 1 -> (0, L, 1) 1 ^ -> (1, S, H) 2 0 -> (0, L, 2) 2 1 -> (1, L, 2) 2 ^ -> (^, R, H) q0 0 Accept H Reject R Blank ^ ^1011^ ^1010^ ^1000^ ^1100^
  • 18. An equality Test delta = (0,1,^,R,1) (0,^,^,R,4) (0,#,#,R,4) (1,1,1,R,1) (1,^,^,L,2) (1,#,#,R,1) (2,1,^,L,3) (2,#,1,S,H) (3,1,1,L,3) (3,^,^,R,0) (3,#,#,L,3) (4,1,1,S,H) (4,^,^,S,H) (4,#,#,R,4) states = 0,1,2,3,4,H tape alphabet = 1,0,#,^ input alphabet = 1,0,# start = 0 blank = ‘^' final = H
  • 19. Configurations (Sipser pg. 140) • configurations for TM's are strings of the form α q β , where α, β ∈ Γ* and q ∈ Q. (Assume that Q and Γ* are disjoint sets, guaranteeing unique parsing of configurations.) • The string α represents the tape contents to the left of the head. • The string β represents the non-blank tape contents to the right of the head, including the currently scanned cell. • Adding or deleting a few blank symbols at the beginning or end of an confiuration results in an equivalent configuartion. Both represent the same instant in the execution of a TM.
  • 20. Sipser terminology • Other authors call configurations instantaneous descriptions • Starting Configuration • Accepting Configuration • Rejecting Configuration Both of these are halting configurations
  • 21. Relating configurations • TM's transitions induce the relation |- between configurations. • Let ω =X1. . . Xi-1 q Xi . . . Xk be an configuration. • If δ(q,Xi) is undefined, then there are no configurations ω ' such that ω |- ω '. • If δ(q,Xi)=(p,Y,R) then ω |- ω ' holds for ω ' = X1. . . Xi-1 Y p Xi+1. . . Xk • Similarly, if δ(q,X_i)=(p,Y,L) then ω |- ω’ holds for ω’ =X1. . . pXi-1YXi+1 . . . Xk • When ω |- ω’ Sipser says: “ ω yields ω’ ”
  • 22. Note • If, in the first case, we have i=k, (that is we are at the end of the non-blank portion of the tape to the right) then we need to use the equivalent representation • ω = X1 . . . Xk-1 q Xk B • for our formula to make sense. Similarly, we add a B to the beginning of ω whenever necessary.
  • 23. Example • Here is the sequence of configurations of our example machine, showing its execution with the given input 0101: • p0101 |- 0q101 |-01r01 |- 0s101 • The machine halts, since there are no moves from the state s. When the input is 0111, the machine goes forever, as follows: • p0111 |- 0q111 |- 01r11 |- 011t1 |- 0111t |- 0111Bt |- 0111BBt |- …
  • 24. The Language of a TM • We define the language of the TM M to be the set L(M) of all strings w ∈ Σ* • such that: Q0 w |-* α qaccept β • for any α, β • Languages accepted by TM's are call recursively enumerable (RE). Sipser calls this Turing-recognizable • Example. For our example machine, we have L(M)= (0+1)(0+1)0(0+1)* • If the machine recognizes some language, and also halts for all inputs. We say the language is Turing-decidable.
  • 25. Acceptance by Halting • Some text books define an alternative way of defining a language associated with a TM M. (But not Sipser, though the idea is still interesting). • We denote it H(M), and it consists of strings that cause the TM to halt. Precisely, a string w ∈ Σ* belongs to H(M) • iff q0 w |-* α p X β • where δ(p,X) is undefined. • Example. For our example machine, we have • H(M)= ε + 0 + 1 + (0+1)(0+1) + (0+1)(0+1)0(0+1)*
  • 26. Equivalence of Acceptance by Final State and Halting • How would we prove such an equivalence? • 1. Construct a TM that accepts by Halting from an ordinary one. • 2. Construct an ordinary TM from one that accepts by halting.