0% found this document useful (0 votes)
29 views42 pages

Lecture 12 DFA With Output 29052023 112044pm

1. Transducers are finite state machines that produce an output for each input and transition between states. They are similar to finite state automata but associate an output with each transition. 2. There are two main types of transducers: Moore machines, which produce an output based on the current state, and Mealy machines, which produce an output based on the current input and state. 3. An example Moore machine counts the number of 'a's in an input string by outputting 0 except when in the final state, where it outputs 1.

Uploaded by

Hitesh Thahrani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views42 pages

Lecture 12 DFA With Output 29052023 112044pm

1. Transducers are finite state machines that produce an output for each input and transition between states. They are similar to finite state automata but associate an output with each transition. 2. There are two main types of transducers: Moore machines, which produce an output based on the current state, and Mealy machines, which produce an output based on the current input and state. 3. An example Moore machine counts the number of 'a's in an input string by outputting 0 except when in the final state, where it outputs 1.

Uploaded by

Hitesh Thahrani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 42

1

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.

 However, there are no final states, because there is no acceptance or rejection


involved.
Moore machine – M0
5
 Moore machine is a finite state machine with the output
philosophy - One State - One output.
 Every state will have an output associated with it. Even the start
state. a/b
X0 / 0 X1 / 1

 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

4. Put 1 as output in the final state.


b
5. Put 0 as output in the remaining states.
6. Make final state as non final state.
b
a a

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

 How to draw a transducer for the given


problem. b a
X0 X1 X2

1. Check for the pattern that needs to be count.


a
2. Consider the given pattern as an ending b
a
pattern. b

3. Draw the DFA with that restriction. X3


 Example: Count the occurrence of pattern bab
in the given input. a /0 b /0
17

 How to draw a transducer for the given b /0 a/0


X0 X1 X2
problem.
a /0
1. Check for the pattern that needs to be count. b /1
b /0 a /0
2. Consider the given pattern as an ending
pattern.
X3
3. Draw the DFA with that restriction.
4. Put 1 as output with all those edges that end in
final state. /1
5. Put 0 as output with all remaining edges.
6. Make final state as non final state.
 Input: abaababab
18

/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

2. Place the output of sate with the incoming b


edges to that state. b

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

2. Place the output of sate with the incoming b


edges to that state. b

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

2. Place the output of sate with the incoming b


edges to that state. b

3. Remove the output from the state. a


b /0 a

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

2. Place the output of sate with the incoming b


edges to that state. b

3. Remove the output from the state. a


b /0 a

4. Perform step-2,3 for all states in DFA. a b X2 /0


a X3 /1
X0 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

2. Place the output of sate with the incoming b


edges to that state. b

3. Remove the output from the state. a /0


b /0 a /0

4. Perform step-2,3 for all states in DFA. a /0 b X2 /0


a X3 /1
X0 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

2. Place the output of sate with the incoming b


edges to that state. b

3. Remove the output from the state. a /0


b /0 a /0

4. Perform step-2,3 for all states in DFA. a /0 b X2 /0


a X3 /1
X0 X1

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

2. Place the output of sate with the incoming b


edges to that state. b

3. Remove the output from the state. a /0


b /0 a /0

4. Perform step-2,3 for all states in DFA. a /0 b /0 X2 /0


a X3 /1
X0 X1

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

2. Place the output of sate with the incoming b


edges to that state. b

3. Remove the output from the state. a /0


b /0 a /0

4. Perform step-2,3 for all states in DFA. a /0 b /0 X2


a X3 /1
X0 X1

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

2. Place the output of sate with the incoming b


edges to that state. b

3. Remove the output from the state. a /0


b /0 a /0

4. Perform step-2,3 for all states in DFA. a /0 b /0 X2


a /1 X3 /1
X0 X1

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

2. Place the output of sate with the incoming b


edges to that state. b

3. Remove the output from the state. a /0


b /0 a /0

4. Perform step-2,3 for all states in DFA. a /0 b /0 X2


a /1 X3
X0 X1

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

2. Place the output of incoming edges with


the state. X2

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

2. Place the output of incoming edges with


the state. X2

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

2. Place the output of incoming edges with


the state. X2

3. Remove the output of edges. a /0 X1 /0


X0 /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

2. Place the output of incoming edges with


the state. X2

3. Remove the output of edges. a X1 /0


X0 /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

You might also like