Identify Context free languages using Pumping lemma
Theory
1.Context free grammar
CFG stands for context-free grammar. It is is a formal grammar which is used to generate all possible patterns of strings in a given formal language. Context-free grammar G can be defined by four tuples as:
V - It is the collection of variables or nonterminal symbols. T - It is a set of terminals. P - It is the production rules that consist of both terminals and nonterminals. S - It is the Starting symbol.
Pumping lemma for context free Language
Pumping lemma for context free language (CFL) is used to prove that a language is not a Context free language
Theorem
If A is a context free language ,then ,A has a pumping length “p” such that any string “S’, where |S|>= p may be divided into 5 pieces S=uvxyz such that the following conditions must be true :
Uvixyiz is in the A for every i≥0
|vy|>0
|vxy|≤p
Steps to apply pumping lemma
Detailed description of the steps mentioned above:
1. Assume the language L is context-free: This is our starting point for the proof.
2. Identify the pumping length (p): The lemma guarantees the existence of a pumping length p for any context-free language. This p applies to all strings in the language with a length greater than or equal to p (L ≥ p).
3 .Choose a string S ∈ L and |S| ≥ p: Select a string S from the language L that has a length greater than or equal to the pumping length (n).
4. Divide S into five substrings as follows:
5. Apply pumping for different values of i: The lemma states that we can "pump" the substring v by inserting copies of it i times (where i is a non-negative integer) and obtain a new string.
6. Analyze the resulting strings: The key step is to analyze the resulting strings (uwxz, S, and uvixyiz) and show that at least one of them does not belong to the language L. This contradicts the initial assumption that L is context-free.