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
Related
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.
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.
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.
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!
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.