CSC262 Theory of Computation

Theory of ComputationUnit 311 min read

Pumping Lemma & Closure Properties of Regular Languages

Unit 3 of Theory of Computation explores the Pumping Lemma for Regular Languages (proof technique to disprove non-regular languages) and Closure Properties (how regular languages behave under operations like union, concatenation, and complement). Master these to distinguish regular from non-regular languages and solve

TAKEAWAYS

  • The Pumping Lemma is a disproof tool: if a language fails its conditions, it’s not regular.
  • Closure Properties show regular languages are closed under union, concatenation, Kleene star, intersection, complement, and reversal—but not under complementation of non-regular languages.
  • Worked examples are key: trace the lemma’s 3 steps (pump, split, and verify) for languages like .
  • Real-world tie: Daraz’s order queue (FIFO) is a regular language; Ncell’s billing system uses regex to validate phone numbers.
  • Common pitfalls: Forgetting to check all cases in the lemma (e.g., ) or misapplying closure to non-regular languages.
  • Exam focus: 30% of questions test lemma applications; 20% test closure properties with proofs.

1. The Pumping Lemma for Regular Languages: Definition & Intuition

The Pumping Lemma is a theorem that gives a necessary condition for a language to be regular. If a language satisfies the lemma, it might be regular—but if it fails, it’s definitely not regular.

Formal Statement

Let be a regular language. There exists a pumping length such that for every string with , can be divided into three parts: where:

  1. (the prefix is "pumpable"),
  2. (the middle part is non-empty),
  3. For all , the string is also in .

Visualizing the Pumping Lemma

flowchart TD
    A["String \( w \)"] --> B["Split into \( xyz \)"]
    B --> C["Prefix \( xy \) (≤ \( p \))"]
    B --> D["Middle \( y \) (≥ 1)"]
    B --> E["Suffix \( z \)"]
    C --> F["Pump \( y \) to \( y^i \)"]
    F --> G["New string \( xy^i z \) must be in \( L \)"]

Why Does This Work?

  • A finite automaton (FA) has a finite number of states. If is long enough (), the FA must revisit a state when reading .
  • "Pumping" (i.e., repeating it) keeps the FA in the same state, so is accepted.

2. How to Use the Pumping Lemma: Step-by-Step

To disprove a language is not regular, assume it is regular and show a contradiction.

Example 1: is Not Regular

Goal: Show fails the pumping lemma.

  1. Assume is regular → there exists a pumping length .
  2. Pick a string with . Let’s choose .
  3. Split where and .
    • Since , can only contain ’s (no ’s).
    • So where .
  4. Pump to → new string: .
    • But because the number of ’s () ≠ number of ’s ().
  5. Contradiction: , but the lemma requires it to be in . → Conclusion: is not regular.

Example 2: is Not Regular

Goal: Show fails the pumping lemma.

  1. Assume is regular → pumping length .
  2. Pick (length ).
  3. Split where is all ’s or all ’s (since ).
    • Case 1: . Pump to → .
      • This is not of the form (mismatched counts).
    • Case 2: . Pump to → .
      • Again, not .
  4. Contradiction: . → Conclusion: is not regular.

3. Closure Properties of Regular Languages

Regular languages are closed under certain operations. This means if you apply the operation to regular languages, the result is still regular.

Table: Closure Properties

Operation Definition Regular? Example
Union Yes , →
Concatenation Yes
Kleene Star union of all concatenations of Yes
Intersection Yes (still regular)
Complement Yes
Reversal Yes
Positive Closure Yes

Non-Closure Example: Non-Regular Languages

  • Not closed under intersection with non-regular languages: (not regular) ∩ (not regular) = (still not regular, but the operation itself isn’t defined for regular languages).

Proof: Regular Languages are Closed Under Union

Let and be regular languages with FAs and .

  • Construct :
    • States: .
    • Transitions: Copy transitions from and , plus:
      • From , -transitions to (start of ) and (start of ).
      • From and , -transitions to .
  • Result: accepts .
