Languages and automata
László Kabódi
László Kabódi
Example
I L={w|w is a code for a Turing machine and Mw halts in all inputs in at most 100 steps}. Show thatL∈coRE
Solution
I L∈coRE ⇔L∈RE
I L={w|w is not a code for a Turing machine or there is at least one input whereMw does not halt in at most 100 steps{. I An M Turing machine forL:
I rstM checks ifw is a code for a Turing machine: if not, stop and accept
I otherwise runMw with all inputs for 101 steps
I if it accepts one before that, continue to the next word I if it would run for more steps, stop and acceptw
László Kabódi
Language properties
I AT language property is non-trivial is there are L1,L2∈RE languages whereL1 has T andL2 does not haveT
I We can useT for all languages that have the T property, then T is non-trivial if
I T∩RE6=∅ I T∩RE6=RE
I Let LT ={w |wis a code for a TM,L(Mw) has T}
Some properties
I LT =LT∩L0 where L0 ={w|w is a code for a Turing machine }
I LT contains all words that are not codes for Turing machines, or they accept languages that does not haveT
I LT ∈R ⇔LT ∈R
I IfLT ∈R, its complemet is also recursive I L0 is recursive
László Kabódi
Rice's theorem
I If T is a non-trivial language property thenLT ∈/ R I we can use this to show that languages in the form of
LT ={w|w is a code for a Turing machine andL(Mw) hasT} are not recursive
I for this, we have to show one language that has T and recursively enumerable and another that does not have T and recursively enumerable
I or in other words L1,L2 ∈RE where L1 ⊆T andL2 6⊂T
Proof of Rice's theorem
I Theorem: ifT is a non-trivial language property thenLT ∈/ R I Let ∅∈/ T (otherwise we can prove forT)
I Let L∈RE be a language that has T as a property, and its Turing machine M
I Indirect proof: suppose LT ∈R, so there exist anMT Turing machine that stops on all inputs and L(MT) =LT
I We will create an M0 Turing machine that stops on all inputs andL(M0) =Lu, which is a contradiction becauseLu∈RE\R
László Kabódi
Proof of Rice's theorem - the M
0Turing machine
I rst it check the input: if it is not in w#s form, orw is not a code for a Turing machine, stops and rejects
I otherwise it constructs a w00 code for anM00 Turing machine:
I rst it runsMw(s): if it stops, and rejects,M00stops and rejectsx (its input)
I ifMw(s)never stops, thenM00 will never stop onx I ifMw(s)stops and accepts, then it runsM(x)
I ifM(x)stops and accepts, thenM00will stop and accept I ifM(x)stops and rejects, thenM00will stop and reject I ifM(x)never stops, thenM00will never stop
I thenM0 runs MT(w00), which stops on all inputs, and accepts the input only if it is in Lu
Proof of Rice's theorem - why M
00has T only if w #s is in L
uI If w#s ∈/Lu, thenw is not a code of a Turing machine, or s ∈/ L(Mw). In this case M00 either stops and rejects every input, or never stops, soL(M00) =∅
I If w#s ∈Lu, thens ∈L(Mw). In this case M00 will run its input with M, soL(M00) =L(M) =L. And L has the T property.
I So if we run MT(w00), it will stop, and either reject or accept the input.
I If it rejects, it is becauseL(M00) =∅. In this casew#s∈/Lu. I If it accepts, thenL(M00)has theT property, soL(M00) =L.
This is becausew#s∈Lu.
I So M0 is a Turing machine that stops on all inputs and accepts Lu, which is a contradiction.
László Kabódi
Example
ShowL1,L2 ∈RE that one hasT and the other does not have it.
I T1: the language is not empty
LT1 ={w |w is a code for a TM and L(Mw)6=∅ } I T2: the language has at least 100 elements
LT2 ={w |w is a code for a TM and |L(Mw)| ≥100} I T3: the language is regular
LT3 ={w |w is a code for a TM and L(Mw) is regular}
Solution
I T1: the language is not empty
LT1 ={w |w is a code for a TM and L(Mw)6=∅ } L1 =∅,L2 = Σ∗
I T2: the language has at least 100 elements
LT2 ={w |w is a code for a TM and |L(Mw)| ≥100} L1 =∅,L2 = Σ∗
I T3: the language is regular
LT3 ={w |w is a code for a TM and L(Mw) is regular} L1 =∅,L2 =anbn
László Kabódi
Example
I IsL={w|w is a code for a Turing machine and
|L(Mw)|=5} ∈R?
I IsL={w|w is a code for a Turing machine and L(Mw) =Lu} ∈R?
Solution
I IsL={w|w is a code for a Turing machine and
|L(Mw)|=5} ∈R?
No, because of Rice's theorem. L1=∅,L2={0,1,00,01,10}. I IsL={w|w is a code for a Turing machine and
L(Mw) =Lu} ∈R?
No, because of Rice's theorem. L1=∅,L2=Lu.
László Kabódi
Example
LetL={w|w is a code for a TM andL(Mw) contains only even length words}
I IsL∈R? I IsL∈coRE? I IsL∈RE?
Solution I
L={w|w is a code for a TM and L(Mw)contains only even length words}
I L∈/ R, because of Rice's theorem. L1 ={0,01,000}, L2 ={00,0011}
I L∈coRE. We have to show thatL∈RE.
L={w|w is not a code for a Turing machine orL(Mw) contains at least one odd length word}.
László Kabódi
Solution II
I A Turing machine for L:
I rst it checks isw is a code for a Turing machine and if it is not, stops and accepts
I otherwise it checks all odd length words using the diagonal method
I if there is a word it accepts, then stop and accept I otherwise it runs forever
I L∈/ RE, because L∈/R, butRE ∩coRE =R.
Post correspondence problem
I Introduced by (and named after) Emil Post
I Given a set of word pairs, is there an order in which the concatenation of the rst words in each pair and the second words of each pair gives the same word?
I Given{(si,ti)|si,ti ∈Σ∗,i =1,2, . . . ,k}is there an i1,i2, . . . ,in not empty index list (there can be repetitions) where si1si2. . .sin =ti1ti2. . .tin?
László Kabódi
Example
Is there a solution for the following PCP sets?
I {(ab,aba),(ab,ba),(aba,ba)} I {(1,111),(10111,10),(10,0)} I {(ab,a),(ab,ba),(b,ba)}
Solution
I {(ab,aba),(ab,ba),(aba,ba)} Index list: 1, 3
s1s3 =ab aba t1t3 =aba ba I {(1,111),(10111,10),(10,0)}
Index list: 2, 1, 1, 3
s2s1s1s3 =10111 1 1 10 t2t1t1t3 =10 111 111 0 I {(ab,a),(ab,ba),(b,ba)}
There is no solution, because the all rst words end with b and the second words end with a.
László Kabódi
The PCP language
I PCP ={the set of{(si,ti),i =1,2, . . . ,k} word pairs where there is a good index list}
I PCP ∈RE \R
I Turing machine forPCP that does not stop on all inputs:
I check is the input consists of word pairs, if not stop and reject I otherwise it tries all the 1 element index lists then 2 element
index lists and so on
I if there is a good index list, stop and accept I if there is not, run forever
Example
I Is it recursive, if we know for a PCP problem that|si|=|ti|for all i?
I Is it recursive, if we also get an m integer that is the max length of the index list that can be good for the PCP problem?
László Kabódi
Solution
I Is it recursive, if we know for a PCP problem that|si|=|ti|for all i?
Yes, only have to check if there a pair that is the same.
(si =ti)
I Is it recursive, if we also get an m integer that is the max length of the index list that can be good for the PCP problem?
Yes, only have to check a nite number of index lists (2·nm) to see if there is a solution, because we know that there is no longer solution.