1 / 30

In een reguliere taal…

lengte  n. x. y. z. A. B. S. E. x. u. w. z. x. u. u. v. v. w. v. w. z. x. u. v. v. v. w. z. x. u. v. v. v. v. w. z. In een reguliere taal…. zin. x. y. z. u. v. w. x. u. v. v. v. w. z. In een reguliere taal…. Er is een n , zo dat ….

Download Presentation

In een reguliere taal…

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. lengte n x y z A B S E x u w z x u u v v w v w z x u v v v w z x u v v v v w z In een reguliere taal… zin

  2. x y z u v w x u v v v w z In een reguliere taal… Er is een n , zo dat … Voor elke deelzin y met lengte n … Er is een kern v , waarvoor … Voor alle i  0 … x u vi w z is ook een zin

  3. x y z u v w x u v v v w z “Pomp-stelling” L is Regulier  n  x, y, z xyzL |y|n  u, v, w uvw=y |v|1  i  0 x u vi w z L

  4. Pomp-stelling omdraaien…    L is Regulier  n  x, y, z xyzL |y|n  u, v, w uvw=y |v|1  i  0 x u vi w z L

  5. Noem mij een n ! x y z …dan geef ik jeeen zin xyz … …en nou mag jij v aanwijzen … u v w …dan vind ik een i zoals nodig! Gebruik vanomgekeerde Pomp-stelling  n  x, y, z xyzL |y|n  u, v, w uvw=y |v|1  i  0 x u vi w z L  L is niet Regulier

  6. Noem mij een n ! Nou, ehh, 7 ! …dan is hier een zin … …met een opsplitsing … a a a a a a a b b b b b b b a a a a a a a b b b b b b b a a deze neem ik! neem dan i=2… a a a a a a a a a b b b b b b b Voorbeeld:{ ambm | m0 } is niet regulier …wijs maar een v aan!  L

  7. Gevolg S aSbS   • (Hoofdstuk 2){ am bm | m0 } is contextvrij • (Pomp-stelling){ am bm | m0 } is niet regulier • Er zijn contextvrije talendie niet regulier zijn

  8. triviaal Stelling 12 onmogelijk triviaal Stelling 13 Stelling 16 triviaal NFA DFA RE ZRG CFG RG Stelling 11 Definitie 8 +9 Definitie 4 +6 Definitie (11) Definitie 1 +3 Definitie 2.5+7 Definitie 14+15 Stelling 7 Stelling 17 Reguliere talen: overzicht

  9. Chomsky-hierarchie • Type 3: Reguliere grammatica’slinks:Nrechts:T* N? • Type 2: Contextvrije grammatica’slinks:Nrechts: (NT)* • Type 1: Contextgevoelige grammatica’slinks: N rechts: (NT)* • Type 0: Algemene grammatica’slinks: (NT)+rechts: (NT)*

  10. Chomsky-hierarchie • Er zijn talen die contextvrij zijnmaar niet regulier { am bm | m0 }(bewijs met Pomp-stelling) • Er zijn talen die zelfs niet contextvrij zijn { am bm cm | m0 } (bewijs met uitgebreide Pomp-stelling)

  11. Pomp-stellingen • We kunnen ook een pompstelling formuleren voorContextvrije talen • …en daarmee bewijzen datbepaalde talen niet Contextvrij zijn • { am bm cm | m0 } is niet contextvrij

  12.  m S knivo’s z  m k Ontleedboom bij CFG S  ……… | …… A  ………… | …… B  …… | …… | …C  …… | … | …

  13.  m k non- terminals A A > m k Ontleedboom bij CFG S  ……… | …… A  ………… | …… B  …… | …… | …C  …… | … | … S >knivo’s z • Als de zin lang genoeg is,is er een pad met een dubbele nonterminal

  14. S A A A A A A u v v v w w w x x x y Pomp-stelling voor CFG

  15. S A u w y Pomp-stelling voor CFG A

  16. S A A A A u v v w w x x y Pomp-stelling voor CFG • Voor alle i  0 …u vi w xi yis ook een zin

  17. S A  k+1nivo’s A u v w x y Pomp-stelling voor CFG • Voor alle i  0 …u vi w xi yis ook een zin • v en x niet allebei leeg • |vwx| m k+1

  18. x y z u v w x u v v v w z Pomp-stellingvoor Reguliere talen L is Regulier  n  x, y, z xyzL |y|n  u, v, w uvw=y |v|1  i  0 x u vi w z L namelijk|N|

  19. Pomp-stellingvoor Contextvrije talen L is Contextvrij  c  z zL |z|>c  u,v,w,x,y uvwxy=z |vx|  1  i  0 u vi w xi y L namelijkm k namelijkm k+1 , d |vwx|  d

  20. Omgekeerde Pomp-stellingvoor Contextvrije talen  c, d  z zL |z|>c  u,v,w,x,y uvwxy=z |vx|  1  i  0 u vi w xi y L  L is niet Contextvrij |vwx|  d

  21. max(c,d) v v w w x x Voorbeeld:{ anbncn | n0 } is niet CF Noem mij een c,d ! …dan is hier een zin … a a a … a a a b b b … b b b c c c … c c c • Opsplitsing bevat <3 verschillende letters • Pompen met i>1 vermeerdert niet alle letters …wijs maar eenopsplitsing uvwxy aan! |vwx|  d

  22. Als L en MCF-talen zijn dan… L  M is ook CF L M is ook CF L* is ook CF Stelling 5.11 Als L en MReg-talen zijn dan… • L  M is ook Reg • L M is ook Reg • L* is ook Reg Stelling 2.10 • L  M is niet CF • Cmpl(L) is niet CF • L  M is ook Reg • Cmpl(L) is ook Reg

  23. Doorsnede van CF-talenis niet altijd CF • { an bn | n  0 } is contextvrij • { ck | k  0 } is contextvrij • { an bnck | n, k  0 } is contextvrij • { ak bncn | n, k  0 } is contextvrij • Met de pompstelling bewezen we: { an bncn | n  0 } is niet contextvrij • Dus CF-eigenschap blijft niet behouden onder doorsnede

  24. a b b a a S S S S S b Ontleden met een Stackmachine • Nonterminal bovenop stack?Vervang door een van de regels! • Terminal bovenop stack?Accepteer die input S  aS S  cS S  b maar door welke? a a b

  25. c c b a a b a c c c c b a b a c c c b a c b a c c c b a c c b a c c c c b B c B C a A a C C A C C Ontleden met een Stackmachine S  cA |b A  cB C |b S A |a B  c c | C b C  a S |b a c c c c b a S

  26. Leftmost Lookahead(k) LL(1) grammatica’s • Als je op grond van het eerstvolgende input-symboolde keuze kunt makendan is de grammatica een LL(1)-grammatica • … en kan het met de eerste k symbolendan is het een LL(k )-grammatica

  27. Complexiteit van ontleden Tijd nodig voor het parsenvan een zin met lengte n • Contextvrije grammatica: O(n3) • Contextvrije grammaticamet LL(1)-eigenschap: O(n) Wanneer is een grammatica LL(1) ?

  28. Definitie LL(1) Een grammatica is LL(1) • Als je op grond van het eerstvolgendeinput-symbool kunt kiezen uit alternatieven Formeel: • Als de lookahead-sets van dealternatieven van elke nonterminalonderling disjunct zijn

  29. S N   x  Definitie Lookaheadset van alternatief N Lah(Nx) = {x} Lah(NP) = …… { x | S* N   * x }

  30. S N N  x  x  Eigenschappen vanNonterminals … nodig om Lookahead-sets te bepalen • Empty(N) • First(N) • Follow(N) N* 

More Related