2. SYLLABUS
Regular Expressions: Finite Automata and Regular Expressions,
Applications of Regular Expressions, Algebraic Laws for Regular
Expressions, Conversion of Finite Automata to Regular Expressions.
Pumping Lemma for Regular Languages, Statement of the pumping
lemma, Applications of the Pumping Lemma.
Closure Properties of Regular Languages: Closure properties of
Regular languages, Decision Properties of Regular Languages,
Equivalence and Minimization of Automata.
3. Regular Expressions.
● Regular expressions are used for representing certain
sets of strings in algebraic fashion.
● Any terminal symbol belongs to Σ including ɸ,ɛ are
RE
● The union of 2 RE is also RE
● The Concatenation of 2 RE is also RE
● The iteration or closure of RE is also RE
4. Regular Expressions Regular Set
(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…….}
(11)* Set consisting of even number of 1’s
including empty string, So L= {ε, 11, 1111,
111111, ……….}
(0+1)*011(0+1)* Sub string 011
5. Operators of RE
Operators used in regular expressions include:
• Union: If R1 and R2 are regular expressions, then R1 | R2 (also written as R1 U R2 or R1 +
R2) is also a regular expression.
L(R1|R2) = L(R1) U L(R2) or L(R1+R2)
• Concatenation: If R1 and R2 are regular expressions, then R1R2 (also written as R1.R2) is
also a regular expression.
L(R1R2) = L(R1) concatenated with L(R2).
• Kleene closure: If R1 is a regular expression, then R1* (the Kleene closure of R1) is also a
regular expression.
L(R1*) = epsilon U L(R1) U L(R1R1) U L(R1R1R1) U ...
7. Applications of RE
● RE in unix
• [ :digit:][0-9]
• [:alpha:]a-z A-Z
• [:Alnum:] [A-Z a-z 0-9]
● Lexical Analysis
● Finding Patterns in Text
● Grep utility in unix.
8. Algebraic Laws of RE
● COMMUTATIVITY
● ASSOCIATIVITY
● IDENTITIES
● ANNIHILATOR
● DISTRIBUTIVE
● IDEMPOTENT
9. COMMUTATIVITY
● For regular expressions, we have:
● L + M = M + L
● Commutative law for union: we may make the union of two
languages in either order
● Clearly the law L.M = M.L is FALSE (Commutative law for
concatenation)
10. ASSOCIATIVITY
● (L + M) + N = L + ( M + N) Associative law for union: we
may take the union of three languages either by taking the
union of the first two initially, or taking the union of the last
two initially. Together with the commutative law we can take
the union of any collection of languages with any order and
grouping, and the result will be the same. Intuitively, a string
is in L1 ∪ L2 . . . ∪ Lk iff it is in one or more of the Li s.
● (L.M).N = L.(M.N) Associative law for concatenation: we
can concatenate three-languages by concatenating either the
first two or the last two initially
11. IDENTITIES
● An identity for an operator is a value that when the
operator is applied to the identity and some other value, the
result is the other value.
● ∅ + L = L + ∅ = L
● e.L = L.e = L
12. ANNIHILATOR
● An annihilator for an operator is value that when the
operator is applied to the annihilator and some other
value, the result is the annihilator.
● ∅.L = L. ∅ = ∅
13. DISTRIBUTIVE
● For regular expressions we have:
● Left distributivity: L.(M + N) = LM + LN
● Right distributivity: (M + N).L = ML + NL
14. IDEMPOTENT
● An operator is idempotent if the result of applying it to two
of
● the same values as arguments is that value.
● Idempotent Law for union:
● L + L = L
● If we take the union of two identical expressions, we can
replace them by one copy of the expression.
15. Identities Related to Regular Expressions l={0,1}{l2}
Given R, P, L, Q as regular expressions, the following
identities hold −
• ∅* = ε
• ε* = ε
• RR* = R*R=R+
• R*R* = R*
• (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*
16. 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.
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.
18. From DFA to RE
● Arden’s Theorem Steps:
● 1) Build RE for each state
● 2) Solve final states equations first
● State Elimination Method Steps
● 1) The start state of DFA must not have any incoming edges. If there exists any
incoming edge to start state ,then create a new state having no income edges.
● 2)There must be only one final state in DFA, If DFA contain more final states,
then create a new final state and all other final states to non final states
● 3) The final state of DFA doesn’t contain any out going edges, then create new
final state without any out going edges
● 4) Now start elimination intermediate states in any order. Finally we have
initial state going to final state.
22. Limitation of FA
● It have finite number of states.
● Finite amount of memory so doesn’t remember
previous state outcome.
● So in above scenarios we use pumping lemma.
23. Pumping Lemma
Theorem
Let L be a regular language. Then there exists a
constant ‘n’ such that for every string w in L −
|w| ≥ n
We can break w into three strings, w = xyz, such that −
• |y| = ε
• |xy| ≤ n
• For all k ≥ 0, the string xykz is also in L.
Applications of Pumping Lemma
Pumping Lemma is to be applied to show that certain
languages are not regular. It should never be used to show a
language is regular.
• If L is regular, it satisfies Pumping Lemma.
• If L does not satisfy Pumping Lemma, it is non-regular.
25. Properties of Regular Sets/ Closure Properties
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)
Hence, proved.
26. 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.
27. 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.
28. 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.
29. 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.
30. 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.
31. 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.
32. Decision Properties of Regular Languages
● Membership
L={ends with 00|{0,1}}
w={1100,00,100,0100,00100….}
● Emptiness
● Equivalence