1 / 54

Introduction to Computability Theory

Introduction to Computability Theory. Lecture5: Context Free Languages Prof. Amos Israeli. Introduction and Motivation. On the last lecture we completed our study of regular languages. (There is still a lot to learn but our time is limited…). Introduction and Motivation.

kedma
Download Presentation

Introduction to Computability Theory

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. Introduction to Computability Theory Lecture5: Context Free Languages Prof. Amos Israeli

  2. Introduction and Motivation On the last lecture we completed our study of regular languages. (There is still a lot to learn but our time is limited…).

  3. Introduction and Motivation In our study of RL-s we Covered: • Motivation and definition of regular languages. • DFA-s, NFA-s, RE-s and their equivalence. • Non Regular Languages and the Pumping Lemma.

  4. Introduction and Motivation In this lecture, we turn to Context Free Grammars and Context Free Languages. The class of Context Free Languages is an intermediate class between the class of regular languages and the class of Decidable Languages (To be defined).

  5. Introduction and Motivation A Context Free Grammar is a “machine” that creates a language. A language created by a CF grammar is called A Context Free Language. (We will show that) The class of Context Free Languages Properly Contains the class of Regular Languages.

  6. Context Free Grammar - Example Consider grammar : A CFL consists of substitution rules called Productions. The capital letters are theVariables. The other symbols are the Terminals.

  7. Context Free Grammar - Example Consider grammar : The grammar generates the language called the language of ,denoted by .

  8. Context Free Grammar - Example Consider grammar : This is a Derivation of the word by : On each step, a single rule is activated. This mechanism is nondeterministic.

  9. Context Free Grammar - Example This is A Parse Treeof the word by :

  10. Context Free Grammar - Example Each internal node of the tree is associated with a single production.

  11. CF Grammar – A Formal Definition A Context Free Grammar is a 4-tupple where: • is a finite set called the variables. • is a finite set, disjoint from V called the terminals. • is a set of rules, where a rule is a variable and a string of variables and terminals, and • is the start variable . ,

  12. A Derivation – A Formal Definition A word is a string of terminals. A derivation of a word w from a context Free Grammaris a sequence of strings ,over , where: • is the start variable of G. • For each , is obtained by activating a single production (rule) of G on one of the variables of .

  13. CF Grammar – A Formal Definition A word w is in the Language of grammar G, denoted by , if there exists a derivation whose rightmost string is w . Thus,

  14. Example2: Arithmetical EXPS Grammar : Rules: 1. 2. 3.

  15. Example2: Arithmetical EXPS Derivation of by Grammar : input

  16. Example2: Arithmetical EXPS Derivation of by Grammar : input rule

  17. Example2: Arithmetical EXPS Derivation of by Grammar : input output rule

  18. Example2: Arithmetical EXPS Derivation of by Grammar : input

  19. Example2: Arithmetical EXPS Derivation of by Grammar : input rule

  20. Example2: Arithmetical EXPS Derivation of by Grammar : input output rule

  21. Example2: Arithmetical EXPS Derivation of by Grammar : input

  22. Example2: Arithmetical EXPS Derivation of by Grammar : input rule

  23. Example2: Arithmetical EXPS Derivation of by Grammar : input output rule

  24. Example2: Arithmetical EXPS Derivation of by Grammar : input

  25. Example2: Arithmetical EXPS Derivation of by Grammar : input rule

  26. Example2: Arithmetical EXPS Derivation of by Grammar : input output rule

  27. Example2: Arithmetical EXPS Derivation of by Grammar : input

  28. Example2: Arithmetical EXPS Derivation of by Grammar : input rule

  29. Example2: Arithmetical EXPS Derivation of by Grammar : input output rule

  30. Example2: Arithmetical EXPS Derivation of by Grammar : input

  31. Example2: Arithmetical EXPS Derivation of by Grammar : input rule

  32. Example2: Arithmetical EXPS Derivation of by Grammar : input output rule

  33. Example2: Arithmetical EXPS Derivation of by Grammar : input

  34. Example2: Arithmetical EXPS Derivation of by Grammar : input rule

  35. Example2: Arithmetical EXPS Derivation of by Grammar : input output rule

  36. Example2: Arithmetical EXPS Derivation of by Grammar : input

  37. Example2: Arithmetical EXPS Derivation of by Grammar : input rule

  38. Example2: Arithmetical EXPS Derivation of by Grammar : output rule

  39. Example2: Arithmetical EXPS Derivation of by Grammar : input

  40. Example2: Arithmetical EXPS Derivation of by Grammar : input rule

  41. Example2: Arithmetical EXPS Derivation of by Grammar : output rule

  42. Example2: Arithmetical EXPS Derivation of by Grammar : input

  43. Example2: Arithmetical EXPS Derivation of by Grammar : input rule

  44. Example2: Arithmetical EXPS Derivation of by Grammar :

  45. Example2: Arithmetical EXPS Derivation of by Grammar : Note: There is more than one derivation.

  46. Example3: The Language of WF ( ) To be Demonstrated on the blackboard

  47. Ambiguity We already saw that a word may have more then a single derivation from the same grammar. A Leftmost Derivation is a derivation in which rules are applied in order left to right. A grammar is ambiguous if it has Two parse trees.

  48. Ambiguity Reminder: Two parse trees are equal if they are equal as trees and if all productions corresponding to inner nodes are also equal .

  49. Example4: Similar to Arith. EXPS Grammar : Rules: , ,

  50. Example4: 1st Parse Tree for______

More Related