cs 126 lecture t3 formal languages outline
play

CS 126 Lecture T3: Formal Languages Outline Introduction Defining - PowerPoint PPT Presentation

CS 126 Lecture T3: Formal Languages Outline Introduction Defining grammar Type 3 grammars Type 2 grammars Chomsky hierarchy Conclusions CS126 16-1 Randy Wang Where We Are T1 - Simplest language generators: regular


  1. CS 126 Lecture T3: Formal Languages

  2. Outline • Introduction • Defining grammar • Type 3 grammars • Type 2 grammars • Chomsky hierarchy • Conclusions CS126 16-1 Randy Wang

  3. Where We Are • T1 - Simplest language generators: regular expressions - Simplest language recognizer: FSAs • T2: more powerful machines - FSA, NFSA - PDA, NPDA - TM • T3: more powerful languages associated with the more powerful machines • T4: - Nature of most powerful machines - Languages that no machine can ever deal with CS126 16-2 Randy Wang

  4. Review: Formal Languages • Formal definitions - An alphabet : a finite set of symbols - A string : a finite sequence of symbols from the alphabet - A language : a (potentially infinite) set of strings over an alphabet • Intriguing topic: finite representation of a language - How? + language generators (a set of rules for producing strings) + language recognizers CS126 16-3 Randy Wang

  5. Languages and Automata CS126 16-4 Randy Wang

  6. Why Learn Languages? CS126 16-5 Randy Wang

  7. Outline • Introduction • Defining grammar • Type 3 grammars • Type 2 grammars • Chomsky hierarchy • Conclusions CS126 16-6 Randy Wang

  8. Example 1 CS126 16-8 Randy Wang

  9. Example 1 (cont.) CS126 16-9 Randy Wang

  10. Example 2 CS126 16-10 Randy Wang

  11. Example 2 (cont.) | <iteration-stmt> | ... if (x == 0) { while (y == 1) { if (z > 0) { Each box is one production. s = z * 2; } } } CS126 16-11 Randy Wang

  12. Example 3 CS126 16-12 Randy Wang

  13. Example 3 (cont.) CS126 16-13 Randy Wang

  14. Outline • Introduction • Defining grammar • Type 3 grammars • Type 2 grammars • Chomsky hierarchy • Conclusions CS126 16-14 Randy Wang

  15. Type 3 Grammars CS126 16-15 Randy Wang

  16. Type 3 Grammars and Regular Expressions CS126 16-16 Randy Wang

  17. Example <A> -> <z>0 <z> -> <A>1 <z> -> ε 0 ε ε S z A F 1 CS126 16-17 Randy Wang

  18. Demo: Construction of Equivalent FSA CS126 16-18 Randy Wang

  19. Outline • Introduction • Defining grammar • Type 3 grammars • Type 2 grammars • Chomsky hierarchy • Conclusions CS126 16-19 Randy Wang

  20. Context-Free Grammars CS126 16-20 Randy Wang

  21. Example Context-Free Grammar | <iteration-stmt> | ... if (x == 0) { while (y == 1) { if (z > 0) { Each box is one production. s = z * 2; } } } CS126 16-21 Randy Wang

  22. How to Recognize Context-Free Grammars CS126 16-22 Randy Wang

  23. Outline • Introduction • Defining grammar • Type 3 grammars • Type 2 grammars • Chomsky hierarchy • Conclusions CS126 16-23 Randy Wang

  24. Type 1 Grammars (Context-Sensitive) and Type 0 Grammars CS126 16-24 Randy Wang

  25. Chomsky Hierarchy, Languages and Automata CS126 16-25 Randy Wang

  26. Language Expressiveness and Machine Power CS126 16-26 Randy Wang

  27. Example Language Outside Chomsky Hierarchy: Lindenmayer Systems Reproduction Growth CS126 16-27 Randy Wang

  28. Graftal Plants: Lindenmayer in 2D “Production” rules: add one to each segment of my trunk; replace each branch with myself of prev generation CS126 16-28 Randy Wang

  29. Outline • Introduction • Defining grammar • Type 3 grammars • Type 2 grammars • Chomsky hierarchy • Conclusions CS126 16-29 Randy Wang

  30. More on Languages, Machines, and Life • The fine art of describing infinite beauty and variety with finite representation - Shakespearean sonnets and machines that can identify authorship? (Is intelligence/art nothing but a set of rules, with some non- determinism thrown in?) - DNA: the language of life (Is life nothing but a set of rules, with some non-determinism thrown in?) - ...... CS126 16-30 Randy Wang

  31. What We Have Learned Today • What is a grammar? • What is a type 3 grammar? type 2? type 1? type 0? • How to construct an FSA from a type 3 grammar? • What is the Chomsky Hierarchy? • What type of automata recognize which grammars? CS126 16-31 Randy Wang

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend