Chapter 3 automata
Chapter 3 automata
Chapter Three
Regular Grammars
Regular Grammar
Definition:
A PSG G = ( N, T, P, S) is called a regular grammars provided that
i. If there is a λ-production in G then it is of the form S → λ and then S does not appear on the
right hand side of any production in P.
ii. All other production in P are:
A → a, A Є N, a Є T OR
A → aB, a Є T, B Є N
Examples:
Which of the following are regular grammars?
a) S → a | aB
b) S → aS | λ
c) S → AA | aS
A → aA | B
d) S → a | Sa | λ
e) S → a | aA | λ
A→b
Solutions:
Only a and e are regular grammar
Regular Language
Let G = ( N, T, P, S) be a regular grammar. The language generated by G denoted L(G) is called a
regular language.
Example:
Find the language generated by the following regular grammar.
S → bS | bA
A → aA | a
Solution:
S → bA S → bA S → bS
S → ba S → b aA S → b bS
S → ba aA S → bb bS
S → ba , , , , aA S → bb , , , , , b bA
S → bb , , , , , b baaa , , , , a
L(G) = {bman | m, n > 1}
Let LL = L2
LL2 =L3
L(G)+ G = ( N, T, P, S) L(G)
G+ = (N, T, P+, S) L(G)+
Let G = (N, T, P, S) be λ-free regular grammar construct G+ = (N, T, P+, S) a λ-free grammar such that
L(G)+ is a language generated by G+ [ L(G+) = L(G)+ ]
Construction:
P+ = P U {α → βS for every α → β Э β Є T}
Example:
Let G be a λ-free regular with production
S → bS | bA
A → aA | a
Construct G+ and find L(G)+
Solution:
G+ = ( N, T, P+, S) with
P+ : S → bS | bA
A → aA | a | aS
L(G)+ = { (bman)k | n, m k > 1}
Let G1 = (N1, T1, P1, S1) be a regular grammar with productions:
S1 → bS1 | bA
A → aA | a
L1 = L(G1) = {bman | n, m > 1}
Theorems: