Discrete Math. and Logic II. Turing Machines
SFWR ENG 2FA3
Ryszard Janicki
Winter 2014
Acknowledgments:
Material based on
Automata and Computability by Dexter C. Kozen (Chapters 27 and 28).
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
1 / 19
Introduction
In this lecture we introduce the most powerful of the
automata: Turing machines (TMs),
It is named after Alan Turing, who invented them in 1936
Turing machines can compute any function normally
considered computable
TMs were invented long before real computers appeared
They came at a time when mathematicians were trying to
come to grips with the notion of eective computation
Several alternative formalisms evolved in the attempt to nail
down eectively computable
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
2 / 19
Introduction
These several alternative formalisms are:
Turing machines
(Alan Turing)
Post systems
handle strings over Σ
(Emil Post)
µ-recursive functions (Kurt Gödel) handle the natural numbers
A-calculus (Alonzo Church, Stephan C. Kleene) handles terms
built from combinator symbols
Combinatory logic
(Moses Schönnkel, Haskell B. Curry)
handles terms built from combinator symbols
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
3 / 19
Introduction
The one that most closely resembles a modern computer is
the Turing machine
Besides the most know model, there are also many variations
nondeterministic
multitape
multidimensional tape
two-way innite tapes
They can all simulate one another
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
4 / 19
Introduction
All these mathematicians were looking at the same thing from
dierent angles (Not a coincidence)
They soon came to the realization that the commonality
among all these systems must be the notion of eective
computability
Alonzo Church gave voice to this thought, and it has since
become known as Church's thesis (or the Church-Turing
thesis)
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
5 / 19
Introduction
It is not a theorem, but rather a declaration
All these formalisms capture precisely our intuition about
what it means to be eectively computable in principle, no
more and no less
Very likely that the most compelling development leading to
the acceptance of Church's thesis was the Turing machine
(model considered readily programmable)
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
6 / 19
Informal Description of Turing Machines
We will be considering a deterministic, one-tape Turing
machine
This is the standard model
There are many variations, apparently more powerful or less
powerful but in reality not (for more details on this point see
textbook Lecture 30)
TM has
a nite set of states Q
a semi-innite tape that is delimited on the left end by an
endmarker ` and is innite to the right
a head that can move left and right over the tape, reading and
writing symbols
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
7 / 19
Informal Description of Turing Machines
a b b a
....
b a
Two−way, read/write
Q
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
8 / 19
Formal Description of Turing Machines
[
[
Denition
A deterministic one-tape Turing machine is a 9-tuple
M = (Q , Σ, Γ, `, , δ, s , t , r ), where
Q is a nite set (the states);
Σ is a nite set (the input alphabet);
Γ is a nite set (the tape alphabet) containing Σ as a subset;
∈ Γ − Σ, the blank symbol;
`, the left endmarker;
δ : Q × Γ −→ Q × Γ × {L, R }, the transition function;
s ∈ Q, the start state;
t ∈ Q, the accept state; and
r ∈ Q, the reject state, r 6= t.
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
9 / 19
Formal Description of Turing Machines
Intuitively, δ (p , a) = (q , b, d ) means, "When in state p
scanning symbol a, write b on that tape cell, move the head
in direction d, and enter state q.
The symbols L and R stand for left and right, respectively
We restrict TMs so that
∀(p | p ∈ Q : ∃(q | q ∈ Q : δ (p , `) = (q , `, R ) ) )
We also require that
∀(b | b ∈ Γ : ∃(c , c 0 | c , c 0 ∈ Γ : δ (t , b ) = (t , c , d ) ∧ δ (r , b ) = (r , c 0 , d 0 ) ) )
We refer to the state set and transition function collectively as
the nite control
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
10 / 19
Formal Description of Turing Machines
Example
We are considering a TM that accepts the non-context-free
set {an bn c n | n ≥ 0}
Q = {s , q1 , · · · , q10 , t , r }
Σ = {a, b , c }
S
{`, , a}
[
Γ=Σ
a is just an extra useful symbol in the tape alphabet (NOT a
special symbol)
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
11 / 19
Formal Description of Turing Machines
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
12 / 19
Congurations and Acceptance
[
[
We dene a conguration to be an element of
Q × {y ω | y ∈ Γ∗ } × IN
A conguration is a global state giving a snapshot of all
relevant information about a TM computation at some instant
in time
The conguration (p , z , n) species a current state p of the
nite control, current tape contents z, and current position of
the read/write head n ≥ 0
We usually denote congurations by α, β, γ
The start conguration on input x ∈ Σ∗ is the conguration
(s , ` x ω , 0)
The last component 0 means that the machine is initially
scanning the left endmarker `
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
13 / 19
Congurations and Acceptance
Denition
A Turing Machine is said to halt on input x if it either accepts
x or rejects x (the machine doesn't really grind to a halt in
the literal sense)
It is possible that it neither accepts nor rejects, in which case
it is said to loop on input x
A Turing machine is said to be total if it halts on all inputs
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
14 / 19
Congurations and Acceptance
Denition
We call a set of strings
recursively enumerable (r.e.) if it is L(M ) for some Turing
machine M
co-r.e. if its complement is r.e.
recursive if it is L(M ) for some total Turing machine M
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
15 / 19
Congurations and Acceptance
Example
Consider the non-CFL {ww | w ∈ {a, b}∗ }
It is a recursive set, because we can construct a Turing
machine that accepts all its strings
The TM
[
scans out to the rst blank symbol , counting the number of
symbols mod 2 to make sure x is of even length and rejecting
immediately if not
It lays down a right endmarker a, then repeatedly scans back
and forth over the input
In each pass from right to left, it marks the rst unmarked a or
b it sees with ' (prime to the left)
In each pass from left to right, it marks the rst unmarked a or
b it sees with ` (prime to the right)
It continues this until all symbols are marked
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
16 / 19
Congurations and Acceptance
1
[
[
[
2
[
[
[
3
[
[
[
4
[
[
[
5
[
[
[
6
[
[
[
7
[
[
[
8
[
[
[
[
[
[
Example
On input aabbaaabba the initial tape contents are
` aabbaaabba
···
` aabbaaabb á a
···
` àabbaaabb á a
···
` àabbaaab b́ á a
···
` ààbbaaab b́ á a
···
` ààbbaaab́ b́ á a
···
` ààb̀baaab́ b́ á a
···
` ààb̀baaáb́ b́ á a
···
` ààb̀ b̀aaáb́ b́ á a
···
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
17 / 19
Congurations and Acceptance
` ààb̀ b̀aááb́ b́ á a
2
` ààb̀ b̀ àááb́ b́ á a
3
`
[
[
[
[
[
[
[
···
···
[
[
[
[
[
[
[
[
[
[
[
[
[
[
[
[
[
`
···
a
···
[
[
[
7
[
[
[
[
6
···
àb̀b̀à áb́b́á a
`
b̀b̀à b́b́á a
`
b̀à
b́á a
`
à
á a
[
[
[
[
5
···
[
[
[
[
[
[
[
[
[
[
4
[
[
[
1
[
[
[
Example ((Continued))
Ryszard Janicki
···
It accepts
Discrete Math. and Logic II. Turing Machines
18 / 19
Decidability and Semidecidability
Denition (Decidable)
A property P of strings is said to be decidable if the set of all
strings having property P is a recursive set.
A property P of strings is said to be decidable if there is a total
Turing machine that accepts input strings that have property P
and rejects those that do not.
Denition (Semidecidable)
A property P of strings is said to be semidecidable if the set of
strings having property P is an r.e. set.
A property P is said to be semidecidable if there is a Turing
machine that on input x accepts if x has property P and rejects or
loops if not.
Ryszard Janicki
Discrete Math. and Logic II. Turing Machines
19 / 19
© Copyright 2025 Paperzz