DISTINGUISHING SEQUENCE
10.8 DISTINGUISHING SEQUENCE
Given an FSM M = <S, I, O, s 0 , δ, λ> , an input sequence x is said to be a dis- tinguishing sequence if and only if λ(s i
j , x) ∀s i ,s j ∈ S, and s i j . Therefore, every state produces a unique output sequence in response to a distin- guishing input sequence. The concept of distinguishing sequences was studied to address the machine identification problem in the early days of computing [6–9]. The machine identification problem is as follows: Given an implementation of an FSM in the form of a black box and the number of states of the FSM, derive the state table (equivalently, a state machine) which accurately represents the behavior of the black box. In contrast, the objective of a checking experiment is to decide whether a given black-box implementation of an FSM behaves according to a given state table representation of the FSM.
Given an FSM M = <S, I, O, s 0 , δ, λ> with |S| = n, a state block is defined as a set B of multisets of S such that the sum of the cardinalities of the multisets
of B is equal to n. Thus, a state block may contain just one multiset with all the states of M. Also, a state block may contain n multisets with exactly one element in each of them. Assuming that S = {A, B, C, D} some examples of state blocks are given in Table 10.8.
Given a state block B = {W 1 ,...,W i ,...,W m } and an input symbol a ∈ I , we define a function B ′ = dpert(B, a) such that for each multiset member W i =
(w i 1 ,w i 2 ,...,w ik ) of B we obtain one or more members of B ′ as follows: • If two states of W i produce different outputs in response to input a, then
their next states are put in different multisets of B ′ . • The next states of all those states in W i which produce the same output in
response to input a are put in the same multiset of B ′ .
TABLE 10.8 Examples of State Blocks State block 1
{(ABCD)} State block 2
{(AB), (CC)} State block 3
{(AB), (CD)} State block 4
{(A), (B), (C), (D)} State block 5
{(A), (A), (B), (C)}
285 Given a reduced FSM, the initial state block consists of just one element
10.8 DISTINGUISHING SEQUENCE
containing the set of states of the FSM. Next, we can infinitely perturb all the state blocks for all the input symbols using the dpert() function. One can view the perturbation function B ′ = dpert(B, a) as an edge from a node B to a new node
B ′ with edge label a. Given a state block and the set of inputs I , we can arrange the new |I | nodes {dpert(B, a), ∀a ∈ I } at the same level. All the state blocks of a
given FSM can be arranged in the form of a tree with successive levels 1, 2, . . . , ∞. Such a tree is called a DS tree. Theoretically, a distinguishing sequence (DS) tree
is a tree with infinite levels. However, a finite-level tree would serve our purpose.
A finite-level tree is obtained by pruning the tree based on some conditions, called pruning conditions , defined using the following terms:
D1 : A state block B is a homogeneous state block if at least one multiset member W i of B has repeated states.
D2 : A state block B is a singleton state block if all elements of B have exactly one state member.
D3 : On the path from the initial state block to the current state block B, there exists a state block B.
While constructing a DS tree, if one of the above three pruning conditions is satisfied, we declare state block B to be a terminal state block. Given a DS tree of an FSM M, M has a distinguishing sequence if and only if there exists a singleton state block in the DS tree. The sequence of inputs from the initial state block to
a singleton state block is a DS of machine M. In the following, we present an algorithm to compute a finite DS tree from an FSM.
Algorithm. Generation of DS Tree
Input : M = <S, I, O, s 0 , δ, λ> .
Output : DS tree. Method : Execute the following steps:
Step 1: Let be the set of state blocks in the DS tree. Initially, contains the initial state block marked as nonterminal.
Step 2: Find a nonterminal member ψ ∈ which has not been per- turbed. If no such member exists, then the algorithm terminates. Step 3: Compute ψ ′ = dpert(ψ, a) and add ψ ′ to ∀a ∈ I . Mark ψ to
be perturbed and update the DS tree. Step 4: If dpert(ψ, a), computed in step 3, satisfies the termination con-
dition D1, D2, or D3, then mark ψ ′ as a terminal node. Step 5: Go to step 2.
Example. Let us consider an FSM G 2 = <S, I, O, A, δ, λ>, shown in Figure 10.15, where S = {A, B, C, D} is the set of states, I = {0, 1} is the set of inputs, O = {0, 1} is the set of outputs, A is the initial state, δ : S × I → S
286 CHAPTER 10 TEST GENERATION FROM FSM MODELS
Figure 10.15 Finite-state machine G 2 .
(ABCD) 0 1
(AB)(DD) (DC )(BA) 0 1
Figure 10.16 Distinguishing sequence tree for G 2 (DD)(BA)
(A)(C)(D)(B)
in Figure 10.15.
is the next-state function, and λ : S × I → O is the output function. The DS tree for G 2 is shown in Figure 10.16. The initial state block contains just one
multiset {A, B, C, D}, which has been represented as the initial node (ABCD). We have perturbed the initial node (ABCD) with the members of the input set
I = {0, 1}. Perturbation of the initial state block with input 0 produces the state block (AB)(DD) because of the following reasons:
• States A and B produce the same output 0 with input 0 and move the machine to states B and A, respectively.
• States C and D produce the same output 1 with input 0 and move the FSM to the same state D.
Since (AB)(DD) is a homogeneous state block, it is a terminal node in the DS tree, and, thus, it is no more perturbed. Perturbation of the initial state block with input 1 produces the state block (DC)(BA) because of the following reasons:
• States A and D produce the same output 0 with input 1 and move the machine to states D and C, respectively.
• States B and C produce the same output 1 with input 1 and move the machine to states B and A, respectively.
We obtain a homogeneous state block (DD)(BA) by perturbing the state block (DC)(BA) with input 0 and we obtain a singleton state block (A)(C)(D)(B) by perturbing state block (DC)(BA) with input 1. The complete DS tree is shown
10.9 CHARACTERIZING SEQUENCE
TABLE 10.9 Outputs of FSM G 2 in
Response to Input Sequence 11 in Different States
Present State Output Sequence A 00
B 11 C 10 D 01
in Figure 10.16. Therefore, the input sequence 11 that takes the DS tree from its initial state block to its only singleton state block is a DS for FSM G 2 . The output sequences of FSM G 2 in Figure 10.15 in response to the distinguishing input sequence 11 in all the four different states are shown in Table 10.9.