1 csc3130 formal languages and automata theory tutorial 9 undecidable problem kn hung shb 1026

40
1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

Upload: collin-simmons

Post on 16-Dec-2015

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

1

CSC3130Formal Languages and

Automata Theory

Tutorial 9Undecidable Problem

KN Hung

SHB 1026

Page 2: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

2

Agenda

• Recap– Decidibility, Undecidibility, Turing-

Recognizable …

• Reduction

• Undecidable Problem

Page 3: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

3

Recap

Page 4: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

4

Recap: Recognize

• Given a language L and a machine M “M recognizes L” iff

“For any w ∈ L, M halts and goes to an accepting state”

• “M is a recognizer for L”

• However, for w ∉ L, M may– Reject– Loop forever

Page 5: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

5

Recap: Decide

• Given a language L and a machine M “M decides L” iff

“For any w ∈ L, M halts and accepts AND

Otherwise, M rejects”

• “M is a decider for L”

• Meaning: M can determine whether a given string is in L or not

Page 6: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

6

Recognize VS Decide

• Recognize = Halts for accepting input

• Decide = Halts for all inputs

• Decide => Recognize

• Make sure that you can distinguish these two concepts!

Page 7: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

7

Recap: ~able / ~ability

• L is Turing-recognizable iffthere is a TM that recognizes L

• L is decidable iffthere is a TM that decides L

• L is undecidable iffthere is no TM that decides L

Page 8: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

8

Recognizability VS Decidibility

Turing-Recognizable

Decidable

For a language, L, located here,there is no machine that halts for all input string

Page 9: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

9

Some Decidable Problems

• The following problems are decidable– ADFA = {<A, w> | A is a DFA that accepts w}

– ANFA = {<A, w> | A is a NFA that accepts w}

– EDFA = {<A, w> | A is a DFA and L(A) = Ø}

– EQDFA = {<A, B> | A, B are DFAs, L(A) = L(B)}

– ACFG = {<G, w> | G is a CFG that generates w}

Page 10: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

10

Some Undecidable Problems

• The following problems are undecidable– ATM = {<M, w> | M is a TM that accepts w}

• To prove undecidability of a problem using reduction, ATM is used very frequently (nearly in all situations)

• Used in Example 1 and 2 (Later slides)

Page 11: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

11

Reduction

Page 12: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

12

Reduction

• Occurs in daily life…• Problem A: Travel to Japan• Problem B: Buying a air ticket to Japan• Problem A reduces to Problem B

– Meaning: Settling B automatically solves A– Put in logical statement:

B is solvable A is solvable

Page 13: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

13

Reduction

Buy an air ticket

Travel to Japan

Reduce toReduce to

The problem “To buy an air ticket” enclosesThe problem “To travel to Japan”

Page 14: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

14

Reduction

B

A

Reduce toReduce to

Problem B “encloses” ASo, B is solved => A is solvedThus, B is no harder than A!

Page 15: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

15

Reduction

• A reduces to B• A is reducible to B

– If B is solved, then A is solved– i.e., Whenever there is a solution to B,

then there is a solution to A

• If A cannot be solved, then B cannot be solved (Contrapositive)

• Thus, B is no harder than A

B

AReduced toReduced to

Page 16: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

16

Undecidable Problems

Page 17: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

17

Example 1

• Show that REGULARTM is undecidable

• REGULARTM = {<M> | M is a TM and L(M) is a regular language}

Page 18: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

18

REGULARTM is undecidable?

• Idea (By Contradiction):– Assume there is a TM R that decides

REGULARTM

– Construct a TM S that decides ATM

– Contradiction!

Page 19: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

19

Construction of S

• On input <M, w>– where M is a TM and w is a string:

• Construct M’ by M and w

• Run R on <M’>

• Output the answer

Page 20: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

20

Idea of M’

• Strategy: Convert M into another TM M’: M’ recognizes a regular languageiff M accepts w

• If M accepts w, let M’ recognizes {0, 1}*• Otherwise, let M’ recognizes {0n1n}• With the above properties

– When we run R on <M’>,the output is “accept” iff M accepts w

– Why…? [See next few slides…]

Page 21: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

21

Construction of M’

• M’ = “On input x:1. If x has the form 0n1n, accept

2. If x does not have this form, run M on input w and output answer”

• {0n1n} is recognized by M’ anyway

• How about the other strings?

Page 22: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

22

Construction of M’

• For strings of form 0n1n, M’ accepts• For all the other strings, listing all cases…

– If M accepts w• they are all accepted by M’

– If M rejects w• they are all rejected by M’

– If M loops on w• they all loop on M’

M’ = “On input x:

1. If x has the form 0n1n, accept

