Show is not regular with pumping lemma - regular-language

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.

Related

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.

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.

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

Is this the correct way to use the pumping lemma?

I've been watching lectures from Coderisland on YouTube about finite state machines, DFAs and NFAs, and in one discussion he talks about how to use the pumping lemma to show how a language is not regular. I don't know quite how to apply the lemma and want to understand if I'm doing it right. If I had something like:
w = {anbk, n =/= k}
am I correct in that I can say that:
h = {anbn + r, r > 0} is a subset of w, and thus if I show by the lemma that h is not regular, that w must not be regular since h is a subset of w.
The way I would show this is as follows:
h = xyz
|xy| <= n
x = an-r
y = ar
z = bn + r
xyz = an-rarbn + r
xy2z = an-ra2rbn + r = an + rbn + r
Thus h cannot be regular since an + rbn + r is not of the form {anbn + r, r > 0}, and since h is not regular w must not be regular, since h is an element of w.
Have I applied it correctly? I understand how to apply it for an easy language like {anbn}, because I can apply the lemma directly to this language, but the only way I could think of for my language was to create a subset that belongs to my language, and apply the lemma to that.
If I haven't applied it correctly, is there a way to show that my language is not regular (or regular), using another lemma, or perhaps with closure properties?
This is a really awesome topic, even if I don't understand the pumping lemma fully, I'm excited to explore it further!
There are two mistakes in your proof.
First, is the mistake in this statement of yours:
if I show by the lemma that h is not regular, that w must not be regular since h is a subset of w.
Because consider the language L = {anbm | n,m natural numbers}
h is a subset of L, but clearly L is regular, as it can be represented by the regular expression a*b*.
But you're so close to the solution, in which actually you don't need to consider h. You should instead choose a string in w so that however you apply Pumping Lemma to it, you will always get a string which is not in w.
Now this is your second mistake in step 3 of your pumping lemma. In pumping lemma, we are to prove that "there is an element of that language, such that however you apply pumping lemma to that string, you will always get a string that is outside the language".
In your proof, you deliberately pick x = an-r, without explaining why it must be the case. There might be the case that actually x = an-2 for example. In this case, fortunately, you still have the same conclusion that it doesn't satisfy pumping lemma (and hence it's not regular) since by considering xyr+1z you will definitely have more a's than b's.
One correct way to prove your problem is applying pumping lemma to it directly (there are other methods such as using complement, or intersecting it with a regular language and prove that the intersection is not regular), but for the purpose of explaining pumping lemma, I will show you how to apply pumping lemma for this language.
So, the problem states that we have w = {anbk, n=/=k} and we are to prove that it's not regular.
Now consider the string s = anbn!+n (that is, n number of a's followed by n factorial plus n number of b's). By pumping lemma, if w is regular, there should be xyz such that s = xyz, and that |xy|<=n.
Since |xy|<=n and that we have an at the beginning of s, then both x and y must contain only a's. Let y = am. We know that 1<=m<=n.
Now we have the difference between the number of a's and b's is (n!+n)-n = n!. This number is divisible by any number in the range 1 to n, inclusive. So we have n!/m is a whole number. Let q = n!/m.
Considering the string xyq+1z, we have the number of a's as (n-m)+(q+1)*m = n-m+qm+m = n+qm = n+n!, which is the same as the number of b's. So xyq+1z is not in the language w since number of a's is the same as the number of b's. Therefore the language w doesn't satisfy the pumping lemma.
Therefore w is not regular.
To address the question in your comment, prove using complement.
Suppose w is regular. Then the complement w' should also be regular.
But the complement w' = {anbn, n natural number} is not regular (you showed that already, right?).
Therefore w is not regular.

Resources