0% found this document useful (0 votes)
11 views2 pages

RegularGrammars

Uploaded by

Yazzy Simons
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

RegularGrammars

Uploaded by

Yazzy Simons
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Regular Grammars

Regular Grammars are a notation or representation for a type of Formal Language


known as Regular Languages.

Definition
A Regular Grammar is a tuple (N, Σ, R, S) with:

• N is a set of non-terminal symbols. These are sometimes called the variables


of the grammar and are usually denoted with upper case letters.

• Σ is the alphabet of symbols for the Regular Language.

• R is the set of production rules. These rules have one of the following forms:
N → α, N→ αN, or N →  where N is a single non-terminal symbol and α
is a single alphabet symbol (α ∈ Σ).

• S is the start symbol or variable. S is an element of N (S ∈ N).

The definition above is what is known as a Strict Right Regular Grammar.

Derivation of a Word
The rules of a grammar can be used to derive or generate a word in a formal
language. Any derivation starts with the only the start symbol, S , of the grammar.
Each single step of a derivation modifies the current sequence of symbols by using
one single production rule of the grammar. The production rule replaces some
single occurrence of a non-terminal symbol N with the symbols on the right hand
side of the rule producing a new current sequence of symbols.
A sequence of symbols which contains any symbols in N is a partial deriva-
tion. If the sequence of symbols contains only symbols in Σ then the derivation
is complete. The result of a complete derivation is a valid word in the formal
language generated by the grammar.

1
Example Word Derivations
Consider the grammar (N, Σ, R, S) where:

• N = {S}

• Σ = {a, b, c}

• R = {S → aS, S → }

• S is the start symbol

We derive the word aaa:


S ⇒ aS ⇒ aaS ⇒ aaaS ⇒ aaa
using the first rule until the three ”a” symbols are created and then the second
rule to replace S with the empty word .
The empty word, , can be derived directly using the second rule:
S⇒
These derivations show that the words  and aaa are in the regular language
generated by this grammar. In fact, this grammar generates the same language as
the regular expression a∗ .
Now consider the grammar (N, Σ, R, S) where:

• N = {S}

• Σ = {a, b, c}

• R = {S → aS, S → bS, S → }

• S is the start symbol

We derive the word abab:


S ⇒ aS ⇒ abS ⇒ abaS ⇒ ababS ⇒ abab

and derive the word baa:


S ⇒ bS ⇒ baS ⇒ baaS ⇒ baa
Again these derivations show that the words abab and baa are in the regular
language generated by this grammar. This grammar generates the same language
as the regular expression (a|b)∗ .

You might also like