infinite regular language and finite regular language proof - regular-language

Suppose L is an infinite regular language. Does it follow that there exists a finite language S such that L = SS* ? Prove or disprove by finding a counterexample.
What i have tried:
Intuitively this should be true. Any infinite language can be represented by a finite language S if S has the same alphabets as L e.g if L is the infinite language over the alphabet {a, b}* then S = {a, b} works, so essentially S contains just one occurrence of all the alphabets in L. Is this correct or am i missing something fundamental? or is this just not valid at all?
Any help would be appreciated!

My intuition on this is that it's not true. Let's take the example of the language of all odd-length strings over {a, b}. This is trivially regular, and trivially infinite. However, any finite subset of this language will have odd-length strings, and any infinite suffix would have to have an even length, so there is no reasonable construction of L = SS* for some finite language S.
I'll leave turning this intuition into a formal proof to the reader.

Here's an alternative counterexample that might be easier. Consider the infinite regular language ab*. Now suppose L = SS* for some S. Now, either S contains a string with a in it, or it does not. If it does, then L = SS* contains strings with multiple a's, so it cannot be the language ab*. If S does not contain a, then L = SS* contains no strings with any a's at all, and can't be the language ab*. In either case, L is not ab*, a contradiction. So L cannot be written as SS* for any S.

Related

Show is not regular with pumping lemma

I need help on this pumping lemma case:
L_1 :={a^n b^m c^k | n = m or k = 0}
Can someone explain how to handle k=0?
I started with abc^n, but I don't know how to split this in uvw.
Assume the language is regular. Then, by the pumping lemma for regular languages, strings in the language of length at least p can be written as uvx where |uv| <= p, |v| > 0 and for all n >= 0, u(v^n)x is also a string in the language. Let's choose the string a^p b^p c. This string is in the language because, while k is not equal to zero, it is the case that n = m. If we write uvx = a^p b^p c, the constraints tell us that the prefix uv can consist only of the symbol a (since |uv| <= p). But it also says we can pump some substring of this and get other strings in the language; this is a contradiction since changing the number of a without changing the number of b will make it so that n is not equal to m. Our assumption that the language was regular, and that the pumping lemma for regular languages applied to it, must have been incorrect. Ergo, the language is not regular.

How to Pumping lemma for Regular language

I have this problem that I need to prove that the language is not regular by using pumping lemma, but no matter how much I read how to do it, I still don't understand. Could someone please help how to solve this?
Show that L = { a^n c b^m | n, m are natural numbers and n < m} is not regular.
Choose a^p c b^2p. This string is in the language since p < 2p. Pumping any non-empty substring in the first p characters of this string up by a factor of more than p is guaranteed to cause the number of a to increase beyond the number of b. This contradicts the claim of the pumping lemma that doing that on a string in a regular language must give another string in that language. So, the language cannot have been regular.

Finding error in proof stating the language L = {0^(n)1^(n) | n>0} is a regular expression

