Lecture 22 Pumping Lemma for Context Free Languages - PowerPoint PPT Presentation

1 / 36
About This Presentation
Title:

Lecture 22 Pumping Lemma for Context Free Languages

Description:

Algorithm for generating and reachable symbols. Removal of useless symbols ... Chomsky Hierarchy Venn Diagram. Backus Naur Form (BNF) Backus Naur Form ... – PowerPoint PPT presentation

Number of Views:472
Avg rating:3.0/5.0
Slides: 37
Provided by: mantonm5
Category:

less

Transcript and Presenter's Notes

Title: Lecture 22 Pumping Lemma for Context Free Languages


1
Lecture 22Pumping Lemma forContext Free
Languages
CSCE 355 Foundations of Computation
  • Topics
  • Normal forms
  • Pumping Lemma for CFLs
  • Closure properties

November 19, 2008
2
  • Last Time
  • Useless symbols
  • generating symbols,
  • useful symbols
  • Algorithm for generating and reachable symbols
  • Removal of useless symbols
  • Removal of epsilon productions
  • Removal of unit productions
  • Chomsky normal form
  • New
  • Chomsky normal form
  • Chomsky Hierarchy
  • Pumping Lemma for Context Free Languages

3
  • Useless symbols
  • generating symbols,
  • useful symbols
  • Algorithm for generating and reachable symbols
  • Removal of useless symbols
  • Removal of epsilon productions
  • Removal of unit productions
  • Chomsky normal form

4
Chomsky Normal Form
  • A CFG (Context Free Grammar) is in Chomsky Normal
    form if productions are one of the following two
    forms
  • A ? BC
  • A ? a
  • References
  • http//www.chomsky.info/

5
Conversion to Chomsky Normal Form
  • Remove e-productions, unit productions
  • A ? BCDE
  • A ? abc
  • In general
  • For each terminal a create a new non-terminal
    Na with Na ? a added as a production
  • A ? B1B2Bk create a new non-terminals C1C2Ck
    and replace the production with
  • A ? B1C1 and
  • Ci ? Bi1Ci1 for i1,k-3
  • Ck-2 ? Bk-1Bk

6
Example
7
(No Transcript)
8
(No Transcript)
9
Regular Grammars
  • A CFG is regular if all productions are of the
    form
  • A ? a or
  • A ? aB
  • Note sentential forms in a derivation based on a
    regular grammar have a unique form!
  • What is it ?
  • Grammar ? NFA construction
  • Create a state for each nonterminal.
  • A ? aB means d(A, a) B and
  • A ? a means d(A, a) Qfinal and

10
Example
11
Chomsky Hierarchy
  • http//en.wikipedia.org/wiki/Chomsky_hierarchy

Grammar Languages Automaton Production rules (constraints)
Type-0 Recursively enumerable Turing machine a ? ß no restrictions
Type-1 Context-sensitive Linear-bounded non-deterministic Turing machine aAß ? a?ß
Type-2 Context-free Non-deterministic pushdown automaton A ? a
Type-3 Regular DFA A ? a or A ? aB
12
Chomsky Hierarchy Venn Diagram
13
Backus Naur Form (BNF)
  • Backus Naur Form
  • N a ß (just a CFG)
  • http//en.wikipedia.org/wiki/Backus-Naur_form
  • John Backus
  • Fortran compiler
  • http//en.wikipedia.org/wiki/John_Backus
  • Peter Naur
  • http//en.wikipedia.org/wiki/Peter_Naur

14
Greibach Normal Form
  • Each production RHS starts with a terminal
  • A ? aa or S? e
  • http//en.wikipedia.org/wiki/Greibach_normal_form

15
Showing Languages are not CFLs
  • Recursive productions
  • A ? a A b
  • B ? B a b
  • D ? aDb d
  • A ? a A ß

16
Pumping Lemma for CFLs
  • Let L be a CFL. Then there exists a constant n
    such that if z is a string in L of length at
    least n, then we can write z uvwxy such that
  • vwx lt n
  • vx gt 0
  • uviwxi y is in L for all i gt 0.

17
Idea behind proof
  • Assume CNF (or do for L(G)-e)
  • Consider Parse Tree
  • Sufficiently long string z, means the parse tree
    must be sufficiently big.

18
Similarities to Pumping Lemma for Regular
Languages
  • Given an arbitrary n.
  • Carefully choose z in L (depending on n) with z
    gt n.
  • Then for any partition z uvwxy that satisfies
  • vx gt 0
  • vwx lt n
  • We must be able to pump, i.e.
  • uviwxiy is in L for all i gt 0

19
Example L anbncn n gt 0
  • Given L as above, suppose we chose n for the
    Pumping Lemma (for CFLs).
  • Choose z
  • Consider arbitrary partition of z uvwxy
    satisfying
  • vwx lt n
  • vx gt 0
  • Then show

20
Example
21
(No Transcript)
22
(No Transcript)
23
(No Transcript)
24
(No Transcript)
25
(No Transcript)
26
(No Transcript)
27
(No Transcript)
28
(No Transcript)
29
(No Transcript)
30
(No Transcript)
31
(No Transcript)
32
(No Transcript)
33
(No Transcript)
34
(No Transcript)
35
(No Transcript)
36
Homework
  1. 7.1.4
  2. 7.1.3
  3. 7.1.6
Write a Comment
User Comments (0)
About PowerShow.com