Professional Documents
Culture Documents
REGULAR GRAMMARS
Rao Wakeel Ahmad
2
REGULAR LANGUAGES
• A language is regular if there exists a finite accepter
for it. Therefore, every regular language can be
described by some dfa or some nfa.
3. Star-closure by *
4
Formal Definition of RE
• Let Σ be a given alphabet. Then
Languages Associated RE
• Regular expressions can be used to describe some
simple languages. If r is a regular expression, we will
let L(r) denote the language associated with r.
7
Languages Associated RE
The language L(r) denoted by any regular expression r is
defined by the following rules.
1. Ø is a regular expression denoting the empty set,
2. λ is a regular expression denoting {λ}.
3. For every a ∈ Σ, a is a regular expression denoting {a}.
4. L (r1 + r2) = L (r1)∪ L (r2)
5. L (r1 · r2) = L (r1) ∪ L (r2)
6. L ((r1)) = L (r1)
7. L ( ) = (L (r1))*
Regular Expression
Regular Expression
Building Regular Expressions
Assume that ∑ = {a, b, c}
Languages Associated RE
Languages Associated RE
The expression r =(aa)* (bb)* b
Languages Associated RE
L(r) = {w ∈ Σ*: w has at least one pair of consecutive
zeros}.
Home Practice
1. Find all strings in L((a + b) b (a + ab)*) of length less
than four.
Regular Grammars
• A regular grammar is one that is either right-linear or
left linear.
1. A grammar G =(V, T, S, P) is said to be right-linear if
all productions are of the form
A → xB,
A→x
1. A grammar is said to be left-linear if all productions
are of the form
A → Bx,
A → x.
30
Linear Grammars
• The grammar G =({S, A, B}, {a, b}, S, P) with productions
S→A
A → aB|λ,
B → Ab
Pumping Lemma
34
Pumping Lemma
35
Pumping Lemma
36
Pumping Lemma
37
Pumping Lemma
38
Pumping Lemma
39
Pumping Lemma
40
Pumping Lemma
41
Pumping Lemma
42
Pumping Lemma
43
Pumping Lemma
44
Pumping Lemma
45
Pumping Lemma
46
Pumping Lemma