ITdiapositivas5 (19 1)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 119

Informática Teórica

Andrés A. Aristizábal P.
aaaristizabal@icesi.edu.co

Departamento de Matemáticas y Estadística

2019-1

1 / 55
Agenda

1 Finite State Machines


Aims
Reading Control
Discussion and exercises
Presentation of the next topic

2 / 55
Finite State Machines Aims

Agenda del día

1 Finite State Machines


Aims
Reading Control
Discussion and exercises
Presentation of the next topic

3 / 55
Finite State Machines Aims

Aims

Understand what is a finite state machine


Learn about the components of these machines.
Know the properties they fulfill.
Recognize their different representations.
Know and understand Mealy and Moore machines and the way they can be
used to model different systems.
Learn how to transform a Mealy machine into a Moore machine and the other
way round.
Understand the relationship between states and parts related to the machine’s
complexity.
Recognize and understand the meaning of successor state and state sequence.
Understand the equivalence notion between finite state machines.

4 / 55
Finite State Machines Reading Control

Agenda del día

1 Finite State Machines


Aims
Reading Control
Discussion and exercises
Presentation of the next topic

5 / 55
Finite State Machines Reading Control

Reading Control

These are multiple choice questions. You just need to write the correct option(s) in
front of each number.

6 / 55
Finite State Machines Reading Control

Reading Control

1. These properties are embodied in the finite-state machine model:


A. Non-determinism.
B. Infiniteness.
C. Discreteness.
D. None of the above.

7 / 55
Finite State Machines Reading Control

Reading Control

2. A Mealy machine is:


A. A transition assigned finite state machine.
B. An automaton with output function g : Q × R −→ S.
C. An automaton with state transition function f : Q × R −→ Q.
D. A state assigned finite state machine.

8 / 55
Finite State Machines Reading Control

Reading Control

3. A Moore machine is:


A. A transition assigned finite state machine.
B. An automaton with output function h : Q −→ S.
C. An automaton with state transition function f : Q × S −→ Q.
D. A state assigned finite state machine.

9 / 55
Finite State Machines Reading Control

Reading Control

4. A finite state machine can be represented by means of a:


A. Transition diagram.
B. State matrix.
C. Transition grill.
D. State table.

10 / 55
Finite State Machines Reading Control

Reading Control

5. A finite state machine consists of the folowing:


A. The finite sets S, R, Q.
B. A final state.
C. A predetermined initial state.
D. All of the above.

11 / 55
Finite State Machines Discussion and exercises

Agenda del día

1 Finite State Machines


Aims
Reading Control
Discussion and exercises
Presentation of the next topic

12 / 55
Finite State Machines Discussion and exercises

Discussion about the reading material

Conceptual map presentation

13 / 55
Finite State Machines Discussion and exercises

Exercises

Exercise
Let ω be an input string, S = {a, b, c} and Ns (ω) = the number of
occurrences of symbol s in ω.
a) Display the state table and diagram of a Mealy machine
M = (Q, S, R, f , g, q1 ) whose last output symbol in response to an
input string ω is:

r = (Na (ω) + 2Nb (ω) − 3Nc (ω))mod 5

Let R = {0, 1, 2, 3, 4}.

14 / 55
Finite State Machines Discussion and exercises

Exercises

Exercise
Let ω be an input string, S = {a, b, c} and Ns (ω) = the number of
occurrences of symbol s in ω.
b) Suppose that we ask now that the last output symbol be:

r = Na (ω) + 2Nb (ω) − 3Nc (ω)

Is it still possible to construct a machine M with the appropriate


behavior?

15 / 55
Finite State Machines Discussion and exercises

Exercises

Exercise
Let ω be an input string, S = {a, b, c} and Ns (ω) = the number of
occurrences of symbol s in ω.
b) Suppose that we ask now that the last output symbol be:

r = Na (ω) + 2Nb (ω) − 3Nc (ω)

Is it still possible to construct a machine M with the appropriate


behavior? Suppose that the last output symbol is to be

r = min(100, Na (ω) + 2Nb (ω) − 3Nc (ω))

Is it possible in this case to construct the machine M?

