1

L = {w belongs to {0, 1}* ∣ w has at most three 0’s}. Why is this regular language?

According to pumping lemma, what I think is that.... Suppose $x$=$0^2$, $y$=$0^1$, $z$=$1^n$ ($w=xyz$=${0^2}{0^1}{1^n}$), then if we pump $y$, we may have more than three $0$s. What am I missing?

Mansumen
  • 43
  • 1
  • 6
  • You're missing the pumping lemma's statement. ​ ​ –  Aug 12 '15 at 02:21
  • What do you mean? As far as I know, pumping lemma is, If $L$ is a regular language, there exists $n$ such that for any string $w$ in L and $|w|$>=$n$ we can write $w=xyz$ such that 1)$|xy|$<=$n$, 2)$|y|>=1$, 3)$w=xy^iz$ for all $i$>=0, – Mansumen Aug 12 '15 at 02:28
  • 1
    Welcome to Computer Science Stack Exchange. Please read http://cs.stackexchange.com/tour, if you have not yet done so. --- You are confusing an existential quantifier for a universal one. The pumping lemma states that there is a decomposition $xyz$ of the string such that you can pump $y$. But your are not free to chose it: that would require universal quantification (for all vs there is). – babou Aug 12 '15 at 02:31
  • I do not quite understand. Do you mean that I cannot choose $y=0^1$? – Mansumen Aug 12 '15 at 02:35
  • 1
    Oh I think I understood. So if I choose $y=0^1$, I am just proving for this specific partition, but there may be some other partition that satisfy the pumping lemma.. Therefore, if there exists a single case that satisfy the pumping lemma, we say that this language $L$ is regular.. Am i correct? – Mansumen Aug 12 '15 at 02:45
  • 1
    No, we say the pumping lemma does not prove that the language is not regular. ​ –  Aug 12 '15 at 03:06
  • @ Ricky Demer I understand that if a language doesn't satisfy pumping lemma, the language is not regular. Is it wrong? – Mansumen Aug 12 '15 at 03:50
  • To prove that $L$ is regular, consider that regular languages are closed under set difference. Try to think of two regular expressions, $L_1$ and $L_2$, such that $L = L_1 \setminus L_2$. Set intersection is another way of thinking about the problem. – Pseudonym Aug 12 '15 at 03:52
  • Intuitively: you only need a constant amount of memory to count the 0s. Formally: develop an automaton that does the counting. – reinierpost Aug 12 '15 at 07:52

3 Answers3

1

As the other answers have said, the key is in the statement of the pumping lemma.

The key to understanding how to apply the pumping (and how not to as well) is paying close attention to the quantifiers ("for all" and "there exists") and the order they come in:

The Pumping Lemma for Regular Languages

If the language $L \subseteq \Sigma^{\ast}$ is regular, then there exists a constant $p \geq 1$ such that for every string $s \in L$ where $|s| \geq p$, there exists a division of $s = xyz$ such that:

  1. $|xy| \leq p$,
  2. $|y| \geq 1$, and
  3. for all $i \in \mathbb{N}$, $s' = xy^{i}z \in L$.

So if you wanted to show that a language obeyed the pumping lemma (note that is would not prove that it's regular, there are non-regular languages that can also be pumped), you have to first determine the pumping length $p$, then look at every string $s \in L$ and show that there is some way that $s$ can be broken down so that it can be pumped according to the conditions.

So in your case, if we ignore that you don't know $p$, the mistake is showing that one way of breaking it up doesn't work. So assuming that the pumping length is at least $4$ (it is, but why...?), then the breakdown $x = 000$, $y = 1$, $z = 1^{n-1}$ can quite happily be pumped.

When this has settled in, it also shows how the proofs of non-regularity via the pumping lemma work. You just have to find one string, but you have to show that there is no workable breakdown for that string.

Luke Mathieson
  • 18,125
  • 4
  • 55
  • 86
  • Thanks for you answer! So my conclusion to this problem is that, since there exists at least one case that satisfies the pumping lemma (the breakdown $x = 000$, $y = 1$, $z = 1^{n-1}$), I can say that the language L is indeed a regular language.. Correct? – Mansumen Aug 12 '15 at 08:30
  • 1
    Nearly - it means regularity of $L$ does not contradict the pumping lemma, so that you can not say that $L$ is not regular (recall that the main use of the pumping lemma is proving non-regularity). To prove that it actually is regular, you could construct a regular grammar, finite automaton, or regular expression. – Klaus Draeger Aug 12 '15 at 14:08
  • @KlausDraeger Thanks. Have another question. What if I made up my breakdown as I did in the original question, and concluded that $L$ is not regular? How can someone tell me that I am wrong using the pumping lemma? I am sorry it is a silly question, but I want to fully understand the concept. Thanks again. – Mansumen Aug 13 '15 at 02:28
  • That is because the lemma only requires that there is some breakdown for which the pumping works; the existence of another breakdown for which it doesn't work is not a contradiction. So a proof of non-regularity would have the form "Let $xyz$ be any decomposition satisfying the conditions. The possible cases are (...). In each case, pumping takes us out of $L$". – Klaus Draeger Aug 13 '15 at 04:45
0

You can't use the pumping lemma to prove that a language is regular.

The pumping lemma can be used to prove that a language is not regular, but it doesn't let you prove that a language is regular.

(Why? The pumping lemma says something like "If $L$ is regular then (stuff)." If you prove that (stuff) is false, then you can conclude that $L$ is not regular; that follows from the contrapositive of the pumping lemma. But if you prove that (stuff) is true, you can't conclude anything: $L$ might be regular, or it might not; the pumping lemma makes no promises.)

Instead, to prove that a language is regular, you should use the techniques described in How to prove a language is regular?

D.W.
  • 159,275
  • 20
  • 227
  • 470
  • Ok I understand you point. But still, what is wrong about my case shown above question? Because if I show it like that, I show that L is not regular – Mansumen Aug 12 '15 at 05:13
  • @Mansumen, I've elaborated in my answer to try to explain the error in your reasoning in more detail. – D.W. Aug 12 '15 at 05:36
0

We use the pumping lemma to prove that a determinate language is not regular.

If you want to prove that a determinate language $L$ is regular then you have to write a regular expression, draw a NFA or draw a DFA that denotes $L$.

For example I can say that $L=\{w \in \{0,1\}|$ $w$ has at most three 0's $\}$ is regular because I found the regular expression:

$RE$ = $1^*(0|\epsilon)1^*(0|\epsilon)1^*(0|\epsilon)1^*$

and $\mathscr{L}(RE)=L$

Renato Sanhueza
  • 1,335
  • 8
  • 21