-1
$\begingroup$

The pumping lemma for regular languages states:

Specifically, the pumping lemma says that for any regular language L there exists a constant p such that any word w in L with length at least p can be split into three substrings, w = xyz, where the middle portion y must not be empty, such that the words xz, xyz, xyyz, xyyyz, … constructed by repeating y an arbitrary number of times (including zero times) are still in L.

Now what's the unambigious CFG that produces this (recognizes strings of the form $xy^kz$)?

if $x=z=a$ and $y=b$, then

$X \rightarrow aX | Xa | bX | Xb | a | b$

is ambiguous.

$\endgroup$
  • 3
    $\begingroup$ Please make sure you know what you want to ask before posting. Wasting people's time by changing your question in fundamental ways is not nice. $\endgroup$ – Raphael Dec 29 '15 at 14:36
  • $\begingroup$ The Pumping lemma does not claim the existence of such a grammar. But since these words are all in the language L (that is the claim), just use any grammar for L. It remains to see why there are always unambiguous grammars for regular languages, but that's not too hard. $\endgroup$ – Raphael Dec 29 '15 at 14:39
1
$\begingroup$

For your first question, do check out the pumping lemma for regular languages. It is quite different from what you state.

For the second one, it is the set of strings of $a$ with exactly one $b$. Use:

$\begin{align} S &\rightarrow a S \mid b A \mid b \\ A &\rightarrow a A \mid a \end{align}$

Clearly non-ambiguous. Even a regular grammar.

$\endgroup$
  • $\begingroup$ Is my sentence about the pumping lemma really incorrect? $\endgroup$ – mavavilj Dec 29 '15 at 13:32
  • $\begingroup$ @mavavilj, yes. $\endgroup$ – vonbrand Dec 29 '15 at 13:34
  • $\begingroup$ Then what does: "Specifically, the pumping lemma says that for any regular language L there exists a constant p such that any word w in L with length at least p can be split into three substrings, w = xyz, where the middle portion y must not be empty, such that the words xz, xyz, xyyz, xyyyz, … constructed by repeating y an arbitrary number of times (including zero times) are still in L." mean? $\endgroup$ – mavavilj Dec 29 '15 at 13:34
  • $\begingroup$ @mavavilj, you see the statemement is significantly longer, with a lot of qualifications. $\endgroup$ – vonbrand Dec 29 '15 at 13:35
  • 1
    $\begingroup$ @mavavilj, sorry I won't run around chasing your ever changing question. $\endgroup$ – vonbrand Dec 29 '15 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.