> |}~;(
/00DTimes New Roman\5)D,0DWo
0DTahomaew Roman\5)D,0DWo
0D" DMonotype Sorts\5)D,0DWo
00DLucida Sans Unicode,0DWo
0D"a.
@n?" dd@ @@``tl>8
$%&'(-./0 !"#)*+,12345678c$ f3f33f̙@Mg4FdFd08,ppp@uʚ;2Nʚ;<4!d!ddЁ
0P<4dddddЁ
0P<4BdBddЁ
0P___PPT9/0<?O=m1DecidabilityuTuring Machines Coded as Binary Strings
Diagonalizing over Turing Machines
Problems as Languages
Undecidable Problems,(+ 0Binary-Strings from TM s
We shall restrict ourselves to TM s with input alphabet {0, 1}.
Assign positive integers to the three classes of elements involved in moves:
States: q1(start state), q2 (final state), q3, &
Symbols X1 (0), X2 (1), X3 (blank), X4, &
Directions D1 (L) and D2 (R).yu
<Binary Strings from TM s (2)hSuppose (qi, Xj) = (qk, Xl, Dm).
Represent this rule by string 0i10j10k10l10m.
Key point: since integers i, j, & are all > 0, there cannot be two consecutive 1 s in these strings." ̙[P
<Binary Strings from TM s (2)Represent a TM by concatenating the codes for each of its moves, separated by 11 as punctuation.
That is: Code111Code211Code311 & ha!a
FEnumerating TM s and Binary StringsBRecall we can convert binary strings to integers by prepending a 1 and treating the resulting string as a base-2 integer.
Thus, it makes sense to talk about the i-th binary string and about the i-th Turing machine.
Note: if i makes no sense as a TM, assume the i-th TM accepts nothing.&"3fCP4e ATable of AcceptanceDiagonalization AgainWhenever we have a table like the one on the previous slide, we can diagonalize it.
That is, construct a sequence D by complementing each bit along the major diagonal.
Formally, D = a1a2& , where ai = 0 if the (i, i) table entry is 1, and vice-versa.UTRDfT
54The Diagonalization Argument Could D be a row (representing the language accepted by a TM) of the table?
Suppose it were the j-th row.
But D disagrees with the j-th row at the j-th column.
Thus D is not a row.>b
*Diagonalization (2)Consider the diagonalization language Ld = {w | w is the i-th string, and the i-th TM does not accept w}.
We have shown that Ld is not a recursively enumerable language; i.e., it has no TM.6'X?>
k ProblemsInformally, a problem is a yes/no question about an infinite set of possible instances.
Example: Does graph G have a Hamilton cycle (cycle that touches each node exactly once)?
Each undirected graph is an instance of the Hamilton-cycle problem. fFO f33f/F
Problems (2)NFormally, a problem is a language.
Each string encodes some instance.
The string is in the language if and only if the answer to this instance of the problem is yes. (Example: A Problem About Turing Machines)33"lWe can think of the language Ld as a problem.
Does this TM not accept its own code?
Aside: We could also think of it as a problem about binary strings.
Do you see how to phrase it?L7?Decidable ProblemsA problem is decidable if there is an algorithm to answer it.
Recall: An algorithm, formally, is a TM that halts on all inputs, accepted or not.
Put another way, decidable problem = recursive language.
Otherwise, the problem is undecidable.n?'
f)f
Bullseye Picture ,From the Abstract to the RealWhile the fact that Ld is undecidable is interesting intellectually, it doesn t impact the real world directly.
We first shall develop some TM-related problems that are undecidable, but our goal is to use the theory to show some real problems are undecidable.$>C.Examples: Undecidable Problems33
,Can a particular line of code in a program ever be executed?
Is a given context-free grammar ambiguous?
Do two given CFG s generate the same language?t#The Universal LanguageAn example of a recursively enumerable, but not recursive language is the language Lu of a universal Turing machine.
That is, the UTM takes as input the code for some TM M and some binary string w and accepts if and only if M accepts w.:Tfz$Designing the UTMInputs are of the form:
Code for M 111 w
Note: A valid TM code never has 111, so we can split M from w.
The UTM must accept its input if and only if M is a valid TM code and that TM accepts w.<+3f'The UTM (2)The UTM will have several tapes.
Tape 1 holds the input M111w
Tape 2 holds the tape of M.
Mark the current head position of M.
Tape 3 holds the state of M.6Z%Z%1The UTM (3)Step 1: The UTM checks that M is a valid code for a TM.
E.g., all moves have five components, no two moves have the same state/symbol as first two components.
If M is not valid, its language is empty, so the UTM immediately halts without accepting.B8gZ2gZ2The UTM (4)Step 2: The UTM examines M to see how many of its own tape squares it needs to represent one symbol of M.
Step 3: Initialize Tape 2 to represent the tape of M with input w, and initialize Tape 3 to hold the start state.2dl)The UTM (5)Step 4: Simulate M.
Look for a move on Tape 1 that matches the state on Tape 3 and the tape symbol under the head on Tape 2.
If found, change the symbol and move the head marker on Tape 2 and change the State on Tape 3.
If M accepts, the UTM also accepts.2+
A Question?Do we see anything like universal Turing machines in real life?5:Proof That Lu is Recursively Enumerable, but not Recursive0;3f.We designed a TM for Lu, so it is surely RE.
Suppose it were recursive; that is, we could design a UTM U that always halted.
Then we could also design an algorithm for Ld, as follows.66Proof (2)3f
Given input w, we can decide if it is in Ld by the following steps.
Check that w is a valid TM code.
If not, then its language is empty, so w is in Ld.
If valid, use the hypothetical algorithm to decide whether w111w is in Lu.
If so, then w is not in Ld; else it is.D!u3usu*!)33H338Proof (3)3fBut we already know there is no algorithm for Ld.
Thus, our assumption that there was an algorithm for Lu is wrong.
Lu is RE, but not recursive.H/8;Bullseye Picture /
!"
%&(*-/03479:< ` ̙33` ` ff3333f` 333MMM` f` f` 3>?" dd@,?udd@ w " @ ` n?" dd@ @@``PR @ ` `p>>f(
6m) P)
T Click to edit Master title style!
!
0|p) )
RClick to edit Master text styles
Second level
Third level
Fourth level
Fifth level!
S
0Xu) ``)
>*
0z) ` )
@*
0) ` )
@*Z
Byh@ ? ̙33 Default Design
0zrP
(
0 P
P*
0
R*
d
c$ ?
0
@
RClick to edit Master text styles
Second level
Third level
Fourth level
Fifth level!
S
6 `P
P*
6 `
R*
H
0h ? ̙330$(
r
Sc@
r
SXs` P
H
0h ? ̙33
` :(
r
SxP
S\
"p`PpH
0h ? ̙33
,$(
,r
, S#P
r
, S$
H
,0h ? ̙33
4$(
4r
4 S<P
r
4 S<
H
40h ? ̙33
8$(
8r
8 S$AP
r
8 SA`
H
80h ? ̙33
H7(
Hr
H SGP
LB
H
c$D`00LB
H
c$D`0`
H
<O
A1
2
3
4
5
6
.
.
.
H
<@T H&
6TM
iRB
H
s*D` 0
H
<(XV
F1 2 3 4 5 6 . . .
H
<[
8String j RB
H
s*DPP
PXB
H
0D XB
H
0DP
P
H
<PU
u
1xl
0
H0
,$D
0!
H
<4b
Ix = 0 means
the i-th TM does
not accept the
j-th string; 1
means it does.JJ,ZB
H
s*D
0 H
H0h ? ̙33
P$(
Pr
P SoP
r
P Sp
H
P0h ? ̙33
X$(
Xr
X S{P
r
X S|
H
X0h ? ̙33
@`$(
`r
` SP
r
` S<
H
`0h ? ̙33
`h$(
hr
h S$P
r
h S̒
H
h0h ? ̙33
p$(
pr
p SP
r
p S
H
p0h ? ̙33
x$(
xr
x SP
r
x SLp
H
x0h ? ̙33
$(
r
S,P
r
S
H
0h ? ̙33Q
(
r
SP
2
<
Z(Decidable
problems =
Recursive
languages))X2
0PP0l 0
0,$D
0
<:
P Recursively
enumerable
languages!!ZB
s*D0
`l +
+ ,$D
0
< +~
T$Not recursively
enumerable
languages%%
<Pp
>Ld Z2
s*p[l p
p,$D
0
<E
MAre there
any languages
here?ZB
s*Dpk
H
0h ? ̙33
$(
r
SxP
r
S4
H
0h ? ̙33
P(
r
SP
S<$
0
H
0h ? ̙33
@$(
r
SP
r
Sh
H
0h ? ̙33
$(
r
SpP
r
Sp
H
0h ? ̙33
p$(
r
Sx{P
{
r
S4 {{
H
0h ? ̙33
0(
x
c$l{P
{
x
c$({{
H
0h ? ̙33
0(
x
c${P
{
x
c${{
H
0h ? ̙33
$(
r
S0){P
{
r
S){{
H
0h ? ̙33
$(
r
S5{P
{
r
S5{{
H
0h ? ̙33
$(
r
S@{P
{
r
S@{{
H
0h ? ̙33
0:(
r
SF{P
{
SZ{0{
"p`PpH
0h ? ̙33
P$(
r
Sf{P
{
r
Sf{{
H
0h ? ̙33
?7p(
x
c$l{P
{
2
<
Z(Decidable
problems =
Recursive
languages))X2
0PP0z 0
0,$D
0
<p{:
P Recursively
enumerable
languages!!ZB
s*D0
Bs{@ ~,
T$Not recursively
enumerable
languages%%
Bt{e
>Ld X2
0ppR2
s*
P
@
<|{P
p
>Lu RB
s*D
0
<{%+
mAll these are
undecidableH
0h ? ̙33
0@$(
$X
$ C
$ S
@
H
$0h ? ̙33
0p((
(X
( C
( S
@
H
(0h ? ̙33
00(
0X
0 C
0 S9
@
H
00h ? ̙33
0<(
<X
< C
< S8
@
H
<0h ? ̙33
0@(
@X
@ C
@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-;-$;I-$IW'-$'We5-$5erB-$BrP-$P^-$^l-$lz-$z-$-$-$-$-$$-$-$($(6-$6D-$DR"$"R`0-$0`n>$>n|L-$L|Z$Zh$hv-$v$$$&&&-&$&&-&&
&&-&&&&-$0>$>L$LZ*$*Zh8$8hvF-$FvT$Tb$bp-$p~$~$-$-$$-$$-$-$,$,:
-$
:H$HV&-$&Vd4-$4drB-$BrP$P^-$^k-$ky-$y-$-$-$-$-$-$-$-$'-$'5-$5C-$CQ!-$!Q_/-$/_m=-$=m{K-$K{Y-$Yg-$gu-$u-$-$-$-$-$-$-$-$#-$#1-$1?-$?M-$M[+-$+[i9-$9iwG-$GwU-$Uc-$cq-$q-$-$-$-$-$-$-$-$-$--$-;-$;I-$IW'-$'We5-$5erB-$BrP-$P^-$^l-$lz-$z-$-$-$-$-$$-$-$($(6-$6D-$DR"$"R`0-$0`n>$>n|L-$L|Z$Zh$hv-$v$$$&-
--&&&y&/v`v
4؉v`v?f- @Times New Roman\؉v`v?f- . 2
f1 .--y`H-- @"Tahomav
4\؉v`v?f- .2
LDecidability(
!!
.--1 -- @"Tahomav
E4\؉v`v?f- .72
O Turing Machines Coded as Binary
!
. .2
Strings
. .2
Diagonalizing
. .2
over Turing
. .2
Machines!
. .'2
0Problems as Languages
$
. .2
mUndecidable
. .2
mProblems
$.--"System?f
G-&TNPP &Root EntrydO)2@Current UserPSummaryInformation(c1PowerPoint Document(g
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abdefghijklmnopqrstuvwxyz{
A Question;Proof That Lu is Recursively Enumerable, but not RecursiveProof (2)Proof (3)Bullseye PictureFonts UsedDesign Template
Slide Titles(_C_Michael GoodrichMichael Goodrich_M)JeffJeff
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abdefghijklmnopqrstuvwxyz{Root EntrydO)Й6@Current User,SummaryInformation(c1PowerPoint Document(gDocumentSummaryInformation80DWo
0DDTahomaew Roman\5)D,0DWo
0D" DMonotype Sorts\5)D,0DWo
00DLucida Sans Unicode,0DWo
0D"a.
@n?" dd@ @@``tl>8
$%&'(-./0 !"#)*+,12345678c$ f3f33f̙@Mg4FdFd08,ppp@uʚ;2Nʚ;<4!d!ddЁ
0P<4dddddЁ
0P<4BdBddЁ
0P___PPT9/0<?O=i1DecidabilityuTuring Machines Coded as Binary Strings
Diagonalizing over Turing Machines
Problems as Languages
Undecidable Problems,(+ 0Binary-Strings from TM s
We shall restrict ourselves to TM s with input alphabet {0, 1}.
Assign positive integers to the three classes of elements involved in moves:
States: q1(start state), q2 (final state), q3, &
Symbols X1 (0), X2 (1), X3 (blank), X4, &
Directions D1 (L) and D2 (R).yu
<Binary Strings from TM s (2)hSuppose (qi, Xj) = (qk, Xl, Dm).
Represent this rule by string 0i10j10k10l10m.
Key point: since integers i, j, & are all > 0, there cannot be two consecutive 1 s in these strings." ̙[P
<Binary Strings from TM s (2)Represent a TM by concatenating the codes for each of its moves, separated by 11 as punctuation.
That is: Code111Code211Code311 & ha!a
FEnumerating TM s and Binary StringsBRecall we can convert binary strings to integers by prepending a 1 and treating the resulting string as a base-2 integer.
Thus, it makes sense to talk about the i-th binary string and about the i-th Turing machine.
Note: if i makes no sense as a TM, assume the i-th TM accepts nothing.&"3fCP4e ATable of AcceptanceDiagonalization AgainWhenever we have a table like the one on the previous slide, we can diagonalize it.
That is, construct a sequence D by complementing each bit along the major diagonal.
Formally, D = a1a2& , where ai = 0 if the (i, i) table entry is 1, and vice-versa.UTRDfT
54The Diagonalization Argument Could D be a row (representing the language accepted by a TM) of the table?
Suppose it were the j-th row.
But D disagrees with the j-th row at the j-th column.
Thus D is not a row.>b
*Diagonalization (2)Consider the diagonalization language Ld = {w | w is the i-th string, and the i-th TM does not accept w}.
We have shown that Ld is not a recursively enumerable language; i.e., it has no TM.6'X?>
k ProblemsInformally, a problem is a yes/no question about an infinite set of possible instances.
Example: Does graph G have a Hamilton cycle (cycle that touches each node exactly once)?
Each undirected graph is an instance of the Hamilton-cycle problem. fFO f33f/F
Problems (2)NFormally, a problem is a language.
Each string encodes some instance.
The string is in the language if and only if the answer to this instance of the problem is yes. (Example: A Problem About Turing Machines)33"lWe can think of the language Ld as a problem.
Does this TM not accept its own code?
Aside: We could also think of it as a problem about binary strings.
Do you see how to phrase it?L7?Decidable ProblemsA problem is decidable if there is an algorithm to answer it.
Recall: An algorithm, formally, is a TM that halts on all inputs, accepted or not.
Put another way, decidable problem = recursive language.
Otherwise, the problem is undecidable.n?'
f)f
Bullseye Picture ,From the Abstract to the RealWhile the fact that Ld is undecidable is interesting intellectually, it doesn t impact the real world directly.
We first shall develop some TM-related problems that are undecidable, but our goal is to use the theory to show some real problems are undecidable.$>C.Examples: Undecidable Problems33
,Can a particular line of code in a program ever be executed?
Is a given context-free grammar ambiguous?
Do two given CFG s generate the same language?t#The Universal LanguageAn example of a recursively enumerable, but not recursive language is the language Lu of a universal Turing machine.
That is, the UTM takes as input the code for some TM M and some binary string w and accepts if and only if M accepts w.:Tfz$Designing the UTMInputs are of the form:
Code for M 111 w
Note: A valid TM code never has 111, so we can split M from w.
The UTM must accept its input if and only if M is a valid TM code and that TM accepts w.<+3f'The UTM (2)The UTM will have several tapes.
Tape 1 holds the input M111w
Tape 2 holds the tape of M.
Mark the current head position of M.
Tape 3 holds the state of M.6Z%Z%1The UTM (3)Step 1: The UTM checks that M is a valid code for a TM.
E.g., all moves have five components, no two moves have the same state/symbol as first two components.
If M is not valid, its language is empty, so the UTM immediately halts without accepting.B8gZ2gZ2The UTM (4)Step 2: The UTM examines M to see how many of its own tape squares it needs to represent one symbol of M.
Step 3: Initialize Tape 2 to represent the tape of M with input w, and initialize Tape 3 to hold the start state.2dl)The UTM (5)Step 4: Simulate M.
Look for a move on Tape 1 that matches the state on Tape 3 and the tape symbol under the head on Tape 2.
If found, change the symbol and move the head marker on Tape 2 and change the State on Tape 3.
If M accepts, the UTM also accepts.2+
A Question?Do we see anything like universal Turing machines in real life?5:Proof That Lu is Recursively Enumerable, but not Recursive0;3f.We designed a TM for Lu, so it is surely RE.
Suppose it were recursive; that is, we could design a UTM U that always halted.
Then we could also design an algorithm for Ld, as follows.66Proof (2)3f
Given input w, we can decide if it is in Ld by the following steps.
Check that w is a valid TM code.
If not, then its language is empty, so w is in Ld.
If valid, use the hypothetical algorithm to decide whether w111w is in Lu.
If so, then w is not in Ld; else it is.D!u3usu*!)33H338Proof (3)3fBut we already know there is no algorithm for Ld.
Thus, our assumption that there was an algorithm for Lu is wrong.
Lu is RE, but not recursive.H/8;Bullseye Picture /
!"
%&(*-/03479:<
,$(
,r
, S#P
r
, S$
H
,0h ? ̙33rq?M+<
՜.+,0
(POn-screen ShowStanford University, CS Dept.seg Times New RomanTahomaMonotype SortsLucida Sans UnicodeDefault Design
DecidabilityBinary-Strings from TMsBinary Strings from TMs (2)Binary Strings from TMs (2)$Enumerating TMs and Binary StringsTable of AcceptanceDiagonalization AgainThe Diagonalization ArgumentDiagonalization (2) ProblemsProblems (2))Example: A Problem About Turing MachinesDecidable ProblemsBullseye PictureFrom the Abstract to the RealExamples: Undecidable ProblemsThe Universal LanguageDesigning the UTMThe UTM (2)The UTM (3)The UTM (4)The UTM (5)