Pumping Lemma for Context Free Languages

Pumping Lemma for Context Free Languages

The Pumping Lemma is made up of two words, in which, the word pumping is used to generate many input strings by pushing the symbol in input string one after another, and the word Lemma is used as intermediate theorem in a proof.

Pumping lemma is a method to prove that certain languages are not context free.

The set of all context free language is identical to the set of languages accepted by Push down Automata.

Theorem:   

If L be a Context free language, then there is a constant ‘n’ depending only on L such that, if w ? L and |w| >= n, then w may be divided into five pieces w = uvxyz, satisfying the following conditions.

  • For all i >= 0, uvixyiz ? L.
  • |vy| >= 1
  • |vxy| <= p

Proof:

Let G be in Chomsky normal form (CNF). It does not contain any empty string. As we know the right hand side of productions in CNF contain maximum two variables. So, the derivation tree representing G is a binary tree in which, no node contains two children.

How to Apply Pumping Lemma?

We can apply pumping lemma in context free language to prove that given language is not context free. The steps needed to prove that given languages is not context free are given below:

Step 1: Let L is a context free language, and we will get contradiction. Let n be a natural number obtained by pumping lemma.

Step 2: Now choose a string w ? L where |w| >= n. By using pumping lemma, we can write w = uvxyz with |vy| >= 1 and |vxy| <= n.

Step 3: Find suitable i, so that uvixyiz ? L. It contradicts our assumption and it is proved that given languages is not context free.

Example 1:

Let L= { anbncn | n>=0 }. By using pumping lemma show that L is not context free language.

Solution:

Step 1: Let L is a context free language, and we will get contradiction. Let n be a natural number obtained by pumping lemma.

Step 2: Let w = anbncn   where| w |>= 3n. By using pumping lemma we can write w = uvxyz with |vy| >= 1 and |vxy| <= n.

Step 3: In step 3, we consider two cases.

  • Case 1:  Here, v and y contain only one type of alphabet symbol, i.e. both contains only a’s.

Here, uvxyz = anbncn

Let i = 2

Then we have uv2xy2z, which pumped more a’s into the string, but the number of b’s remain same. It contradicts our assumption, and it is proved that given language is not context free.

  • Case 2:

In given context free language, we have equal number of a’s, b’s and c’s. The possible substring from given language anbncn  can be ab and bc, but not ba, ca, ac and cb.

If we choose substring v and y as combination of a and b or b and c.

Then uv2xy2z may contain equal number of three alphabet symbols but not in correct order. The resulting string is of the form

aaaa.aaaaaaaaa..aabb…bbbcc…..bcccbc

Here not all b’s follows a’s and not all c’s follows b’s. Hence it cannot be member of context free language L and a contradiction occurs. Both the cases result in contradictions so L is not context free language.

Example 2:

Let L= { anbnan | n> 0 }. By using pumping lemma show that L is not context free language.

Solution:

Step 1: Let L is a context free language and we will get contradiction. Let n be a natural number obtained by pumping lemma.

Step 2: Let w = anbnan   where| w |>= n. By using pumping lemma we can write w = uvxyz with |vy| >= 1 and |vxy| <= n.

Step 3: In step 3 we consider two cases:

Case 1:   When both v and y contains equal number of a’s and b’s.

Let, i = 2

Then uv2xy2z = an+k  b n+k a n  or a n b n+k  an+k   which is not in L.

Case 2: Allwords in anbnan  have one occurrence of substring ab or ba no matter what n is.

Let, i = 2

Then uv2xy2z will have more than one substring ab or ba, so it cannot be in the form anbnan.

Hence, uv2xy2z ? L.

There is contradiction in both the cases, so L is not context free language.


Related Topics

Chomsky's Normal Form - Automata

Chomsky's Normal Form (CNF) In context free grammar, the left-hand side of production rules contains only one variable, and right side may contain any number of variables or terminals in production...

4 minutes read.

Conversion from Mealy Machine to Moore Machine

Conversion from Mealy Machine to Moore Machine In this topic, we will see different ways that are used for the conversion of Mealy Machine to Moore Machine. Moore Machine The output of Moore...

