MELJUN CORTES Automata Theory (Automata18)

29
CSC 3130: Automata theory and formal languages More undecidable languages Fall 2008 MELJUN P. CORTES, MBA,MPA,BSCS,ACS MELJUN P. CORTES, MBA,MPA,BSCS,ACS MELJUN CORTES MELJUN CORTES

description

MELJUN CORTES Automata Theory (Automata18)

Transcript of MELJUN CORTES Automata Theory (Automata18)

Page 1: MELJUN CORTES Automata Theory (Automata18)

CSC 3130: Automata theory and formal languages

More undecidable languages

Fall 2008MELJUN P. CORTES, MBA,MPA,BSCS,ACSMELJUN P. CORTES, MBA,MPA,BSCS,ACS

MELJUN CORTESMELJUN CORTES

Page 2: MELJUN CORTES Automata Theory (Automata18)

More undecidable problems

L1 = { 〈 M 〉 : M is a TM that accepts input }

L2 = { 〈 M 〉 : M is a TM that accepts some input}

L4 = { 〈 M, M’ 〉 : M and M’ accept the same inputs}

L3 = { 〈 M 〉 : M is a TM that accepts all inputs}

decidable recognizable butundecidable

unrecognizable

Page 3: MELJUN CORTES Automata Theory (Automata18)

Example 1

• Step 1: You gotta believe it– To know if M accepts , it looks like we have to

simulate it– But then we might end up in a loop

• Step 2: Use what you know

L1 = { 〈 M 〉 : M is a TM that accepts input }

ATM is undecidable

Page 4: MELJUN CORTES Automata Theory (Automata18)

Proof by “reduction”

• Show that if L1 can be decided,

... so can ATM

L1 = { 〈 M 〉 : M is a TM that accepts input }

Areject if not

accept if M accepts 〈M〉

?〈 M 〉 , w

reject if not

accept if M accepts w

Page 5: MELJUN CORTES Automata Theory (Automata18)

Proof by “reduction”

〈 M 〉 , w

reject if not

accept if M accepts w

Areject if not

accept if M accepts 〈 M〉

A〈 M’ 〉

M’ is a Turing Machine such that:

If M accepts w, then M’ accepts If M does not accept w, then M’ does not accept

Page 6: MELJUN CORTES Automata Theory (Automata18)

Proof by “reduction”

〈 M 〉 , w

reject if not

accept if M accepts w

A〈 M’ 〉

M’: On input z,

If z = , then simulate M on wOtherwise, reject

construct

M’

M’

q0

qaccqrej

☐/☐R

☐/☐

L

q1

M

Page 7: MELJUN CORTES Automata Theory (Automata18)

Recognizable or not?

L1 = { 〈 M 〉 : M is a TM that accepts input }

decidable recognizable butundecidable

unrecognizable

Algorithm for L1

On input 〈 M 〉 : Simulate M on input

Page 8: MELJUN CORTES Automata Theory (Automata18)

Example 2

L2 = { 〈 M 〉 : M is a TM that accepts some input}

• Step 1: You gotta believe it– To know if M accepts, it looks like we have to

simulate it– But then we might end up in a loop

• Step 2: Use what you know

ATM is undecidable L1 is undecidable

Page 9: MELJUN CORTES Automata Theory (Automata18)

Example 2

〈 M 〉

reject if not

accept if M accepts

Areject if not

accept if M accepts some input〈 M〉

A〈 M’ 〉

M’ is a Turing Machine such that:

If M accepts , then M’ accepts some inputIf M does not accept , then M’ does not accept anything

Page 10: MELJUN CORTES Automata Theory (Automata18)

Example 2

〈 M 〉

reject if not

accept if M accepts w

A〈 M’〉

construct

M’

M’: On input w,

If w = , then simulate M on Otherwise, reject

decidable recognizable butundecidable

unrecognizable

Page 11: MELJUN CORTES Automata Theory (Automata18)

