Theory of Automata
Theory of Automata
Finite Automata
Definition of an Automaton
“An automaton is defined as a system where energy,
materials and information are transformed,
transmitted and used for performing some functions
without direct participation of man.”
Examples are
Automatic machine tools, automatic packing machines, and
automatic photo printing machines.
Automaton
I1 Automaton O1
I2 O2
I3 O3
q1, q2, …..qn
Ip Oq
The model of a discrete automaton
Characteristics of Discrete Automaton
Input
At each discrete instance of time t1, t2,…. Input values I1, I2,…. Each of which
can take a finite number of fixed values from the input alphabet Σ, are applied
to the input side of the model.
Output
O1, O2,…. Are the outputs of the model, each of which can take finite number
of fixed values from an output O.
States
At any instant of time the automaton can be in one of the states q 1, q2, q3….
State relation
The next state of an automaton at any instant of time is determined by the
present state and the present input.
Output relation
Output is related to either state only or to both the input and the state. It
should be noted that at any instant of time the automaton is in some state.
Example 1
10 Rs. 15
Rs. 5
deposited deposited
5 5
Rs. 0 5 5 10
deposited
5
10
Rs. 10 10 Rs. 20 or
deposited more deposited
10
Each circle represents a state of the machine
Unlabelled arrow indicates the initial state of the machine
Double circle indicates that candy is released, called accepting state.
Example 1 (contd:)
C-MWG W-MCG
G G G G
MGC-W MWG-C
C W
C W
G M
Φ - MWGC MG-WC G-MWC
G M
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.
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
Example Continued …
Reading a Reading b
x- z y
y y y
z+ z z
Note
y
b
x–
a,b
a
Z+
Remark
q σ δ(q,σ)
q0 a q0
q0 b q1
q1 a q1
q1 b q0
The Language of DFA
M passes from state q0 to q1 or from q1 back to
q0 when a b is read, but M essentially ignores a’s,
always remaining in its current state when an a
is read. Thus M accepts a string if and only if the
number of b’s is even.
Then L(M) is the set of all strings in {a,b}* that
have an even number of b’s.
L(M) = { w | w Є { a, b }* and w contains
even number of b’s }
Transition Diagram
A transition diagram for a DFA M = (Q,
Σ, δ, s, F) is a graph defined as follows:
1. For each state in Q there is a node
(vertex).
2. For each state q in Q and each input
symbol a in Σ, let δ(q, a) = p. Then the
transition diagram has an arc (edge)
from node q to node p, labeled a.
3. There is an arrow into the start state a
q0, labeled start. a
b
4. Nodes corresponding to accepting
states (those in F) are marked by a q0 q1
double circle.
b
How a DFA Processes Strings?
A transition table is a
conventional, tabular
representation of a function 0 1
like δ that takes two
arguments and returns a q0 q2 q0
value.
The rows of the table *q1 q1 q1
correspond to the states, and
the columns correspond to the
inputs. q2 tableqfor
Transition q1
2 the DFA
Extending the Transition Function to
String
Design a DFA to accept the language:
L = { w | w Є {0, 1}* and w has an even
number of 0’s and even number of 1’s}
0 1
*->q0 q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2
Extending the Transition Function to
String
δ(q
^
0 , 1) = (δ(δ(q
^
0, ε ), 1) = δ(q0,1)=q1.
δ(q
^
0, 11) = (δ(δ(q0, 1), 1) = δ(q1,1)=q0.
^
δ(q
^
0, 110) = (δ(δ(q0, 11), 0) = δ(q0,0)=q2.
^
δ(q
^
0, 1101) = (δ(δ(q0, 110), 1) = δ(q2,1)=q3.
^
δ(q
^ 0, 11010) = (δ(δ(q^ 0, 1101), 0) = δ(q 3,0)=q1.
δ(q
^ 0, 110101) = (δ(δ(q ^ 0
, 11010), 1) = δ(q1,1)=q0.
Example
Build an FA accepting the Language L of Strings,
defined over Σ = {a, b}, beginning with and
ending in same letters.
Solution:The language L may be expressed by
the following regular expression
(a+b)+a(a + b)*a + b(a + b)*b
This language L may be accepted by the
following FA
Solution continued …
a b a
a
b 6+
a
2+ 4
b
1– b a b
b
b
a 7+
3+ 5
a
Example
a b b
2 4+
a a
1–
b a
a
b
3 5+
b
Example
a,b
1 2+
(a + b)*
Example
a,b
a,b
– +
FA2 a,b
1 – 2
a,b a,b
a,b
FA3 1– 2 3
+
Note (Equivalent FAs)
b a,b
a
a
1- 2 3+
b
Example
Consider the language L of strings, defined over
Σ={0, 1}, having double 0’s or double 1’s,
The language L may be expressed by the
regular expression (0+1)*
(00 + 11) (0+1)*
This language may be accepted by the following
FA
Example Continued …
0
0
0,1
- 0 1 +
1
1
y
Example
a
a
b a,b
1–– a b 6+
b a
b
3 b 5
Example
1 3
b
a a a a
2 4
b