• Nem Talált Eredményt

LászlóKabódi Languagesandautomata

N/A
N/A
Protected

Academic year: 2022

Ossza meg "LászlóKabódi Languagesandautomata"

Copied!
22
0
0

Teljes szövegt

(1)

Languages and automata

László Kabódi

László Kabódi

(2)

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

(3)

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

(4)

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 TRE6= I TRE6=RE

I Let LT ={w |wis a code for a TM,L(Mw) has T}

(5)

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

(6)

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

(7)

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

(8)

Proof of Rice's theorem - the M

0

Turing 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

(9)

Proof of Rice's theorem - why M

00

has T only if w #s is in L

u

I 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#sLu.

I So M0 is a Turing machine that stops on all inputs and accepts Lu, which is a contradiction.

László Kabódi

(10)

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}

(11)

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

(12)

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?

(13)

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

(14)

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?

(15)

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

(16)

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.

(17)

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

(18)

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)}

(19)

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

(20)

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

(21)

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

(22)

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.

Hivatkozások

KAPCSOLÓDÓ DOKUMENTUMOK

The second column (‘useful’) shows the number of useful word pairs which comprise all word pairs except of the ones in which the source word is not a valid word, since

• 3 We say that a smart element x does not know the defective element, if the query family satisfies the following property: no matter what the defective element y is, after the

The questionnaire used four-point Likert-scales and although students indicated that they were most secure with their vocabulary knowledge (mean: 2.41), their overall written

If we calculate a volume index by using a price index formula not passing the factor reversal test, and then the value index is divided by this index, we obtain the

As the vulnerability index of a tank is known only at certain ages of its life cycle, the approached function I V (t) is approximate by a finite element modelling on this

If the Turing machine have a time complexity f (n) then it stops in nite steps fot all inputs4. So it

At the heart of this algorithm is the following observation: if all even-index entries of the

We only nish a derivation with a deduction rule created form an accepting