decidability
play

Decidability CSCI 3130 Formal Languages and Automata Theory Siu On - PowerPoint PPT Presentation

1/23 Decidability CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Chinese University of Hong Kong Fall 2015 2/23 b Q w F a accept input abb? b a Does Problems about automata q 0 q 1 We can formulate this question as a


  1. 1/23 Decidability CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Chinese University of Hong Kong Fall 2015

  2. 2/23 b Q w F a accept input abb? b a Does Problems about automata q 0 q 1 We can formulate this question as a language A DFA = {� D , w � | D is a DFA that accepts input w } Is A DFA decidable? One possible way to encode a DFA D = ( Q , Σ , δ, q 0 , F ) and input w ((q0,q1) (a,b) ((q0,a,q0)(q0,b,q1)(q1,a,q0)(q1,b,q1)) (q0) (q1) )( abb ) ���� � �� � ���� � �� � ���� ���� Σ δ q 0

  3. 3/23 Problems about automata Pseudocode: TM description: a DFA, w is a string Simulate D on input w If simulation ends in an accept state, accept; else reject A DFA = {� D , w � | D is a DFA that accepts input w } On input � D , w � , where On input � D , w � , where D is D = ( Q , Σ , δ, q 0 , F ) Set q ← q 0 For i ← 1 to length ( w ) q ← δ ( q , w i ) If q ∈ F accept, else reject

  4. 4/23 Problems about automata Turing machine details: Check input is in correct format (Transition function is complete, no duplicate transitions) Perform simulation: A DFA = {� D , w � | D is a DFA that accepts input w } (( ˙ q0,q1)(a,b)((q0,a,q0)(q0,b,q1)(q1,a,q0)(q1,b,q1))(q0)(q1))( ˙ abb) q0,q1)(a,b)((q0,a,q0)(q0,b,q1)(q1,a,q0)(q1,b,q1))(q0)(q1))(a ˙ (( ˙ bb) q1)(a,b)((q0,a,q0)(q0,b,q1)(q1,a,q0)(q1,b,q1))(q0)(q1))(ab ˙ ((q0, ˙ b) q1)(a,b)((q0,a,q0)(q0,b,q1)(q1,a,q0)(q1,b,q1))(q0)(q1))(abb ˙ ((q0, ˙ )

  5. 5/23 Problems about automata Turing machine details: Check input is in correct format (Transition function is complete, no duplicate transitions) Perform simulation: (very high-level) Put markers on start state of D and first symbol of w Until marker for w reaches last symbol: Update both markers If state marker is on accepting state, accept; else reject A DFA = {� D , w � | D is a DFA that accepts input w } Conclusion: A DFA is decidable

  6. 6/23 Acceptance problems about automata Which of these is decidable? A DFA = {� D , w � | D is a DFA that accepts input w } ✓ A NFA = {� N , w � | N is an NFA that accepts input w } A REX = {� R , w � | R is a regular expression that generates w }

  7. 7/23 Acceptance problems about automata The following TM decides A NFA : Convert N to a DFA D using the conversion procedure from Lecture 3 If M accepts, accept; else reject A NFA = {� N , w � | N is an NFA that accepts input w } On input � N , w � where N is an NFA and w is a string Run TM M for A DFA on input � D , w � ✓ Conclusion: A NFA is decidable

  8. 8/23 Acceptance problems about automata The following TM decides A REX Convert R to an NFA N using the conversion procedure from Lecture 4 If N accepts, accept; else reject A REX = {� R , w � | R is a regular expression that generates w } On input � R , w � , where R is a regular expression and w is a string Run the TM for A NFA on input � N , w � ✓ Conclusion: A REX is decidable

  9. 9/23 Other problems about automata Which of the above is decidable? MIN DFA = {� D � | D is a minimal DFA } EQ DFA = {� D 1 , D 2 � | D 1 and D 2 are DFAs and L ( D 1 ) = L ( D 2 ) } E DFA = {� D � | D is a DFA and L ( D ) is empty }

  10. 10/23 Other problems about automata The following TM decides MIN DFA Run the DFA minimization algorithm from Lecture 7 If every pair of states is distinguishable, accept; else reject MIN DFA = {� D � | D is a minimal DFA } On input � D � , where R is a DFA ✓ Conclusion: MIN DFA is decidable

  11. 11/23 Other problems about automata The following TM decides EQ DFA EQ DFA = {� D 1 , D 2 � | D 1 and D 2 are DFAs and L ( D 1 ) = L ( D 2 ) } On input � D 1 , D 2 � , where D 1 and D 2 are DFAs Run the DFA minimization algorithm from Lecture 7 on D 1 to obtain a minimal DFA D ′ 1 Run the DFA minimization algorithm from Lecture 7 on D 2 to obtain a minimal DFA D ′ 2 1 = D ′ If D ′ 2 , accept; else reject ✓ Conclusion: EQ DFA is decidable

  12. 12/23 Other problems about automata The following TM T decides E DFA If S accepts, T accepts; else T rejects E DFA = {� D � | D is a DFA and L ( D ) is empty } On input � D � , where D is a DFA Run the TM S for EQ DFA on input � D , � ✓ Conclusion: E DFA is decidable

  13. 13/23 Problems about context-free grammars L where L is a context-free language Which of the above is decidable? A CFG = {� G , w � | G is a CFG that generates w } EQ CFG = {� G 1 , G 2 � | G 1 , G 2 are CFGs and L ( G 1 ) = L ( G 2 ) }

  14. 14/23 Problems about context-free grammars The following TM V decides A CFG If the CYK algorithm finds a parse tree, V accepts; else V rejects A CFG = {� G , w � | G is a CFG that generates w } On input � G , w � , where G is a CFG and w is a string Eliminate the ε - and unit productions from G Convert G into Chomsky Normal Form G ′ Run Cocke–Younger–Kasami algorithm on � G ′ , w � ✓ Conclusion: A CFG is decidable

  15. 15/23 Problems about context-free grammars L where L is a context-free language Let L be a context-free language There is a CFG G for L The following TM decides L On input w If V accepts, accept; else reject Conclusion: every context-free language L is decidable Run TM V from the previous slide on input � G , w � ✓

  16. 16/23 Problems about context-free grammars is not decidable But there is no method that, given a CFG or PDA, produces a unique equivalent minimal CFG or PDA EQ CFG = {� G 1 , G 2 � | G 1 , G 2 are CFGs and L ( G 1 ) = L ( G 2 ) } ✗ What’s the difference between EQ DFA and EQ CFG ? To decide EQ DFA we minimize both DFAs

  17. 17/23 Universal Turing Machine and Undecidability

  18. 18/23 Turing Machines versus computers computer program input output A computer is a machine that manipulates data according to a list of instructions How does a Turing machine take a program as part of its input?

  19. 19/23 The universal Turing machine U input w for M whatever M does on w The universal TM U takes as inputs a program M and a string x , and simulates M on w The program M itself is specified as a TM program � M �

  20. 20/23 A Turing machine is M q acc q rej Turing machines as strings This Turing machine can be described by the string � / � R 0 / 0 R q 0 ( Q , Σ , Γ , δ, q 0 , q acc , q rej ) 1 / 1 R � M � = (q,qa,qr)(0,1)(0,1, � ) ((q,q, � / � R)(q,qa,0/0R)(q,qr,1/1R)) (q)(qa)(qr)

  21. 21/23 The universal Turing machine U input w for M Simulate M on input w If M enters accept state, U accepts If M enters reject state, U rejects (q,qa,qr)(0,1)(0,1, � ) 001 program � M � U on input � M , w � :

  22. 22/23 Acceptance of Turing machines M accepts w M rejects w M loops on w A TM = {� M , w � | M is a TM that accepts w } U on input � M , w � simulates M on input w ⇓ ⇓ ⇓ U accepts � M , w � U rejects � M , w � U loops on � M , w � TM U recognizes A TM but does not decide A TM

  23. 23/23 Recognizing versus deciding q acc Accept q rej Reject Infinite loop halt The language recognized by a TM M is the set of all inputs that M accepts A TM decides language L if it recognizes L and halts on every input A language L is decidable if some TM decides L � �� �

Recommend


More recommend