Chapter 2 REGULAR EXPRESSION
Chapter 2 REGULAR EXPRESSION
REGULAR EXPRESSION
Regular Expressions
2
Examples
0 + 1 represents the set {0, 1}
1 represents the set {1}
(0 +1)1 represents the set {01, 11}
(a+b)⋅(b+c) represents the set {ab, bb, ac, bc}
(0 + 1)* = ∈+ (0 + 1) + (0 + 1) (0 + 1)..........= Σ*
(0 + 1 )+ =(0 +1) (0 +1)*= Σ+ =Σ*- {ε}
Building Regular Expressions
4
To say zero or more ab’s, i.e.,{λ, ab,abab........,} you need to say (ab)*.
One or more: Since a* means zero or more a’s, you can use aa*
(or equivalently a*a) to mean one or more a’s.
Kleene Closure
Concatenation
Union
Regular Languages
7
ii. L = {a, ab} is a language over Σ = {a, b}because, both {a} and
{b} are regular languages by rule (b).
iii. The language over the alphabet {0,1} where strings contain an
even number of 0’s can be constructed by
1*(01* 01*)*.
10
Solutio
ns:
Regular Expressions to NFA
11
M = (Q , O , ,Σ , δ , λ , q0 ) consists of
A finite set Q of states,
A finite input alphabet Σ,
A finite output alphabet O,
A transition function δ that assigns to each
state and input pair a new state,
An output function X that assigns to each
state and input pair an output, and
An initial state q0.
17
Examples
18
Now we will swap its accepting states with its non-accepting states
and vice versa and will get the following −