Is it recognizable?

• Attempt to recognize L2:

L2 = { 〈 M 〉 : M is a TM that accepts some input}

Simulate M on input Simulate M on input Simulate M on input Simulate M on input ...

Accept if one of them accepts

... but there are infinitely many!

Page 12: MELJUN CORTES Automata Theory (Automata18)

Is it recognizable?

• Attempt to recognize L2:

L2 = { 〈 M 〉 : M is a TM that accepts some input}

For all possible strings x (in lexicographic order):

Simulate M on input x

If it accepts, accept.If it rejects, reject.

lexicographic order: , 0, 1, 00, 01, 10, 11, 000, 001, ...

what if M loops on but M accepts, say, 11?

Page 13: MELJUN CORTES Automata Theory (Automata18)

Is it recognizable?

• Description of Turing Machine that recognizes L2:

L2 = { 〈 M 〉 : M is a TM that accepts some input}

For all possible strings x (in lexicographic order):

For all strings y that come before x

If it accepts, accept.If it rejects, reject.

k := 1

k := k + 1

Simulate M on y for k steps

Page 14: MELJUN CORTES Automata Theory (Automata18)

Explanation of algorithm

• Execution of algorithm

inputs 0 1 00 01 ...

Simulate M on for 1 step

Simulate M on for 2 stepsSimulate M on 0for 2 steps

Simulate M on for 3 stepsSimulate M on 0for 3 stepsSimulate M on 1for 3 steps...

If M accepts some w,algorithm will see thisin some stage of thesimulation

decidable recognizable butundecidable

unrecognizable

Page 15: MELJUN CORTES Automata Theory (Automata18)

Example 3

• Step 1: You gotta believe it– To know if M accepts, it looks like we have to simulate

it– But then we might end up in a loop

• Step 2: Use what you know... by yourself this time!

L3 = { 〈 M 〉 : M is a TM that accepts all inputs}

decidable recognizable butundecidable

unrecognizable

Page 16: MELJUN CORTES Automata Theory (Automata18)

Is it recognizable?

• Let’s try...

L3 = { 〈 M 〉 : M is a TM that accepts all inputs}

Simulate M on for 1 step

Simulate M on for 2 stepsSimulate M on 0for 2 steps

Simulate M on for 3 stepsSimulate M on 0for 3 stepsSimulate M on 1for 3 steps...

and then what?

accept if all of them accept

but there are infinitely many!

Page 17: MELJUN CORTES Automata Theory (Automata18)

Is it recognizable?

– To check that 〈 M 〉 is in L3, it looks like we have to wait for an infinite number of simulations to finish

– But we don’t have that much time!

• Step 1: You gotta believe it... but I don’t!

L3 = { 〈 M 〉 : M is a TM that accepts all inputs}

decidable recognizable butundecidable

unrecognizable

Page 18: MELJUN CORTES Automata Theory (Automata18)

How to argue unrecognizability

• First attempt: Remember that

... so we can try to argue that L3 is recognizable

L3 = { 〈 M 〉 : M is a TM that accepts all inputs}

If L and L are both recognizable, then L isdecidable.

Page 19: MELJUN CORTES Automata Theory (Automata18)

First attempt

L3 = { 〈 M 〉 : M is a TM that accepts all inputs}

L3 = { 〈 M 〉 : M is a TM that does not accept all inputs}

• Let’s try...Simulate M on for 1 step

Simulate M on for 2 stepsSimulate M on 0for 2 steps

Simulate M on for 3 stepsSimulate M on 0for 3 stepsSimulate M on 1for 3 steps...

accept if M rejects or loops

but how to know if it loops?

Page 20: MELJUN CORTES Automata Theory (Automata18)

How to argue unrecognizability

• Second attempt: Use what you know

• We can try to argue that

L3 = { 〈 M 〉 : M is a TM that accepts all inputs}

ATM is not recognizable

