Pumping Lemma

The Pumping Lemma for regular languages is a tool used to prove that a language is not regular. 

  • It says: if LL is regular, there is a constant pp (pumping length) such that any string ss in LL with sp|s| \ge p can be split into three parts s=xyzs = xyz where:

    1. yϵy \ne \epsilon(middle part is non-empty)

    2. xyp|xy| \le p (loop happens early)

    3. xyizLxy^i z \in L for all i0 (loop can be pumped any number of times)

This property comes directly from the pigeonhole principle applied to the finite states of a DFA.

Note:Keep in mind that all finite languages are regular, and there is no need to check whether they are regular or not, but all infinite languages may or may not be Regular. For example, as a^n, b^n is an infinite language but not a Regular language. So, the Pumping Lemma Test is important to check whether infinite languages are regular or not.

Formal Statement

If L is a regular language, then there exists an integer pp (called the pumping length) such that any string ss in L with sp can be written as:

s=xyzs = xyz

where:

  1. y1 (i.e., yy is not empty),

  2. xyp|xy| \le p(i.e., the “loop”—yy—occurs within the first pp characters),

  3. For all i0i \ge 0, xyizLxy^i z \in L (i.e., you can pump yy any number of times, and the resulting string stays in LL)


A property that every regular language must satisfy, based on the fact that a DFA has only a finite number of states, so sufficiently long strings must repeat states and form loops

Explanation ( unformal proof)
  1. If A is a regular language, then some DFA M decides the language.
  2. Let p be the number of states in M.
  3. Consider any string s∈ A with length greater than or equal to p. The characters in s will cause the machine to transition through a number of states, eventually reaching an accepting state after the last character in s.
  4. Because the number of characters in s equals or exceeds the number of states in M, the machine will pass through at least one state more than once as M reads s. That is, the path that s traces through the machine has at least one loop in it.
  5. For this argument we will use the first repeated state along the path: we will circle back around to that state for the first time before we have processed p characters.
  6. We divide our path into three parts: x is the portion of s that leads from the start state to the first occurance of the repeated state. y is the part of s that traces the loop back around to the repeated state. z is the final part of s that takes us eventually to the accepting state.
  7. M will now accept any string of the form xy^iz for i ≥ 0, because such a string takes M from start to the repeated state, goes i times around the loop back to the repeated state, and then runs from the repeated state on to the accepting state.

Proof  (via DFA and Pigeonhole Principle)

Follows the classic DFA-based argument:

  • Let M=(Q,Σ,δ,q0,F) be a DFA recognizing LL.

  • Set p=Qp = |Q|, the number of states in MM.

  • Consider any string sLs \in L with sp|s| \ge p.

  • As MM processes ss, it transitions through s+1|s| + 1 states. By the pigeonhole principle, since there are only pp distinct states, some state must repeat within the first p+1 visited states.

  • Decompose ss as:

    • xx: the prefix leading up to the first occurrence of that repeated state,

    • yy: the substring that loops from the first to the second occurrence of that same state,

    • zz: the remaining suffix.

  • This guarantees:

    1. yy is non-empty (it represents at least one transition),

    2. xyp|xy| \le p,

    3. Pumping yy—i.e., repeating it—keeps the machine in the same looped state and thus xyizLxy^i z \in L for all ii

Use of the Pumping Lemma

  • Main purpose: To prove a language is not regular.

  • How:

    1. Assume LL is regular.

    2. Apply the lemma to a carefully chosen string ss in LL.

    3. Show that pumping yy breaks the property of the language.

    4. Conclude LL is not regular (proof by contradiction).

NOTE: The pumping lemma gives the result of the failure of any condition. That’s why it is also called a negative test.

We can say,If an infinite Language (L) does not satisfy all three conditions of the Pumping Lemma, then it is not a regular language.
If given an infinite Language that satisfies all three conditions of the Pumping Lemma, then it may or may not be a regular language.


Detailed Examples

Language: L={anbnn0}

Goal: Show L is not regular.

  1. Assume LL is regular.

  2. Let pp be the pumping length given by the lemma.

  3. Choose the specific string s=apbps = a^p b^p, which is in LL and satisfies sp|s| \ge p.

  4. According to the lemma, s=xyzs = xyz with:

    • xyp|xy| \le p — so xx and yy consist only of aas,

    • y1|y| \ge 1 — y=aky = a^k for some k1k \ge 1.

  5. Pump with i=0i = 0:
    xy0z=xz=apkbpxy^0 z = xz = a^{p-k} b^p.
    Now the number of aas (which is p ⁣ ⁣kp \!-\! k) is not equal to the number of bbs (pp), so xzLxz \notin L.

  6. This contradicts the pumping lemma’s requirement that xyizLxy^i z \in L for all ii.
    Thus, LL cannot be regular—proof by contradiction is complete.

  • We want to prove that A = { aⁿbⁿ | n ≥ 0 } is not regular.
  • Assume A is regular and let the pumping length be p = 3.
  • Choose a string S = aaabbb from A (n = 3).
  • Split S into x = aay = az = bbb, where |xy| ≤ p and |y| > 0.
  • Pump y: xy²z = aaaabbb, which has 4 a’s and 3 b’s → not in A.
  • So, the string after pumping is not in the language → A is not regular

A simple, short description of the given example to prove that the language A = { anb2n | n ≥ 0 } is not Regular is given below

  • We want to prove that A = { aⁿb²ⁿ | n ≥ 0 } is not regular.
  • Assume A is regular and let the pumping length be p = 3.
  • Choose a string S = aaabbbbbb from A (n = 3 → 3 a’s and 6 b’s).
  • Split S into x = aay = az = bbbbbb, where |xy| ≤ p and |y| > 0.
  • Pump y: xy²z = aaaabbbbbb, which has 4 a’s and 6 b’s → not in A (should be a⁴b⁸).
  • So, the string after pumping is not in the language → A is not regular

A straightforward, short description of the given example to prove that the language A = { yy | y ∈ {0,1}* } is not Regular is given below

  • We want to prove A = {yy | y ∈ {0,1}*} is not regular.
  • Assume it is regular and choose a string S = 0101 from A.
  • Let pumping length be p = 2, so |xy| ≤ 2 and |y| > 0.
  • Split: x = 0, y = 1, z = 01 → S = xyz = 0101.
  • Pump y: xy²z = 01101, which is not in the form yy.
  • So, pumping fails → A is not regular.

Comments

Popular posts from this blog

Theory Of Computation PCCST302 KTU Semester 3 BTech 2024 Scheme

Non deterministic Finite Automata NFA

Example DFAs University Questions