You are on page 1of 9

Theory of Computation (With Automata Theory)

Equivalence of Regular
Expressions and Finite
Automata
Regular Expressions and Finite
Automata

Introduction

Regular
expressions
are
similar to finite automata
(deterministic
and
nondeterministic) in the sense
that they are used to describe
languages.

A language is regular if there


is some NFA that recognizes
it.

Equivalence of Regular Expressions and Finite Automata

* Property of STI
Page 1 of 9

Theory of Computation (With Automata Theory)

Do regular expressions also


define regular languages in the
same
manner
as
finite
automata do?

To
determine
if
regular
expressions define regular
languages, it must shown that:

1. If a language is described
by a regular expression,
then it is a regular
language.

2. If a language is regular,
then there is a regular
expression that describes
it.

Equivalence of Regular Expressions and Finite Automata

* Property of STI
Page 2 of 9

Theory of Computation (With Automata Theory)

Regular Expressions to NFA

To show if a language that is


described
by
a
regular
expression
is
a
regular
language, it must be shown
that there is an NFA that
recognizes the language.

To do this, a procedure must


be outlined for converting the
regular
expression
that
describes a certain language
to an NFA.

If this is done, then the


language
that
is
being
described by the regular
expression
is
a
regular
language.

Equivalence of Regular Expressions and Finite Automata

* Property of STI
Page 3 of 9

Theory of Computation (With Automata Theory)

The procedure for converting a


regular expression to an NFA
will be based on the definition
of regular expressions.
1. The empty string is a
regular expression.
The NFA that accepts the
empty string is

2. The empty language is a


regular expression.
The NFA that accepts the
empty language is

Equivalence of Regular Expressions and Finite Automata

* Property of STI
Page 4 of 9

Theory of Computation (With Automata Theory)

3. Every symbol x in is a
regular expression.
The NFA that accepts the
symbol x is
x

4. If R1 and R2 are regular


expressions, then R1 + R2
is
also
a
regular
expression.
The NFA that accepts R1 +
R2 is

NFA for R1
q0

NFA for R2

Equivalence of Regular Expressions and Finite Automata

* Property of STI
Page 5 of 9

Theory of Computation (With Automata Theory)

5. If R1 and R2 are regular


expressions, then R1R2 is
also a regular expression.
The NFA that accepts R1R2
is
e

q1
NFA for R1

q2
NFA for R2

6. If
R1
is
a
regular
expression, then R1* is
also a regular expression.
The NFA that accepts R1*
is

q0

q1

e
`

NFA for R1

Equivalence of Regular Expressions and Finite Automata

* Property of STI
Page 6 of 9

Theory of Computation (With Automata Theory)

Example:
Convert the regular expression
(0 + 1)* 01 to an NFA
NFA for 0:
0

NFA for 1:
1

NFA for (0 + 1):


e

Equivalence of Regular Expressions and Finite Automata

* Property of STI
Page 7 of 9

Theory of Computation (With Automata Theory)

NFA for (0 + 1)*:


e

NFA for 01:

Equivalence of Regular Expressions and Finite Automata

* Property of STI
Page 8 of 9

Theory of Computation (With Automata Theory)

NFA for (0 + 1)*01:


e

e
1

Equivalence of Regular Expressions and Finite Automata

* Property of STI
Page 9 of 9