15 / 55
Finite State Machines Discussion and exercises

Exercises

Exercise
Design a Mealy automaton M = (Q, R, S, f , g, q1 ) with S = R = {0, 1} and the
following output behavior:
a)
r (1) = r (2) = 0
for t > 2(r (t) = 1) ⇔ ((s(t) = 0) ∧ (s(t − 1) = 1) ∧ (s(t − 2) = 1))

16 / 55
Finite State Machines Discussion and exercises

Exercises

Exercise
Design a Mealy automaton M = (Q, R, S, f , g, q1 ) with S = R = {0, 1} and the
following output behavior:
b)
r (1) = r (2) = 0
for t > 2(r (t) = 1) ⇔ (((s(t) = 0) ∧ (s(t − 1) = s(t − 2) = 1)) ∨
((s(t) = 1) ∧ (s(t − 1) = 0 ∨ s(t − 2) = 0)))

17 / 55
Finite State Machines Discussion and exercises

Exercises

Exercise
Let M = (Q, R, S, f , h, q1 ) be a Moore machine with S = R = {0, 1}
An input sequence ω is said to be accepted by M just if M’s response
to ω ends with 1. Present the state diagram of a machine M that
accepts:
a) All strings ω ∈ S ∗ in which the substring 101 appears.

18 / 55
Finite State Machines Discussion and exercises

Exercises

Exercise
Let M = (Q, R, S, f , h, q1 ) be a Moore machine with S = R = {0, 1}
An input sequence ω is said to be accepted by M just if M’s response
to ω ends with 1. Present the state diagram of a machine M that
accepts:
b) All strings ω ∈ S ∗ in which the substring 101 does not appear.

19 / 55
Finite State Machines Discussion and exercises

Exercises

Exercise
Let M = (Q, R, S, f , h, q1 ) be a Moore machine with S = R = {0, 1}
An input sequence ω is said to be accepted by M just if M’s response
to ω ends with 1. Present the state diagram of a machine M that
accepts:
c) All strings ω ∈ S ∗ in which

(N0 (ω) − N1 (ω))mod 4 = 0

20 / 55
Finite State Machines Discussion and exercises

Exercises

Exercise
Present a state table of a Moore machine that accepts just those
strings accepted by the following Mealy machine.

0 1
A A1 B1
B C1 D0
C B0 C0
D D1 A1

21 / 55
Finite State Machines Discussion and exercises

Exercises

Exercise
Construct a Mealy machine similar to the following Moore machine.

0 1
A B C 0
B C B 1
C A C 0

22 / 55
Finite State Machines Discussion and exercises

Exercises

Exercise
Let M be a finite state machine with a state set Q. Suppose that Q
contains n states, including initial state q1 . For any state q ∈ Q, prove
that q is accessible in M only if q is the ω−successor of q1 , for some
string ω of length less than n. Intuitively, for q to be accessible means
that there exists a sequence from q1 until q.

23 / 55
Finite State Machines Presentation of the next topic

Agenda del día

1 Finite State Machines


Aims
Reading Control
Discussion and exercises
Presentation of the next topic

24 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When are two states equivalent?

25 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When are two states equivalent?

We consider two states of a machine to be equivalent if it is impossible


to distinguish two copies of the machine, one started in each state

25 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When are two states equivalent?

We consider two states of a machine to be equivalent if it is impossible


to distinguish two copies of the machine, one started in each state

For a Mealy machine

25 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When are two states equivalent?

We consider two states of a machine to be equivalent if it is impossible


to distinguish two copies of the machine, one started in each state

For a Mealy machine


Definition
Two states qa and qb of a Mealy machine M = (Q, R, S, f , g, q1 ) are
equivalent states if and only if the machines Ma = (Q, S, R, f , g, qa )
and Mb = (Q, R, S, f , g, qb ) are equivalent. If qa and qb are equivalent
states we write qa ∼ qb .

25 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

For a Moore machine

26 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

For a Moore machine


Definition
Two states qa and qb of a Moore machine M = (Q, R, S, f , h, q1 ) are
equivalent states if and only if the machines Ma = (Q, S, R, f , h, qa )
and Mb = (Q, R, S, f , h, qb ) are equivalent. If qa and qb are equivalent
states we write qa ∼ qb .

