FAFL Final Lecture 2.1
FAFL Final Lecture 2.1
Lecture 2.1
Regular Expressions
School of CSE
OUTLINE
Recap of Previous 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
Regular
Languages
r = ε is a RE and L(r) = { ε }
1. Highest is *
2. Concatenation(.)
3. Lowest is +
REGULAR EXPRESSIONS
Meaning
(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.
(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}
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.
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.
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 one=(a + b)
????