Professional Documents
Culture Documents
FORMAL LANGUAGES,
AUTOMATA, AND
COMPUTABILITY
* Read chapter 4 of the book for next time *
Lecture9x.ppt
REVIEW
A Turing Machine is represented by a 7-tuple T
= (Q, Σ, Γ, , q0, qaccept, qreject):
q7
1 1 0 1 0 0 0 1 1 0
11010q700110
A TM recognizes a language iff it accepts all
and only those strings in the language.
r.e. recursive
languages languages
Theorem: If A and A are r.e. then A is decidable.
Given:
a Turing Machine TMA that recognizes A and
a Turing Machine TMR that recognizes A,
we can build a new machine that decides A.
How can we prove this?
• Run TMA and TMR in parallel.
(Or more precisely, interleave them.)
• One of them will eventually recognize the
input string.
• If TMA recognizes it, then accept.
• If TMR recognizes it, then reject.
2n
A TM that decides { 0 | n ≥ 0 }
We want to accept iff:
• the input string consists entirely of zeros, and
• the number of zeros is a power of 2.
High-Level Idea.
• Repeatedly divide the number of zeros in half
until it becomes an odd number.
• If we are left with a single zero, then accept.
• Otherwise, reject.
2n
A TM that decides { 0 | n ≥ 0 }
PSEUDOCODE:
aaabbbbcccccccccccc
3 4 3×4 = 12
C = {aibjck | k = i×j, and i, j, k ≥ 1}
High-Level Idea.
For each occurrence of a: {
For each occurrence of b: {
Delete an occurrence of c.
}
}
C = {aibjck | k = i×j, and i, j, k ≥ 1}
PSEUDOCODE:
1. If the input doesn’t match a*b*c*, reject.
2. Move the head back to the leftmost symbol.
3. Cross off an a, scan to the right until b.
Sweep between b’s and c’s, crossing out one of
each until all b’s are out. If too few c’s, reject.
4. Uncross all the b’s.
If there’s another a left, then repeat stage 3.
If all a’s are crossed out,
Check if all c’s are crossed off.
If yes, then accept, else reject.
C = {aibjck | k = i×j, and i, j, k ≥ 1}
aabbbcccccc
xabbbcccccc
xayyyzzzccc
xabbbzzzccc
xxyyyzzzzzz
TURING-MACHINE VARIANTS
Turing machines can be extended in various ways,
but so long as a new TM only reads and writes a
finite number of symbols in each step,
an old TM can still simulate it!
FINITE
STATE
CONTROL
: Q Γk → Q Γk {L,R}k
Theorem: Every Multitape Turing Machine can be
transformed into a single tape Turing Machine
1 0 0
FINITE
STATE
CONTROL
FINITE
STATE . . .
1 0 0 # # #
CONTROL
Theorem: Every Multitape Turing Machine can be
transformed into a single tape Turing Machine
1 0 0
FINITE
STATE
CONTROL
FINITE
STATE . . .
1 0 0 # # #
CONTROL
THE CHURCH-TURING THESIS
Anything that can be computed
by algorithm (in our intuitive
sense of the term “algorithm”)
can be computed by a Turing
Machine.
We can encode a TM as a string of 0s and 1s
start reject
n states state state
TM wL? TM wL?
yes no yes no
L is decidable L is semi-decidable
(recursive) (recursively enumerable,
Turing-recognizable)
Theorem: L is decidable if both L and L
are recursively enumerable
There are languages over {0,1}
that are not decidable.
If we believe the Church-Turing Thesis, this is
major: it means there are things that formal
computational models inherently cannot do.
Turing
Machines
Cantor’s Theorem
Let L be any set and 2L be the power set of L
Theorem: There is no map from L onto 2L
Proof: Assume, for a contradiction, that
there is an onto map f : L 2L
Let S = { x L | x f(x) }
: : : : : ∙.
THE MORAL:
For any set L,
2L always has ‘more’ elements than L
Not all languages over {0,1} are decidable, in fact:
not all languages over {0,1} are semi-decidable
{decidable languages over {0,1}}
{semi-decidable langs over {0,1}}
{Languages over {0,1}}
{Turing Machines}
Set L Powerset of L: 2 L
THE ACCEPTANCE PROBLEM
ATM = { (M, w) | M is a TM that accepts string w }
Reject if M
D accepts M
D
D( M
D)= Contradiction!
Accept if M
D does not accept M
D
Theorem: ATM is r.e. but NOT decidable
In other words,
For any machine H that recognizes ATM
we can effectively give an instance
where H fails to decide ATM
In other words,
Given any good candidate for deciding the
Halting Problem, we can effectively construct
an instance where the machine fails.
THE HALTING PROBLEM
HALTTM = { (M,w) | M is a TM that halts on string w }
Theorem: HALTTM is undecidable
Proof: Assume, for a contradiction, that TM H
decides HALTTM
We use H to construct a TM D that decides ATM