Pumping lemma

from Wikipedia, the free encyclopedia

The pumping lemma or pumping lemma (also called loop theorem ) describes a property of certain classes of formal languages in theoretical computer science . In many cases, the lemma can be used to prove that a formal language is not regular or context-free .

It takes its name from the term the lemma to pump to German inflate . It is derived from the fact that parts of words from languages ​​of certain classes can be multiplied (inflated) so that the words that are created are also in the language.

A distinction is first made between the pumping lemma for regular languages ​​and that for context-free languages. Pumping lemmas for extensions of context-free languages ​​can also be found in the literature. However, more powerful language classes in the Chomsky hierarchy such as the context-sensitive languages and also the increasingly context-sensitive languages do not allow a pumping lemma.

Alternatively, the lemma or its characteristics are also referred to as the uvw theorem , uvwxy theorem , loop lemma , iteration lemma or Bar-Hillel's lemma .

Regular languages

Pumping lemma for regular languages

There is a natural number for every regular language , so the following applies: Every word in with a minimum length has a decomposition with the following three properties:

  1. The two words and together have at most the length .
  2. The word is not empty.
  3. For every natural number (with 0) the word is in the language , i.e. H. the words , , , etc are all in the language .

The smallest that fulfills these properties is called the pumping number of language .

In addition to the regular languages, there are also non-regular languages ​​that satisfy this lemma. The Myhill-Nerode theorem or Jaffe's Pumping Lemma provide a necessary and sufficient condition for regular languages .

The pumping lemma contains several changes between universal and existential quantification. This can be seen well from the following formal formulation of the lemma. Therein denotes the set of all regular languages.

proof

The validity of the lemma is based on the fact that for every regular language there is a deterministic finite automaton that accepts the language. Above a finite alphabet, a regular language with an infinite number of words also contains those words that contain more characters than the automaton has states. In order to accept such words, the machine must contain a cycle that can then be run through as often as required. The sequence of letters that is read when running through the cycle can therefore appear any number of times in words of the language.

The idea of ​​the pumping lemma is that a word part can be repeated any number of times through a cycle in the deterministic finite automaton.

The following proof equates the minimum length from the lemma with the number of states of the automaton and shows that because of the existence of a cycle every word with this minimum length has the required decomposition.

Be a regular language. Is finite, then there is a word with maximum length . Suppose that the premise is false for all and the implication is true.

If infinite, then be a deterministic finite automaton that accepts. Since is regular, such an automaton always exists . Let be the number of states of this automaton, and be any word with at least characters. Now use to designate the sequence of states that runs through when reading from beginning with the start state . Since in is must of be accepted d. H. must be an accepting state. Since the automaton currently has statuses, a status repetition must occur after reading characters at the latest . That is, it exist with and . The machine runs through a cycle when reading .

Be the part of that is read when it goes through the cycle . Furthermore, let the part of which is read when the sequence of states preceding it is run through and the part of which is read when the sequence of states behind it runs through . With this choice applies .

With this choice of , and the statements from the pumping lemma apply:

  1. The length of is and therefore not greater than .
  2. The word is not empty, so that at least one character is read during the cycle.
  3. For anything , the automaton first runs through the sequence of states when reading the word , then runs through the cycle and finally the sequence of states . At the end the machine is in the accepting state . Thus applies to everyone .

example

Is the language regular?

Suppose it is a regular language. Then there is a number according to the pumping lemma , so that all words can be decomposed with as described.

In particular, there is a decomposition with the properties described for the word . As a prefix of this word is, and according to one characteristic maximum length , has composed and entirely of letters . According to property 3 (for ) the word in must also lie. But since (property 2), this word contains more than , so it is not in .

So the assumption that it is a regular language leads to a contradiction and is therefore wrong.

A non-regular language that satisfies the conditions of the pumping lemma

The language is not regular. However, it fulfills the properties of the pumping lemma, because every word can be broken down in such a way that it can also be used for all . You can simply choose the first letter. This is either a , the number of leading s is arbitrary. Or it is one or , without leading s but the number of leading s or s is arbitrary.

Jaffe's pumping lemma

Jeffrey Jaffe developed a generalized pumping lemma that is equivalent to the definition of regular languages . It is therefore a necessary and sufficient condition to prove the regularity of a language.

The language is regular if and only if a constant exists, making it suitable for all , a division with there, so for all and suffixes applies:

.

Context Free Languages

Pumping lemma for context-free languages

For every context-free language , there is a natural number , so that: Each word in with a minimum length has a partition with the following three properties:

  1. The words , and together have at most the length , i.e. H. .
  2. One of the words , is not empty. So .
  3. For every natural number (with 0) the word is in the language , i.e. H. the words , , etc. are all in .

In addition to the context-free languages, there are also non-context-free languages ​​that satisfy this pumping lemma. The reverse of the lemma does not apply in general. A generalization of the pumping lemma for context-free languages ​​is Ogden's lemma .

proof

Given a context-free grammar G in Chomsky normal form with variables, for which it is true that it describes the desired language. Be it a word given in this language, the following applies: .

The idea of ​​the pumping lemma for context-free languages ​​is that a word part can be repeated any number of times by deriving the same variable multiple times.

Let us now consider a derivation tree  T for with height h. Since our language was given in CNF , T has the form of a binary tree . It follows for the amount of T . So there is a path in T from the root to a leaf that is considered to be long . There are therefore two nodes with on this path that the same variables of G represent.

If you look at the subtree that is spanned from, its leaves form the substring . The subtree that is opened by has the tree as a subtree . So you can divide the leaves of into leaves to the left of and leaves to the right of and thus obtain a division of the leaves of the form . The subtree also divides the entire derivation tree into three parts . So we get the sub- strings that are in the derivation tree to the left or right of the subtree spanned by , the sub- strings that are in the subtree but not in , and finally the sub- string that is in. Since and represent the same variables in our grammar, it follows that the path from to can be repeated any number of times. By repeating the path, we would create words of form without leaving our language. With which we would have proved the pumping lemma for context-free languages.

example

The word contains a maximum of two different letters.

Is the language context free?

We assume it is context free. Then be the corresponding constant from the pumping lemma.

We look at the word . It then has a decomposition give so that , , for all is. There , the word contains at most two different letters. Therefore, and it is true, does not contain the same number of all three letters, is therefore not included in. That is a contradiction; the assumption that it is context-free is therefore wrong.

A non-context-free language that satisfies the pumping lemma

The languages and are not context-free. However, and fulfill the properties of the pumping lemma: If a word does not contain the letter , this also applies to all words . If, on the other hand, the letter is contained, there is a decomposition with ( designate the empty word), and a suffix , so that again all words are contained in. For can and choose and thus is in included.

Individual evidence

  1. Script (PDF) Humboldt University Berlin
  2. Jeffrey Jaffe: A necessary and sufficient pumping lemma for regular languages . doi: 10.1145 / 990524.990528