Beruflich Dokumente
Kultur Dokumente
I. B UILDING DFA FOR DIVISIBILITY BY 3 AND NOT 4 C. Building DFA for binary strings not divisible by 4
0 0 0
0 0
States 0 1 0 0 0
r0 r0 r1 q2 r0 q2 r1 q2 r2 q2 r3
r1 r2 r3 1 1
r2 r0 r1 1
r3 r2 r3 1
Fig. 4: DFA for binary strings divisible by 3 and not divisible
TABLE II: State Transition Table by 4
2
II. M OORE AND M EALY M ACHINES C. Equivalence of Moore and Mealy Machines
Finite State Machines are basically mathematical models As far as equivalence of both the machines is concerned, a
of computation. Many finite state machines do exist which Moore machine can never be correctly equivalent to a Mealy
produce output apart from just accept and reject states. Moore Machine since the length of the output string varies from
and Mealy Machines are examples of such machines. The Moore Machine to Mealy Machine. Nevertheless we can say
machines are discussed in much more detail below. that a Moore Machine M and a Mealy Machine M 0 can be
considered equivalent if for all inputs w if
A. Moore Machines
bTM 0 (w) = TM (w)
Moore Machines are finite state machines whose output where b = output of initial state of Moore machine M for its
depends only on the current state. Unlike regular DFA and initial state
NFA, it is defined by a six-tuple (Q, Σ, O, δ, λ, q0 ). T(w) = output of the machine taking word w as input
where Q = finite set of states. We can observe here that the Moore Machine and Mealy
Σ = input alphabet. Machine mentioned earlier are infact equivalent. It can be
O = output alphabet. verified by the output of the input string we had taken
q0 = initial state. earlier ”baab”. Moore Machine gives ”00110” where as Mealy
δ is the input transition function where δ:Q × Σ → Q Machine gives ”0110”. So when we concatenate the initial
λ is the output transition function where λ:Q → O output of Moore’s Machine i.e. ”0”, we find that the output
strings are infact equivalent. Similarly we can test for any
string which belongs to the input language defined to hold
b a a, b
equal result for these two machines, provided the initial state
of Moore’s Machine is appended to Mealy’s Machine output
a b at the beginning. The idea is clearly presented in the following
start q0 |0 q1 |1 q2 |0 figure.
Consider the example of a Moore Machine mentioned here. |0 a|1 b|0
If we consider the string ”baab” as input, we get ”00110” as start q q0 q1 q2
output. The first ”0” from the starting state q0 and then ”b”
giving ”0” in q1 , followed by ”a”, ”a” and ”b” giving ”1”, ”1”, Fig. 7: An example of Mealy Machine adjusted to make it a
”0” from the states q1 , q1 and q2 respectively. The length of a Moore Machine
output string in a Moore Machine is always greater than the
length of the input string by 1. III. M YHILL -N ERODE T HEOREM
A. Definition
B. Mealy Machines Myhill-Nerode theorem states that a language L over alpha-
Mealy Machines are finite state machines whose output bet Σ is regular if and only if the set of equivalence classes
depends not only on the current state but on the current input of relation RL is finite.
as well. Similar to Moore Machines, it is also described by a This is because the number of states in the smallest DFA
six-tuple (Q, Σ, O, δ, λ, q0 ). possible is equal to the number of equivalence classes since
according to the formal definition of RL , xRL y if and only
if x and y are indistinguishable with respect to L. It can be
b|0 a|1 a|0, b|0 more formally defined as follows:
If RL is a relation on Σ∗ , then for strings x and y of Σ∗ ,
xRL y if and only if {z|xz ∈ L} = {z|yz ∈ L} i.e. both x
a|1 b|0
start q0 q1 q2 and y are indistinguishable with respect to L.
C. Table Filling Algorithm taken as [a, b] due to pruning of the upper triangle to avoid
1) Draw a table for all pairs of states[q, r]. duplicate values) and with s = 1, they give [c, d] which is
2) After drawing the table, prune the part above the diago- also unmarked. Considering [c, d] with s = 0, 1 gives the same
nal since it’s no longer needed as all pair combinations [c, d] which is still unmarked. Therefor we have completed this
are present below the diagonal itself. step too and head towards the final step i.e. combining states.
3) Mark all cells as marked where q ∈ F and r ∈ / F. Therefore, the final unmarked states are [a, b] and [c, d]. The
4) For every unmarked cell [q, r], if [δ(q, s), δ(r, s)] where final minimized DFA can be shown as follows.
a is an input symbol is marked, then mark [q, r] as
marked. 0 0, 1
Repeat this until maximum number of cells are marked.
5) Combine the unmarked pairs to make them a single state
in minimized DFA. 1
start (a, b) (c, d)
t]
D. Example
Fig. 9: Minimized DFA
0, 1
We observe that the final minimized DFA consists of only 2
states unlike the original one which has 4 states. We observe
1 that this finite machine works the same as the previous one
start a c
with minimized states.
Hence, in this way Myhill-Nerode theorem can be used to
0 0 minimize the DFA and also check if a language is regular or
not based on the number of equivalence classes.
b d REFERENCES
1
1) https://www.geeksforgeeks.org/mealy-and-moore-
0, 1 machines/
2) https://www.slideshare.net/lavishka anuj/moore-and-
Fig. 8: An example of non-minimised DFA mealy-machines-12176634
3) https://www.cs.odu.edu/ toida/nerzic/390teched/regular/reg-
lang/Myhill-Nerode/index.html
States a b c d 4) https://www.tutorialspoint.com/automata theory/dfa minimization.ht
a − − − −
b − − −
c − −
d −