0% found this document useful (0 votes)
63 views21 pages

FAFL Final Lecture 2.1

Uploaded by

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

FAFL Final Lecture 2.1

Uploaded by

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

Established as per the Section 2(f) of the UGC Act, 1956

Approved by AICTE, COA and BCI, New Delhi

Lecture 2.1
Regular Expressions
School of CSE
OUTLINE
Recap of Previous Lecture

Topic of the Lecture

Objective and Outcome of Lecture

Lecture Discussion
• Introduction to Regular Languages
• Definition of Regular Expressions
• Examples on Regular Expressions
NFA Minimization
Recap of Previous Lecture
RECAP OF PREVIOUS
LECTURE
NFA Minimization

Course Description

• Problem on minimization using Table Filling Method


Regular Expressions
To p i c o f t h e L e c t u r e
TOPIC OF THE LECTURE
Regular Expressions

• Introduction to Regular Languages


Regular • Definition of Regular Expressions
Expressions • Examples on Regular Expressions
Regular Expressions
Objective and Outcome of Lecture
OBJECTIVE AND OUTCOME OF LECTURE
Regular Expressions

Lecture • Demonstrate the use of Regular Expressions


Objective for constructing DFA and NFA.

Lecture • Make use of Regular Expressions for


Outcome constructing DFA and NFA.
Regular Languages
Introduction
REGULAR LANGUAGES
Introduction
Regular
DFA NFA
Expression

Regular
Languages

A Regular Language can be described using Regular Expressions


consisting of the symbols such as alphabets in Σ , operators such as ‘.’ ,’+’, ‘*’
Regular Expressions
D e fi n i t i o n
REGULAR EXPRESSIONS
Definition
A Regular Expression (RE) over Σ is an expression formed using the
following rules: ( If r is a regular expression then L(r) is language of r)
 r = Ф is a RE and L(r) = { }

 r = ε is a RE and L(r) = { ε }

 For every a  Σ, r = a is RE and L(r) = { a }

If R and S are regular expressions then:


 r = R+S is Regular and L(r) = L(R) U L(S)

 r = RS is Regular and L(r) = L(R)L(S) and


 r = R* is Regular and L(r) = (L(R))*

r = (R) is Regular and L(r) = L(R).


REGULAR EXPRESSIONS
Precedence of Operators

Parentheses may be used wherever needed to influence the grouping


of operators.

Order of precedence is * (highest), then concatenation(.), then + (lowest).

1. Highest is *

2. Concatenation(.)

3. Lowest is +
REGULAR EXPRESSIONS
Meaning

a* String consisting of any number of a’s.

a+ String consisting of at least one a.

(a + b) String consisting of either one a (or) one b.

(a + b)* Set of Strings of a’s and b’s of any length.

(a + b)* abb Set of Strings of a’s and b’s ending with string abb.

ab (a + b)* Set of Strings of a’s and b’s starting with string ab.
REGULAR EXPRESSIONS
Meaning

(a + b)* aa (a + b)* Set of Strings of a’s and b’s having a substring aa.

(a + b)* (a + bb) Set of Strings of a’s and b’s ending with either a
(or) bb.

(aa)*(bb)*b Set of Strings consisting of even numbers of a’s


followed by odd number of b’s.

(a + b) (a + b)
Strings of a’s and b’s whose length is 2.
(0 + 1)* 000 Set of String of 0’s and 1’s ending with three
consecutive zero (or) ending with 000.
Regular Expressions
Problems
REGULAR EXPRESSIONS
Problems
1: Obtain a Regular Expression to represent set of all strings over {0, 1}.

Zero Length = λ
One Length = (0 + 1)={ 0, 1}

Two Length = (0 + 1) ( 0 + 1)=(00,01,10,11}

So on………..

L={λ 0,1,01,10,11…….}

RE=(0 + 1)(0+1)(0+1)……..

RE=(0 + 1)*
REGULAR EXPRESSIONS
Problems

2: Obtain a Regular Expression where set of all strings of 0’s and 1’s beginning with 0
and ending with 1.

Starting=0, Ending=1 so, 01

Any length of 0’s and 1’s is (0 + 1)*

L={01,011,0011…….}

RE=0 (0 + 1)* 1
REGULAR EXPRESSIONS
Problems

3: Obtain a Regular Expression representing strings of a’s and b’s having length 2.

L={aa, ab, ba, bb}

Length two=(aa + ab+ ba+ bb)

Length two= a(a + b)+b(a + b)

RE=(a + b) (a + b)
REGULAR EXPRESSIONS
Problems

4: Obtain a Regular Expression to accept strings of a’s and b’s of length <=2.

Length zero= λ RE= λ+ a+ b+ aa+ ab+ ba+ bb

Length one=(a + b)

Length two= (a + b)(a + b) RE= (λ+ a+ b) (λ+ a+ b)

L={λ , a, b, aa, ab, ba, bb}


RE= (λ+ a+ b)2
DISCUSSION
5 MINUTES

????

You might also like