2.Regular Grammars§
Here is another way to describe a language: Use a grammar.
Grammar G=(V,T,S,P)
V, T, and P are finite sets.
Here is another way to describe a language: Use a grammar.
Grammar G=(V,T,S,P)
V, T, and P are finite sets.
Note: x is a string of length 0 or more.
Definition:
Any right-linear or left-linear grammar is defined to be a regular grammar.
(There is a more restrictive definition in which the length of x is ≤1.)
<< What language is this? >>
Cannot mix left/right rules! This is not a regular grammar.
<< What language is this? >>
This is a right linear grammar representing the language L={strings with an even number of a's},Σ={a,b}
Theorem: L is a regular language iff ∃ regular grammar G such that L=L(G).
Theorem: L is a regular language iff ∃ regular grammar G such that L=L(G).
<< What is the machine for Example 2? >>
What about a rule like S→abB? Or S→ab?
Theorem: L is a regular language iff ∃ regular grammar G such that L=L(G).
(⟹) Given a DFA M, construct regular grammar G such that L(G)=L(M)
Construct the Regular Grammar for the NFA
Construct the Regular Grammar for the NFA
L={anbn∣n>0}
Is language L regular? Can you draw a DFA, regular expression, or Regular grammar for this language?