1 / 11

Languages, Grammar, and Automata

Languages, Grammar, and Automata. Reading: 1.2. Languages. FORMAL languages, not natural languages (not even machine languages) Alphabet is all symbols allowed. Σ is alphabet, λ is null letter String variables: w = abba Concatenation, reverse, length

Download Presentation

Languages, Grammar, 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. Languages, Grammar, and Automata Reading: 1.2

  2. Languages • FORMAL languages, not natural languages (not even machine languages) • Alphabet is all symbols allowed. Σ is alphabet, λ is null letter String variables: w = abba Concatenation, reverse, length Σ* is 0 or more letters, Σ+ is 1 or more letters

  3. Set Notation for Languages • Σ = {a,b} • Σ* = {λ,a,b,aa,ab,ba,bb,aaa,aab,…} • Σ+ = Σ* - {λ} • L = {anbn : n >0} • Which are in L? • λ • ab • aaa • aba • aaaaaabbb

  4. More Language Notation Σ = {a,b,c}, L1 = {ab, bc, aba}, L2 = {c,bc,bcc} • L1 U L2 = • L1 ∩ L2 = • L1 = • L1 ∩ L2 = • L1L2 = • L10 = • L22 = • L1* = • L2R =

  5. Grammars • A set of rules which govern the structure of a language <sentence> <nounPhrase><predicate> <nounPhrase> Fritz <nounPhrase> The dog <predicate> ate <predicate> left

  6. Formal Grammar Notation • G = {V,T,S,P} • V are variables (<predicate>) • T are terminals (Fritz) • S is the start variable (<sentence>) • P are the production rules • Let W be a string of variables and terminals • W Y means that W can be transformed into Y using the production rules

  7. Languages + Grammars • A grammar defines a language • Many grammars can define the same language • Grammars that generate the same language are equivalent.

  8. Coming: Automata Input Tape a b b a a b Tape Head (moves ->) Current State 0 1

  9. Exercises • If L = {anbn ,n>0} what is L2? • Write a grammar that generates:L={anbm, n<2, m<=2} • What language does this generate? S -> aA | λ A -> bS

  10. ... or Puzzles? • Write a grammar that generates:L={anbm, n>0, m>=0} • Write a grammar that generates all strings on {a,b}* with exactly 2 a’s • Write a grammar that generates:L={anbn, n>0} • Write a grammar that generates: • L = {w  {a}*: |w| mod 4 = 0}

  11. Mathy Questions • Suppose a grammar for L1 has start symbol S1 and a grammar for L2 has start symbol S2. What grammar describes • L1 U L2? • L1L2? • L1*? • Can you prove that your answer is correct? • Can you prove your neighbor’s answer is wrong?

More Related