Is this proof with the pumping lemma (no regular language) ok? - regular-language

I need to proof that a given language is not regular, could this work?
The language is M={a^m a^l c b^(m+l)|m,l in N} with the
alphabet = {a,b,c}.
Proof:
Be n in N arbitrary but firm. We choose the word w=a^(2n)cb^(2n) with w in M and |w|>=n.
Be w=xyz a arbitrary decomposition with y!=lambda and |xy|<=n.
Then we have x=a^(2i), y=a^(2j) and z= a^(2n-2i-2j)cb^(2n) for j!=0 and 2(i+j)<=2n.
Now we choose k=0. The we have xy^0z=a^(2n-2i)cb^(2n).
=> xy^0z is not in M because 2n-2i!=2n for j!=0.
=> M is no regular language.
Yeah or nah?
If you could tell me my mistakes i would be very thankful

Your idea is right. Just a few details:
"fixed" not "firm" (translation from German?)
You need to distinguish the n you choose and the constant from the pumping lemma (which you do not choose).
So:
Let K be the constant for M from the pumping lemma and let n be a natural number such that n>K.
We choose the word w=a^(2n)cb^(2n) with w in M and |w|>=K.
Be w=xyz a arbitrary decomposition with y!=lambda and |xy|<=n.
Then we have x=a^(2i), y=a^(2j) and z= a^(2n-2i-2j)cb^(2n) for j!=0 and 2(i+j)<=2n.
Now we choose k=0. The resulting word is xy^0z=a^(2n-2i)cb^(2n).
xy^0z is not in M because 2n-2i!=2n for j!=0.
=> M is no regular language.

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.

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!

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