Proving Regular Languages - regular-language

I have to prove this statement is false.
If L1 = {ab| a∈L2, b∉L2} is a regular language, then L2 is a regular language.
(a and b are strings.)
(Assume L1 and L2 have the same alphabets.)
My work:
The question can be rewritten as: if L2 is regular, then L1
is non-regular. (Prove this is true)
proof by contrapositive: If L2 is regular, then L1={ab| a∈L2, b∉L2} is
non-regular
I'm not sure what to do after this line. Is that the right approach?
Can someone give me some hints on how to do this?

Let A = "L1 = {ab| a∈L2, b∉L2} is a regular language".
Let B = "L2 is a regular language".
The problem is to prove that A → B is false. This is equivalent to proving A ∧ ¬B. Which in English, reads:
L1 = {ab| a∈L2, b∉L2} is a regular language but L2 is not a regular language.
So one tactic might be to find a non-regular L2 which leads to L1 being regular. If you can do that then you have a counter-example and so you've proven the original statement false.

Related

infinite regular language and finite regular language proof

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.

Is it possible for a subset of a non-context free language to be context-free?

For example, if I have a non-context free language of B, is there such a context free language A such that A is a subset of B? I have been thinking of examples but unable to think of any valid ones.
I thought I got it when I said that A = {A = {w | w is of even length and w ∈ {a, b, c}}, which is context-free, and B = {ww | w ∈ {a,b,c}}, which is not context free. However, I realized that there are some strings A can produce that B cannot, and therefore, A is not a subset of B.
Does anyone know of any examples that could be valid in my situation?
Any finite set of strings is a context-free language. (Indeed, it is a regular language.) So any finite subset of a language is context-free, regardless of what the language is.
Another trivial case is the language L = L1 ∪ L2 where the alphabet of L1 is Σ1 and the alphabet of L2 is Σ2 and Σ1 ∩ Σ2 = ∅. Now L is context-free only if both L1 and L2 are context-free. (This is not the case if the alphabets are not disjoint.) So if exactly one of L1 and L2 is context-free, then it is a subset of the non-context-free language L.
If neither of those are interesting enough for you, then the language { a* } (where a is a symbol) is a subset of { ww | w ∈ {a, b}* }. Another subset of the same classic non-context-free language is { ww | w ∈ {a, b}* ∧ w = wR } (that is, the language of all duplicated even-length palindromes) which is context-free because it is exactly the same as { wwR | w ∈ {a, b}* ∧ w = wR }, as a result of the second condition.

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) ⊆ Σ* 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 ∈ pref(L). This shows that Σ* ⊆ pref(L) and that pref(L) ⊆ Σ*, 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 ∈ 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.

Struggling to understand Myhill-Nerode

I think I know the pumping lemma and was told that Myhill-Nerode is a very elegant way to show that something is regular or not regular. But I am having a lot of trouble with it. Take this for example:
= {0k, k = 2n, n >̲ 1}
My language is the repetition of 0 to a length that's a power of 2. I want to use the Myhill-Nerode to show that this is either regular or not regular. Is it possible?
I know how to set this up to resemble other Myhill-Nerode looking proofs but I don't understand the equivalence concept that much.
I could say that I have some and where ≠ and both are of the form 2h and , I then define , and so that:
= 0j/2
= 0p/2
= 0j/2
Where = 0j/20j/2 = 0j is in my language since is of the form 2n, however = 0p/20j/2 is not guaranteed to be in my language for every p and j, since ≠
Given a languages L, two strings u, v 2 L are equivalent if for all
strings w belong to sigma * we have that u.w belongs to L iff v.w belongs to L
consider the set of {0,0^2,0^4,0^8....}, in this case for some m and n 0^m and 0^n should be mapped to the same equivalence class or else there would be infinite equivalence classes making it non-regular by Myhill-Nerode theorem. However 0^m.0^m belong to L but 0^n.0^m would not ..Hence

Resources