Languages and Automata 2020 #11 Decidable and recognizable languages
1. Prove that the language of all prime numbers (in binary representation) is recursive (Turing-decidable).
(You can use tha fact, that arithmetic operations can be performed by Turing machines.)
Solution: The Turing machine checks if the input can be divided by any number smaller than itself.
If yes, it rejects. If not, it accepts.
2. Prove that (a) Ld 6∈R (b) Ld ∈RE
Solution: A Turing machine for Ld:
(a) checkw - if it is not a code for a TM, accept (b) otherwise runMw on w
(c) if it accepts, stop and accept, otherwise reject or run forever
If Ld would be recursive, then R =RE would hold. But there are languages inRE\R, so Ld∈/ R.
3. Let L={w#s:w∈Ld, and s6∈L(Mw)}. Prove that L /∈R.
Solution: IfL∈R, then there is a Turing machine that stops on all inputs, and decides if w#s ∈L.
If we give that Turing machine w#w as an input, we have a Turing machine for Ld. But we know, that there can not be one, so L /∈R.
4. Let L be the language of descriptions w of Turing machines where Mw accepts the prefix of w of length 5 (i.e. the string formed by the first 5 characters ofw). Show that this language is recognizable (it is in RE).
Solution: A Turing machine for L:
(a) checkw - if it is not a code for a TM, reject (b) otherwise runMw on the first five letter of w
(c) if it accepts, stop and accept, otherwise reject or run forever 5. Let L={w:w is a decription of a TM and L(Mw) =∅}.
(a) Prove that L /∈R.
(b) Is it true that L∈RE?
(c) Is it true that L∈co RE?
Solution:
(a) Rice’s theorem. L1 =∅ ∈RE has this property,L2 = Σ∗ ∈RE does not have this property.
(c) It is in coRE. L={w|wis not a description of a TM, or L(Mw) accepts at least one word}
A Turing machine for L:
(a) checkw - if it is not a code for a TM, accept
(b) otherwise check all possible words withMw using the diagonal method (c) if there is one input it accepts, stop and accept
(b) Because L∈coRE\R, it cannot be in RE.
6. The languageLconsists of Turing machine descriptionsw, such that Mw accepts only strings of odd length (but not necessarily accepts all of these strings). Prove that
(a) L /∈R.
(b) L∈RE.
Solution:
(a) Rice’s theorem: L1 =}w| |w|= 3} ∈RE has this property,L2 = Σ∗ ∈REdoes not have this property.
(b) L={w|w is not a description of a TM, or L(Mw) accepts at least one even length word}
A Turing machine for L:
(a) checkw - if it is not a code for a TM, accept
(b) otherwise check all possible even length words with Mw using the diagonal method (c) if there is one input it accepts, stop and accept