Procedures Versus Algorithms: Recursively Enumerable
Procedures Versus Algorithms: Recursively Enumerable
Plan
1. Show a particular language not to be RE.
✦ Like the \hello-world" argument, we
show no TM can tell whether a given TM
halts on a given input | the proof is by
\diagonalization," or self-reference.
2. Use the non-RE language from (1) to show
another language to be RE, but not recursive.
✦ Trick: if a language and its complement
are both RE, then they are both
recursive.
✦ Thus, if a language L is RE, but its
complement is not, then L is not
recursive.
TM's as Integers
We shall focus on TM's whose input alphabet is
f0; 1 . Each such TM can be represented by one or
g
qi by 0i.
1
Assume the tape symbols are X1 ; X2 ; : : : ,
f g
Proof Ld is not RE
Suppose Ld is RE. Then Ld = H (M ) for some TM
M.
2
Since we derive a contradiction in either case,
we conclude that our assumtion H (M ) = Ld
was wrong, and in fact, there is no such TM
M.
If L is recursive, so is L.
✦ Proof: Find a TM M that accepts L by
nal state but always halts. Arrange for a
TM M 0 to simulate M , but accept if and
only if M halts before accepting.
If L and L are RE, then both are recursive.
✦ Proof: Simulate TM's for both L and L
on separate tracks. One or the other is
guaranteed to accept, so the simulating
TM can always be made to halt.
The Universal Language
Lu = the set of binary strings consisting of a code
for some TM Mi followed by some binary string w,
such that w is in H (Mi ).
Proof in reader that Lu is RE.
✦ In essence: a TM can be treated as a
stored-program device, just like a real
computer.
✦ Hard part of proof: Since Mi may have
any number of states and tape symbols,
one multitape TM M cannot simulate
these states and symbols directly. Rather,
it represents them as strings of 0's (as
in the code we developed) and compares
using scratch tapes.
Proof Lu is not recursive: show Lu is not RE.
✦ Remember, if Lu were recursive, then Lu
would be recursive, and therefore RE.
Proof that Lu is not RE:
✦ A reduction from Ld to Lu : Show that if
there is a TM for Lu , then there is a TM
for Ld (which we know there isn't).
✦ Transform w by rst checking that 1w
represents some TM Mi (i.e., it is of the
form 111codes111). If so, produce 1ww
as input to a hypothetical Lu TM. If not,
reject w, since 1w represents a TM that
accepts everything.
3
✦ If 1ww is produced, simulate the Lu TM
on this input. If it accepts, then TM Mi
(represented by 1w) does not accept the
ith string, w, so w is in Ld .
Summary:
✦ Ld is undecidable (not recursive), and in
fact not RE.
✦ Lu is undecidable, but RE.
✦ Lu is like Ld , not RE.
✦ Ld is like Lu , RE, although we did not
prove this.
Rice's Theorem
Essentially, any nontrivial property of the language
of a TM is undecidable.
Note the dierence between a property of
L(M ) from a property about M :
language.
✦ Example: \M has at least 100 states" is a
property of the TM itself.
✦ \= " is undecidable; \has 100 states" is
;
Properties
A property of the RE languages is a set of strings,
those that represent TM's in a certain class.
Example: the property \is context-free" is the
set of codes for all TM's M such that L(M ) is
a CFL.
The property is \of languages" if TM's whose
languages are the same either all have the
property or none do.
Proof of Rice's Theorem
Let P be any nontrivial property of the RE
languages; i.e., at least one RE language has the
property, and at least one does not.
We shall prove that P (as a language, i.e., a
set of TM codes) is undecidable.
4
Assume does not have property P .
;
whether M accepts w.
✦ N simulates M on w. Note that w is
not input to N ; rather N writes w on a
scratch tape and simulates M which is
part of N 's own states.
✦ If M accepts w, N then simulates a TM
ML for language L on N 's own input x.
If ML accepts x then N accepts x.
✦ If M never accepts w, N never gets to
simulate ML , and therefore accepts .;
5
contradiction of the assumption P1 is
decidable.
The same idea works for showing P1 not to
be RE, but now P2 must be non-RE, and
the transformation from instances of P2 to
instances of P1 may be a procedure, not
necessarily an algorithm.
Common error: trying to do the reduction in
the wrong direction.