Lecture 12 DFA With Output 29052023 112044pm
Lecture 12 DFA With Output 29052023 112044pm
Spring 23
Amna Iftikhar
Theory of Automata
Lecture 12
AMNA IFTIKHAR
Introduction To Transducers (DFA with Output)
2
In the previous Topics, an abstract model of a machine that accepts input values but
doesn't produce any output values, was discussed.
In the case of FSA (finite state automata), movements from state xi to xj depend
on the input at xi and no output emerges.
Some machines, however, produce output values after accepting input values.
In the case of FSM, a move from a state xi to state xj results in an output.
Introduction To Transducers (DFA with Output)
3
Tuples for Transducer:
1. Q is a finite set called the states
2. Σ is a finite set called the alphabet
3. Γ is a finite set called the output alphabet
4. δ : Q × Σ ∪ {ε} → Q, Γ is the transition function
Next State = {Current State, Input}
Output = {Current State}
5. q0 ∈ Q is the start state
Introduction To Transducers (DFA with Output)
4
Two classical machines are designed that transform input strings into output strings.
They are:
Moore machine – M0, named after Edward Moore, who introduced it in 1956.
Mealy machine – Me, named after George H.Mealy, who introduced it in 1955.
These machines are basically DFAs, except that they associate an output symbol with
each state or with each state transition.
You can have an output since the machine is in the start state and it
has an output.
Moore machines can respond to empty string.
a
X0 / 0 X1 / 1
X2 / 0
Example: Count the numbers of a’s in the given input.
6
b a
How to draw a transducer for the given problem.
1. Check for the pattern that needs to be count. a
X0 X1
2. Consider the given pattern as an ending pattern.
b
3. Draw the DFA with that restriction.
Example: Count the numbers of a’s in the given input.
7
b a
How to draw a transducer for the given problem.
1. Check for the pattern that needs to be count. a
X0 /0 X1 / 1
2. Consider the given pattern as an ending pattern.
b
3. Draw the DFA with that restriction.
4. Put 1 as output in the final state. b a
5. Put 0 as output in the remaining states.
6. Make final state as non final state. a
X0 /0 X1 / 1
b
b a 8
a
X0 /0 X1 / 1
Input : abaaba
b
Input a b a a b a
State x0 x1 x0 x1 x1 x0 x1
Output 0 1 0 1 1 0 1
Count the pattern ab in the given input
How to draw a transducer for the given problem.
9
1. Check for the pattern that needs to be count. b
a a
2. Consider the given pattern as an ending pattern.
3. Draw the DFA with that restriction. a b X2 / 1
X0 /0 X1 /0
a b X2 / 1
X0 /0 X1 /0
b
Input : aabbaababab
b
10
a a
a b X2 / 1
X0 /0 X1 /0
Input a a b b a a b a b a b
State x0 x1 x1 x2 x0 x1 x1 x2 x1 x2 x1 x2
Output 0 0 0 1 0 0 0 1 0 1 0 1
Count the pattern aba in the given input
11
b a a
a b a
X0 X1 X2 X3
b b
a
b a
a b a
X0 /0 X1 /0 X2 /0 X3 / 1
a b b
b a
a b a
X0 /0 X1 /0 X2 /0 X3 / 1
b b
Count all the occurrence of aba and bb in the input (Single Moore Machine)
12
a a
b
a b a
X0 /0 X1 /0 X2 /0 X3 / 1
a
b a b
a a
b
X4 /0
b
X5 / 1 a b a
X0 /0 X1 /0 X2 /0 X3 / 1
b a
b a b
X4 /0
b
X5 / 2
b
Mealy machine – Me 13
Mealy machine is a machine in which output symbol
depends upon the present input symbol. a/0,
X0
b/0 X1
In the Mealy machine, the output is represented with each
input symbol for each state separated by /.
a/1
X0 X1
b/0
X2
Example: Count the numbers of a’s in the given input.
14
b a
How to draw a transducer for the given problem.
1. Check for the pattern that needs to be count. a
X0 X1
2. Consider the given pattern as an ending pattern.
b
3. Draw the DFA with that restriction.
Example: Count the numbers of a’s in the given input.
15
b /0 a/ 1
How to draw a transducer for the given problem.
1. Check for the pattern that needs to be count. a/ 1
X0 X1
2. Consider the given pattern as an ending pattern.
b /0
3. Draw the DFA with that restriction.
4. Put 1 as output with all those edges that end in final state.
5. Put 0 as output with all remaining edges.
b /0 a/ 1
6. Make final state as non final state.
a/ 1
X0 X1
b /0
Example: Count the occurrence of pattern
bab in the given input. 16
a b
/1
Input a b a a b a b a b
State
x0 x0 x1 x2 x0 x1 x2 x3 x2 x3
Output
0 0 0 0 0 0 1 0 1
Conversion from Mo To Me 19
a
b a
1. Remove the output from Start state, if
there is no incoming edge.
a b X2 /0
a X3 /1
X0 /0 X1 /0
a
b a
a b X2 /0
a X3 /1
X0 /0 X1 /0
b
b
Conversion from Mo To Me 20
a
b a
1. Remove the output from Start state, if
there is no incoming edge.
a b X2 /0
a X3 /1
X0 /0 X1 /0
a
b /0 a
a b X2 /0
a X3 /1
X0 /0 X1 /0
b
b /0
Conversion from Mo To Me 21
a
b a
1. Remove the output from Start state, if
there is no incoming edge.
a b X2 /0
a X3 /1
X0 /0 X1 /0
a b X2 /0
a X3 /1
X0 /0 X1 /0
b
b /0
Conversion from Mo To Me 22
a
b a
1. Remove the output from Start state, if
there is no incoming edge.
a b X2 /0
a X3 /1
X0 /0 X1 /0
b
b /0
Conversion from Mo To Me 23
a
b a
1. Remove the output from Start state, if
there is no incoming edge.
a b X2 /0
a X3 /1
X0 /0 X1 /0
b
b /0
Conversion from Mo To Me 24
a
b a
1. Remove the output from Start state, if
there is no incoming edge.
a b X2 /0
a X3 /1
X0 /0 X1 /0
b
b /0
Conversion from Mo To Me 25
a
b a
1. Remove the output from Start state, if
there is no incoming edge.
a b X2 /0
a X3 /1
X0 /0 X1 /0
b /0
b /0
Conversion from Mo To Me 26
a
b a
1. Remove the output from Start state, if
there is no incoming edge.
a b X2 /0
a X3 /1
X0 /0 X1 /0
b /0
b /0
Conversion from Mo To Me 27
a
b a
1. Remove the output from Start state, if
there is no incoming edge.
a b X2 /0
a X3 /1
X0 /0 X1 /0
b /0
b /0
Conversion from Mo To Me 28
a
b a
1. Remove the output from Start state, if
there is no incoming edge.
a b X2 /0
a X3 /1
X0 /0 X1 /0
b /0
b /0
Conversion from Me To Mo Example:-1 29
a /0
1. Place the output 0 with start state, if there X0 X1
is no incoming edge.
b /0
X2
a /0
X0 /0 X1
b /0
X2
Conversion from Me To Mo Example:-1 30
a /0
1. Place the output 0 with start state, if there X0 X1
is no incoming edge.
b /0
a /0
X0 /0 X1
b /0
X2
Conversion from Me To Mo Example:-1 31
a /0
1. Place the output 0 with start state, if there X0 X1
is no incoming edge.
b /0
a /0 X1 /0
X0 /0
b /0
X2 /0
Conversion from Me To Mo Example:-1 32
a /0
1. Place the output 0 with start state, if there X0 X1
is no incoming edge.
b /0
b /0
X2 /0
Conversion from Me To Mo Example:-1 33
a /0
1. Place the output 0 with start state, if there X0 X1
is no incoming edge.
b /0
X2 /0
Conversion from Me To Mo Example: 2 34
a /0
b /0 a /0
a /0 b /0 X2
a /1 X3
X0 X1
b /0
b /0
Conversion from Me To Mo Example: 2 35
a /0
b /0 a /0
a /0 b /0 X2
a /1 X3
X0 /0 X1
b /0
b /0
Conversion from Me To Mo Example: 2 36
a /0
b a /0
a /0 b /0 X2
a /1 X3
X0 /0 X1
b /0
b
Conversion from Me To Mo Example: 2 37
a /0
b a /0
a /0 b /0 X2
a /1 X3
X0 /0 X1 /0
b /0
b
Conversion from Me To Mo Example: 2 38
a
b a
a b /0 X2
a /1 X3
X0 /0 X1 /0
b /0
b
Conversion from Me To Mo Example: 2 39
a
b a
a b /0 X2 /0
a /1 X3
X0 /0 X1 /0
b /0
b
Conversion from Me To Mo Example: 2 40
a
b a
a b X2 /0
a /1 X3
X0 /0 X1 /0
b
b
Conversion from Me To Mo Example: 2 41
a
b a
a b X2 /0
a /1 X3 /1
X0 /0 X1 /0
b
b
Conversion from Me To Mo Example: 2 42
a
b a
a b X2 /0
a X3 /1
X0 /0 X1 /0
b
b