26 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

For a Moore machine


Definition
Two states qa and qb of a Moore machine M = (Q, R, S, f , h, q1 ) are
equivalent states if and only if the machines Ma = (Q, S, R, f , h, qa )
and Mb = (Q, R, S, f , h, qb ) are equivalent. If qa and qb are equivalent
states we write qa ∼ qb .

In what does the relation of state equivalence partitions the states of a


machine?

26 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

For a Moore machine


Definition
Two states qa and qb of a Moore machine M = (Q, R, S, f , h, q1 ) are
equivalent states if and only if the machines Ma = (Q, S, R, f , h, qa )
and Mb = (Q, R, S, f , h, qb ) are equivalent. If qa and qb are equivalent
states we write qa ∼ qb .

In what does the relation of state equivalence partitions the states of a


machine?
The relation of state equivalence partitions the states of a machine into
equivalence classes such that:

26 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

For a Moore machine


Definition
Two states qa and qb of a Moore machine M = (Q, R, S, f , h, q1 ) are
equivalent states if and only if the machines Ma = (Q, S, R, f , h, qa )
and Mb = (Q, R, S, f , h, qb ) are equivalent. If qa and qb are equivalent
states we write qa ∼ qb .

In what does the relation of state equivalence partitions the states of a


machine?
The relation of state equivalence partitions the states of a machine into
equivalence classes such that:
1 All states in the same class are mutually equivalent.

26 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

For a Moore machine


Definition
Two states qa and qb of a Moore machine M = (Q, R, S, f , h, q1 ) are
equivalent states if and only if the machines Ma = (Q, S, R, f , h, qa )
and Mb = (Q, R, S, f , h, qb ) are equivalent. If qa and qb are equivalent
states we write qa ∼ qb .

In what does the relation of state equivalence partitions the states of a


machine?
The relation of state equivalence partitions the states of a machine into
equivalence classes such that:
1 All states in the same class are mutually equivalent.
2 Any two states in different classes are not equivalent.

26 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What can we say if two states are not equivalent?

27 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What can we say if two states are not equivalent?

If two states are not equivalent, there must be an input sequence


which, when applied to two copies of a machine, will produce different
output sequences.

27 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What can we say if two states are not equivalent?

If two states are not equivalent, there must be an input sequence


which, when applied to two copies of a machine, will produce different
output sequences.

And if two states are equivalent?

27 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What can we say if two states are not equivalent?

If two states are not equivalent, there must be an input sequence


which, when applied to two copies of a machine, will produce different
output sequences.

And if two states are equivalent?

If two states are equivalent, one of them is clearly redundant, since all
transitions into one of the states may be switched to the equivalent
state without affecting the behavior of the machine.

27 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Theorem
States qa and qb of a finite state machine M are equivalent if and only if

28 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Theorem
States qa and qb of a finite state machine M are equivalent if and only if
1a. For Mealy machines: For all s ∈ S, g(qa , s) = g(qb , s).
That is, the outputs for corresponding transitions are
identical.

28 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Theorem
States qa and qb of a finite state machine M are equivalent if and only if
1a. For Mealy machines: For all s ∈ S, g(qa , s) = g(qb , s).
That is, the outputs for corresponding transitions are
identical.
1b. For Moore machines: h(qa ) = h(qb ). That is, the output
symbols for the two states are identical.

28 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Theorem
States qa and qb of a finite state machine M are equivalent if and only if
1a. For Mealy machines: For all s ∈ S, g(qa , s) = g(qb , s).
That is, the outputs for corresponding transitions are
identical.
1b. For Moore machines: h(qa ) = h(qb ). That is, the output
symbols for the two states are identical.
2. For all s ∈ S, f (qa , s) ∼ f (qb , s). That is, the
s−successors of the two states are themselves
equivalent states.

28 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Example
If we have the following Mealy machine

Are A and B equivalent?

29 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Answer
g(A, 0) = g(B, 0) = 0

30 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Answer
g(A, 0) = g(B, 0) = 0

g(A, 1) = g(B, 1) = 0

