
- Automata Theory - Applications
- Automata Terminology
- Basics of String in Automata
- Set Theory for Automata
- Finite Sets and Infinite Sets
- Algebraic Operations on Sets
- Relations Sets in Automata Theory
- Graph and Tree in Automata Theory
- Transition Table in Automata
- What is Queue Automata?
- Compound Finite Automata
- Complementation Process in DFA
- Closure Properties in Automata
- Concatenation Process in DFA
- Language and Grammars
- Language and Grammar
- Grammars in Theory of Computation
- Language Generated by a Grammar
- Chomsky Classification of Grammars
- Context-Sensitive Languages
- Finite Automata
- What is Finite Automata?
- Finite Automata Types
- Applications of Finite Automata
- Limitations of Finite Automata
- Two-way Deterministic Finite Automata
- Deterministic Finite Automaton (DFA)
- Non-deterministic Finite Automaton (NFA)
- NDFA to DFA Conversion
- Equivalence of NFA and DFA
- Dead State in Finite Automata
- Minimization of DFA
- Automata Moore Machine
- Automata Mealy Machine
- Moore vs Mealy Machines
- Moore to Mealy Machine
- Mealy to Moore Machine
- Myhill–Nerode Theorem
- Mealy Machine for 1’s Complement
- Finite Automata Exercises
- Complement of DFA
- Regular Expressions
- Regular Expression in Automata
- Regular Expression Identities
- Applications of Regular Expression
- Regular Expressions vs Regular Grammar
- Kleene Closure in Automata
- Arden’s Theorem in Automata
- Convert Regular Expression to Finite Automata
- Conversion of Regular Expression to DFA
- Equivalence of Two Finite Automata
- Equivalence of Two Regular Expressions
- Convert Regular Expression to Regular Grammar
- Convert Regular Grammar to Finite Automata
- Pumping Lemma in Theory of Computation
- Pumping Lemma for Regular Grammar
- Pumping Lemma for Regular Expression
- Pumping Lemma for Regular Languages
- Applications of Pumping Lemma
- Closure Properties of Regular Set
- Closure Properties of Regular Language
- Decision Problems for Regular Languages
- Decision Problems for Automata and Grammars
- Conversion of Epsilon-NFA to DFA
- Regular Sets in Theory of Computation
- Context-Free Grammars
- Context-Free Grammars (CFG)
- Derivation Tree
- Parse Tree
- Ambiguity in Context-Free Grammar
- CFG vs Regular Grammar
- Applications of Context-Free Grammar
- Left Recursion and Left Factoring
- Closure Properties of Context Free Languages
- Simplifying Context Free Grammars
- Removal of Useless Symbols in CFG
- Removal Unit Production in CFG
- Removal of Null Productions in CFG
- Linear Grammar
- Chomsky Normal Form (CNF)
- Greibach Normal Form (GNF)
- Pumping Lemma for Context-Free Grammars
- Decision Problems of CFG
- Pushdown Automata
- Pushdown Automata (PDA)
- Pushdown Automata Acceptance
- Deterministic Pushdown Automata
- Non-deterministic Pushdown Automata
- Construction of PDA from CFG
- CFG Equivalent to PDA Conversion
- Pushdown Automata Graphical Notation
- Pushdown Automata and Parsing
- Two-stack Pushdown Automata
- Turing Machines
- Basics of Turing Machine (TM)
- Representation of Turing Machine
- Examples of Turing Machine
- Turing Machine Accepted Languages
- Variations of Turing Machine
- Multi-tape Turing Machine
- Multi-head Turing Machine
- Multitrack Turing Machine
- Non-Deterministic Turing Machine
- Semi-Infinite Tape Turing Machine
- K-dimensional Turing Machine
- Enumerator Turing Machine
- Universal Turing Machine
- Restricted Turing Machine
- Convert Regular Expression to Turing Machine
- Two-stack PDA and Turing Machine
- Turing Machine as Integer Function
- Post–Turing Machine
- Turing Machine for Addition
- Turing Machine for Copying Data
- Turing Machine as Comparator
- Turing Machine for Multiplication
- Turing Machine for Subtraction
- Modifications to Standard Turing Machine
- Linear-Bounded Automata (LBA)
- Church's Thesis for Turing Machine
- Recursively Enumerable Language
- Computability & Undecidability
- Turing Language Decidability
- Undecidable Languages
- Turing Machine and Grammar
- Kuroda Normal Form
- Converting Grammar to Kuroda Normal Form
- Decidability
- Undecidability
- Reducibility
- Halting Problem
- Turing Machine Halting Problem
- Rice's Theorem in Theory of Computation
- Post’s Correspondence Problem (PCP)
- Types of Functions
- Recursive Functions
- Injective Functions
- Surjective Function
- Bijective Function
- Partial Recursive Function
- Total Recursive Function
- Primitive Recursive Function
- μ Recursive Function
- Ackermann’s Function
- Russell’s Paradox
- Gödel Numbering
- Recursive Enumerations
- Kleene's Theorem
- Kleene's Recursion Theorem
- Advanced Concepts
- Matrix Grammars
- Probabilistic Finite Automata
- Cellular Automata
- Reduction of CFG
- Reduction Theorem
- Regular expression to ∈-NFA
- Quotient Operation
- Parikh’s Theorem
- Ladner’s Theorem
Pumping Lemma for Regular Languages
Pumping Lemma provides a method to prove that certain languages are not regular. The Pumping Lemma states that for any regular language, there exists a length such that any string longer than this length can be divided into three parts, and by repeating or removing the middle part, the resulting string will also be in the language.
In this chapter, we will see a very basic recap of pumping lemma for regular languages and see different examples for a better understanding.
Basics of Pumping Lemma
The Pumping Lemma can be formally stated as follows −
If L is a regular language, then there exists an integer n (the pumping length) such that any string w in L with | w | ≥ n can be decomposed into three parts, w = xyz, satisfying the following conditions −
$$\mathrm{|xy| \:\le \: n\:|xy|\:,}$$
$$\mathrm{|y| \:\gt \:0\:,}$$
$$\mathrm{xy^{i} \: z \:\in \:L \:\:for \:\: all \:\:i\: \ge\: 0}$$
These conditions states that for any sufficiently long string in a regular language, there is a section of the string that can be "pumped" (repeated or removed) to produce new strings that also belong to the language.
Examples of Pumping Lemma for Regular Languages
Let us see some examples for a better understanding.
Example 1
Prove that L = {ai2 | i ≥ 1} is not regular.
Solution
Assume the set L is regular. Let n be the number of states of the FA accepting the set L.
Let w = an2. The length of w is n2, which is greater than n, the number of states of the FA accepting L. By using the Pumping Lemma, we can write w = xyz with |x|y| ≤ n and |y| > 0.
Take i = 2, so the string will become xy2z.
$$\mathrm{|xy^{2}z| \:=\: |x|\:+\:2|y|\:+\:|z|}$$
$$\mathrm{=\:|x| \:+\: |y|\:+\:|z|\:+\:|y|}$$
$$\mathrm{= \:n^{2} \:+\: |y|}$$
Since |xy| n, |y| n, therefore |xy2z| n2 + n
From the previous derivations, we can write −
$$\mathrm{n^{2} \:\lt\: |xy^{2}z| \:\le\: n^{2} \:+\: n \: \lt\: (n \:+\: 1)^{2}}$$
Hence, |xy2z| lies between n2 and (n + 1)2. They are the squares of two consecutive positive integers. In between the squares of two consecutive positive integers, no square of a positive integer belongs.
But ai2, where i ≥ 1, is a perfect square of an integer. So, the string derived from it, i.e., |xy2z| is also a square of an integer, which lies between the squares of two consecutive positive integers. This is not possible.
So, xy2z ∈ L. This is a contradiction and L is not regular.
Example 2
Prove that L = { ap | p is prime } is not regular.
Solution
Assume the set L is regular. Let n be the number of states of the FA accepting the set L.
Let p be a prime number greater than n. Let the string w = ap, w ∈ L. By using the Pumping Lemma, we can write w = xyz with |xy| ≤ n and |y| > 0. As the string w consists of only 'a's, x, y, and z are also strings of 'a's. Let us assume that y = am for some m with 1 ≤ m ≤ n.
Let us take, i = p + 1.
$$\mathrm{|xy^{i}z| \:=\: |xyz| \:+\: |y^{(i\:-\:1)}|}$$
$$\mathrm{p \:+\: (i \:-\: 1)\: |y|}$$
$$\mathrm{( p \:+\: (p \:+\: 1 \:-\: 1)m )}$$
$$\mathrm{= \:p \:+\: pm}$$
$$\mathrm{p(1 \:+\: m)}$$
p(1 + m) is not a prime number as it has factors p and (1 + m), including 1 and p(1 + m). So, xy(p + 1)z ∉ L. This is a contradiction.
Example 3
Prove that L = {an bn | n ≥ 1} is not regular.
Solution
Assume the set L is regular. Let n be the number of states of the FA accepting the set L.
Let w = an bn, where |w| = 2n. By the Pumping Lemma, we can write w = xyz with |xy| ≤ n and |y| > 0.
We want to find a suitable i so that xyiz ∉ L.
The string y can be one of the following −
- y is a string of only 'a's, so y = ak for some k ≥ 1.
- y is a string of only 'b's, so y = bk for some k ≥ 1.
- y is a string of both 'a's and 'b's, so, y = ak bl for some k, l ≥ 1.
For case (i), take i = 0. As xyz = an bn, xy0 z = xz will be an-k bn.
$$\mathrm{As \:k\: \ge \:1, \:(n \:-\: k) \:\neq \:n,\: so\: xy^{0}z \: \notin\: L}$$
For case (ii), take i = 0. As xyz = an bn, xy0 z = xz will be an bn-k.
$$\mathrm{As \:k\: \ge \:1, \:(n \:-\: k) \:\neq\: n,\: so\: xy^{0}z \:\notin\: L}$$
For case (iii), take i = 2. As xyz = an bn,
$$\mathrm{xy^{2}z \:=\: xyyz'}$$
We know,
$$\mathrm{xyz \:=\: a^{n}\:b^{n} \:=\: a^{n\:-\:k}\: a^{k}\: b^{l}\: b^{n\:-\:l}}$$
So, xyyz will be,
$$\mathrm{a^{n\:-\:k}\: a^{k}\: b^{l}\: a^{k}\: b^{l}\: b^{n\:-\:l} \:=\: a^{n}\: b^{l} \:a^{k}\: b^{n}}$$
Which is not in the form an bn, so xy2 z ∉ L.
For all three cases, we find a contradiction. Therefore, L is not regular.
Conclusion
The Pumping Lemma is a powerful tool in automata theory and formal languages. It provides a systematic method to prove that certain languages are not regular by demonstrating that they do not satisfy the properties required by the lemma.
In this chapter, we used a set of examples to illustrate how the Pumping Lemma can be applied to various languages to show that they are not regular.