Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

In theoretical computer science, a regular grammar is a formal grammar that describes a regular

language.

A right regular grammar (also called right linear grammar) is a formal grammar (N, Σ, P, S) such
that all the production rules in P are of one of the following forms:

1. B → a - where B is a non-terminal in N and a is a terminal in Σ

2. B → aC - where B and C are in N and a is in Σ

3. B → ε - where B is in N and ε denotes the empty string, i.e. the string of length 0.

In a left regular grammar (also called left linear grammar), all rules obey the forms

1. A → a - where A is a non-terminal in N and a is a terminal in Σ

2. A → Ba - where A and B are in N and a is in Σ

3. A → ε - where A is in N and ε is the empty string.

An example of a right regular grammar G with N = {S, A}, Σ = {a, b, c}, P consists of the
following rules

S → aS

S → bA

A→ε

A → cA

and S is the start symbol. This grammar describes the same language as the regular expression
a*bc*.

A regular grammar is a left or right regular grammar.


EXTENDED REGULAR GRAMMAR

An extended right regular grammar is one in which all rules obey one of

1. B → a - where B is a non-terminal in N and a is a terminal in Σ

2. A → wB - where A and B are in N and w is in Σ*

3. A → ε - where A is in N and ε is the empty string.

An extended left regular grammar is one in which all rules obey one of

1. A → a - where A is a non-terminal in N and a is a terminal in Σ

2. A → Bw - where A and B are in N and w is in Σ*

3. A → ε - where A is in N and ε is the empty string.

There is a direct one-to-one correspondence between the rules of a (strictly) left regular grammar
and those of a nondeterministic finite state automaton, such that the grammar generates exactly
the language the automaton accepts. Hence, the left regular grammars generate exactly all
regular languages. The right regular grammars describe the reverses of all such languages, that
is, exactly the regular languages as well.

REGULAR SETS

a) 0 represents the set {0}

b) 1 represents the set {1}

c) ε represents the set {ε} (the empty string)

d) ∅ represents the empty set

Now for some general cases. If α and β are regular expressions representing the

sets A and B, then:


a) (αβ) represents the set AB

b) (α + β) represents the set A∪B

c) (α)* represents the set A*

The sets which can be represented by regular expressions are called regular

sets. When writing down regular expressions to represent regular sets we shall

often drop parentheses around concatenations. Some examples are 11(0 + 1)*

(the set of strings beginning with two ones), 0*1* (all strings which contain a

possibly empty sequence of zeros followed by a possibly null string of ones),

You might also like