Professional Documents
Culture Documents
Meenakshi D’Souza
IIIT-Bangalore
Term II 2017-18
Examples of Regular Expressions
(b ∗ ab ∗ a)∗ b ∗
Examples of Regular Expressions
r ::= ∅ | a | r + r | r · r | r ∗
where a ∈ A.
Semantics: associate a language L(r ) ⊆ A∗ with regexp r .
L(∅) = {}
L(a) = {a}
L(r + r 0 ) = L(r ) ∪ L(r 0 )
L(r · r 0 ) = L(r ) · L(r 0 )
L(r ∗ ) = L(r )∗ .
Formal definitions
r ::= ∅ | a | r + r | r · r | r ∗
where a ∈ A.
Semantics: associate a language L(r ) ⊆ A∗ with regexp r .
L(∅) = {}
L(a) = {a}
L(r + r 0 ) = L(r ) ∪ L(r 0 )
L(r · r 0 ) = L(r ) · L(r 0 )
L(r ∗ ) = L(r )∗ .
r ::= ∅ | a | r + r | r · r | r ∗
where a ∈ A.
Semantics: associate a language L(r ) ⊆ A∗ with regexp r .
L(∅) = {}
L(a) = {a}
L(r + r 0 ) = L(r ) ∪ L(r 0 )
L(r · r 0 ) = L(r ) · L(r 0 )
L(r ∗ ) = L(r )∗ .
(a∗ + b ∗ ) · c
·
∗ ∗
a b c
Example: Semantics of regexp
(a∗ + b ∗ ) · c
·
∗ ∗
(a∗ + b ∗ ) · c
·
(a∗ + b ∗ ) · c
·
(a∗ + b ∗ ) · c
· {c, ac, bc, aac, bbc, . . .}
p q
LQ
S
Then L(A) = f ∈F sf .
DFA → RE: Kleene’s construction
p q
Advantage:
X ∪{r } X ∗
Lpq = LX X X
pq + Lpr · (Lrr ) · Lrq .
DFA → RE: Kleene’s construction (2)
Method:
Begin with LQsf for each f ∈ F .
Simplify by using terms with strictly smaller X ’s:
X ∪{r } X ∗
Lpq = LX X X
pq + Lpr · (Lrr ) · Lrq .
s f
a
DFA → RE: Kleene’s construction (2)
Method:
Begin with LQsf for each f ∈ F .
Simplify by using terms with strictly smaller X ’s:
X ∪{r } X ∗
Lpq = LX X X
pq + Lpr · (Lrr ) · Lrq .
s f e o
a