1 / 14

Grammars and Automata

Grammars and Automata. Review Questions (1/2). What is the size of the empty set? What is the size of the set containing just the empty string? Let L 2 = { λ , 00,0000} be defined over the alphabet ∑ = {0}. Describe the strings in the set L 2 *. Describe the complement of L 2.

liuz
Download Presentation

Grammars and Automata

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. Grammars and Automata

  2. Review Questions (1/2) • What is the size of the empty set? • What is the size of the set containing just the empty string? • Let L2 = {λ, 00,0000} be defined over the alphabet ∑ = {0}. Describe the strings in the set L2*. • Describe the complement of L2.

  3. Questions (2/2) • Let L3 = {awb | w  {a,b}*}. Define the language L3R • How would you prove that L3 = {a}.{a,b}*.{b}? • How would you prove that L3 ≠ L3R?

  4. Grammars • One formal way to present a solution to a problem. • Describes rules on how to form string for a language. • A grammar generates a language

  5. English Grammar • <sentence> -> <noun-phrase> <predicate> • <noun-phrase> -> <article> <noun> • <predicate> -> <verb> • <article> -> a | the

  6. Definition of a Grammar • A grammar G is a 4-tuple (V,T,S,P), where • V is a finite set of variables • T is a finite set of terminal symbols • S  V is the start variable • P is a finite set of productions

  7. Productions of a Grammar • A production has the form x -> y, where • x  (V  T)+ • y  (V  T)* • And can be applied to a string w = uxv by replacing x with y. • Productions are generally used to generate a string of terminals from the start symbol.

  8. Example • Let G=({S,A},{0,1},S,P), where P contains • S -> A1 • A -> 0A | 1A | λ

  9. Derivations • w => z if • w = uxv, and • z = uyv, and • x -> y is a production in the grammar • If w1 => w2 => w3 => … => wn then w1 =>* wn

  10. Language of a Grammar • The set of strings of terminals that can be generated from the start symbol of the grammar. • L(G) = { w  T* | S =>* w }

  11. Automata • Abstract model of a computer • May contain: • Input file • Temporary storage • Control unit – contains states and transitions • Output • Acceptor – output is yes or no • Transducer – output is a string

  12. Example - Acceptor b 1 a a 0 b 2 b a

  13. Example - Transducer 0/𝜆 0/𝜆 0/1 0/𝜆 0 1 2 3 4 1/0

  14. Example • Design automata that accepts passwords. • A password must contain at least one upper case character and at least one digit. • Assume that the only terminals are upper and lower case characters and digits.

More Related