DOC PREVIEW
Winthrop CSCI 371 - Regular Grammars

This preview shows page 1-2-3-4 out of 11 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Strings that End with aaaaSlide 10Slide 11Regular GrammarsChapter 7Regular GrammarsA regular grammar G is a quadruple (V, , R, S), where: ● V is the rule alphabet, which contains nonterminals and terminals, ●  (the set of terminals) is a subset of V, ● R (the set of rules) is a finite set of rules of the form: X  Y, ● S (the start symbol) is a nonterminal.Regular GrammarsIn a regular grammar, all rules in R must: ● have a left hand side that is a single nonterminal ● have a right hand side that is: ● , or ● a single terminal, or ● a single terminal followed by a single nonterminal.Legal: S  a, S  , and T  aSNot legal: S  aSa and aSa  TRegular Grammar Example L = {w  {a, b}* : |w| is even} ((aa)  (ab)  (ba)  (bb))*Regular Grammar Example L = {w  {a, b}* : |w| is even} ((aa)  (ab)  (ba)  (bb))*S  S  aT S  bTT  aT  bT  aST  bSRegular Languages and Regular GrammarsTheorem: The class of languages that can be defined with regular grammars is exactly the regular languages. Proof: By two constructions.Regular Languages and Regular GrammarsRegular grammar  FSM: grammartofsm(G = (V, , R, S)) = 1. Create in M a separate state for each nonterminal in V. 2. Start state is the state corresponding to S . 3. If there are any rules in R of the form X  w, for some w  , create a new state labeled #. 4. For each rule of the form X  w Y, add a transition from X to Y labeled w. 5. For each rule of the form X  w, add a transition from X to # labeled w. 6. For each rule of the form X  , mark state X as accepting. 7. Mark state # as accepting.FSM  Regular grammar: Similarly.Example 1 - Even Length Strings S   T  aS  aT T  bS  bT T  aS T  bSStrings that End with aaaaL = {w  {a, b}* : w ends with the pattern aaaa}. S  aSS  bS S  aBB  aCC  aDD  aStrings that End with aaaaL = {w  {a, b}* : w ends with the pattern aaaa}. S  aSS  bS S  aBB  aCC  aDD  aExample 2 – One Character MissingS   A  bA C  aCS  aB A  cA C  bCS  aC A   C  S  bA B  aBS  bC B  cBS  cA B  S 


View Full Document

Winthrop CSCI 371 - Regular Grammars

Documents in this Course
Load more
Download Regular Grammars
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Regular Grammars and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Regular Grammars 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?