2. If x does not have this form, run M on input w and output answer”

Page 23: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

23

L(M’) in relation to S

• If M accepts w– M’ recognizes {0n1n}∪{0,1}*– {0,1}* is regular– R will accept M’

• If M does not accept w– M’ recognizes {0n1n}∪Ø– {0n1n} is not regular– R will reject M’

Page 24: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

24

REGULARTM is undecidable

• Assume “R that decides REGULARTM” exists

• We construct S to decide ATM

“On input <M, w>, where M is a TM and w is a string:1. Construct the following TM M’

M’ = “On input x:

1. If x has the form 0n1n, accept

2. If x does not have this form, run M on input w and accept if M accepts w”

2. Run R on input <M’>

3. Output the output of R”

• Now, S decides ATM… Contradiction!

Page 25: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

25

Example 2

• L = {<M, w> | M accepts all strings shorter than w}

• Show that L is undecidable

Page 26: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

26

L is undecidable?

• L = {<M, w> | M accepts all strings shorter than w}

• Again, we try to use the undecidability of ATM to achieve a contradiction

• Idea (By Contradiction):– Assume there is a TM R that decides L

– Construct a TM (by R), S that decides ATM

– Contradiction!

Page 27: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

27

Construction of S

• On input <M, w>– where M is a TM and w is a string:

• Construct M’ by M and w

• Run R on <M’, ?>– This time, we have a TM that takes 2

arguments – a TM, and a string – as inputs– Think what string to put as the 2nd input

• Output the answer

Page 28: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

28

Idea of M’

• Strategy: Convert M into another TM M’: M’ accepts all strings shorter than ziff M accepts w

• We want to achieve the following:– When we run R on <M’, z>,

the output is “accept” iff M accepts w

Page 29: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

29

Idea of M’

• Strategy: Convert M into another TM M’: M’ accepts all strings shorter than “1”iff M accepts w

• We want to achieve the following:– When we run R on <M’, “1”>,

the output is “accept” iff M accepts w

Page 30: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

30

Construction of M’

• M’ = “On input x:1. If x =ε

Run M on w

Output the answer

2. If x ≠ε Reject

Page 31: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

31

Construction of M’

• For M’– If M accepts w

• the only possibility is input isε AND M’ accepts ε

– If M rejects w, • Case 1: x =ε

– M’ rejects

• Case 2: x ≠ε– M’ rejects

– If M loops on w• Case 1: x =ε

– M’ loops

• Case 2: x ≠ε– M’ rejects

M’ = “On input x: If x =ε run M on w and output answer If x ≠ε reject”

Page 32: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

32

Construction of M’

• For M’– If M accepts w

• M’ accepts only ε

– Otherwise• M’ does not accepts any string

– including εM’ = “On input x:

If x =ε run M on w and output answer If x ≠ε reject”

Page 33: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

33

L(M’) in relation to S

• If M accepts w– L(M’) = {ε}– {ε} is exactly the language that contains all

string shorter than “1”– S accepts <M’, “1”>

• Otherwise (i.e., M loops on or rejects w)– L(M’) = Ø– S rejects <M’, “1”>

Page 34: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

34

L is undecidable

• Assume “R that decides REGULARTM” exists• We construct S to decide ATM

“On input <M, w>, where M is a TM and w is a string:1.Construct the following TM M’

M’ = “On input x:1. If x =ε

Run M on xOutput the answer

2. If x ≠εReject

2. Run R on input <M’, “1”>3. Output the output of R”

• Now, S decides ATM… Contradiction!

Page 35: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

35

Conclusion

Page 36: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

36

Pf: Undecidability by Reduction

R• Given an undecidable language, L• Assume such a decider TM R, exists

Page 37: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

37

• Given an undecidable language, L• Assume such a decider TM R, exists• Construct a TM, M’, by M and w

– M is from input

Pf: Undecidability by Reduction

R

M M’Modify

Input

w

Page 38: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

38

• Given an undecidable language, L• Assume such a decider TM R, exists• Construct a TM, M’, by M and w

– M is from input

• Feed M’ to R

Pf: Undecidability by Reduction

R

M M’Modify

Input

w

Page 39: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

39

• Given an undecidable language, L• Assume such a decider TM R, exists• Construct a TM, M’, by M and w

– M is from input

• Feed M’ to R• If you are right

– R will accept M’ iff M accepts w– R will reject M’ iff M does not accept w

• Thus, you obtain a decider for ATM

– Contradiction!!

Pf: Undecidability by Reduction

R

M M’Modify

Input

“M acc w” then ACC

Otherwise,REJ

w

Page 40: 1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026

40

Q & A

• Thanks for coming!

• I understand that this topic is confusing…

• Should have some questions?