Professional Documents
Culture Documents
Lecture 15: Computing With Turing Machines
Lecture 15: Computing With Turing Machines
1
Recursive Languages
Definition:
A language L is said to be recursive (also known as Turing-
decidable) if and only if there is a TM that decides it.
2
Recursive Languages
a,d b,d c
d
a b c
R dR dR dR L
c, a,
b, c a, b
Two new basic machines:
y : changes state to y
y n n: changes state to n
3
An informal description:
1. Start from the left end of the string.
2. Move to the right in search of an a; if found, replace it by
a d; if b or c is found instead, reject.
3. Move further right in search of a b; if found, replace it by a
d; if not found, reject.
4. Move further right in search of a c; if found, replace it by a
d; if not found, reject.
5. If all input has been replaced by d’s, accept.
6. Return to the left end of the input, go to 2.
4
Examples of recursive languages
5
Recursive Functions
6
Recursively Enumerable Languages
7
Recursively enumerable languages
Definition:
A language L is said to be recursively enumerable (a.k.a.
Turing-acceptable) if and only if there is a TM that semide-
cides L.
8
Examples
R a
σ a and σ
R n
a
y
Note: All the languages you have seen so far in this course are
recursive. Examples of languages that are not recursive or not
recursively enumerable are complicated. We’ll see some later.
• TMs that decide languages are algorithms.
• TMs that semidecide languages are NOT algorithms.
9
Language Hierarchy
Proof:
Idea: Since L is recursive, there is a machine M that decides L.
Make the rejecting state of M (i.e., the state n) a non-halting
state and make the machine loops forever on that state.
– If w ∈ L,
⇒ M will halt in state y.
⇒ M ′ will also halt in state y.
– If w ∈
/ L,
⇒ M will halt in state n.
⇒ M ′ will loop forever in state n. (i.e., n is no
longer a halting state)
Question:
If L is recursively enumerable, is L always recursive? No (see
examples later).
10
Theorem 2 If L is context-free, then L is recursive.
Sketch:
The objective is to show that there is a TM that decides L.
• First, we state without proof the following theorem:
Every CFG can be converted to the Chomsky normal form.
Every rule of a CFG in Chomsky Normal form is of the form
either X → Y Z or X → σ, where X, Y, Z are nontermi-
nals, and σ is a terminal. In addition, S → e is permitted
only if e ∈ L.
• Since L is context-free, there exists a CFG that generates
L. Convert the CFG into Chomsky Normal Form. Then,
any string w of length n would have derivations of at most
2n − 1 steps (without using S → e would take exactly
2n − 1 steps).
• If n=0, the TM lists all derivations of 1 step; if n > 0, it
lists all derivations of at most 2n − 1 steps. If any of these
derivations yield w, accept; if not, reject.
Example of CNF
S → aSb|e can be converted to
S → AX|e
X → SB
A→a
B→b
11
Hierarchy of languages
recursively enumerable
languages
recursive languages
contex-free
languages
regular
languages
12
Theorem 3 If L is recursive, then L is recursive (i.e., the
set of recursive languages is closed under complementation).
Question:
Is the complement of a recursively enumerable language always
recursively enumerable? No (example later).
13