1 / 74

Context-Free Languages

Context-Free Languages. Regular Languages. Context-Free Languages. Regular Languages. stack. automaton. Context-Free Languages. Context-Free Grammars. Pushdown Automata. Context-Free Grammars. Grammars. Grammars express languages Example: the English language.

Télécharger la présentation

Context-Free Languages

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. Context-Free Languages

  2. Regular Languages

  3. Context-Free Languages Regular Languages

  4. stack automaton Context-Free Languages Context-Free Grammars Pushdown Automata

  5. Context-Free Grammars

  6. Grammars • Grammars express languages • Example: the English language

  7. A derivation of “the dog walks”:

  8. A derivation of “a cat runs”:

  9. Language of the grammar: L = { “a cat runs”, “a cat walks”, “the cat runs”, “the cat walks”, “a dog runs”, “a dog walks”, “the dog runs”, “the dog walks” }

  10. Notation Production Rules Variable Terminal

  11. Another Example • Grammar: • Derivation of sentence :

  12. Grammar: • Derivation of sentence :

  13. Other derivations:

  14. Language of the grammar

  15. More Notation • Grammar Set of variables Set of terminal symbols Start variable Set of Production rules

  16. Example • Grammar :

  17. More Notation • Sentential Form: • A sentence that contains • variables and terminals • Example: Sentential Forms sentence

  18. We write: • Instead of:

  19. In general we write: • If:

  20. By default:

  21. Example Grammar Derivations

  22. Example Grammar Derivations

  23. Another Grammar Example • Grammar : Derivations:

  24. More Derivations

  25. Language of a Grammar • For a grammar • with start variable : String of terminals

  26. Example • For grammar : Since:

  27. A Convenient Notation

  28. Example A context-free grammar : A derivation:

  29. A context-free grammar : Another derivation:

  30. (((( )))) Describes parentheses:

  31. Example A context-free grammar : A derivation:

  32. A context-free grammar : Another derivation:

  33. Example A context-free grammar : A derivation:

  34. A context-free grammar : A derivation:

  35. Describes matched parentheses: () ((( ))) (( ))

  36. Definition: Context-Free Grammars Grammar Variables Terminal symbols Start variable Productions of the form: Variable String of variables and terminals

  37. Definition: Context-Free Languages • A language is context-free • if and only if • there is a context-freegrammar • with

  38. Leftmost derivation: Rightmost derivation: Derivation Order

  39. Leftmost derivation: Rightmost derivation:

  40. Derivation Trees

  41. Derivation Tree

  42. Derivation Tree yield

  43. Partial Derivation Trees Partial derivation tree

More Related