30 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Answer
g(A, 0) = g(B, 0) = 0

g(A, 1) = g(B, 1) = 0

f (A, 0) = B f (A, 1) = C

30 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Answer
g(A, 0) = g(B, 0) = 0

g(A, 1) = g(B, 1) = 0

f (A, 0) = B f (A, 1) = C

f (B, 0) = B f (B, 1) = C

30 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Answer
g(A, 0) = g(B, 0) = 0

g(A, 1) = g(B, 1) = 0

f (A, 0) = B f (A, 1) = C

f (B, 0) = B f (B, 1) = C
And certainly B ∼ B and C ∼ C.

30 / 55
Finite State Machines Presentation of the next topic

Finite State Machines


When is finite state machine a reduced one?

31 / 55
Finite State Machines Presentation of the next topic

Finite State Machines


When is finite state machine a reduced one?

Definition
A finite state machine is reduced if it contains no pair of equivalent states.

31 / 55
Finite State Machines Presentation of the next topic

Finite State Machines


When is finite state machine a reduced one?

Definition
A finite state machine is reduced if it contains no pair of equivalent states.

When is a state q, in a finite state machine, accessible?

31 / 55
Finite State Machines Presentation of the next topic

Finite State Machines


When is finite state machine a reduced one?

Definition
A finite state machine is reduced if it contains no pair of equivalent states.

When is a state q, in a finite state machine, accessible?


Definition
A state q, in a finite state machine, is accessible if there is some input string
ω
ω such that q1 ⇒ q.

31 / 55
Finite State Machines Presentation of the next topic

Finite State Machines


When is finite state machine a reduced one?

Definition
A finite state machine is reduced if it contains no pair of equivalent states.

When is a state q, in a finite state machine, accessible?


Definition
A state q, in a finite state machine, is accessible if there is some input string
ω
ω such that q1 ⇒ q.

When is a finite state machine connected?

31 / 55
Finite State Machines Presentation of the next topic

Finite State Machines


When is finite state machine a reduced one?

Definition
A finite state machine is reduced if it contains no pair of equivalent states.

When is a state q, in a finite state machine, accessible?


Definition
A state q, in a finite state machine, is accessible if there is some input string
ω
ω such that q1 ⇒ q.

When is a finite state machine connected?


Definition
A finite state machine is connected if every state is accessible from the initial
state.

31 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

It should be evident that no state can be removed from a reduced and


connected machine without affecting its behavior. Inaccessible states
can always be removed from a machine, since the machine can never
enter such states.

32 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When can we say that two states are distinguishable?

33 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When can we say that two states are distinguishable?

Two states are distinguishable if they are not equivalent, that is, if we have two copies
of a finite state machine, and each of those have one of the aforementioned states as
their initial state, they will evoke responses differing in at least one symbol.

33 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When can we say that two states are distinguishable?

Two states are distinguishable if they are not equivalent, that is, if we have two copies
of a finite state machine, and each of those have one of the aforementioned states as
their initial state, they will evoke responses differing in at least one symbol.

When can we say that two states are k −distinguishable?

33 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When can we say that two states are distinguishable?

Two states are distinguishable if they are not equivalent, that is, if we have two copies
of a finite state machine, and each of those have one of the aforementioned states as
their initial state, they will evoke responses differing in at least one symbol.

When can we say that two states are k −distinguishable?

For a Mealy machine:

33 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When can we say that two states are distinguishable?

Two states are distinguishable if they are not equivalent, that is, if we have two copies
of a finite state machine, and each of those have one of the aforementioned states as
their initial state, they will evoke responses differing in at least one symbol.

When can we say that two states are k −distinguishable?

For a Mealy machine:

Definition
States qa and qb of a transition assigned machine M = (Q, R, S, f , h, q1 ) are
k −distinguishable if there exists a string ω ∈ S ∗ with |ω| ≤ k such that the responses
of Ma = (Q, R, S, f , g, qa ) and Mb = (Q, R, S, f , g, qb ) to ω differ in at least a symbol.

33 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When can we say that two states are distinguishable?

