Lesson 04
Lesson 04
3
Note
4
Equivalent Regular Expressions
Definition:
Two regular expressions are said to be
equivalent if they generate the same language.
Example:
Consider the following regular expressions
r1= (a + b)* (aa + bb)
r2= (a + b)*aa + ( a + b)*bb then
both regular expressions define the language of
strings ending in aa or bb.
5
Note
6
Regular Languages
Definition:
The language generated by any regular
expression is called a regular language.
It is to be noted that if r1, r2 are regular
expressions, corresponding to the
languages L1 and L2 then the languages
generated by r1+ r2, r1r2( or r2r1) and
r1*( or r2*) are also regular languages.
7
Note
8
Example
9
All finite languages are regular.
Example:
Consider the language L, defined over
Σ={a,b}, of strings of length 2, starting
with a, then
L={aa, ab}, may be expressed by the
regular expression aa+ab. Hence L, by
definition, is a regular language.
10
Note
11
Irregular Languages
13
Finite Automaton Continued …
15
Defining Languages (continued)…
Method 4 (Finite Automaton)
Definition:
A Finite automaton (FA), is a collection of the
followings
1) Finite number of states, having one
initial and some (maybe none) final states.
2) Finite set of input letters (Σ) from which
input strings are formed.
3) Finite set of transitions i.e. for each state
and for each input letter there is a transition
showing how to move from one state to
another.
16
Example
Σ = {a,b}
States: x, y, z where x is an initial state and z is
final state.
Transitions:
1. At state x reading a go to state z,
2. At state x reading b go to state y,
3. At state y reading a, b go to state y
4. At state z reading a, b go to state z
17
Example Continued …
Reading a Reading b
x- z y
y y y
z+ z z
18
Note
y
b
x–
a,b
a
Z+ 19
Remark
20