4 minutes read.

Closure Properties of Regular Languages -Automata

Closure Properties of Regular Languages We use the term “Closure” when we talk about sets of things. If we have two regular languages L1 and L2, and L is obtained by...

3 minutes read.

Non-deterministic Turing Machine - Automata

A non-deterministic Turing machine (NTM) is a theoretical machine used in computability theory to study the extent to which a machine can "guess" at a solution and yet still be...

4 minutes read.

Automata Tutorial

What is Automata? Automata is a mathematical model and abstract model, which is used to detect string in various languages. In Automata, Regular language is recognized by Finite state AutomataContext Free language...

4 minutes read.

Minimization of Finite Automata with Output

Minimization of Finite Automata with Output The method to minimize the Moore and Mealy machine is very much similar to the method that we have used to minimize the DFA. Methods to...

3 minutes read.

Automata Regular Expressions

Regular Expressions Regular expressions are also referred as rational expressions, which are used to describe the algebraic description of regular languages. It is generally a sequence of characters that is used...

3 minutes read.

Conversion of DFA to Regular expression

Conversion of DFA to Regular expression To convert the DFA to Regular Expression (RE), we are going to use a method called converting DFA to regular expression by eliminating states. This...

3 minutes read.

Automata Greibach Normal Form

Greibach Normal Form In Greibach Normal Form, there is restriction on the position, in which, terminals and variables can appear on right-hand side of production rules. In Greibach Normal Form, every...

4 minutes read.

Equivalence of Regular Grammar and Finite Automata

Equivalence of Regular Grammar and Finite Automata Regular Grammar / type -3 grammar A regular grammar or type-3 defines the language called regular language that is accepted by finite Automata.A Regular Grammar...

3 minutes read.

Finite Automata

Finite Automata Finite state Automata or Finite State Machine is the simplest model used in Automata. Finite state automata accepts regular language. In this, the term finite means it has a...

4 minutes read.

Recursive Language and Recursive Enumerable Language

Recursive Language and Recursive Enumerable Language Before discussing Recursive language and Recursive Enumerable language, let us see what Turing machine responds for some input string. If we have the Turing machine T...

4 minutes read.

Pumping Lemma for Regular Languages - Automata

Pumping Lemma for Regular Languages The language accepted by the finite automata is called Regular Language. If we are given a language L and asked whether it is regular or not?...

4 minutes read.

Pumping Lemma for Context Free Languages

Pumping Lemma for Context Free Languages The Pumping Lemma is made up of two words, in which, the word pumping is used to generate many input strings by pushing the symbol...

3 minutes read.

Automata Chomsky Hierarchy

Chomsky Hierarchy Formal languages: A language with precise syntax and semantics are called formal languages. Noam Chomsky has defined the Chomsky hierarchy in 1956. He is an American scientist and philosopher, and...

3 minutes read.

Converting Finite Automata to Regular Expression using Arden’s Theorem

Converting Finite Automata to Regular Expression using Arden’s Theorem The Arden’s Theorem can be applied to find the regular expression recognized by the given transition diagram. This theorem can be applied...

4 minutes read.

Simplification of Context Free Grammar - Automata

Simplification of Context Free Grammar Context Free Grammar has recursive structure. The languages that are accepted with Context Free Grammar are called Context Free Languages. Context Free Grammar has one condition...

3 minutes read.

Derivation Tree of Context Free Grammar - Automata

Derivation Tree of Context Free Grammar Derivation tree gives a way to show how a string can be derived from context free grammar. It is also called as parse tree, production...

3 minutes read.

Conversion from Moore Machine to Mealy Machine

Conversion from Moore Machine to Mealy Machine Moore Machine The output of Moore machine depends only on the present state. In this, if machine has N number of states, then it will...

6 minutes read.

Undecidable Problem of Turing Machine

Automata Undecidable Problem of Turing Machine Undecidable problems areproblems which cannot be solved by any Turing machine. Example: Post Correspondence Problem is the type of undecidable Problem. Post Correspondence Problem Post Correspondence problem is...

7 minutes read.