Two states are distinguishable if they are not equivalent, that is, if we have two copies
of a finite state machine, and each of those have one of the aforementioned states as
their initial state, they will evoke responses differing in at least one symbol.

When can we say that two states are k −distinguishable?

For a Mealy machine:

Definition
States qa and qb of a transition assigned machine M = (Q, R, S, f , h, q1 ) are
k −distinguishable if there exists a string ω ∈ S ∗ with |ω| ≤ k such that the responses
of Ma = (Q, R, S, f , g, qa ) and Mb = (Q, R, S, f , g, qb ) to ω differ in at least a symbol.
Such a string ω is called a distinguishable sequence for states qa and qb .

33 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When can we say that two states are distinguishable?

Two states are distinguishable if they are not equivalent, that is, if we have two copies
of a finite state machine, and each of those have one of the aforementioned states as
their initial state, they will evoke responses differing in at least one symbol.

When can we say that two states are k −distinguishable?

For a Mealy machine:

Definition
States qa and qb of a transition assigned machine M = (Q, R, S, f , h, q1 ) are
k −distinguishable if there exists a string ω ∈ S ∗ with |ω| ≤ k such that the responses
of Ma = (Q, R, S, f , g, qa ) and Mb = (Q, R, S, f , g, qb ) to ω differ in at least a symbol.
Such a string ω is called a distinguishable sequence for states qa and qb . If states qa
and qb are not k −distinguishable, we say that they are k −equivalent.

33 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

For a Moore machine:

34 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

For a Moore machine:


Definition
States qa and qb of a state assigned machine M = (Q, R, S, f , g, q1 )
are k −distinguishable if there exists a string ω ∈ S ∗ with |ω| ≤ k such
that the responses of Ma = (Q, R, S, f , h, qa ) and
Mb = (Q, R, S, f , h, qb ) to ω differ in at least a symbol.

34 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

For a Moore machine:


Definition
States qa and qb of a state assigned machine M = (Q, R, S, f , g, q1 )
are k −distinguishable if there exists a string ω ∈ S ∗ with |ω| ≤ k such
that the responses of Ma = (Q, R, S, f , h, qa ) and
Mb = (Q, R, S, f , h, qb ) to ω differ in at least a symbol. Such a string ω
is called a distinguishable sequence for states qa and qb .

34 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

For a Moore machine:


Definition
States qa and qb of a state assigned machine M = (Q, R, S, f , g, q1 )
are k −distinguishable if there exists a string ω ∈ S ∗ with |ω| ≤ k such
that the responses of Ma = (Q, R, S, f , h, qa ) and
Mb = (Q, R, S, f , h, qb ) to ω differ in at least a symbol. Such a string ω
is called a distinguishable sequence for states qa and qb . If states qa
and qb are not k −distinguishable, we say that they are k −equivalent.

34 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When are two states in a finite state machine k −equivalent?

35 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When are two states in a finite state machine k −equivalent?


Theorem
Two states of a finite state machine are k −equivalent if and only if

35 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When are two states in a finite state machine k −equivalent?


Theorem
Two states of a finite state machine are k −equivalent if and only if
1 They are 1−equivalent

35 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

When are two states in a finite state machine k −equivalent?


Theorem
Two states of a finite state machine are k −equivalent if and only if
1 They are 1−equivalent
2 For each input symbol s, their s−successors are
(k − 1)−equivalent.

35 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Recall that:

36 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Recall that: an equivalence relation on a set partitions the set into


mutually exclusively, collectively exhaustive blocks (equivalence
classes).

36 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Recall that: an equivalence relation on a set partitions the set into


mutually exclusively, collectively exhaustive blocks (equivalence
classes). If P1 and P2 are partitions of a set X , and each if each block
of P2 is a subset of exactly one block of P1 ,

36 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Recall that: an equivalence relation on a set partitions the set into


mutually exclusively, collectively exhaustive blocks (equivalence
classes). If P1 and P2 are partitions of a set X , and each if each block
of P2 is a subset of exactly one block of P1 , then P2 is a refinement of
P1 .

36 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Recall that: an equivalence relation on a set partitions the set into


