Decidability CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Fall 2018 Chinese University of Hong Kong 1/22
Problems about automata ((q0,q1) ) w )(abb F (q1) q 0 (q0) ((q0,a,q0)(q0,b,q1)(q1,a,q0)(q1,b,q1)) Does Q (a,b) 2/22 accept input abb? q 0 q 1 a b b a 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 ���� � �� � � �� � � �� � � �� � � �� � Σ δ
Problems about automata TM description: reject accept state, accept; else If simulation ends in an Simulate D on input w a DFA, w is a string 3/22 Pseudocode: 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
Problems about automata abb) ) b) bb) 4/22 Perform simulation: (Transition function is complete, no duplicate transitions) Check input is in correct format Turing machine details: 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))( ˙ q0,q1)(a,b)((q0,a,q0)(q0,b,q1)(q1,a,q0)(q1,b,q1))(q0)(q1))(a ˙ (( ˙ q1)(a,b)((q0,a,q0)(q0,b,q1)(q1,a,q0)(q1,b,q1))(q0)(q1))(ab ˙ ((q0, ˙ q1)(a,b)((q0,a,q0)(q0,b,q1)(q1,a,q0)(q1,b,q1))(q0)(q1))(abb ˙ ((q0, ˙
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 fjrst symbol of w Until marker for w reaches last symbol: Update both markers If state marker is on accepting state, accept; else reject 5/22 A DFA = {� D , w � | D is a DFA that accepts input w } Conclusion: A DFA is decidable
Acceptance problems about automata Which of these is decidable? 6/22 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 }
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 7/22 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
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 8/22 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
Other problems about automata Which of the above is decidable? 9/22 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 }
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 10/22 MIN DFA = {� D � | D is a minimal DFA } On input � D � , where D is a DFA ✓ Conclusion: MIN DFA is decidable
Other problems about automata The following TM decides EQ DFA 1 2 2 , accept; else reject 11/22 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 ′ Run the DFA minimization algorithm from Lecture 7 on D 2 to obtain a minimal DFA D ′ If D ′ 1 = D ′ ✓ Conclusion: EQ DFA is decidable
Other problems about automata The following TM T decides E DFA If S accepts, T accepts; else T rejects 12/22 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
Problems about context-free grammars L where L is a context-free language Which of the above is decidable? 13/22 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 ) }
Problems about context-free grammars The following TM V decides A CFG If the CYK algorithm fjnds a parse tree, V accepts; else V rejects 14/22 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
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 15/22 Run TM V from the previous slide on input � G , w � ✓
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 16/22 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
Universal Turing Machine and Undecidability
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? 17/22
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 specifjed as a TM 18/22 program � M �
Turing machines as strings M q 0 q acc q rej A Turing machine is This Turing machine can be described by the string (q)(qa)(qr) 19/22 � / � R 0 / 0 R ( 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))
Universal Turing machine U 001 input w for M Simulate M on input w If M enters accept state, U accepts If M enters reject state, U rejects 20/22 (q,qa,qr)(0,1)(0,1, � ) program � M � U on input � M , w � :
Acceptance of Turing machines M accepts w M rejects w M loops on w 21/22 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 loops on � M , w � U rejects � M , w � TM U recognizes A TM but does not decide A TM
Recognizing versus deciding q acc Accept q rej Reject Infjnite 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 22/22 � �� �
Recommend
More recommend