0% found this document useful (0 votes)
42 views30 pages

WINSEM2024-25 ISWE203L TH VL2024250503413 2025-01-20 Reference-Material-I

The document provides a comprehensive overview of Regular Expressions, including their definitions, properties, and theorems such as Arden's Theorem. It explains how to construct regular expressions from finite automata and illustrates various examples and proofs related to regular sets. Additionally, it outlines methods for converting regular expressions into finite automata using Thompson's Construction.

Uploaded by

vallerutejasree
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views30 pages

WINSEM2024-25 ISWE203L TH VL2024250503413 2025-01-20 Reference-Material-I

The document provides a comprehensive overview of Regular Expressions, including their definitions, properties, and theorems such as Arden's Theorem. It explains how to construct regular expressions from finite automata and illustrates various examples and proofs related to regular sets. Additionally, it outlines methods for converting regular expressions into finite automata using Thompson's Construction.

Uploaded by

vallerutejasree
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

REGULAR EXPRESSIONS

A Regular Expression can be recursively defined as follows −


1) ε is a Regular Expression indicates the language containing an empty
string. (L (ε) = {ε})
2) φ is a Regular Expression denoting an empty language. (L (φ) = { })
3) x is a Regular Expression where L = {x}
4) If X is a Regular Expression denoting the language L(X) and Y is a
Regular Expression denoting the language L(Y), then
1) X + Y is a Regular Expression corresponding to the
language L(X) ∪ L(Y) where L(X+Y) = L(X) ∪ L(Y).
2) X . Y is a Regular Expression corresponding to the
language L(X) . L(Y) where L(X.Y) = L(X) . L(Y)
3) R* is a Regular Expression corresponding to the
language L(R*)where L(R*) = (L(R))*
• If we apply any of the rules several times from 1 to 4, they are
Regular Expressions.
Regular Set
• Any set that represents the value of the Regular
Expression is called a Regular Set.
Regular Regular Set
Expressions
(0 + 10*) L = { 0, 1, 10, 100, 1000, 10000, … }
(0*10*) L = {1, 01, 10, 010, 0010, …}
(0 + ε)(1 + ε) L = {ε, 0, 1, 01}
(a+b)* Set of strings of a’s and b’s of any length
including the null string. So L = { ε, a, b, aa ,
ab , bb , ba, aaa…….}
(a+b)*abb Set of strings of a’s and b’s ending with the
string abb. So L = {abb, aabb, babb, aaabb,
ababb, …………..}
Regular Set

Regular Regular Set


Expressions
(11)* Set consisting of even number of 1’s including empty
string, So L= {ε, 11, 1111, 111111, ……….}
(aa)*(bb)*b Set of strings consisting of even number of a’s
followed by odd number of b’s , so L = {b, aab, aabbb,
aabbbbb, aaaab, aaaabbb, …………..}
(aa + ab + ba + String of a’s and b’s of even length can be obtained by
bb)* concatenating any combination of the strings aa, ab, ba
and bb including null, so L = {aa, ab, ba, bb, aaab,
aaba, …………..}
Properties of Regular Sets
• Property 1. The union of two regular set is regular.

Proof −
Let us take two regular expressions
RE1 = a(aa)* and RE2 = (aa)*
So, L1 = {a, aaa, aaaaa,.....} (Strings of odd length excluding
Null)
and L2 ={ ε, aa, aaaa, aaaaaa,.......} (Strings of even length
including Null)
L1 ∪ L2 = { ε, a, aa, aaa, aaaa, aaaaa, aaaaaa,.......}
(Strings of all possible lengths including Null)
RE (L1 ∪ L2) = a* (which is a regular expression itself)
• Property 2. The intersection of two regular set is
regular.
Proof −
Let us take two regular expressions
RE1 = a(a*) and RE2 = (aa)*
So, L1 = { a,aa, aaa, aaaa, ....} (Strings of all possible
lengths excluding Null)
L2 = { ε, aa, aaaa, aaaaaa,.......} (Strings of even length
including Null)
L1 ∩ L2 = { aa, aaaa, aaaaaa,.......} (Strings of even length
excluding Null)
RE (L1 ∩ L2) = aa(aa)* which is a regular expression itself.
Hence, proved.
Property 3. The complement of a regular set is regular.
Proof −
Let us take a regular expression −
RE = (aa)*
So, L = ,ε, aa, aaaa, aaaaaa, .......} (Strings of even length
including Null)
Complement of L is all the strings that is not in L.
So, L’ = ,a, aaa, aaaaa, .....} (Strings of odd length
excluding Null)
RE (L’) = a(aa)* which is a regular expression itself.
Hence, proved.
• Property 4. The difference of two regular set is regular.
Proof −
Let us take two regular expressions −
RE1 = a (a*) and RE2 = (aa)*
So, L1 = {a, aa, aaa, aaaa, ....} (Strings of all possible
lengths excluding Null)
L2 = { ε, aa, aaaa, aaaaaa,.......} (Strings of even length
including Null)
L1 – L2 = {a, aaa, aaaaa, aaaaaaa, ....}
(Strings of all odd lengths excluding Null)
RE (L1 – L2) = a (aa)* which is a regular expression.
Hence, proved.
Identities Related to Regular Expressions

Given R, P, L, Q as regular expressions, the following identities hold