mutually exclusively, collectively exhaustive blocks (equivalence
classes). If P1 and P2 are partitions of a set X , and each if each block
of P2 is a subset of exactly one block of P1 , then P2 is a refinement of
P1 . That is:

36 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Recall that: an equivalence relation on a set partitions the set into


mutually exclusively, collectively exhaustive blocks (equivalence
classes). If P1 and P2 are partitions of a set X , and each if each block
of P2 is a subset of exactly one block of P1 , then P2 is a refinement of
P1 . That is:

Let P1 = {A1 , ..., An } and P2 = {B1 , ..., Bn } be partitions of a set X and


P2 a refinement of P1 ,

36 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Recall that: an equivalence relation on a set partitions the set into


mutually exclusively, collectively exhaustive blocks (equivalence
classes). If P1 and P2 are partitions of a set X , and each if each block
of P2 is a subset of exactly one block of P1 , then P2 is a refinement of
P1 . That is:

Let P1 = {A1 , ..., An } and P2 = {B1 , ..., Bn } be partitions of a set X and


P2 a refinement of P1 , then for each block Bj in P2 , there is a block Ai
in P1 such that Bj ⊆ Ai .

36 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Recall that: an equivalence relation on a set partitions the set into


mutually exclusively, collectively exhaustive blocks (equivalence
classes). If P1 and P2 are partitions of a set X , and each if each block
of P2 is a subset of exactly one block of P1 , then P2 is a refinement of
P1 . That is:

Let P1 = {A1 , ..., An } and P2 = {B1 , ..., Bn } be partitions of a set X and


P2 a refinement of P1 , then for each block Bj in P2 , there is a block Ai
in P1 such that Bj ⊆ Ai .
The number of blocks in P2 is never less than the number in P1 .

36 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Recall that: an equivalence relation on a set partitions the set into


mutually exclusively, collectively exhaustive blocks (equivalence
classes). If P1 and P2 are partitions of a set X , and each if each block
of P2 is a subset of exactly one block of P1 , then P2 is a refinement of
P1 . That is:

Let P1 = {A1 , ..., An } and P2 = {B1 , ..., Bn } be partitions of a set X and


P2 a refinement of P1 , then for each block Bj in P2 , there is a block Ai
in P1 such that Bj ⊆ Ai .
The number of blocks in P2 is never less than the number in P1 . A
partition is always a refinement of itself.

36 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is the partitioning algorithm for Mealy machines?

37 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is the partitioning algorithm for Mealy machines?


Step 1. Form an initial partition P1 of Q by grouping together states that are
1−equivalent, that is, states that produce identical outputs for each
input symbol. States q and q 0 are in the same block of P1 if and only if,
for each s ∈ S, g(q, s) = g(q 0 , s).

37 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is the partitioning algorithm for Mealy machines?


Step 1. Form an initial partition P1 of Q by grouping together states that are
1−equivalent, that is, states that produce identical outputs for each
input symbol. States q and q 0 are in the same block of P1 if and only if,
for each s ∈ S, g(q, s) = g(q 0 , s).
Step 2. Obtain Pk +1 from Pk as follows: states q and q 0 are in the same block
of Pk +1 if and only if

37 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is the partitioning algorithm for Mealy machines?


Step 1. Form an initial partition P1 of Q by grouping together states that are
1−equivalent, that is, states that produce identical outputs for each
input symbol. States q and q 0 are in the same block of P1 if and only if,
for each s ∈ S, g(q, s) = g(q 0 , s).
Step 2. Obtain Pk +1 from Pk as follows: states q and q 0 are in the same block
of Pk +1 if and only if
1 They are in the same block of Pk

37 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is the partitioning algorithm for Mealy machines?


Step 1. Form an initial partition P1 of Q by grouping together states that are
1−equivalent, that is, states that produce identical outputs for each
input symbol. States q and q 0 are in the same block of P1 if and only if,
for each s ∈ S, g(q, s) = g(q 0 , s).
Step 2. Obtain Pk +1 from Pk as follows: states q and q 0 are in the same block
of Pk +1 if and only if
1 They are in the same block of Pk
2 For each s ∈ S their s−successors f (q, s) and f (q 0 , s) are in the
same block of Pk .

37 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is the partitioning algorithm for Mealy machines?