If we can recognize L3 then we can also recognize ATM

Page 21: MELJUN CORTES Automata Theory (Automata18)

Proof by “reduction”

Arej/loop if not

accept if M accepts all inputs〈 M〉

〈 M 〉, w

rej/loop if M accepts w

accept if M does not accept w

A〈 M’ 〉

construct M’

M’ is a Turing Machine such that:

If M does not accept w, then M’ accepts all inputsIf M accepts w, then M’ rejects or loops on some input

Page 22: MELJUN CORTES Automata Theory (Automata18)

Constructing M’

• To do this, we want to simulate M on w... but what if simulation loops?

• Idea: M’ keeps accepting more and more of its inputs as long as M has not halted on w– If M never halts on w, M’ will accept all inputs

M’ is a Turing Machine such that:

If M does not accept w, then M’ accepts all inputsIf M accepts w, then M’ rejects or loops on some input

Page 23: MELJUN CORTES Automata Theory (Automata18)

Constructing M’

• Description of M’:

On input z,

Simulate M on input w for |z| steps

If simulation of M reaches state qacc, reject.If simulation of M reaches state qrej, accept.If neither state is reached, accept.

M’ is a Turing Machine such that:

If M does not accept w, then M’ accepts all inputsIf M accepts w, then M’ rejects or loops on some input

length of z

Page 24: MELJUN CORTES Automata Theory (Automata18)

Correctness of construction

M’ is a Turing Machine such that:

If M does not accept w, then M’ accepts all inputsIf M accepts w, then M’ rejects or loops on some input

On input z,

Simulate M on input w for |z| steps

If simulation of M reaches state qacc, reject.If simulation of M reaches state qrej, accept.If neither state is reached, accept.

Description of M’:

Page 25: MELJUN CORTES Automata Theory (Automata18)

Correctness of construction

Simulate M on input w for |z| steps

If simulation of M reaches state qacc, reject.If simulation of M reaches state qrej, accept.If neither state is reached, accept.

M’ is a Turing Machine such that:

If M does not accept w, then M’ accepts all inputsIf M accepts w, then M’ rejects or loops on some input

On input z,

Description of M’: In k steps

z = 0k

M’ rejects input 0k

Page 26: MELJUN CORTES Automata Theory (Automata18)

Example 3 recap

L3 = { 〈 M 〉 : M is a TM that accepts all inputs}

• We showed that

... but we know ATM is not recognizable so

If we can recognize L3 then we can also recognize ATM

decidable recognizable butundecidable

unrecognizable

Page 27: MELJUN CORTES Automata Theory (Automata18)

Example 4

• Step 1: You gotta believe it

• Step 2: Use what you know

decidable recognizable butundecidable

unrecognizable

ATM is recognizablebut undecidable

L1 is recognizablebut undecidable

L2 is recognizablebut undecidable

L3 is unrecognizableATM is unrecognizable

L4 = {( 〈 M1 〉 , 〈 M2 〉 ): M1 and M2 accept the same inputs}

Page 28: MELJUN CORTES Automata Theory (Automata18)

Example 4

L4 = {( 〈 M1 〉 , 〈 M2 〉 ): M1 and M2 accept the same inputs}

L3 = { 〈 M 〉 : M is a TM that accepts all inputs}

?〈 M 〉

rej/loop if not

accept if M accepts all inputs

Arej/loop if not

accept if M1, M2 accept same inputs〈 M1 〉 , 〈 M2 〉

Page 29: MELJUN CORTES Automata Theory (Automata18)

Example 4

Arej/loop if not

accept if M1, M2 accept same inputs〈 M1 〉 , 〈 M2 〉

〈M〉

rej/loop if not

accept if M accepts all inputs

A

〈 M1 〉〈 M2 〉

If M accepts all inputs, then M1, M2 accepts same inputsIf M does not, then M1, M2 do not accept same inputs

M1 = M M2 = TM that always accepts

qacc