Upload
darena
View
87
Download
0
Embed Size (px)
DESCRIPTION
Context-Free Grammars – Regular Grammars. Lecture 14 Section 2.1 Fri, Sep 21, 2007. Regular Grammars. Yet another way to describe regular languages is through regular grammars . Start symbol S . Set of variables V . Set of terminal symbols . Set of rules R. Regular Grammars. - PowerPoint PPT Presentation
Citation preview
Context-Free Grammars – Regular Grammars
Lecture 14Section 2.1
Fri, Sep 21, 2007
Regular Grammars
• Yet another way to describe regular languages is through regular grammars. • Start symbol S.• Set of variables V.• Set of terminal symbols .• Set of rules R.
Regular Grammars
• Each rule is of one of the following forms:• A aB• A
where A and B are variables and a is a terminal.
Regular Grammars
• Then we begin with the start symbol and apply rules until we obtain a string of all terminals.
Example
• Let the rules be• S aX• S bY• S • X aS• X bZ• X • :
Example
• Y aY• Y bY• Y • Z aY• Z bX
Example
• What strings can be obtained by these rules?
• One example:• S aX aaS aabY aab.
• Another example:• S bY bbY bbaY bba.
The Language of a Grammar
• The set of all strings obtainable from the grammar, by starting with the start symbol, is called the language of the grammar.
Regular Grammars and Regular Languages
• It is easy to derive a regular grammar from a DFA, and vice versa.
Regular Grammars and Regular Languages
• Given a DFA, • Let V be the set of states Q.• The start symbol is the start state.• For each transition (p, a) = q, write a
rule p aq.• For each accept state q, write a rule q
.
• This process is reversible.
Example
• Construct a DFA from the previous example.
• What is the language of the grammar?