chapter002 Finite State Automata, Rebular Languages, and Regular Expressions
section005Regular Grammars
Our Second Regular Grammar

Regular Grammars: A Second Look

From the previous page we learned that a regular grammar specifies grammar rules that describe how valid strings in a language can be produced.  Any string over the alphabet of the language that can be produced from the grammar rules is in the language.  Any string that cannot be produced by application of the rules is not in the language.

Notation

Of course, there is some standard notation that is used for describing regular grammars.

Standards

We also are beginning to see that there are apparently some formatting rules for regular grammars.

Let's look at aonther example.

Example: A Regular Grammar for Even Parity

Recall that even parity describes the set of all binary strings that contain an even number of 1's.  Here is a set of grammar rules for this language.

  1. S → 0S
  2. S → ε
  3. S → 1A
  4. A → 0A
  5. A → 1S

Notice the production S → ε.  This means that S can be replaced by the empty string.  Since the empty string contains zero 1's and we count zero to be an even number, the empty string has even parity.

Now consider the string 00101101 that has even parity.  The following derivation, in which at each step we apply the apprpriate rule to the capital letter on the left side of the double arrow, produces this string.

S ⇒ 0S ⇒ 00S ⇒ 001A ⇒ 0010A ⇒ 00101S ⇒ 001011A ⇒ 0010110A ⇒ 00101101S ⇒ 00101101

Notice that the last rule applied in the last step of the derivation is S → ε.

Similarly, a parse tree for this same string would look like

Try it Yourself

Again, if you would find it helpful, try this grammar yourself below.