Is the language $L = \{\omega : \omega\text{ contains exactly one 'foobar'}\}$ regular? I have a hunch that it is non-regular because a regular expression representing the language must remember that is has encountered the substring 'foobar.'
However, I can't seem to use the pumping lemma to prove that it is indeed not regular. Say $s \in L$ and $s$ is of the form
[substring not containing 'foobar']foobar[substring not containing 'foobar'].
Then, $L$ is pumpable because $s = xyz \in L$ for $|s| > p$, where $y$ can be a substring within either section labeled [substring not containing 'foobar']
. If we repeat $y$ $j$ times, $xy^jz$ will still be in $L$.
However, again, $L$ doesn't seem regular to me... why is my pumping lemma proof erring?
foobar
that it sees, and it never has to count higher than 2 to know the answer. – MJD Sep 29 '12 at 05:40foobar
that it sees" might be a bit misleading to the question at hand. Perhaps it is better to say that similar to some (caricatures of) primitive tribes, DFAs can count the number of occurrences offoobar
as 0, 1, 2, 3, $\ldots$ , $n-1$, many. – user642796 Sep 29 '12 at 07:38