Is a subset of a context free language decidable? - formal-languages

L is a context free language and J is a subset of L. Is J decidable?
Context free languages are decidables.

Σ* is context-free (indeed, it's regular) and it has a lot of subsets.

If L is a context-free language of infinite size, then there are subsets J of L that are decidable, and some that are undecidable. For example, the empty subset is decidable.
To show that there are undecidable subsets, consider the set of all subsets of L. This is an uncountably infinite set since L is an infinite set (in fact, L is countable, but that's irrelevant). But the set of all decidable sets is countable, hence there exist subsets of L that are not decidable.

Related

How to demonstrate a set is decidible, semi-decidible or not semi-decidible?

I have been asked to prove if the following set is decidible, semi-decidible or not semi-decidible:
In other words, it is the set of inputs such that exists a Turing Machine encoded with the natural y with input p that returns its input.
Consider the set K as the set of naturals such that the Turing machine encoded with x and input x stops. This is demonstrated to be a non-decidible set.
I think that what I need is to find a reduction of K to L, but I don't know how to prove that L is decidible, semi-decidible or not semi-decidible.
L may not look decidable at first glance, because there is this nasty unbounded quantifier included, which seems to make necessary a possibly infinite search when you look for a y satisfying the condition for a specific p.
However, the answer is much simpler: There is a turing machine M which always returns its input, i.e. M(p) = p holds for all p in the considered language. Let y be a code of M. Then you can use this same y for all p, showing that L contains all words of the language. Hence L is of course decidable.
In fact, this is an example to demonstrate the principle of extensionality (if two sets have the same elements and one is decidable, then the other is decidable too, even if it doesn't look so).

How is Turing Machine which accepts nothing is not Recursively Enumerable?

How is Turing Machine which accepts nothing is not Recursively Enumerable.
We will use an indirect argument to show that the language of encodings of Turing Machines that accept nothing cannot be recursively enumerable.
Lemma 1: if L and its complement are recursively enumerable, then L is recursive.
Proof: let M be a TM that enumerates L and M' be a TM that enumerates the complement of L. Given any string s, we can decide whether s is in L as follows. Begin running M and M', interleaving their executions so that each one eventually gets an arbitrary amount of runtime. If s is in L, M will eventually list it, at which point we know s is in L and we halt-accept. If s is not in L, M' will eventually list it, at which point we know s is not in L and we halt-reject. Thus, for any s, we can halt-accept if s is in L or halt-reject otherwise. Therefore, L and its complement are recursive.
Lemma 2: The language of encodings of Turing Machines that accept something is recursively enumerable.
Proof: The set of all Turing Machine encodings is countable, and so is the set of all possible tape inputs. Thus, the set (M, s) of pairs of machines and inputs is countable. We may therefore assume some ordering of these pairs p1, p2, ..., pk, ... For each pair p = (M, s), begin executing machine M on input s, interleaving the executions of pairs p1, p2, ..., pk, ... so each eventually gets an arbitrary amount of runtime. If pk enters the halt-accept state, we may immediately list M as a TM that accepts something (namely, the corresponding s), and we can even terminate all other running instances checking the same M (and forego starting any new ones). Any machine M that accepts some input will eventually be started and will eventually halt-accept on an input, so all machines are eventually enumerated.
Lemma 3: The language of encodings of Turing Machines that accept nothing is not recursive.
Proof: This is a direct result of Rice's Theorem. The property "accepts nothing" is a semantic property of the language itself and is true for some, but not all, languages; therefore, no TM can decide whether another TM accepts a language with the property or not.
Theorem: The language of encodings of Turing Machines that accept nothing is not recursively enumerable.
Proof: Assume this language is recursively enumerable. We have already proven in Lemma 2 that its complement is recursively enumerable. By Lemma 1, then, both languages are recursive. However, Lemma 3 proves that the language is not recursive. This is a contradiction. The only assumption was that the language is recursively enumerable, so that assumption must have been false: so the language is not recursively enumerable.

Prove that all P problems except {} and {a,b}* are complete

It is easy to say that {} and {a,b}* are not P complete because other problems in P can't be reduced to these because {} can't accept anything and {a,b}* cannot reject anything. So, proper mapping can't be done with a reduction function.
But I'm stuck with proving that every other problem in P is P-complete.
You have to be careful when talking about P-completeness because this means different things to different people based on what type of reductions you're allowing. I'm going to assume that you're talking about using polynomial-time reductions. In that case, choose any language L ∈ P other than ∅ or {a, b}*. Now pick any language M in P that you like. Here's a silly reduction from M to L:
Given an input string w, decide whether w in M in polynomial time (this is possible because M ∈ P.)
If w ∈ M, output any string w ∈ L that you'd like (at least one exists because L is nonempty.)
Otherwise, w ∉ M, so output any string w ∉ L that you'd like (at least one exists, because L isn't {a, b}*.
This reduction takes polynomial time because each step takes polynomial time, so it's a polynomial-time reduction from an arbitrary P language to L. Therefore, L is P-complete with respect to polynomial-time reductions.
Generally speaking, when you talk about notions of completeness, you have to make sure that your reductions are given fewer computational resources than the class of solvers that you're using, or you can do weird things like what's described here that make reductions essentially useless.

Challenge on Alphabet and Formal Grammar and Language

We know set A is countable if A is finite or in a one-to-one mapping to natural numbers.
Suppose ALPH be an arbitrary finite alphabet.
I summarize my inference:
a) Each arbitrary Language on ALPH is Countable. (I think this is True)
b) the set of all language from ALPH is Countable.(I think this is False)
c) for Each arbitrary Language on ALPH we have a generative formal grammar. (I think this is False)
d) Each arbitrary Language on ALPH that can be generated by formal grammar, is recursive. (I think this is True)
anyone could help me, and maybe correct me?
Without loss of generality, we can assume that ALPH is merely the set {0,1}. (Any other finite language can of course be encoded using the set {0,1}). Assuming that by a language L that you intend some arbitrary subset of ALPH*, we can assume that L is an arbitrary subset of {0,1}*.
Let S = {0,1}*.
a) The set S is countable. Since L is a subset of S, L is countable.
b) The set of all languages over S then is the powerset of S, which can be put into 1-1 correspondence with the Real numbers. Hence, not countable.
c) I believe that this is false, agreeing with your supposition. However, it depends on your definition of a 'generative formal grammar'. If you allow for formal grammars where individual rules of the grammar are undecidable, and/or allow for infinite generation rules, this becomes less clear. For any particular definition for 'generative formal grammar', where the collection of 'generative formal grammars' is enumerable, then of course, the answer is false.
d) In general, I believe that the answer to this is false. If you restrict yourself to formal grammars corresponding to context-free languages, then of course, your answer is true. However, consider http://en.wikipedia.org/wiki/Post_correspondence_problem The problem is undecidable, yet the generation rules are pretty clear.

