06L4

Embed Size (px)

Citation preview

  • 8/13/2019 06L4

    1/10

    Class Discussion

    Can you draw a DFA that accepts the language

    {akbk| k = 0,1,2,} over the alphabet ={a,b}?

  • 8/13/2019 06L4

    2/10

    Limitations of FA

    Many languages are non-regular:

    {anbn| n = 0,1,2,}

    {0i2

    | i 0,1,2,} {0

    p| p is a prime number }

    the set of all well-formed parentheses overthe alphabet ={(, )}

    the set of all palindromes over the alphabet={a, b}

    ...

  • 8/13/2019 06L4

    3/10

    Why Impossible?

    We want to prove that L = {aibi| i = 0,1,2,} isnon-regular. Prove by contradiction:

    Assume that there is a DFA M that recognizes

    L. Let n be the total number of states in M.

    Consider the path followed by the input string

    anbnin M:

    q(0) q(1) q(n) q(n+1) q(2n)a b b b......

    a a

  • 8/13/2019 06L4

    4/10

    Why Impossible?

    Since M has only n states, there must be at least onestate visited twice in the first n transitions. Let this

    state be visited at the ithand the jthsteps, where j > i.

    By skipping the loop, an-(j-i)bnshould also be accepted,

    but this is contradictory since an-(j-i)bnL

    q(0)

    q(i) = q(j)

    q(2n)F

    The path in M when reading anbn

  • 8/13/2019 06L4

    5/10

    Another Example

    We want to prove that L = {1k2| k > 0} is non-

    regular. Prove by contradiction:

    Assume that there is a DFA M that recognizesL. Let n be the total number of states in M.

    M should also accept the string 1n2

    q(0) q(1) q(2) q(n2)1 1

    ...1 1

  • 8/13/2019 06L4

    6/10

    Another Example Since n2n and M has only n states, there must be

    at least two equal states from q(0)to q (n2). Let q(i)= q(j)be the first repeated state where j-i = m n.

    By repeating the loop one more time, 1(n2+m) is also

    accepted by M, which is a contradiction, since

    (n2+m) cannot be a square (the next square after n2

    is (n+1)2

    but n2

    +m < (n+1)2

    ).

    q(0)

    q(i) = q(j)

    q(n2)FThe path in M

    when reading 1n2

    a loop of

    length m

  • 8/13/2019 06L4

    7/10

    Pumping Lemma for Regular Set

    If L be a regular language, there is a constant n such

    that if z is any word in L and |z| n, we can write z

    = uvw in such a way that |uv| n, |v| 1, and for alli 0, uviw is in L. (This constant n can be the

    number of states of a DFA accepting L.)

  • 8/13/2019 06L4

    8/10

    Proof of Pumping Lemma

    If L is a regular language, there are DFAs thatrecognize L. Let n be the number of states in onesuch DFA (called M) recognizing L.

    If z is a word in L with |z| = k n:

    where z(i) is the ithsymbol of the string z.

    Since k n and M has only n states, there must be

    at least one repeated states from q(0)to q(k). Letq(i)be the first such repeated state.

    q(0) q(1) q(2) q(k)z(2) z(k)

    ...z(1) z(3)

  • 8/13/2019 06L4

    9/10

    Proof of Pumping Lemma

    Let u be the string obtained by traversing from q(0)to q(i),

    and v be the string obtained by traversing the loop once

    (|v|1). In the traversal from q(0)

    to q(i)

    and then through

    the loop once back to q(i), nothing except q(i)repeats, so

    |uv|n. By traversing the loop 0 or more times, we obtain

    uviw where i 0. These strings should all be accepted by M

    since they can all reach q(k)which is a final state in M.

    a path in Mq(0)

    q(k)F

    q(i)

  • 8/13/2019 06L4

    10/10