You are on page 1of 28

FA with output

Finite Automata with Output


Finite automata as mathematical models of computers letters of words transitions state ? input execution of instructions (a program) contents of memory output

Moore machine
A Moore machine is a collection of 6 things: 1. a finite set of states q0,q1,q2,, where q0 is designated the start state 2. an alphabet of input letters 3. an alphabet of output characters 4. a transition table that shows for each state and each input letter what state to go to next. 5. an output table that shows what character is output (or printed) when entering a state. 6. q0 the starting state

(state, letter from )

transition

state

Moore machine
Example: states = {q0,q1,q2,q3} Old state q0 q1 q2 q3 q0/ 1 Output by the old state 1 0 0 1 S={a,b} G={0,1}

New state After input a After input b q1 q3 q3 q1 q0 q3 q3 q2 q1/ 0

a
q2/ 0

a b
b b

abab

a
q3/ 1

10010

Moore machine
Example: A machine that counts aabs

b a
q0/0 q1/0

a a
a
q2/0

q3/1

b b
Input State Output q0 0 a q1 0 a q2 0 a q2 0 b q3 1 a q1 0 b q0 0 b q0 0 a q1 0 a q2 0 b q3 1 b q0 0

Printing 1 final state

words that end in aab

Mealy machine
A Mealy machine is: 1. a finite set of states q0,q1,q2,, where q0 is designated the start state 2. an alphabet S of input letters 3. an alphabet G of output characters 4. a finite set of transitions that indicate, for each state and letter of the input alphabet, the state to go to next and the character that is output (printed).
state input/output state

Mealy machine
b/0 a/0
q0 q1

a/0
a/0
q2

a/0 b/1

q3

b/0

b/0

Mealy machine
Example a/0
q0
q1

b/1 a/0
q2

baaba 01110

b/0

a/1
q3

b/1

b/1

a/1

Mealy machine
Abbreviation: a/x
q4

q7

b/y

q4

a/x, b/y

q7

Example: binary complement S={0,1} G={0,1}


0/1,1/0
q0 101 010 001010 110101

Mealy machine
Example: an Increment Machine 0/1
start

0/0,1/1 0/1 1/0


carry

1/0
decimal: binary : reverse: 11 1011 1101

1111 (overflow)
reverse: decimal: 00 11 1100 12

0000

Mealy machine
Parity checker using mealy machine

Moore M/c For 1s Complement

Mealy Machine for 2s Complement


Read input from LSB to MSB. Keep all Zeros until we read first 1. Keep that 1 as it is then change remaining 1s by 0s and 0s by 1s.

Equivalence
Let Mo be a Moore machine that prints x in the start state. Let Me be a Mealy machine. The two machines are equivalent if for every input, whenever the output from Me is w, the output from Mo is xw.

Moore to Mealy M/C


Theorem: For every Moore machine, there exists a Mealy machine that is equivalent to it.

Proof: By constructive algorithm


a b c
q4 / t

a/t

b/t
c/t

q4

Moore to Mealy M/C


For Example, Convert the given Moore m/c to Mealy m/c

a
q0/0

q1/1

a,b
q3/1

q2/0

Moore to Mealy M/C


Solution :

a/1
q0

q1

a/1

a/1,b/1
q3

b/0 b/0
q2

b/1

a/0

Mealy to Moore M/C


Theorem: For every Mealy machine, there exists a Moore machine that is equivalent to it.

Proof: By constructive algorithm


a/0 b/0 a/1
q4

b
q1 4/ 0

a/1 b/1 b

q24/ 1

a/1 b/1

b/1

b/1

Mealy to Moore M/C


We must consider 1. incoming edges 2. outgoing edges 3. loops

a
q13/0

a/0
a/0 a/0
q6

q6

b/1

q3

a/0
b
q23/1

Mealy to Moore M/C


If there is no entering arrow, choose any letter from output character set .

a/0
q3

q13/ 0

a/0 b/1

b/1

Mealy to Moore M/C


For example:
b/1
q1

a/0
q0

a/1

b/0
q2

a/1 b/0 b/1


q3

a/0

Mealy to Moore M/C


Solution :
a
q1 0/ 0

b a
q1/1

b
q12/0

b
q2 0/ 1

b
q22/ 1

a b b a
q3/0

Another Method Mealy to Moore Conversion

Mealy to Moore conversion Example

Solution

A Good Book
Theory Of Computation By A.A.Puntambekar
Available on Google Books http://booklens.com/dexterkozen/automata-andcomputability?ref=related

Moore M/c Mealy M/c


Moore M/c

Mealy M/c

Mealy Moore
Mealy M/c

Moore M/c

You might also like