stateDiagram-v2
    [*] --> q0
    q0 --> q1: ε
    q0 --> q2: ε
    q1 --> q_accept1: a/b
    q2 --> q_accept2: b/a
    q_accept1 --> q_accept: ε
    q_accept2 --> q_accept: ε
    q_accept --> [*]

4. Real-World Applications

Example 1: Daraz Order Queue (FIFO)

  • Language: .
  • Why Regular?
    • Orders arrive in sequence (like a string).
    • Daraz’s system processes them in FIFO order (like a deterministic FA).
  • Closure Used:
    • Concatenation: New orders are appended to the queue.
    • Kleene Star: Any number of orders (including zero) is allowed.

Example 2: Ncell Billing System (Regex Validation)

  • Language: (Ncell phone numbers).
  • Why Regular?
    • Fixed prefix (98) + 8 digits.
    • Can be represented by regex: 98[0-9]{8}.
  • Closure Used:
    • Concatenation: Prefix + digits.
    • Kleene Star: Digits can repeat (but here, fixed length).

Example 3: NEPSE Stock Ticker (Non-Regular Check)

  • Language: .
  • Why Not Regular?
    • NEPSE tracks nested transactions (e.g., buy/sell pairs).
    • Language like (balanced buy/sell) is not regular.
  • Pumping Lemma Failure:
    • If you pump , the number of ’s won’t match.

5. Common Mistakes & How to Avoid Them

Mistake Why It’s Wrong Fix
Forgetting in the lemma. The middle part must be non-empty.
Choosing too short. Must satisfy . Always pick with length .
Misapplying closure to non-regular languages. Closure only applies to regular languages. First prove the language is regular.
Ignoring the in the lemma. The pumping length is crucial. Assume exists but don’t fix it.

6. Worked Example: Proving is Regular

Goal: Show is regular by using closure properties.

  1. Break into simpler languages:
    • (not regular, but we’ll handle it differently).
    • Instead, use:
      • .
  2. Complement Approach:
    • is not regular (by pumping lemma).
    • But is the complement of this language over .
    • Wait! Complement of a non-regular language is not necessarily regular. → Correction: This language is actually regular because it’s the complement of a non-regular language within a regular context.
  3. Better Approach:
    • can be written as: .
    • But this is complex. Instead, observe:
      • Any string not of the form is in .
      • Since is not regular, its complement over is regular (because regular languages are closed under complement).
    • Conclusion: is regular.

Visual Proof:

flowchart TD
    A["All strings over {a,b,c}"] --> B["Subtract"]
    B --> C["{a^i b^i c^i}"]
    C --> D["Not Regular"]
    A --> E["L = Complement of C"]
    E --> F["Regular (since complement of non-regular over regular is regular)"]

Exam Tip

  1. For Pumping Lemma Questions:

    • Always start by assuming the language is regular.
    • Pick a string where the lemma fails (e.g., for ).
    • Show that pumping breaks the language’s structure.
  2. For Closure Properties:

    • If asked to prove a language is regular using closure, express it as a combination of known regular languages (e.g., union, concatenation).
    • Never assume a language is regular just because it looks simple (e.g., is not regular).
  3. Common Exam Patterns:

    • Part (a): Prove a language is not regular using the pumping lemma (30% weight).
    • Part (b): Show a language is regular using closure properties (20% weight).
    • Part (c): Convert a regex to an FA and apply the lemma (20% weight).

Summary Table: Key Results

Concept Key Idea Example
Pumping Lemma If a language is regular, long strings can be "pumped" without breaking acceptance. fails pumping.
Closure Under Union is regular if and are regular. .
Closure Under Kleene Star is regular if is regular. .
Non-Closure Example Regular languages are not closed under intersection with non-regular languages. (not regular).

pumping lemma diagramA labeled FA showing how a string is pumped in a regular language. (Image: Jochen Burghardt, CC BY-SA 4.0, via Wikimedia Commons)

Based on the TU BSc CSIT syllabus for Theory of Computation (CSC262), unit 3.

Discussion

Loading…