Exhibiting an algorithm that determines if L = L*, given any regular language L

I am studying membership algorithms and I am working on this particular problem which says the following:
Exhibit an algorithm that, given any regular language L, determines whether or not L = L*
So, my first thought was, we have L* which is Kleene star of L and to determine if L = L*, well couldn't we just say that since L is regular, we know L* is by definition which states that the family of regular languages is closed under star-closure.
Therefore L will always be equal to L*?
I feel like there is definitely a lot more to it, there is probably something I am missing. Any help would be appreciated. Thanks again.
since L is regular, we know L* is by definition which states that the family of regular languages is closed under star-closure. Therefore L will always be equal to L*?
No. Regular(L) --> Regular(L*), but that does not mean that L == L*. Just because two languages are both regular does not mean that they are the same regular language. For instance, a* and b* are both regular languages, but this does not make them the same language.
A example of L != L* would be the language L = a*b*, and thus L* = (a*b*)*. The string abab is part of L* but not part of L.
As far as an algorithm goes, let me remind you that the concept of a regular language is one that can be parsed by a DFA - and for any given DFA, there is a single optimal reduction of that DFA.
The implication that you stated is wrong. Closedness under the Kleene star means only that L* is again regular, if L is regular.
One possibility to check whether L = L* is to compute the minimal automaton for both and then checking for equivalence.

Resources