✬ ✩ Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Decidability ✫ ✪ 12-0
✬ ✩ Decidable Problems Interesting problems regarding regular languages are generally decidable. We can phrase these problems as language decidability problems. For example, the acceptance problem for DFAs is whether, given a DFA D and a string w , D accepts input w . Since we can encode the DFA as a string, the acceptance problem can be seen as testing for membership of the language A DF A = {� D, w � | D is a DFA that accepts w } ✫ ✪ 12-1
✬ ✩ DFA Acceptance Is Decidable Theorem: A DFA is a decidable language. Proof sketch: The crucial point is that it is possible for a Turing machine M to simulate a DFA D . M finds on its tape, say 1 ...n ## ab...z ## 1 a 2# ... # nbn ## 1 ## 3 7 ## baa... $ ���� ���� ���� ���� ���� � �� � Q q 0 F w Σ δ First M checks that the first five components represent a valid DFA, and if not, rejects. Then M simulates the moves of D , keeping track of D ’s state and the current position in w , by writing these details on its tape, after $. When the last symbol in w has been processed, M accepts if D is in a state in F , and rejects otherwise. ✫ ✪ 12-2
✬ ✩ TMs as Interpreters We did not show the details of how a Turing machine goes about simulating a DFA D . Many low-level programming steps are involved. However, it should be clear that it is possible for a Turing machine to mimic DFA behaviour this way. The description of D is nothing but a “program” and the claim is that a Turing machine can act as an interpreter for this language. Turing machines themselves can be encoded as strings, and then a Turing machine can interpret Turing machines. This is no more strange than the fact that we can write an interpreter for Haskell, say, in Haskell. ✫ ✪ 12-3
✬ ✩ NFA Acceptance Is Decidable Theorem: A NFA = {� N, w � | N is a NFA that accepts w } is a decidable language. Proof sketch: The procedure we gave for translating an NFA to an equivalent DFA was mechanistic and terminating, so a halting Turing machine can do that job. Having written the encoding of the DFA on its tape, the Turing machine can then “run” the machine M from the previous proof. ✫ ✪ 12-4
✬ ✩ DFA Emptiness Is Decidable Theorem: E DFA = {� D � | D is a DFA and L ( D ) = ∅} is decidable. Proof sketch: We can design a Turing machine which takes � D � = ( Q, Σ , δ, q 0 , F ) as input and performs a reachability analysis: 1. Set reachable = { q 0 } , D ’s start state. 2. Set new = { q | δ ( m, x ) = q, m ∈ reachable } \ reachable 3. If new � = ∅ , set reachable = reachable ∪ new and go to step 2. 4. If reachable ∩ F = ∅ , accept, otherwise reject. ✫ ✪ 12-5
✬ ✩ DFA Equivalence Is Decidable Theorem: EQ DFA = {� A, B � | A and B are DFAs and L ( A ) = L ( B ) } is decidable. Proof sketch: We previously saw how it is possible to construct, from DFAs A and B , DFAs for A ∩ B , A ∪ B , and A . These procedures are mechanistic and finite—a halting Turing machine M can perform them. Hence from A and B , M can produce a DFA C to recognise � � � � L ( A ) ∩ L ( B ) ∪ L ( A ) ∩ L ( B ) L ( C ) = Note that L ( C ) = ∅ iff L ( A ) = L ( B ). So all M then need to do is to simulate the constructed DFA C and accept iff C accepts. ✫ ✪ 12-6
✬ ✩ Generation by CFGs Is Decidable Theorem: A CFG = {� G, w � | G is a CFG that generates w } is decidable. Proof: We can put a bound on the number of derivation steps needed to derive any w ∈ L ( G ). First convert G to an equivalent grammar G ′ in Chomsky Normal Form. So every rule is of form A → B C or A → a . Let | w | = n . To derive w we would need to use a rule of the first form n − 1 times, and a rule of the second form n times. So any derivation of w has exactly 2 n − 1 steps. A Turing machine can therefore take G and w , generate G ′ , and list all derivations of length 2 n − 1. It accepts iff any of these generate w . ✫ ✪ 12-7
✬ ✩ CFG Emptiness Is Decidable Theorem: E CFG = {� G � | G is a CFG and L ( G ) = ∅} is decidable. Proof: We can design a Turing machine which takes � G � = ( V, Σ , R, S ) as input and performs a “producer” analysis: 1. Set producers = Σ, all of G ’s terminals. 2. Set new = � � � A → U 1 · · · U n � ∈ R, � \ producers A � � { U 1 , . . . , U n } ⊆ producers � 3. If new � = ∅ , set producers = producers ∪ new and go to step 2. 4. If S ∈ producers , reject, otherwise accept. ✫ ✪ 12-8
✬ ✩ Every CFL Is Decidable Two slides back we saw that it is decidable whether a CFG G generates a string w . The deciding Turing machine, S , thus took � G, w � as input. Now we’re saying that any particular CFL L 0 is decidable: Theorem: Every context-free language L 0 is decidable. Proof: This amounts to saying that we can specialise (or partially evaluate) S . If L 0 has a grammar G 0 , the decider for L 0 simply takes input w and runs S on � G 0 , w � . ✫ ✪ 12-9
✬ ✩ Every CFL Is Decidable (cont.) What we have shown by now: Turing recognisable (r.e.) Decidable Context-free Regular ✫ Are there r.e. languages that are not decidable? ✪ 12-10
✬ ✩ An Undecidable Language We now show that it is undecidable whether a Turing machine accepts a given input string. That is, A TM = {� M, w � | M is a TM and M accepts w } is undecidable. The main difference from the case of A CFG , for example, is that a Turing machine may fail to halt. (The problem we are up against is really a variant of the halting problem for Turing machines.) ✫ ✪ 12-11
✬ ✩ TM Acceptance Is Undecidable Theorem: A TM = {� M, w � | M is a TM and M accepts w } is undecidable. Proof: Assume (for contradiction) that A TM is decidable, decided by H : if M accepts w accept H � M, w � = reject if M does not accept w Using H we can construct a Turing machine D which decides whether a given machine M accepts its own encoding � M � : 1. Input is � M � , where M is some Turing machine. 2. Run H on � M, � M �� . 3. If H accepts, reject. If H rejects, accept. ✫ ✪ 12-12
✬ ✩ TM Acceptance (cont.) In summary: if M does not accept � M � accept D � M � = if M accepts � M � reject But no machine can satisfy that specification! We obtain an absurdity when we investigate D ’s behaviour on its own encoding: if D does not accept � D � accept D � D � = if D accepts � D � reject Hence neither D nor H can exist. Sipser shows very nicely how this proof is really just another use of diagonalisation. ✫ ✪ 12-13
✬ ✩ A Universal Turing Machine Note that A TM = {� M, w � | M is a TM and M accepts w } is Turing recognisable. The reason is that it is possible to construct a universal Turing machine U which is able to simulate any Turing machine. On input � M, w � , U simulates M on input w . If M enters its accept state, U accepts. If M enters its reject state, U rejects. If M never halts, neither does U . ✫ ✪ 12-14
✬ ✩ Some Languages Are Not Even R.E. Recall that a set is countable if it is finite or in a one-to-one correspondence with N . For a finite (non-empty) alphabet Σ, Σ ∗ is countable. We can enumerate first all strings of length 0, then those of length 1, and so on. Also recall how we used diagonalisation to show that there are sets, such as R , that are not countable. A similar argument shows that the set B of all infinite binary sequences is uncountable. ✫ ✪ 12-15
✬ ✩ A Diagonalisation Argument Assume B is countable. Then we can enumerate B : Element 0 0 1 0 1 1 1 b 1 . . . b 2 1 0 1 1 1 0 1 . . . b 3 1 0 1 1 1 0 1 . . . b 4 0 1 0 0 1 0 0 . . . . . . However, the infinite sequence which has 0 if the i th bit of b i is 1 i ’th bit = 1 if the i th bit of b i is 0 cannot be any of b i . Hence B is uncountable. ✫ ✪ 12-16
✬ ✩ Too Many Languages But then the set of all languages over Σ is also uncountable. Namely, there is a one-to-one correspondence with B . Let an enumeration of Σ ∗ yield s 1 , s 2 , s 3 , . . . For each language A over Σ, there is a unique characteristic sequence χ A , whose i th bit is 1 if s i ∈ A and 0 otherwise: Σ ∗ : { ǫ, 0 , 1 , 00 , 01 , 10 , 11 , 000 , 001 , . . . } A : { . . . } 0 , 00 , 01 , 000 , χ A : 0 1 0 1 1 0 0 1 0 . . . Hence we cannot put the set of all languages into a one-to-one correspondence with the set of all Turing machines. ✫ ✪ 12-17
✬ ✩ Closure Properties The set of Turing-recognisable languages is closed under the regular operations, and intersection. The set of decidable languages are closed under the same operations, and also under complement. Theorem: A language L is decidable iff both L and L are Turing-recognisable. Proof: If L is decidable, clearly L and also L are recognisable. Assume both L and L are recognisable. That is, there are recognisers M 1 and M 2 for L and L , respectively. A Turing machine M can then take input w and run M 1 and M 2 on w in parallel. If M 1 accepts, so does M . If M 2 accepts, M rejects. Note that at least one of M 1 and M 2 is guaranteed to accept. ✫ ✪ Hence M decides L . 12-18
Recommend
More recommend