Context Free Pumping Lemma - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

Context Free Pumping Lemma

Description:

Title: Grammar and Machine Tranforms Author: Valued Sony Customer Last modified by: Zeph Grunschlag Created Date: 10/11/2001 1:27:07 AM Document presentation format – PowerPoint PPT presentation

Number of Views:139
Avg rating:3.0/5.0
Slides: 35
Provided by: Valued1331
Category:

less

Transcript and Presenter's Notes

Title: Context Free Pumping Lemma


1
Context Free Pumping Lemma
  • Zeph Grunschlag

2
Agenda
  • Context Free Pumping
  • Motivation
  • Theorem
  • Proof
  • Proving non-Context Freeness
  • Examples on slides
  • Examples on blackboard

3
Pumping FAs
x
y
  • Strings of length 3 or more in DFA above can be
    pumped because such strings correspond to paths
    of length ? 3, so visit ? 4 vertices. Hence,
    pigeonhole principle guarantees some vertex
    visited twice, and hence a pumpable cycle.

z
4
Pumping PDAs
(, e ?X ), X?e
  • However, regular pumping lemma fails in this
    example.
  • Q Give an example of a pattern that cannot be
    pumped.

e , ?e
e , e?
r
s
q
5
Pumping PDAs
(, e ?X ), X?e
  • A (n )n cant be pumped in the first half.
  • However, could pump two substrings at once.
    I.e. could take k left parens if take k right
    parens. I.e. can tandem pump.

e , ?e
e , e?
r
s
q
6
Tandem Pumping
  • DEF A string s in L is said to be tandem
    pumpable if can break s up into
  • s uvxyz
  • such that for all i ? 0 we have that
  • s uv ixy iz ? L
  • with at least one of v,y nonempty.
  • Q1 Is 00111 tandem pumpable in 0111 ?
  • Q2 Is 00100 tandem pumpable in 0n10n ?
  • Q3 Is 00100100 tandem pumpable in
    0n10n10n ?

7
Tandem Pumping
  • A1 Yes. Any pumpable string is automatically
    tandem pumpable by letting y e. In our case,
    let u e, v 00, x y e, z 111.
  • uv ixy iz (00)i111 is indeed in 0111.
  • A2 Yes. Let u e, v 00, x 1, y 11 and z
    e.
  • uv ixy iz (00)i1(00)i is indeed in 0n10n
  • A3 NO! Tandem pumping 00100100 leads either to
    too many 1s, or would increase two of the
    0-streaks, without ability to increase the
    remaining 0-streak.

8
Tandem Pumping
  • In general, since pumping automatically implies
    tandem pumping, all (infinite) regular languages
    are tandem pumpable. Turns out, that all
    (infinite) context free languages are as well.
    But Q3 can be generalized to show that 0n10n10n
    does not admit tandem pumping of strings which
    are past a certain length. This will end up
    proving that 0n10n10n is not context free

9
Context Free Pumping Lemma
  • THM Given a context free language L, there is a
    number p (tandem-pumping number) such that any
    string in L of length ? p is tandem-pumpable
    within a substring of length p. In other words,
    for all s ? L with s ? p we we can write
  • s uvxyz
  • vy ? 1 (some pumpable stuff non-empty)
  • vxy ? p (pumping inside length-p portion)
  • uv ixy iz ? L for all i ? 0 (tandem-pump v
    and y)

10
CFPL Intuition
tk t2 t1 sk s2 s1
-y?
  • Intuitively s uvxyz is found as follows Only
    finitely many stack changes possible at cycles in
    the graph of length ? n (the number of states).
    Thus if s is long enough, there will have to be
    some states q,r such that the same string is
    pushed at q as is popped at r and such that the
    path from q to r starts and ends with same stack
    configuration. With these assumption, can then
    pump up v and y in tandem as v pushes same stuff
    that y pops off.

-v?
-x?
-u?
q
r
-z?
s
p
sk s2 s1
11
CFPL - Proof
  • The previous can actually be formalized and used
    to prove the Context Free Pumping Lemma.
    However, this is actually quite painful compared
    to very simple grammar-theoretic proof
  • Proof of CFPL We may assume that the language
    is in CNF. This is not an essential assumption
    but it makes the proof a little easier.
  • Consider a derivation tree in which some
    occurring variable node has itself as an ancestor

12
CFPL Proof
S
a
A
  • Could replace last appearance of A by its first
    appearance. I.e., in tree replace
  • A ? and a by
  • A ? chuga and a choo
  • to get the following

f
o
r
y
o
u
A
c
h
u
g
a
a
n
d
a
c
h
o
o
13
CFPL Proof
S
a
A
  • And again

f
o
r
y
o
u
A
c
h
u
g
a
c
h
o
o
A
c
h
u
g
a
a
n
d
a
c
h
o
o
14
CFPL Proof
S
a
A
f
o
r
y
o
u
A
c
h
u
g
a
c
h
o
o
A
c
h
u
g
a
c
h
o
o
A
c
h
u
g
a
a
n
d
a
c
h
o
o
15
CFPL Proof
S
a
A
  • Or could replace
  • A ? chuga and a choo by
  • A ? and a
  • This is called tandem-pumping down

f
o
r
y
o
u
A
c
h
u
g
a
a
n
d
a
c
h
o
o
16
CFPL Proof
S
a
A
a
n
d
a
f
o
r
y
o
u
17
CFPL Proof
  • In our particular case, we were able to create
    any string of the form
  • a (chuga)i and a (choo)i for you
  • In general, any branch down the derivation tree
    with a repeated variable gives rise to strings of
    the form uv ixy iz all of which are in L.
  • The end of the proof is just a counting argument
    to see when a repeated variable is guaranteed to
    occur.

18
CFPL Proof
  • Q If n is the number of variables in the
    grammar, what tree-height guarantees that a
    variable is repeated?
  • (Recall the height of the trivial tree just a
    root is 0)

19
CFPL Proof
  • A If n is the number of variables in the
    grammar, any subtree of height h n1 will have
    a repeated variable. This is because the bottom
    row of a derivation tree is composed of
    terminals, so height n1 ( n2 levels)
    guarantees n1 levels of variables, at least on
    one branch from the root. Pigeonhole principle
    guarantees that some variable will be encountered
    twice!

20
CFPL Proof
  • Q If the grammar is in CNF, what kind of tree
    is any derivation tree?

21
CFPL Proof
  • A A binary tree!
  • Q What is the maximum number of leaves that a
    binary tree of height n may have?

22
CFPL Proof
  • A 2n
  • Q What the maximum number of leaves that a CNF
    derivation-tree of height n1 may have?

23
CFPL Proof
  • A Still 2n! This is because the only way to
    get a terminal is through rule of the form A?a so
    there is no branching at the final level.
  • Q What string length will guarantee a
    derivation tree of height ? n1 ?

24
CFPL Proof
  • A 2n. This is because no tree with height lt n1
    could generated this many leaves, or terminal
    letters.
  • This leads to setting the tandem-pumping number
    to be p2n.
  • The rest of the theorem follows from the above
    considerations. Only fact that need to verify is
    that the pumping can happened within a substring
    of length p. This just follows from finding a
    repeating variable in the last n2 levels of
    tree.
Write a Comment
User Comments (0)
About PowerShow.com