• ∅* = ε
• ε* = ε
• RR* = R*R
• R*R* = R*
• (R*)* = R*
• RR* = R*R
• (PQ)*P =P(QP)*
• (a+b)* = (a*b*)* = (a*+b*)* = (a+b*)* = a*(ba*)*
• R + ∅ = ∅ + R = R (The identity for union)
• R ε = ε R = R (The identity for concatenation)
• ∅ L = L ∅ = ∅ (The annihilator for concatenation)
• R + R = R (Idempotent law)
• L (M + N) = LM + LN (Left distributive law)
• (M + N) L = ML + NL (Right distributive law)
• ε + RR* = ε + R*R = R*
Property 5. The reversal of a regular set is regular.
Proof −
We have to prove LR is also regular if L is a regular set.
Let, L = {01, 10, 11, 10}
RE (L) = 01 + 10 + 11 + 10
LR = {10, 01, 11, 01}
RE (LR) = 01 + 10 + 11 + 10 which is regular
Hence, proved.
Property 6. The closure of a regular set is regular.
Proof −
If L = {a, aaa, aaaaa, .......} (Strings of odd length
excluding Null)
i.e., RE (L) = a (aa)*
L* = {a, aa, aaa, aaaa , aaaaa,……………- (Strings of all
lengths excluding Null)
RE (L*) = a (a)*
Hence, proved.
• Property 7. The concatenation of two regular sets is
regular.
Proof −
Let RE1 = (0+1)*0 and RE2 = 01(0+1)*
Here, L1 = {0, 00, 10, 000, 010, ......} (Set of strings ending
in 0)
and L2 = {01, 010,011,.....} (Set of strings beginning with
01)
Then, L1 L2 =
{001,0010,0011,0001,00010,00011,1001,10010,.............}
Set of strings containing 001 as a substring which can be
represented by an RE − (0 + 1)*001(0 + 1)*
Hence, proved.
RE examples
RE examples
Arden's Theorem

In order to find out a regular expression of a


Finite Automaton, we use Arden’s Theorem
along with the properties of regular expressions.
Assumptions for Applying Arden’s Theorem
• The transition diagram must not have NULL
transitions
• It must have only one initial state
Arden’s Theorem
Statement −
Let P and Q be two regular expressions.
If P does not contain null string, then R = Q + RP has a
unique solution that is R = QP*
Proof −
R = Q + (Q + RP)P [After putting the value R = Q + RP]
= Q + QP + RPP
When we put the value of R recursively again and again,
we get the following equation −
R = Q + QP + QP2 + QP3…..
R = Q (ε + P + P2 + P3 + …. )
R = QP* [As P* represents (ε + P + P2 + P3 + ….) +
Hence, proved.
Method
Step 1 − Create equations as the following form for all
the states of the DFA having n states with initial state q1.
q1 = q1R11 + q2R21 + … + qnRn1 + ε
q2 = q1R12 + q2R22 + … + qnRn2
…………………………
…………………………
…………………………
…………………………
qn = q1R1n + q2R2n + … + qnRnn
Rij represents the set of labels of edges from qi to qj, if no
such edge exists, then Rij = ∅
Step 2 − Solve these equations to get the equation for
the final state in terms of Rij
Problem 1
• Construct a regular expression corresponding
to the automata given below −
The equations for the three states q1, q2, and q3 are
as follows −
q1 = q1a + q3a + ε (ε move is because q1 is the initial
state0
q2 = q1b + q2b + q3b
q3 = q2a
Now, we will solve these three equations −
q2 = q1b + q2b + q3b
= q1b + q2b + (q2a)b (Substituting value of q3)
= q1b + q2(b + ab)
= q1b (b + ab)* (Applying Arden’s Theorem)
q1 = q1a + q3a + ε
= q1a + q2aa + ε (Substituting value of q3)
= q1a + q1b(b + ab*)aa + ε (Substituting value of q2)
= q1(a + b(b + ab)*aa) + ε
= ε (a+ b(b + ab)*aa)*
= (a + b(b + ab)*aa)*
Hence, the regular expression is (a + b(b + ab)*aa)*.
Problem 2
• Construct a regular expression corresponding
to the automata given below −
Solution
Here the initial state is q1 and the final state is q2
Now we write down the equations −
q1 = q10 + ε
q2 = q11 + q20
q3 = q21 + q30 + q31
Now, we will solve these three equations −
q1 = ε0* *As, εR = R]
So, q1 = 0*
q2 = 0*1 + q20
So, q2 = 0*1(0)* *By Arden’s theorem+
Hence, the regular expression is 0*10*.
Construction of an FA from an RE

Thompson's Construction to find out a Finite


Automaton from a Regular Expression.
We will reduce the regular expression into
smallest regular expressions and converting
these to NFA and finally to DFA
• Some basic RA expressions are the following −
Case 1 − For a regular expression ‘a’, we can construct
the following FA −

Case 2 − For a regular expression ‘ab’, we can


construct the following FA −
Case 3 − For a regular expression (a+b), we can
construct the following FA −

Case 4 − For a regular expression (a+b)*, we can


construct the following FA −
Method
Step 1 Construct an NFA with Null moves from
the given regular expression.
Step 2 Remove Null transition from the NFA and
convert it into its equivalent DFA.
Problem
Convert the following RA into its equivalent DFA
− 1 (0 + 1)* 0
• concatenate three expressions "1", "(0 + 1)*" and
"0“

• Now we will remove the ε transitions. After we


remove the ε transitions from the NDFA, we get the
following −

You might also like