Which of the following is true for the language
View worked solution
Answer: D
Let the language be .
We can analyze the properties of as follows:
- Not Regular: We can prove this using the Pumping Lemma for regular languages. Suppose is regular with pumping length . Choose a prime . Let . We split such that and . According to the pumping lemma, for all . The length of is . If we choose , the length becomes . Since and , the length is a composite number. Thus, , which is a contradiction. Hence, is not regular.
- Not Context-Free: By Parikh's Theorem, any context-free language over a unary alphabet (a single-letter alphabet like ) must also be regular. Since is over a unary alphabet and is not regular, it cannot be context-free.
- Accepted by a Turing Machine: Primality testing is a decidable problem. We can easily construct a Turing Machine that, given an input , systematically tests if has any divisors other than and (by simulating division). Since the TM halts and accepts if is prime, the language is recursive (and hence accepted by a Turing Machine).
Thus, the language is neither regular nor context-free, but it is accepted by a Turing machine.
Free practice · Your answers on this page are not saved.
