A Pumping Lemma for Regular Languages.docx

download A Pumping Lemma for Regular Languages.docx

of 4

Transcript of A Pumping Lemma for Regular Languages.docx

  • 7/28/2019 A Pumping Lemma for Regular Languages.docx

    1/4

    A Pumping Lemma for Regular Languages Applications of the Pumping Lemma A Generalization to the Pumping Lemma

    It can be intuitively argued that there are computations that finite-memory programs cannot carry

    out, because of the limitations imposed on the amount of memory the programs can use. For instance, it can be argued that { a n bn | n 0 } is not recognizable by any finite-memory program.The reasoning here is that upon reaching the first b in a given input, the program must remember how many a's it read. Moreover, the argument continues that each finite-memory program has anupper bound on the number of values that it can record, whereas no such bound exists on thenumber of a's that the inputs can contain. As a result, one can conclude that each finite-memory

    program can recognize only a finite number of strings in the set { a n bn | n 0 }.

    The purposes of this section are to show that there are computations that cannot be carried out byfinite-memory programs, and to provide formal tools for identifying such computations. The

    proofs rely on abstractions of the intuitive argument above. However, it should be mentioned that

    the problem of determining for any given language, whether the language is recognizable by afinite-memory program, can be shown to be undecidable (see Theorem 4.5.6 ). Therefore, no toolcan be expected to provide an algorithm that decides the problem in its general form.

    A Pumping Lemma for Regular Languages

    The following theorem provides necessary conditions for a language to be decidable by a finite-memory program. The proof of the theorem relies on the observations that the finite-memory

    programs must repeat a state on long inputs, and that the subcomputations between therepetitions of the states can be pumped.

    Theorem 2.4.1 (Pumping lemma for regular languages) Every regular language L has anumber m for which the following conditions hold. If w is in L and |w| m, then w can bewritten as xyz, where xy k z is in L for each k 0. Moreover, |xy| m, and |y| > 0.

    Proof Consider any regular language L. Let M be a finite-state automaton that recognizes L.By Theorem 2.3.1 it can be assumed that M has no transition rules. Denote by m the number of states of M.

    On input w = a 1 an from L the finite-state automaton M has a computation of the form

    The computation goes through some sequence p 0, p1, . . . , p n of n + 1 states, where p 0 is theinitial state of M and p n is an accepting state of M. In each move of the computation exactly oneinput symbol is being read.

    If the length n of the input is equal at least to the number m of states of M, then the computationconsists of m or more moves and some state q must be repeated within the first m moves. That is,

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q1-30004-18http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q1-30004-18http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q1-30004-19http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q1-30004-19http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q1-30004-20http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q1-30004-20http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse5.html#50005-20016t4.5.6http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse5.html#50005-20016t4.5.6http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse5.html#50005-20016t4.5.6http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q2-30004-18http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q2-30004-18http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose3.html#30003-13001t2.3.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose3.html#30003-13001t2.3.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose3.html#30003-13001t2.3.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose3.html#30003-13001t2.3.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q2-30004-18http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse5.html#50005-20016t4.5.6http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q1-30004-20http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q1-30004-19http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q1-30004-18
  • 7/28/2019 A Pumping Lemma for Regular Languages.docx

    2/4

    if n m then p i = p j for some i and j such that 0 i < j m. In such a case, take x = a 1 ai, y =ai+1 a j, and z = a j+1 an.

    With such a decomposition xyz of w the above computation of M takes the form

    During the computation the state q = p i = p j of M is repeated. The string x is consumed beforereaching the state q that is repeated. The string y is consumed between the repetition of the stateq. The string z is consumed after the repetition of state q.

    Consequently, M also has an accepting computation of the form

    for each k 0. That is, M has an accepting computation on xy k z for each k 0, where M startsand ends consuming each y in state q.

    The substring y that is consumed between the repetition of state q is not empty, because byassumption M has no transition rules.

    Example 2.4.1 Let L be the regular language accepted by the finite-state automaton of Figure 2.4.1 .

    Figure 2.4.1 A finite-state automaton.

    Using the terminology in the proof of the pumping lemma (Theorem 2.4.1 ), L has the constant m= 3.

    On input w = ababaa, the finite-state automaton goes through the sequence q 0, q1, q0, q1, q0, q1, q2 of states. For such an input the pumping lemma provides the decomposition x = , y = ab, z =

    abaa; and the decomposition x = a, y = ba, z = baa. The first decomposition is due to the firstrepetition of state q 0; the second is a result of to the first repetition of state q 1.

    For each string w of a minimum length 3, the pumping lemma implies a decomposition xyz inwhich the string y must be either ab or ba or ac. If y = ab, then x = and the repetition of q 0 isassumed. If y = ba, then x = a and the repetition of q 1 is assumed. If y = ac, then x = a and therepetition of q 1 is assumed.

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-18005r2.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-18005r2.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-18005r2.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-18001t2.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-18001t2.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-18001t2.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-18001t2.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-18005r2.4.1
  • 7/28/2019 A Pumping Lemma for Regular Languages.docx

    3/4

    Applications of the Pumping Lemma

    For proving that a given language L is not regular, the pumping lemma implies the followingschema of reduction to contradiction.

    a.

    For the purpose of the proof assume that L is a regular language. b. Let m denote the constant implied by the pumping lemma for L, under the assumption in(a) that L is regular.

    c. Find a string w in L, whose length is at least m. Require that w implies a k, for eachdecomposition xyz of w, such that xy k z is not in L. That is, find a w that implies, by usingthe pumping lemma, that a string not in L must, in fact, be there.

    d. Use the contradiction in (c) to conclude that the pumping lemma does not apply for L.e. Use the conclusion in (d) to imply that the assumption in (a), that L is regular, is false.

    It should be emphasized that in the previous schema the pumping lemma implies only theexistence of a constant m for the assumed regular language L, and the existence of a

    decomposition xyz for the chosen string w. This lemma does not provide any information aboutthe specific values of m, x, y, and z besides the restriction that they satisfy the conditions |xy|m and |y| > 0. The importance for the schema of the condition |xy| m lies in allowing somelimitation on the possible decompositions that are to be considered for the chosen w. Theimportance of the restriction |y| > 0 is in enabling a proper change in the pumped string.

    Example 2.4.2 Consider the nonregular language L = { 0 n1n | n 0 }. To prove that L isnonregular assume to the contrary that it is regular. From the assumption that L is regular deducethe existence of a fixed constant m that satisfies the conditions of the pumping lemma for L.

    Choose the string w = 0 m1m in L. By the pumping lemma, 0 m1m has a decomposition of the form

    xyz, where |xy| m, |y| > 0, and xyk

    z is in L for each k 0. That is, the decomposition must be of the form x = 0 i, y = 0 j, and z = 0 m-i-j 1m for some i and j such that j > 0. (Note that the values of i, j, and m cannot be chosen arbitrarily.) Moreover, xy 0z must be in L. However, xy 0z = 0 m-j1m cannot be in L because j > 0. It follows that the pumping lemma does not apply for L,consequently contradicting the assumption that L is regular.

    Other choices of w can also be used to show that L is not regular. However, they might result ina more complex analysis. For instance, for w = 0 m-1 1m-1 the pumping lemma provides three

    possible forms of decompositions:

    a. x = 0 i, y = 0 j, z = 0 m-i-j-1 1m-1 for some j > 0.

    b.

    x = 0m-1-j

    , y = 0 j

    1, z = 1m-2

    for some j > 0.c. x = 0 m-1 , y = 1, z = 1 m-2 .

    In such a case, each of the three forms of decompositions must be shown to be inappropriate toconclude that the pumping lemma does not apply to w. For (a) the choice of k = 0 provides xy 0z= 0 m-1-j 1m-1 not in L. For (b) the choice of k = 2 provides xy 2z = 0 m-110 j1m-1 not in L. For (c) thechoice of c = 0 provides xy 0z = 0 m-1 1m-2 not in L.

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q2-30004-19http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q2-30004-19http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q2-30004-19http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q2-30004-19
  • 7/28/2019 A Pumping Lemma for Regular Languages.docx

    4/4

    Example 2.4.3 Consider the nonregular language L = { rev | is in {a, b}* }. To prove that Lis not regular assume to the contrary that it is regular. Then deduce the existence of a fixedconstant m that satisfies the conditions of the pumping lemma for L.

    Choose w = a m bba m in L. By the pumping lemma, a m bba m = xyz for some x, y, and z such that

    |xy| m, |y| > 0 and xyk

    z is in L for each k 0. That is, x = ai

    , y = a j

    , and z = am-i-j

    bbam

    for some iand j such that j > 0. However, xy 0z = a m-j bba m is not in L, therefore contradicting the assumptionthat L is regular.

    It should be noted that not every choice for w implies the desired contradiction. For instance,consider the choice of a 2m for w. By the pumping lemma, a 2m has a decomposition xyz in whichx = a i, y = a j, and z = a 2m-i-j for some i and j such that j > 0. With such a decomposition, xy k z =a2m+(k-1)j is not in L if and only if 2m + (k - 1)j is an odd integer. On the other hand, 2m + (k - 1)jis an odd integer if and only if k is an even number and j is an odd number. However, although k can arbitrarily be chosen to equal any value, such is not the case with j. Consequently, the choiceof a 2m for w does not guarantee the desired contradiction.

    A Generalization to the Pumping Lemma

    The proof of the pumping lemma is based on the observation that a state is repeated in eachcomputation on a "long" input, with a portion of the input being consumed between therepetition. The repetition of the state allows the pumping of the subcomputation between therepetition to obtain new accepting computations on different inputs. The proof of the pumpinglemma with minor modifications also holds for the following more general theorem.

    Theorem 2.4.2 For each relation R that is computable by a finite-state transducer, there existsa constant m that satisfies the following conditions. If (v, w) is in R and |v| + |w| m, then v can

    be written as x vyvzv and w can be written as x wywzw, where (x vyvk

    zv, x wywk

    zw) is in R for each k 0. Moreover, |x vyv| + |x wyw | m, and |y v| + |y w| > 0.

    A schema, similar to the one that uses the pumping lemma for determining nonregular languages,can utilize Theorem 2.4.2 for determining relations that are not computable by finite-statetransducers.

    Example 2.4.4 The relation R = { (u, u rev) | u is in {0, 1}* } is not computable by a finite-statetransducer. If R were computable by a finite-state transducer, then there would be a constant mthat satisfies the conditions of Theorem 2.4.2 for R. In such a case, since (0 m1m, 1m0m) is in R,then u = 0 m1m could be written as x vyvzv and u rev = 1 m0m could be written as x wywzw, where x v =

    0i

    v, yv = 0 j

    v, zv = 0m-i

    v

    -j

    v1m

    , x w = 1i

    w, yw = 1 j

    w, zw = 1m-i

    w

    -j

    w0m

    , and j v + j w > 0. Moreover, it would be implied that (x vyv0zv, xwyw0zw)

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q2-30004-20http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q2-30004-20http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-20001t2.4.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-20001t2.4.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-20001t2.4.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-20001t2.4.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-20001t2.4.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-20001t2.4.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-20001t2.4.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#30004-20001t2.4.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-twose4.html#Q2-30004-20