ACD UNIT 2 RegularExpression
ACD UNIT 2 RegularExpression
UNIT-III
Objective:
To familiarize how to employ regular expressions.
Syllabus:
Regular sets, regular expressions, identity rules, construction of finite
Automata for a given regular expressions and its inter conversion, pumping
lemma of regular sets, closure properties of regular sets (proofs not
required),applications of regular languages.
Learning Outcomes:
Students will be able to:
understand the regular sets and how to represent the regular
expressions.
construct finite Automata for a given regular expression and viceversa.
list closure properties of regular languages.
understand the different applications of regular languages.
Learning Material
Regular set:
A language is a regular set (or just regular) if it is the set accepted by some
finite automaton.
Example:
L= {0, 1, 10, 00, 01, 11, 000, 101, .................} is a regular set representing
any no of 0’s and any no of 1’s.
Regular expression:
The languages accepted by finite automata are easily described by simple
expressions called regular expressions.
an alphabet and the sets that they
denote are defined recursively as follows.
1) Ø is a regular expression and denotes the empty set.
is a regular e }.
r+ = rr* = r*r
r*r* = r*
(r*)* = r*
r+s=s+r
(r + s) + t = r + (s + t)
(rs)t = r(st)
r(s + t) = rs + rt
(r + s)t = rt + st
r+ = +r=r
L=L =
r+r=r
* *
Construct
M = (Q1 Q2 {q0, f0}, , , q0, {f0}) where is defined by
i) (q0,
iv) (f1, { f0 }
where is defined by
ii) (f1,
i) (q0, (f1,
Example:
1. Construct an NFA for the regular expression 01*+1
Example:
1. Construct regular expression for the given finite automaton.
Step 1: Find the reachability for each and every state in given Finite
automata.
Reachability of a state is the set of states whose edges enter into that state.
q0=q0 0 1
q1= q0 1 + q10 + q2 1 2
q2= q1 1 + q20 3
Step 2: For the initial state of finite automata, add epsilon to the
reachability equation.
q0=q0 0 +
Step 3: Solve the equations by using Arden’s Theorem.
After applying arden’s theorem for equation 3
q2=q1 10* 4
Substitute equation 4 in equation 2
q1= q0 1 + q10+q1 10*
q1= q0 1 + q1(0+10*) 5
Apply arden’s theorem on equation 5
q1= q01 (0+10*)* 6
Apply arden’s theorem on equation 1
q0=q0 0 +
q0= 0* 7
Substitute equation 7 in equation 6
q1= 0* 1 (0+10*)* 8
Step 4: Substitute the results of each state equation into the final state
equation, to get the regular expression for the given DFA.