Answers to Sample Test - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Answers to Sample Test

Description:

Now that you have had a chance to try the sample test, you can check out my ... David Hannay's 'Top Ten' List (with apologies to David Letterman) 1) NFA DFA ... – PowerPoint PPT presentation

Number of Views:69
Avg rating:3.0/5.0
Slides: 17
Provided by: daveh5
Category:

less

Transcript and Presenter's Notes

Title: Answers to Sample Test


1
Answers to Sample Test 2
  • Now that you have had a chance to try the sample
    test, you can check out my answers on the
    bulletin board outside my office.
  • Those of you who are not normally on campus can
    follow me back to my office to make a copy this
    afternoon.

2
7a CFL Pumping Lemma Closure Decision Problems
8.1,8.2
  • The Pumping Lemma for Context-Free Languages
  • Languages that are NOT Context-Free
  • SKIP Pumping Lemma for Linear Languages
  • Closure of CFL under Union, Concatenation, and
  • Non-Closure under Intersection and Complement
  • Determining if L(G) is Empty, Infinite

3
The Pumping Lemma for Context-Free
Languages--Theorem 8.1 page 206
  • Let L be an infinite context-free language.
  • Then there exists some positive integer m such
    that any w ? L with w ? m can be decomposed as
  • w uvxyz
  • with
  • vxy ? m
  • and
  • vy ? 1
  • such that
  • uvixyiz ? L
  • for all i 0, 1, 2, ...

4
Pumping Example
  • S ? aSb cAd
  • A ? eBf g
  • B ? hAi j
  • Pick w acehgifdb
  • S?aSb?acAdb?aceBfdb?acehAifdb?acehgifdb
  • then uac veh xg yif zdb

5
Where does "m" come from?
  • Consider a grammar with 5 non-terminals and
    productions whose right-hand sides have at most 3
    symbols
  • Any tree of height more than 5 must contain a
    "loop"
  • Each level of the tree can increase the word
    length by a factor of at most 3
  • Consider words of length 3(51) 729
  • Forces tree height gt 5
  • (recall that we can assume no ? or unit
    productions)
  • Therefore, derivations of any word of length 729
    or greater forces a loop
  • 729 could serve as our m (remember the joke)
  • Note that m simply becomes a power of 2 for
    Chomsky Normal Form grammars

6
Graphical Representation of CFL Pumping Lemma
S
A
u
z
A
v
y
x
7
Languages that are NOT Context-Free
  • L anbncn n ? 0
  • Consider w ambmcm
  • Proof by Cases What are the possible values for
    u,v,x,y and z recall that we must show that we
    get something not in L when we pump v and y, no
    matter what choices we make for u, v, x, y and z.
  • L ww w ? a,b
  • Consider w ambmambm

8
Exercise 8.1.7(e) page 212L anbjck nltj, n
? k ? j
  • Select w ambm1cm
  • Case 1 v or y contains both a's and b's or both
    b's and c'sNo Good (violates a's first, b's
    second, c's last when pumped)
  • Case 2 v within the a's, y within the c'sNo
    Good (vxy ? m)
  • Case 3 v and y both entirely within one letter
    (a's, b's or c's)a's) No Good (pump up, get n gt
    j)b's) No Good (pump down, get j ? n)c's) No
    Good (pump up, get k gt j)
  • Case 4 v in a's, y in b'sNo Good (pump up, get
    n gt k
  • Case 5 v in b's, y in c'sNo Good (pump down,
    get k lt n)
  • No other cases, therefore cannot pump!
    CONTRADICTION.

9
Closure of CFL under Union
  • Union L(S1)?L(S2)
  • Given two context-free grammars
  • G1 (V1, T1, S1, P1) and G2 (V2, T2, S2, P2)
  • Create a new grammar G (V, T, S, P) whereS ?
    S1 S2
  • V1 and V2 must be disjoint (Why?)

10
Closure of CFL Concatenation, and
  • Catenation L(S1)L(S2)
  • S ? S1S2
  • (This construction does NOT work for linear
    grammars.)
  • Star L(S1)
  • S ? ? S1 S1S1 S1S1S1 S1S1S1S1
  • Using recursion to avoid infinitely many
    productions
  • S ? ? S1S

11
Non-Closure under Complement and Intersection
  • Intersection
  • Consider aibicj ? aibjcj i, j?0
  • Can give a CFG for each part
  • Complement follows from DeMorgan

12
Complement of anbncn IS a CFL
  • Hints on grammar
  • More a's than b's, b's than a's, a's than c's,
    etc.
  • c in front of a, b in front of a, c in front of
    b
  • Makes an interesting test question

13
Determining if L(G) is Empty, Infinite
  • Assume ? not in L (or consider L - ?)
  • Eliminate useless symbols and productions
  • Eliminate ? and unit productions
  • Empty if S is useless
  • Infinite if grammar contains derivation of form A
    ? xAy, and x or y non-empty.

14
David Hannays "Top Ten" List(with apologies to
David Letterman)
  • 1) NFA º DFA
  • 2) Unique minimal DFA equivalent to any DFA
  • 3) Regular Expressions º Finite-State Machines
  • 4) Pumping Lemmas (regular CFL)
  • 5) Syntax Trees Ambiguous Context-Free
    Grammars
  • 6) CFL º NPDA
  • 7) Turing's Thesis
  • 8) Universal Turing Machine
  • 9) Halting Problem for Turing Machines
  • 10) Recursive Functions º Turing Machines

15
In-Class ExerciseExercise 8.1.8(b,c) page 212
  • Work in groups of 2 or 3
  • Hints on next slide (no peeking)
  • First group done with both parts put (b) on board
  • Second group done with both parts put (c) on board

16
In-Class ExerciseAnswers
  • 8.1.8(b) NO. consider ambmambm
  • Give complete proof with all cases!
  • 8.1.8(c) YES. give grammar
  • Give actual grammar
Write a Comment
User Comments (0)
About PowerShow.com