Step 1. Form an initial partition P1 of Q by grouping together states that are
1−equivalent, that is, states that produce identical outputs for each
input symbol. States q and q 0 are in the same block of P1 if and only if,
for each s ∈ S, g(q, s) = g(q 0 , s).
Step 2. Obtain Pk +1 from Pk as follows: states q and q 0 are in the same block
of Pk +1 if and only if
1 They are in the same block of Pk
2 For each s ∈ S their s−successors f (q, s) and f (q 0 , s) are in the
same block of Pk .
Step 3. Repeat step 2 until Pm+1 = Pm for some m. We call Pm the final
partition of Q.

37 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is the partitioning algorithm for Moore machines?

38 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is the partitioning algorithm for Moore machines?


Step 1. Form an initial partition P1 of Q by grouping together states that are
1−equivalent, that is, states that produce identical outputs for each
input symbol. States q and q 0 are in the same block of P1 if and only if,
h(q) = h(q 0 ).

38 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is the partitioning algorithm for Moore machines?


Step 1. Form an initial partition P1 of Q by grouping together states that are
1−equivalent, that is, states that produce identical outputs for each
input symbol. States q and q 0 are in the same block of P1 if and only if,
h(q) = h(q 0 ).
Step 2. Obtain Pk +1 from Pk as follows: states q and q 0 are in the same block
of Pk +1 if and only if

38 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is the partitioning algorithm for Moore machines?


Step 1. Form an initial partition P1 of Q by grouping together states that are
1−equivalent, that is, states that produce identical outputs for each
input symbol. States q and q 0 are in the same block of P1 if and only if,
h(q) = h(q 0 ).
Step 2. Obtain Pk +1 from Pk as follows: states q and q 0 are in the same block
of Pk +1 if and only if
1 They are in the same block of Pk

38 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is the partitioning algorithm for Moore machines?


Step 1. Form an initial partition P1 of Q by grouping together states that are
1−equivalent, that is, states that produce identical outputs for each
input symbol. States q and q 0 are in the same block of P1 if and only if,
h(q) = h(q 0 ).
Step 2. Obtain Pk +1 from Pk as follows: states q and q 0 are in the same block
of Pk +1 if and only if
1 They are in the same block of Pk
2 For each s ∈ S their s−successors f (q, s) and f (q 0 , s) are in the
same block of Pk .

38 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is the partitioning algorithm for Moore machines?


Step 1. Form an initial partition P1 of Q by grouping together states that are
1−equivalent, that is, states that produce identical outputs for each
input symbol. States q and q 0 are in the same block of P1 if and only if,
h(q) = h(q 0 ).
Step 2. Obtain Pk +1 from Pk as follows: states q and q 0 are in the same block
of Pk +1 if and only if
1 They are in the same block of Pk
2 For each s ∈ S their s−successors f (q, s) and f (q 0 , s) are in the
same block of Pk .
Step 3. Repeat step 2 until Pm+1 = Pm for some m. We call Pm the final
partition of Q.

38 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Example
From the following state table of a Mealy machine, apply the partitioning procedure.

39 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Answer

40 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

How do we construct an equivalent reduced machine for a Mealy


automaton?

41 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

How do we construct an equivalent reduced machine for a Mealy


automaton?
Let M = (Q, R, S, f , g, q1 ) be a Mealy machine. We want to construct
an equivalent reduced machine M 0 = (Q 0 , S, R, f 0 , g 0 , q10 ). The states of
M 0 will represent the state equivalence classes of machine M; that is,
they will correspond to the blocks of the final partition Pf resulting from
applying the partitioning procedure to M. The initial state q10
corresponds to the block containing the initial state of M.

41 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

The state table of M 0 is obtained by applying two rules:

42 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

The state table of M 0 is obtained by applying two rules:


1 To find the s−successor of a state q 0 in M 0 select any state in the
block of the partition Pf corresponding to q 0 and find the block
containing its s−successor; the corresponding state of M 0 is the
s−successor of q 0 .

42 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

The state table of M 0 is obtained by applying two rules:


