Properties of CFL - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Properties of CFL

Description:

Properties of CFL s Reading: 8.1a and 8.2 Pumping Lemma for CFLs Let L be a context-free language. Then there exists some positive integer m such that, if s is a ... – PowerPoint PPT presentation

Number of Views:78
Avg rating:3.0/5.0
Slides: 17
Provided by: admin1618
Category:
Tags: cfl | properties

less

Transcript and Presenter's Notes

Title: Properties of CFL


1
Properties of CFLs
  • Reading 8.1a and 8.2

2
Pumping Lemma for CFLs
  • Let L be a context-free language. Then there
    exists some positive integer m such that, if s is
    a string of length at least m, then s can be
    written as
  • s uvwxy such that
  • vwx ltm
  • vx gt0
  • uviwxiy is also in L for any i gt0

3
Why is it true?
  • If the language is finite, then it is regular and
    also context-free.
  • If its infinite, it still must have a finite
    number of non-terminals.
  • So, at least one non-terminal must be used more
    than once.
  • If A is used more than once, at least one
    derivation of it is recursive, and at least one
    is not (or it would be useless.)

4
So
  • Suppose the rule is
  • A -gt vAx
  • A -gt w
  • Then if I can generate
  • s uvwxy
  • I can also generate
  • s uv2wx2y and uv3wx3y by using the recursive
    rule for A more times.

5
Using the Pumping Lemma to show a language is
not CF.
  • Assume the language is context-free.
  • Show it does not satisfy the pumping lemma
  • Conclude (by contradiction) the language could
    not have been context-free.

6
Example axbxcx xgt0
  • Opponent chooses m.
  • I choose s ambmcm.
  • Opponent must choose uvwxy so that vwx is no
    more than m but at least one symbol.
  • There is no way that vwx contains all three
    characters. It contains either one or two.
  • Pumping the string up adds more of one or two
    characters than the third.

7
Example L anbj j n2
  • Opponent chooses m.
  • I choose string ambm2
  • Opponent chooses vwx.
  • If vwx contains as only, I can add to the number
    of as while the number of bs stays the same.
    Likewise for bs only.
  • If vwx contains as and bs, only interesting
    case is v is some number of as (1ltkltm) and x
    is some number of bs (1ltpltm).
  • s am(i-1)k b m2 (i-1)p
  • Choose i 0 s am-k b m2-p
  • (m-k)2 lt (m-1)2 m2 -2m 1
  • m2 -(2m -1)
  • lt m2 -p

8
Closure for CFLs
  • The family of context-free languages is closed
    under union
  • L1 is a CFL with grammar G1, start symbol S1
  • L2 is a CFL with grammar G2, start symbol S2
  • Let L3 L1UL2
  • L3(G3) has start symbol S -gt S1 S2

9
Closure for CFLs
  • The family of context-free languages is closed
    under star-closure.
  • Let L1 be a context-free language with grammar G1
    and start symbol S1.
  • Let L be L1. Then L(G) S -gt S S1 ?

10
Closure for CFLs
  • The family of context-free languages is closed
    under concatenation.
  • Let L1 be a CFL with grammar G1 and start symbol
    S1.
  • Let L2 be a CFL with grammar G2 and start symbol
    S2.
  • Let L3 L1 L2.
  • Then L3(G3) has start symbol S -gt S1 S2.

11
CFLs are not closed under intersection!
  • L1 anbncm n,m gt0
  • L2 anbmcm n,m gt0
  • L1 n L2 anbncn n gt0

12
CFLs are not closed under complementation!
  • Suppose that CFLs are closed under
    complementation.
  • Let L1 and L2 be CFLs.
  • L1 n L2 L1 U L2
  • By closure under union and complementation, we
    get closure under intersection.
  • But we just showed that CFLs are not closed
    under intersection!
  • Contradiction! So, CFLs are not closed under
    complementation.

13
Regular Intersection
  • The intersection of a regular language and a
    context-free language is context-free.
  • This is called closure under regular
    intersection.
  • Idea of proof Make states equal to the states in
    the PDA x the states in the DFA.

14
Proofs Using Closure
  • Prove that the language L w in a,b,c where
    na(w) nb(w) nc(w) is not context-free.
  • Assume L is context free.
  • LnL(abc) anbncn must be context-free by
    closure under regular intersection.
  • But its not, so L must not be context-free.

15
Proofs Using Closure
  • Prove that the language L anbn ngt50 is
    context-free.
  • Idea Dont want to construct! Use closure.
  • Let L1 anbn L1 is context-free.
  • Let L2 anbn nlt50 L2 is Regular.
  • L L1 ? L2, which is CF by closure under
    regular-intersection

16
Decidable Properties
  • A CFL is empty if its start symbol is found to be
    useless.
  • A CFL is finite if no variable can ever repeat.
  • Draw the dependency graph of the language.
  • The language is infinite if and only if the graph
    contains a cycle.
Write a Comment
User Comments (0)
About PowerShow.com