moore & mealy machine
TRANSCRIPT
MOORE & MEALY MOORE & MEALY MACHINEMACHINE
COMPILED BYCOMPILED BYASHWIN PRAKASH SRIVASTAVAASHWIN PRAKASH SRIVASTAVA
22NDND IT IT234/05234/05
LIMITATION OF LIMITATION OF FINITE AUTOMATA MACHINESFINITE AUTOMATA MACHINES
One limitation of the FINITE AUTOMATA is One limitation of the FINITE AUTOMATA is that output is limited to a binary signal that output is limited to a binary signal TRUE(1) or FALSE(0) depending on the TRUE(1) or FALSE(0) depending on the basis of reachability of the final state by the basis of reachability of the final state by the initial state. The only explicit task a machine initial state. The only explicit task a machine has done so far is to recognize a language has done so far is to recognize a language whereas computers can perform calculations whereas computers can perform calculations and convey the result i.e. provide OUTPUT. and convey the result i.e. provide OUTPUT.
FINITE AUTOMATA FINITE AUTOMATA WITH OUTPUTWITH OUTPUT
Moore and Mealy machines remove this Moore and Mealy machines remove this limitation and provide output. They are limitation and provide output. They are FINITE AUTOMATA MACHINE with FINITE AUTOMATA MACHINE with OUTPUT.OUTPUT.
For example We simply want to print out a For example We simply want to print out a copy of the input string.copy of the input string.
DIFFERENCE BETWEENDIFFERENCE BETWEENMEALY AND MOOREMEALY AND MOORE
MACHINESMACHINES In Mealy machine output function Z(t) depends on In Mealy machine output function Z(t) depends on
both the present state q(t) and the present input x(t). both the present state q(t) and the present input x(t).
The expression for Mealy machine is The expression for Mealy machine is Z(t) = Z(t) = λλ[q(t),x(t)] [q(t),x(t)] λλ = output function. = output function. In Moore machine output function Z(t) depends only In Moore machine output function Z(t) depends only
on the present state and is independent of the on the present state and is independent of the current input.current input.
The expression for Moore machine is The expression for Moore machine is Z(t) = Z(t) = λλ[q(t)].[q(t)].
MOORE MACHINEMOORE MACHINE
Developed by E.F. Moore in 1956.Developed by E.F. Moore in 1956. It is a finite automata machine with outputIt is a finite automata machine with output The output is associated with each state. The output is associated with each state.
Every state of this machine has a fixed output.Every state of this machine has a fixed output. There is no concept of final state in Moore There is no concept of final state in Moore
machine.machine. It can be represented by Transition table as It can be represented by Transition table as
well as Transition diagram.well as Transition diagram. It is a six tuple machine.It is a six tuple machine.
MATHEMATICAL MATHEMATICAL REPRESENTATIONREPRESENTATION
M = (Q , M = (Q , ΣΣ , , λλ , , ΔΔ , q , qoo , , δδ)) Q = A nonempty finite set of state in M.Q = A nonempty finite set of state in M. ΣΣ = A nonempty finite set of input symbols. = A nonempty finite set of input symbols. ΔΔ = A nonempty finite set of outputs. = A nonempty finite set of outputs. δδ = It is a transition function which takes two = It is a transition function which takes two
arguments input state and input symbol.arguments input state and input symbol. qqo o = = Initial state of M belongs to Q.Initial state of M belongs to Q. λλ = It is a mapping function which maps Q to = It is a mapping function which maps Q to ΔΔ
giving output associated with each state.giving output associated with each state.
REPRESENTATION OFREPRESENTATION OFMOORE MACHINEMOORE MACHINE
Let M be a Moore machine and a1 , a2 , a3 , Let M be a Moore machine and a1 , a2 , a3 , …….a…….ann be input symbols where n>0 then be input symbols where n>0 then output of M is output of M is λλ(q(q11) , ) , λλ(q(q22), ), λλ(q(q33) , ) , λλ(q(q44) ) ………… ………… λλ(q(qnn) , such that ) , such that
δδ(q(qi – 1 , i – 1 , aai i ) = q) = qi i for 1<i<n. for 1<i<n.
EXAMPLE OF EXAMPLE OF MOORE MACHINEMOORE MACHINE
qq00 qq33 qq11 00
qq11 qq11 qq22 11
qq22 qq22 qq33 00
qq33 qq33 qq00 00
Present Present statestate
inputinput
a=0 a=1a=0 a=1outputoutput
TRANSITION TABLE
VALUES OF VALUES OF Q, Q, ΣΣ, , ΔΔ
Q = {Q = {qq0 0 ,, qq1 1 ,, qq2 2 ,, qq3 3 }} ΣΣ = { 0 , 1 } = { 0 , 1 } ΔΔ = { 0 , 1 } = { 0 , 1 } λλ(q(q00) = 0 , ) = 0 , λλ(q(q11) = 1 , ) = 1 , λλ(q(q22) = 0 , ) = 0 , λλ(q(q33) = 0 ) = 0
TRANSITION DIAGRAM
q0
q2 q3
q1
0
0
11
1
0
0 0
1
01
0
0
PROCESSING OF STRINGPROCESSING OF STRINGTHROUGHTHROUGH
MOORE MACHINEMOORE MACHINE Let the input string be w = 0111 and Output Let the input string be w = 0111 and Output
string will be string will be єєw’ = 00010.w’ = 00010.
q2q01110 01000
q3 q1q0
|w| = 4|w’| = 5
Since for the input of null string the output is 0
єє
A Moore machine that counts the A Moore machine that counts the occurrence of substring “aab” in occurrence of substring “aab” in
the input strungthe input strung Let the input string be w = “aaabbbaabaa”Let the input string be w = “aaabbbaabaa” M = (Q , M = (Q , ΣΣ , , λλ , , ΔΔ , q , qoo , , δδ)) Q = {Q = { qq1 1 ,, qq2 2 ,, qq3 3 ,, qq4 4 }} ΣΣ = { a , b } = { a , b } ΔΔ = { 0 , 1 } = { 0 , 1 } λλ(q(q0 0 ) = 0 , ) = 0 , λλ(q(q1 1 ) = 0 , ) = 0 , λλ(q(q2 2 ) = 0 , ) = 0 , λλ(q(q33) = 1 ) = 1
q0
q1
q2
q3
b
a
bb
a
a
ab
TRANSITION DIAGRAM
1
00
0
a a a b b b a a b a a
q3q0baaa 10000
q1 q2q2
q3q0baab 10000
qo q2q1
q1
b
0q2
0a
a
0 0 0 0 1 0 0 0 0 1 0 0
RESULTRESULT
The occurrence of 1’s in the output string is The occurrence of 1’s in the output string is 2 so the number of times “aab” appears in 2 so the number of times “aab” appears in the input string is 2.the input string is 2.
MEALY MACHINEMEALY MACHINE
Independently developed by G.H. Mealy in Independently developed by G.H. Mealy in 19551955
Output is associated with each transition.Output is associated with each transition. Output is fixed for a particular input symbol.Output is fixed for a particular input symbol. It can be represented by Transition table as It can be represented by Transition table as
well as Transition diagram.well as Transition diagram. It is a six tuple machine.It is a six tuple machine.
MATHEMATICAL MATHEMATICAL REPRESENTATIONREPRESENTATION
M = (Q , M = (Q , ΣΣ , , λλ , , ΔΔ , q , qoo , , δδ)) Q = A nonempty finite set of state in M.Q = A nonempty finite set of state in M. ΣΣ = A nonempty finite set of input symbols. = A nonempty finite set of input symbols. ΔΔ = A nonempty finite set of outputs. = A nonempty finite set of outputs. δδ = It is a transition function which takes two = It is a transition function which takes two
arguments input state and input symbol.arguments input state and input symbol. qqo o = = Initial state of M. Initial state of M. λλ = It is a mapping function which maps Q * = It is a mapping function which maps Q * ΣΣ to to ΔΔ
giving output associated with each transition.giving output associated with each transition.
REPRESENTATION OFREPRESENTATION OFMEALY MACHINEMEALY MACHINE
Let M be a Mealy machine and a1 , a2 , a3 , Let M be a Mealy machine and a1 , a2 , a3 , …….a…….ann be input symbols where n>0 then be input symbols where n>0 then output of M is output of M is λλ(q(q0 0 , , aa11) , ) , λλ(q(q1 1 , , aa22) ) λλ(q(q2 2 , , aa33) ) λλ(q(q3 3 , , aa44) ) λλ(q(q4 4 , , aa55)………… )………… λλ(q(qn - 1 n - 1 , , aann), such ), such that that
δδ(q(qi – 1 , i – 1 , aai i ) = q) = qi i for 1<i<n. for 1<i<n.
EXAMPLE OFEXAMPLE OFMEALY MACHINEMEALY MACHINE
qq11 qq3 3 00 qq22 00
qq22 qq1 1 11 qq44 11
qq33 qq2 2 11 qq11 00
qq44 qq4 4 11 qq33 00
Present Present statestate
Input a = 0 Input a = 0
State outputState output
Input a = 1Input a = 1
State State outputoutput
TRANSITION TABLE
Values of Values of Q , Q , ΣΣ, , ΔΔ
Q = {Q = { qq1 1 ,, qq2 2 ,, qq3 3 ,, qq4 4 }} ΣΣ = { 0 , 1 } = { 0 , 1 } ΔΔ = { 0 , 1 } = { 0 , 1 } λλ(q(q1 1 , 0, 0) = 0 , ) = 0 , λλ(q(q2 2 , 0, 0) = 1 , ) = 1 , λλ(q(q3 3 , 0, 0) = 1 , ) = 1 ,
λλ(q(q4 4 , 0, 0) = 1) = 1 λλ(q(q1 1 , 1, 1) = 0 , ) = 0 , λλ(q(q2 2 , 1, 1) = 0 , ) = 0 , λλ(q(q3 3 , 1, 1) = 1 , ) = 1 ,
λλ(q(q4 4 , 1, 1) = 0) = 0
q1
q3 q4
q2
TRANSITION DIAGRAM
1/0
0/1
0/1
1/0
1/1 0/0
1/0
0/1
PROCESSING OF STRINGPROCESSING OF STRINGTHROUGHTHROUGH
MEALY MACHINEMEALY MACHINE Let the input string be w = 0111 and Output Let the input string be w = 0111 and Output
string will be w’ = 0100.string will be w’ = 0100.
q4q11/01/01/10/0
q3 q2q1
|w| = 4|w’| = 4
TRANSFORMING A MOORE MACHINE INTOTRANSFORMING A MOORE MACHINE INTOA MEALY MACHINEA MEALY MACHINE
q1
q1
P
c
b d
a
d
c/P
b/P
a/P
MOOREMACHINE
MEALYMACHINE
EXAMPLE
q0 q3
q2
q1
a
b
b
a0 1
0
1
b
a
a/b
MOORE MACHINE
CONVERT INTO MEALY MACHINE
q0 q3
q2
q1a/1
b/0
b/0
a/1
b/1
a/0
a/1 , b/1
MEALY MACHINE
TRANSFORMING A MEALY MACHINE INTOTRANSFORMING A MEALY MACHINE INTOA MOORE MACHINEA MOORE MACHINE
q1
q11 q12
b/0
a/0
b/1 b/1
a/1
10
ba
b
a/1a/1
b/1 b/1
MOORE MACHINE
MEALY MACHINE
EXAMPLE
q0
q1
q3
q2
a/0 a/1
a/0b/1
b/0
a/1b/0
b/1
MEALY MACHINE
q02
q3
q22
q21
q1
q01
a
a
ab
b
ab a
b
1b a
0
a
1
1
0
0
b
MOORE MACHINE
THANKYOU