We've seen several ways of representing regular languages:
We can lots of interesting things with regular languages, but there are many languages that are not regular:
These languages have no finite automata which recognizes them, and no regular expression which generates them.
Today we will look at how we can show that a language is not regular.
The pumping lemma states that all regular languages have a certain property. If we can show that a language does not have that property, then it must not be regular.
The pumping lemma states:
If $A$ is a regular language, then there is a number $p$ where if $s$ is any string in $A$ of length at least $p$, then $s$ may be divided into three pieces $s = xyz$ satisfying the following:
If $A$ is a regular language, then we know some DFA $M$ recognizes it. We can assign $p$ to be the number of states of $M$.
We then choose any string $s$ that is part of $A$ and has length at least $p$.
We then look at the states that $M$ is in as it computes $s$. It will visit exactly $n + 1$ states, when $n$ is the length of $s$:
By the pigeonhole principle, we must visit some state twice!
The part of s that comes before the repeated state is $x$. The part between is $y$. The part after is $z$.
This satisfies the three conditions:
The big idea here is that with a finite number of states, a DFA cannot produce strings of arbitrary length without at some point returning to the exact same state it had been at previously.
How can we demonstrate the pumping lemma for the language generated by $01^\ast0$?
The main use of the pumping lemma is to prove that languages are not regular. The basic idea is this:
Given a language $L$ we suspect to be non-regular,
Note that, the pumping lemma holds for any choice of $p$ or $s$. A non-regular language may well have some strings in it that can be pumped!
Let $B = \{0^n1^n \ |\ n \geq 0\}$
There are three cases for our choice of $y$:
No matter the choice of $y$, we cannot pump $y$ without leading us to strings which are not part of our language.
Therefore the pumping lemma does not hold for $B$ and it must be non-regular.
Copyright © 2024 Ian Finlayson | Licensed under a Creative Commons BY-NC-SA 4.0 License.