Proof: Let M be the following NFA:
Automata for L
Now, if x is in L, then x = 0^(n)1^(n). Thus while processing x, M will start in state q0, loop in state q0 n times, then transition to state q1 on the rst 1, and follow the loop in state q1 a total of n 􀀀 1 times. Since it ends in state q1, x will be accepted. Thus M recognizes every string in L, so L is NFA-recognizable (and by Kleene's theorem, is thus regular).
You've shown that M accepts every string of L. But that doesn't mean that M recognizes L: for that to be true, you have to also show that M accepts exactly the strings of L and no others (or equivalently: it doesn't accept any string not in L). Unfortunately in your case, M does accept some non-L strings: for example, "011".
Your proof is indeed wrong. To prove that the language L is regular you need to prove that there exists a finite state automaton M that recognizes the language L. Hence, there are three things that you need to prove about the automaton M:
The automaton M exists.
The automaton M recognizes the language L (nothing more, nothing less).
The automaton M has a finite number of states.
The problem with your proof is that the automaton you posted does not recognize the language L:
This automaton recognizes the language 0*1+ which is not the same as the language L (0^n1^n). Yes, every string in L is recognized by this automaton. However, this automaton also recognizes strings like 1 which is clearly not in L. Hence, using this automaton in your proof is wrong.
So, how do you prove that the automaton M exists? Well, the only way to prove that the automaton M exists is by showing that M exists. The only problem is that L is not a regular language. Hence, there is no finite state automaton M that recognizes L.
The opposite way is to prove that L is not a regular language. To prove that L is not a regular language you need to prove that there is no finite state automaton M that recognizes L. This is an easier proof because you don't have to find the automaton M. You can just assume that it exists.
Here's what you need to do to prove that L is not a regular language:
Assume that an automaton M exists that recognizes the language L.
Show that M must necessarily have an infinite number of states.
The standard way of proving that an automaton M cannot have a finite number of states is by using the Pumping Lemma. I'll leave it as an exercise for you to figure that out because it's not in the scope of your question.

If pref(L) is regular, does that imply L is also regular?

I have this exercise for homework:
Say we have a language L. we know that the language pref(L) (all the prefixes of L, including all the words in L itself) is a regular language. Does this imply that the language L is regular as well?
I took the NFA of pref(L) and divided it (via 2 epsilon transitions from q0) to 2 separate NFA's, as 1 defines L and the other defines pref(L)\L.
What I actually got is a NFA for L, which means it is regular.
I am not sure this is the way or if it legal. I'd be glad for another lead.
Thanks in advance,
Yaron.
It is not necessarily the case that if pref(L) is regular, then L is regular as well.
As an example, let Σ = {a} be a unary alphabet. I'm going to claim that if L is any infinite language over Σ, then pref(L) = Σ*. To see this, first note that pref(L) &subseteq; Σ* because every pref(L) is a language over Σ. Now, consider any string in Σ*, which must have the form an. If L is an infinite language over Σ, it must contain at least one string of the form am where m ≥ n. Then an would be a prefix of am, so an &in; pref(L). This shows that Σ* &subseteq; pref(L) and that pref(L) &subseteq; Σ*, so in this case Σ* = pref(L).
Now, all we need to do is find a nonregular language over Σ = {a}. As an example, take the language { a2n | n &in; N } of all strings whose length is a power of two. It's possible to prove using either the Myhill-Nerode theorem or the pumping lemma that this language is not regular. However, by the above result, we know that pref(L) is a regular language.
Hope this helps!

If L* is regular, then is L regular?

I've tried to look for the answer and I'm getting conflicting answers so I'm not sure. I know the reverse is true, that if L is regular then L* is regular under closure.
I imagine that if L* is regular then L is regular because the subset of L* should be regular and L is part of that subset.
If L* is regular, then L is not necessarily regular. For example, consider any nonregular language L over an alphabet Σ such that Σ ⊆ L. (That is, imagine you have a nonregular language where each individual character in the alphabet is a string in L.) In that case, L* = Σ*, since you can form any string as the concatenation of all the individual characters of Σ.
Here's one possible example. Let Σ = {a} and consider the language L = { a2n | n ∈ N }. This language is not regular, and you can prove it using either the pumping lemma for regular languages or the Myhill-Nerode theorem. However, the language L* is the language a*, which is regular. To see this, notice that since L contains the string a, the language L* contains all strings of the form an for any natural number n.
Another option: pick L to be any nonregular language over Σ, then consider the language L ∪ Σ. This is also a nonregular language (if L ∪ Σ were regular, then we could subtract out each character added in via the union, leaving a regular language at each step, to show that L is regular), and it satisfies the above requirements.
Hope this helps!
Take L = {a,b}*, which is regular, but has a non-regular subset L={a^n b^n} (this one can be proved to be non regular by pumping lemma...), so it's not the case that all subsets of a regular language are regular.

Resources