Professional Documents
Culture Documents
CSC3113 Lec02
CSC3113 Lec02
Theory Of Computation
Finite Automaton
Computational Model
Finite State Machine
Formal Definition
Designing
Regular operations
Mashiour Rahman
Assistant Professor
Computer Science Department
American International University-Bangladesh
Finite Automata
We will use several different models, depending on
the features we want to focus on. Begin with the
simplest model, called the finite automaton.
Good models for computer with an extremely limited
amount of memory. For example, various household
appliances such as dishwashers and electronic
thermostats, as well as parts of digital watches and
calculators.
The design of such devices requires keeping the
methodology and terminology of finite automata in
mind.
Next we will analyze an example to get an idea.
CSC3113 Theory Of Computation
Mashiour Rahman
Finite Automaton 2
An Example
Front
pad
Rear
pad
REAR
BOTH
NEITHER
REAR
BOTH
FRONT
FRONT
CLOSED
OPEN
FRONT
REAR
BOTH
CLOSED
CLOSED
OPEN
CLOSED
CLOSED
OPEN
CLOSED
OPEN
OPEN
OPEN
NEITHER
State
Mashiour Rahman
Simulation
Input Example:
Initial State: CLOSED
Input Signal Sequence: FRONT, REAR, NEITHER, FRONT, BOTH, NEITHER,
REAR, NEITHER.
Present State:
CLOSED
OPEN
Input Signal:
NEITHER
FRONT
REAR
BOTH
REAR
BOTH
NEITHER
REAR
BOTH
FRONT
FRONT
Front
pad
Rear
pad
CLOSED
OPEN
NEITHER
Mashiour Rahman
Finite Automaton 4
Mashiour Rahman
Finite Automaton 5
Terminology
q1
q2
q3
0,1
Mashiour Rahman
Finite Automaton 6
Simulation
q1
1101
1101
Figure: Finite Automaton M1.
q13
01
101
0,1
After feeding the input string 1101 to the above machine, the
processing proceeds as follows
Start in state q1;
Read 1, follow transition from q1 to q2;
Read 1, follow transition from q2 to q2;
Read 0, follow transition from q2 to q3;
Read 1, follow transition from q3 to q2;
Accept, as the machine M1 is in an accept state q2 at the end of
the input string.
CSC3113 Theory Of Computation
Mashiour Rahman
Finite Automaton 7
Formal Definition
A finite automaton is a 5-tuple (Q, , , q0, F), where
Q is a finite set called the states,
is a finite set called the alphabet,
Mashiour Rahman
Finite Automaton 8
Example
0
q1
M1 = (Q, , , q0, F), where
Q = {q1, q2, q3},
q2
q3
0,1
= {0, 1},
is describe as
0 1
q1 q1 q2
q2 q3 q2
q3 q2 q2
or
q 0 = q 1,
F = {q2}.
CSC3113 Theory Of Computation
Mashiour Rahman
Finite Automaton 9
Mashiour Rahman
Finite Automaton 10
Example
a1
2
1
0
a0
Alphabet ={0,1,2}.
2
1
a2
0
a201
Input symbol:
01120101
Accepted
CSC3113 Theory Of Computation
Q1 = {a0,a1,a2},
q1 = a0,
F1 = {a0},
1
a0
a1
a2
|
|
|
|
Mashiour Rahman
0
a0
a1
a2
1
a1
a2
a0
2 .
a2
a0
a1
Finite Automaton 11
Example
0,2
b0
1
1
b1
0,2
Alphabet ={0,1,2}.
Language A1 = {w : the sum of all the symbols
in w is an even number }.
Can be represented as follows
S= the sum of all the symbols in w.
If S modulo 2 = 0 then the sum is even.
Here, bi is modeled as S modulo 2 = i.
b10
Input symbol:
01120101
Accepted
CSC3113 Theory Of Computation
2
b0
b1
|
|
|
Mashiour Rahman
0
b0
b1
1
b1
b0
2 .
b0
b1
Finite Automaton 12
Regular Language
A language is called a regular language if some finite
automaton recognizes it.
Regular Operations: Let A={good, bad}, B = {boy, girl}.
Basic three operations used to study the properties of the regular
languages
Union: AB = {x : x A or x B} = {good, bad, boy, girl}.
Takes all the strings in both A and B and lumps them together into
one language.
Mashiour Rahman
Finite Automaton 13
Closure
A collection of objects is closed under some
operation, if applying that operation to the
members of the collection returns an object
still in the collection.
Theorem: Collection of regular languages is
closed under all three of the regular
operations.
Next, we will prove it for Union operation.
Mashiour Rahman
Finite Automaton 14
= 1 2.
But here, for simplicity, we have considered 1 = 2 to be same.
For each (r1,r2) Q and each a , let ((r1,r2), a) = ((r1, a), (r2, a)).
Hence gets a state of M (which actually is a pair of states from M1 and
M2), together with an input symbol, and returns Ms next state.
Mashiour Rahman
Finite Automaton 15
Example
Let,
So,
Q1 = {a0,a1,a2},
= {0, 1, 2}
= {0, 1, 2}
q1 = a0,
q0 = (a0, b0),
F1 = {a0},
|0
a0 | a 0
a1 | a 1
a2 | a 2
2 .
a2
a0
a1
|
|
|
|
|
|
|
0
(a0, b0)
(a0, b1)
(a1, b0)
(a1, b1)
(a2, b0)
(a2, b1)
1
(a1, b1)
(a1, b0)
(a2, b1)
(a2, b0)
(a0, b1)
(a0, b0)
2
.
(a2, b0)
(a2, b1)
(a0, b0)
(a0, b1)
(a1, b0)
(a1, b1)
q2 = b0,
(a0, b0)
(a0, b1)
(a1, b0)
(a1, b1)
(a2, b0)
(a2, b1)
1
b1
b0
2 .
b0
b1
Simulation
2
(a1,b0)
(a2,b1)
0
1
(a0,b0)
(a1,b1)
2
(a2,b0)
(a0,b1)
0
1
Input symbol:
Accepted
CSC3113 Theory Of Computation
Mashiour Rahman
Finite Automaton 17
Mashiour Rahman
Finite Automaton 18