1 / 97

Formal Languages & Automata Theory Department of Computer Science & Engineering

G. Pullaiah College of Engineering and Technology. Formal Languages & Automata Theory Department of Computer Science & Engineering.

dtirado
Download Presentation

Formal Languages & Automata Theory Department of Computer Science & Engineering

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. G. Pullaiah College of Engineering and Technology Formal Languages & Automata Theory Department of Computer Science & Engineering

  2. ContentMidterm resultsRegular vs. Non-regular Languages Context-Free LanguagesContext-Free GrammarsDerivation Trees. AmbiguityApplicationsPush-Down Automata, PDA

  3. Midterm 1 Solution http://www.idt.mdh.se/kurser/cd5560/12_11/examination/Duggor/MIDTERM1-20121127-Solution.pdf

  4. A comment on the MIDTERM 1 The Pumping Lemma for Regular Languages Pumping Lemma cannot be used to prove that a language is regular! An example: If something is a square it always has four edges (a property of square) But: having proved that something has four edges does not necessarily mean that the object is a square. http://www2.mat.ua.pt/rosalia/cadeiras/TC/pump.pdf

  5. Time to take the next step: beyond Regular Languages Non-regular languages Context-Free Languages Regular Languages

  6. Automata theory: formal languages and formal grammars

  7. Context-Free Languages Based on C Busch, RPI, Models of Computation

  8. Context-Free Languages Context-Free Grammars Pushdown Automata

  9. Context-Free Grammars

  10. Set of variables Set of terminal symbols Start variable Set of production rules Formal Definition • Grammar

  11. isstring of terminals Repetition: Regular Grammars Grammar Variables Terminal symbols Start variables Right or Left Linear Grammars. Productions of the form: or

  12. is string of variablesand terminals Definition: Context-Free Grammars Grammar Variables Terminal symbols Start variables Productions of the form:

  13. Regular vs. Context-free Grammar A regular grammar is either right or left linear, whereas context free* grammar is any combination of terminals and non-terminals. Hence regular grammars are a subset of context-free grammars. Grammar generating palindromes is not regular: *The name context-free grammar is explained by the property of productions that are independent of the surrounding symbols. There are also context-sensitive grammars where productions depend on the context (symbols that surround variables).

  14. Example 1: A context-free grammar A derivation

  15. A context-free grammar Another derivation

  16. Example 2: A context-free grammar A derivation

  17. A context-free grammar Another derivation

  18. Example 3: A context-free grammar A derivation

  19. A context-free grammar A derivation

  20. Example 4:

  21. is string of variables and terminals Definition: Context-Free Grammars Grammar Variables Terminal symbols Start variables Productions of the form:

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

  23. Derivation Order Leftmost derivation

  24. Rightmost derivation Derivation Order

  25. Leftmost derivation

  26. Rightmost derivation

  27. Derivation Trees

  28. Derivation can be represented in a tree form

  29. Derivation Tree

  30. Derivation Tree yield

  31. Partial Derivation Trees Partial derivation tree

  32. Partial derivation tree

  33. sentential form Partial derivation tree yield

  34. Sometimes, derivation order doesn’t matter Leftmost: Rightmost: The same derivation tree

  35. Ambiguity

  36. derivation (* denotes multiplication) leftmost derivation

  37. derivation leftmost derivation

  38. Two derivation trees

  39. String has two derivation trees The grammar is ambiguous!

  40. The grammar has two leftmostderivations: is ambiguous as the string

  41. Definition A context-free grammar is ambiguous if some string has two or more derivation trees (two or more leftmost/rightmost derivations).

  42. Why do we care about ambiguity?

More Related