|
|
Line 1: |
Line 1: |
| The '''pumping lemma for context-free languages''', also known as the '''[[Yehoshua Bar-Hillel|Bar-Hillel]] lemma''', is a [[lemma (mathematics)|lemma]] that gives a property shared by all [[context-free language]]s.
| | I would like to introduce myself to you, I am Andrew and my spouse doesn't like it at all. The favorite hobby for him and his children is fashion and he'll be starting some thing else along with it. For a while I've been in Mississippi but now I'm contemplating other options. He is an information officer.<br><br>Look at my blog ... [http://www.youronlinepublishers.com/authWiki/AdolphvhBladenqq online reader] |
| | |
| == Formal statement ==
| |
| | |
| If a language ''L'' is context-free, then there exists some integer ''p'' ≥ 1 such that every string ''s'' in ''L'' with |''s''| ≥ ''p'' (where ''p'' is a "pumping length"<ref name="BLRS90">{{cite book | last1=Berstel | first1=Jean | last2=Lauve | first2=Aaron | last3=Reutenauer | first3=Christophe | last4=Saliola | first4=Franco V. | title=Combinatorics on words. Christoffel words and repetitions in words | series=CRM Monograph Series | volume=27 | location=Providence, RI | publisher=[[American Mathematical Society]] | year=2009 | isbn=978-0-8218-4480-9 | zbl=1161.68043 | page=90 }}</ref>) can be written as
| |
| | |
| : ''s'' = ''uvxyz''
| |
| | |
| with substrings ''u'', ''v'', ''x'', ''y'' and ''z'', such that
| |
| | |
| : 1. |''vxy''| ≤ ''p'',
| |
| : 2. |''vy''| ≥ 1, and
| |
| : 3. ''uv<sup> n</sup>xy<sup> n</sup>z'' is in ''L'' for all ''n'' ≥ 0.
| |
| | |
| == Informal statement and explanation ==
| |
| | |
| The pumping lemma for context-free languages (called just "the pumping lemma" for the rest of this article) describes a property that all context-free languages are guaranteed to have. | |
| | |
| The property is a property of all strings in the language that are of length at least ''p'', where ''p'' is a constant—called the ''pumping length''—that varies between context-free languages.
| |
| | |
| Say ''s'' is a string of length at least ''p'' that is in the language.
| |
| | |
| The pumping lemma states that ''s'' can be split into five substrings, <math>s = uvxyz</math>, where ''vy'' is non-empty and the length of ''vxy'' is at most ''p'', such that repeating ''v'' and ''y'' any (and the same) number of times in ''s'' produces a string that is still in the language (it's possible and often useful to repeat zero times, which removes ''v'' and ''y'' from the string). This process of "pumping up" additional copies of ''v'' and ''y'' is what gives the pumping lemma its name.
| |
| | |
| Note that [[finite language]]s (which are regular and hence context-free) obey the pumping lemma trivially by having ''p'' equal to the maximum string length in ''L'' plus one. As there are no strings of this length the pumping lemma is not violated.
| |
| | |
| The pumping lemma is often used to prove that a given language is non-context-free by showing that for each ''p'', we can find some string ''s'' of length at least ''p'' in the language that does not have the properties outlined above, i.e. that it cannot be "pumped" without producing some strings that are not in the language.
| |
| | |
| == Usage of the lemma ==
| |
| | |
| The '''pumping lemma for context-free languages''' can be used to show that certain languages are not context-free.
| |
| | |
| For example, we can show that language <math>L = \lbrace a^ib^ic^i|i>0\rbrace</math> is not context-free by using the pumping lemma in a [[proof by contradiction]]. First, assume that <math>L</math> is context free. By the pumping lemma, there exists an integer <math>p</math> which is the pumping length of language <math>L</math>. Consider the string <math>s = a^pb^pc^p</math> in <math>L</math>. The pumping lemma tells us that <math>s</math> can be written in the form <math>s=uvxyz</math>, where <math>u, v, x, y</math>, and <math>z</math> are substrings, such that <math>|vxy| \le p</math>, <math>|vy|\ge 1</math>, and <math>uv^ixy^iz</math> is in <math>L</math> for every integer <math>i\ge 0</math>. By our choice of <math>s</math> and the fact that <math>|vxy| \le p</math>, it is easily seen that the substring <math>vxy</math> can contain no more than two distinct letters. That is, we have one of five possibilities for <math>vxy</math>:
| |
| | |
| # <math>vxy = a^j</math> for some <math>j \le p</math>.
| |
| # <math>vxy = a^jb^k</math> for some <math>j</math> and <math>k</math> with <math> j+k \le p</math>.
| |
| # <math>vxy = b^j</math> for some <math>j \le p</math>.
| |
| # <math>vxy = b^jc^k</math> for some <math>j</math> and <math>k</math> with <math> j+k \le p</math>.
| |
| # <math>vxy = c^j</math> for some <math>j \le p</math>.
| |
| | |
| For each case, it is easily verified that <math>uv^ixy^iz</math> does not contain equal numbers of each letter for any <math>i\ne 1</math>. Thus, <math>uv^2xy^2z</math> does not have the form <math>a^ib^ic^i</math>. This contradicts the definition of <math>L</math>. Therefore, our initial assumption that <math>L</math> is context free must be false.
| |
| | |
| While the pumping lemma is often a useful tool to prove that a given language is not context-free, it does not give a complete characterization of
| |
| the context-free languages. If a language does not satisfy the condition given by the pumping lemma,
| |
| we have established that it is not context-free. On the other hand, there are languages that are not context-free, but still
| |
| satisfy the condition given by the pumping lemma. There are more powerful proof techniques available, such as [[Ogden's lemma]], but also these techniques do not give a complete characterization of the context-free languages.
| |
| | |
| == See also ==
| |
| | |
| * [[Pumping lemma for regular languages]]
| |
| * [[Formal languages]]
| |
| | |
| == References ==
| |
| | |
| <references />
| |
| | |
| * {{cite journal| last=Bar-Hillel|first=Y.|authorlink=Yehoshua Bar-Hillel|coauthors=Perles, M. and Shamir, E.|title=On formal properties of simple phrase-structure grammars|journal=Zeitschrift fur Phonetik, Sprachwissenschaft, und Kommunikationsforschung|volume=14|pages=143–177|year=1961}}
| |
| * {{cite book|author = [[Michael Sipser]] | year = 1997 | title = Introduction to the Theory of Computation | publisher = PWS Publishing | isbn = 0-534-94728-X}} Section 1.4: Nonregular Languages, pp. 77–83. Section 2.3: Non-context-free Languages, pp. 115–119.
| |
| | |
| {{DEFAULTSORT:Pumping Lemma For Context-Free Languages}}
| |
| | |
| [[Category:Formal languages]]
| |
| [[Category:Lemmas]]
| |
I would like to introduce myself to you, I am Andrew and my spouse doesn't like it at all. The favorite hobby for him and his children is fashion and he'll be starting some thing else along with it. For a while I've been in Mississippi but now I'm contemplating other options. He is an information officer.
Look at my blog ... online reader