The Wayback Machine - https://web.archive.org/web/20240607080327/https://www.geeksforgeeks.org/pumping-lemma-in-theory-of-computation/
Open In App

Pumping Lemma in Theory of Computation

Last Updated : 21 Oct, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

There are two Pumping Lemmas, which are defined for 1. Regular Languages, and 2. Context – Free Languages   Pumping Lemma for Regular Languages For any regular language L, there exists an integer n, such that for all x ? L with |x| ? n, there exists u, v, w ? ?*, such that x = uvw, and (1) |uv| ? n (2) |v| ? 1 (3) for all i ? 0: uviw ? L   In simple terms, this means that if a string v is ‘pumped’, i.e., if v is inserted any number of times, the resultant string still remains in L.   Pumping Lemma is used as a proof for irregularity of a language. Thus, if a language is regular, it always satisfies pumping lemma. If there exists at least one string made from pumping which is not in L, then L is surely not regular. The opposite of this may not always be true. That is, if Pumping Lemma holds, it does not mean that the language is regular. 

p1

 For example, let us prove L01 = {0n1n | n ? 0} is irregular. Let us assume that L is regular, then by Pumping Lemma the above given rules follow. Now, let x ? L and |x| ? n. So, by Pumping Lemma, there exists u, v, w such that (1) – (3) hold.   We show that for all u, v, w, (1) – (3) does not hold. If (1) and (2) hold then x = 0n1n = uvw with |uv| ? n and |v| ? 1. So, u = 0a, v = 0b, w = 0c1n where : a + b ? n, b ? 1, c ? 0, a + b + c = n But, then (3) fails for i = 0 uv0w = uw = 0a0c1n = 0a + c1n ? L, since a + c ? n.

p2

Pumping Lemma for Context-free Languages (CFL) Pumping Lemma for CFL states that for any Context Free Language L, it is possible to find two substrings that can be ‘pumped’ any number of times and still be in the same language. For any language L, we break its strings into five parts and pump second and fourth substring. Pumping Lemma, here also, is used as a tool to prove that a language is not CFL. Because, if any one string does not satisfy its conditions, then the language is not CFL. Thus, if L is a CFL, there exists an integer n, such that for all x ? L with |x| ? n, there exists u, v, w, x, y ? ?*, such that x = uvwxy, and (1) |vwx| ? n (2) |vx| ? 1 (3) for all i ? 0: uviwxiy ? L 

p3

For above example, 0n1n is CFL, as any string can be the result of pumping at two places, one for 0 and other for 1. Let us prove, L012 = {0n1n2n | n ? 0} is not Context-free. Let us assume that L is Context-free, then by Pumping Lemma, the above given rules follow. Now, let x ? L and |x| ? n. So, by Pumping Lemma, there exists u, v, w, x, y such that (1) – (3) hold. We show that for all u, v, w, x, y (1) – (3) do not hold.   If (1) and (2) hold then x = 0n1n2n = uvwxy with |vwx| ? n and |vx| ? 1. (1) tells us that vwx does not contain both 0 and 2. Thus, either vwx has no 0’s, or vwx has no 2’s. Thus, we have two cases to consider. Suppose vwx has no 0’s. By (2), vx contains a 1 or a 2. Thus uwy has ‘n’ 0’s and uwy either has less than ‘n’ 1’s or has less than ‘n’ 2’s. But (3) tells us that uwy = uv0wx0y ? L. So, uwy has an equal number of 0’s, 1’s and 2’s gives us a contradiction. The case where vwx has no 2’s is similar and also gives us a contradiction. Thus L is not context-free.   Source : John E. Hopcroft, Rajeev Motwani, Jeffrey D. Ullman (2003). Introduction to Automata Theory, Languages, and Computation.

This article has been contributed by Nirupam Singh.   


Previous Article
Next Article

Similar Reads

Introduction of Theory of Computation
Automata theory (also known as Theory Of Computation) is a theoretical branch of Computer Science and Mathematics, which mainly deals with the logic of computation with respect to simple machines, referred to as automata. Automata* enables scientists to understand how machines compute the functions and solve problems. The main motivation behind dev
3 min read
Decidable and Undecidable problems in Theory of Computation
Prerequisite - Turing Machine A problem is said to be Decidable if we can always construct a corresponding algorithm that can answer the problem correctly. We can intuitively understand Decidable problems by considering a simple example. Suppose we are asked to compute all the prime numbers in the range of 1000 to 2000. To find the solution of this
4 min read
Relationship between grammar and language in Theory of Computation
A grammar is a set of production rules which are used to generate strings of a language. In this article, we have discussed how to find the language generated by a grammar and vice versa as well. Language generated by a grammar - Given a grammar G, its corresponding language L(G) represents the set of all strings generated from G. Consider the foll
4 min read
Theory of Computation | Regular languages and finite automata | Question 2
What is the complement of the language accepted by the NFA shown below? (A) A (B) B (C) C (D) D Answer: (B) Explanation: Quiz of this QuestionPlease comment below if you find anything wrong in the above post
1 min read
Arden's Theorem in Theory of Computation
Arden's theorem state that: "If P and Q are two regular expressions over "∑", and if P does not contain "∈" , then the following equation in R given by R = Q + RP has a unique solution i.e., R = QP*." That means, whenever we get any equation in the form of R = Q + RP, then we can directly replace it with R = QP*. So, here we will first prove that R
4 min read
Halting Problem in Theory of Computation
To understand better the halting problem, we must know Decidability, Undecidability and Turing machine, decision problems and also a theory named as Computability theory and Computational complexity theory. Some important terms: Computability theory - The branch of theory of computation that studies which problems are computationally solvable using
4 min read
Decidability Table in Theory of Computation
Prerequisite - Undecidability, Decidable and undecidable problems Identifying languages (or problems*) as decidable, undecidable or partially decidable is a very common question in GATE. With correct knowledge and ample experience, this question becomes very easy to solve. A language is undecidable if it is not decidable. An undecidable language ma
2 min read
Introduction to Computation Complex Theory
Broad Overview : Complexity theory, in a nutshell, a complexity word is a quite fancy word, literally, it sounds complex, but it is not an intimidating topic. What it really means is analyzing the program or we can say analyzing the efficiency of the program, figuring out whether the program is correct, figuring out whether one program is better th
4 min read
Introduction To Grammar in Theory of Computation
Prerequisite - Theory of ComputationGrammar :It is a finite set of formal rules for generating syntactically correct sentences or meaningful correct sentences.Constitute Of Grammar :Grammar is basically composed of two basic elements - Terminal Symbols -Terminal symbols are those which are the components of the sentences generated using a grammar a
3 min read
Chomsky Hierarchy in Theory of Computation
According to Chomsky hierarchy, grammar is divided into 4 types as follows: Type 0 is known as unrestricted grammar.Type 1 is known as context-sensitive grammar.Type 2 is known as a context-free grammar.Type 3 Regular Grammar.Type 0: Unrestricted Grammar: Type-0 grammars include all formal grammar. Type 0 grammar languages are recognized by turing
2 min read
Article Tags :