1 To find the s−successor of a state q 0 in M 0 select any state in the
block of the partition Pf corresponding to q 0 and find the block
containing its s−successor; the corresponding state of M 0 is the
s−successor of q 0 .
2 The output for an s−transition from state q 0 of M 0 is the output for
an s−transition from any state in the block corresponding to q 0 .

42 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Example
From the following state table of a Mealy machine, find its equivalent reduced
automaton.

43 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Answer
The first step is to apply the partitioning procedure on M.

44 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Answer
Each block belonging to the final partition Pf of M is a state of M 0 . That
is why we have to rename them.

45 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Answer
To find the s−successor of a state q 0 in M 0 , select any state in the block of the partition Pf
corresponding to q 0 and find the block containing its s−successor; the corresponding state of M 0
is the s−successor of q 0 . The output for an s−transition from state q 0 of M 0 is the output for an
s−transition from any state in the block corresponding to q 0 .

46 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Answer
Taking into account the new state table, we assign the new names to the blocks.

47 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is an isomorphism of equivalent machines?

48 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is an isomorphism of equivalent machines?


Definition
Let M1 and M2 be reduced, connected finite state machines. Then the
state graphs of M1 and M2 are isomorphic if and only if M1 and M2 are
equivalent.

48 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is a direct-sum machine?

49 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is a direct-sum machine?


Definition
Let M1 and M2 be finite state machines, and assume the state are so
named that Q1 ∩ Q2 = ∅. The direct-sum machine for M1 and M2 is the
result of considering the state graphs of M1 and M2 as constituting a
single machine with state set Q = Q1 ∪ Q2 . The initial state of the
direct-sum machine is unspecified. A state q in M1 is equivalent to a
state q 0 in M2 just if q and q 0 are equivalent in the direct-sum machine.

49 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is machine containment?

50 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

What is machine containment?


Definition
Let M1 and M2 be finite state machines. If each state in M1 is
equivalent to a state in M2 we say that M2 contains M1 .

50 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Procedure for deciding whether M1 ∼ M2 and, if so, for obtaining a


reduced machine M equivalent to M1 and M2 .

51 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Procedure for deciding whether M1 ∼ M2 and, if so, for obtaining a


reduced machine M equivalent to M1 and M2 .
Step 1. Eliminate states of M1 and M2 inaccessible from their
respective initial states.

51 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Procedure for deciding whether M1 ∼ M2 and, if so, for obtaining a


reduced machine M equivalent to M1 and M2 .
Step 1. Eliminate states of M1 and M2 inaccessible from their
respective initial states.
Step 2. Partition the state set of the direct-sum machine. Let Pf
denote the final partition.

51 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Procedure for deciding whether M1 ∼ M2 and, if so, for obtaining a


reduced machine M equivalent to M1 and M2 .
Step 1. Eliminate states of M1 and M2 inaccessible from their
respective initial states.
Step 2. Partition the state set of the direct-sum machine. Let Pf
denote the final partition.
Step 3. Ascertain whether each block of Pf contains at least one
state from each of M1 and M2 . If so, M1 ∼ M2 just if the
initial states of M1 and M2 are in the same block of Pf .

51 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Procedure for deciding whether M1 ∼ M2 and, if so, for obtaining a


reduced machine M equivalent to M1 and M2 .
Step 1. Eliminate states of M1 and M2 inaccessible from their
respective initial states.
Step 2. Partition the state set of the direct-sum machine. Let Pf
denote the final partition.
Step 3. Ascertain whether each block of Pf contains at least one
state from each of M1 and M2 . If so, M1 ∼ M2 just if the
initial states of M1 and M2 are in the same block of Pf .
Step 4. If M1 ∼ M2 , an equivalent reduced machine M, whose
states correspond to the blocks of Pf is given.

51 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Example
Prove the equivalence of the following Mealy machines.

52 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Example
We apply the direct sum between the automata.

53 / 55
Finite State Machines Presentation of the next topic

Finite State Machines

Example
We apply the partitioning algorithm on the direct sum result.

54 / 55
Finite State Machines Presentation of the next topic

Next class

Exercises and section


Finite-State Machines pages 107-120
Exercises: 4.15,4.24

55 / 55

You might also like