Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 50

CS8501 THEORY OF COMPUTATION

ONLINE CLASS

UNIT-2
REGULAR EXPRESSIONS AND LANGUAGES

PRESENTED BY
Mr. K. SANKAR GANESH
AP&HOD/CSE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC,
VELLORE
Regular Expression
•The language accepted by finite automata can be easily
described by simple expressions called Regula Expressions.
• It is the most effective way to represent any language.
•The languages accepted by some regular expression are
referred to as Regular languages.
•A regular expression can also be described as a sequence
of pattern that defines a string.
•Regular expressions are used to match character
combinations in strings. String searching algorithm used this
pattern to find the operations on a string.

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
In a regular expression,
• x* means zero or more occurrence of x.
• It can generate {e, x, xx, xxx, xxxx, .....}

In a regular expression,
• x+ means one or more occurrence of x.
• It can generate {x, xx, xxx, xxxx, .....}

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
R = 1 (0+1)* 0

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
CLOSURE PROPERTIES OF REGULAR LANGUAGES

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
CONVERSION OF REGULAR EXPRESSION TO FINITE AUTOMATA

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
State q goes via ε either to the initial state of N(s) or N(t). Their final states
become intermediate states of the whole NFA and merge via two ε-transitions into
the final state of the NFA.
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
The initial state of N(s) is the initial state of the whole NFA.
The final state of N(s) becomes the initial state of N(t). The
final state of N(t) is the final state of the whole NFA.

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
An ε-transition connects initial and final state of the NFA with the sub-NFA N(s) in
between.
Another ε-transition from the inner final to the inner initial state of N(s) allows for
repetition of expression s according to the star operator.
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Conversion of RE to FA
To convert the RE to FA,
we are going to use a method called the subset method.
This method is used to obtain FA from the given regular expression.

Step 1: Design a transition diagram for given regular expression, using NFA with ε
moves.
Step 2: Convert this NFA with ε to DFA.

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Example 2:

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Arden's Theorem

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
PUMPING LEMMA FOR REGULAR LANGUAGE

For any regular language L, there exists an integer n, such that for
all x ∈ L with |x| ≥ n, there exists u, v, w ∈ Σ∗, such that x = uvw,
and
(1) |uv| ≤ n
(2) |v| ≥ 1
(3) for all i ≥ 0: uviw ∈ L

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
For example, let us prove L01 = {0n1n | n ≥ 0} is irregular.
Let us assume that L is regular, then by Pumping Lemma the above given rules
follow.
Now, let x ∈ L and |x| ≥ n.
So, by Pumping Lemma, there exists u, v, w such that (1) – (3) hold.

We show that for all u, v, w, (1) – (3) does not hold.

If (1) and (2) hold then x = 0n1n = uvw with |uv| ≤ n and |v| ≥ 1.

So, u = 0a, v = 0b, w = 0c1n where : a + b ≤ n, b ≥ 1, c ≥ 0, a + b + c = n

But, then (3) fails for i = 0

uv0w = uw = 0a0c1n = 0a + c1n ∉ L, since a + c ≠ n.

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE

You might also like