Академический Документы
Профессиональный Документы
Культура Документы
Mohammad Mousavi
University of Leicester, UK
Outline
4 Conformance Testing
5 Machine Identification
Problem
Given an FSM spec M and a black-box implementation I,
does I conform to M, i.e.,
does I implement the same output and transfer function as M?
Problem
Given an FSM spec M and a black-box implementation I,
does I conform to M, i.e.,
does I implement the same output and transfer function as M?
Problem
Given an FSM spec M and a black-box implementation I,
does I conform to M, i.e.,
does I implement the same output and transfer function as M?
Notations I
a /0
: empty sequence s1
b /1
s3
a /0
Notations I
a /0
: empty sequence s1
Notations II
a /0
a /1 s2 b /0
b /1
s3
a /0
Notations II
a /0
Outline
4 Conformance Testing
5 Machine Identification
An FSM is reduced when each two different states can show different
output on at least one sequence of inputs
An FSM is reduced when each two different states can show different
output on at least one sequence of inputs
Reduced FSM always has a homing sequence
FSM that is not reduced may not have a homing sequence
Example
b /0
a /0 s1 s2 s3 a /0
b /1 b /1
a /1
Partition of S: {{s1 , s2 , s3 }}
Take B = {s1 , s2 , s3 }, next (B , ) = B.
Take: s1 and s2
Example
b /0
a /0 s1 s2 s3 a /0
b /1 b /1
a /1
Partition of S: {{s1 , s2 , s3 }}
Take B = {s1 , s2 , s3 }, next (B , ) = B.
Take: s1 and s2
Separating sequence: a
Output sequences: output (s1 , a ) = output (s3 , a ) = 0 and
output (s2 , a ) = 1
New partition: {{s1 , s3 }, {s2 }}
Example
b /0
a /0 s1 s2 s3 a /0
b /1 b /1
a /1
Example
b /0
a /0 s1 s2 s3 a /0
b /1 b /1
a /1
Outline
4 Conformance Testing
5 Machine Identification
State identification
Problem: Given an FSM, can we determine the initial state of the FSM?
Distinguishing sequence
Example
b /0
a /1 s1
b /0 a /0
s6 b /0 s2
a /0
a /1
b /0
s5 s3
a /1 a /0
s4
b /0 b /0
Example
a
b /0 1
0
a /1 s1
a b
b /0 a /0
1 0
b a
s6 b /0 s2
1
0 0
s6 b
a /0 a
a /1 0 0
b /0
b 1 s5 a
s5 s3 0
0 1
s2 s4
a /1 a /0 a
0
s4
b /0 b /0 1
s1 s3
b /1
a /0 b /1
a /0 s1 s2 s3 a /1
b /0
An input a is valid for a set C of states if it does not merge any two states
s and s 0 from C without distinguishing them, i.e.,
Algorithm
1 Start with partition π of S with only one block {S }.
2 While there is a block B ∈ π with |B | > 1,
1 Take a valid input symbol a ∈ I for B such that two states s , s 0 ∈ B
(s , s 0 ), output (s , a ) , output (s 0 , a ) or move to states in different
blocks of π,
2 refine the partition π by replacing block B by a set of new blocks, where
two states in B are assigned to the same block in the new partition iff
they produce the same output on a and move to the same block in π.
Property
An FSM has a distinguishing sequence iff the final partition contains
singleton sets.
Example
b /0
a /1 s1
b /0 a /0
Initial partition π = {S }
s6 b /0 s2 Input symbol b is not valid
a /0 Input symbol a is valid
a /1
b /0 New partition:
π = {{s1 , s3 , s5 }, {s2 , s4 , s6 }}
s5 s3
a /1 a /0
s4
b /0 b /0
Example
b /0
a /1 s1
b /0 a /0
Initial partition
s6 b /0 s2 π = {{s1 , s3 , s5 }, {s2 , s4 , s6 }}
Input symbol b is valid for
a /0 {s1 , s3 , s5 }
a /1
b /0
New partition:
s5 s3 π = {{s1 }, {s3 , s5 }, {s2 , s4 , s6 }}
a /1 a /0
s4
b /0 b /0
Example
b /0
a /1 s1
b /0 a /0
Initial partition
s6 b /0 s2 π = {{s1 }, {s3 , s5 }, {s2 , s4 , s6 }}
Input symbol a is valid for
a /0 {s2 , s4 , s6 }
a /1
b /0
New partition:
s5 s3 π = {{s1 }, {s3 , s5 }, {s2 , s4 }, {s6 }}
a /1 a /0
s4
b /0 b /0
Example
b /0
a /1 s1
b /0 a /0
Initial partition
s6 b /0 s2 π = {{s1 }, {s3 , s5 }, {s2 , s4 }, {s6 }}
Input symbol b is valid for
a /0 {s3 , s5 }
a /1
b /0
New partition: π =
s5 s3 {{s1 }, {s3 }, {s5 }, {s2 , s4 }, {s6 }}
a /1 a /0
s4
b /0 b /0
Example
b /0
a /1 s1
b /0 a /0 Initial partition π =
{{s1 }, {s3 }, {s5 }, {s2 , s4 }, {s6 }}
s6 b /0 s2 Input symbol a is valid for
{s2 , s4 }
a /0 New partition: π =
a /1
b /0 {{s1 }, {s3 }, {s5 }, {s2 }, {s4 }, {s6 }}
s5 s3 Thus FSM has a distinguishing
sequence
a /1 a /0
s4
b /0 b /0
Example
b /0
a /1 s1
b /0 a /0
s6 b /0 s2 Initial partition π =
{{s1 }, {s3 }, {s5 }, {s2 }, {s4 }, {s6 }}
a /0
a /1 Thus FSM has a distinguishing
b /0 sequence
s5 s3
a /1 a /0
s4
b /0 b /0
s1
Essential Notions
1 Reduced FSM:
for all distinct s , s 0 ∈ S, there exists an x ∈ I∗ such that
output (s , x ) , output (s 0 , x ). I.e., x separates s and s 0 .
2 Completeness:
For each input a, and state s, there exists a s 0 such that
next (s , a ) = s 0 .
3 Determinism: For each input a, and state s, there exists at most one
s 0 such that next (s , a ) = s 0 .
Equivalence
2 Machine equivalence
M ≈ M 0 ∀s ∈S ∃s 0 ∈S 0 s ≈ s 0 ∧ ∀s 0 ∈S 0 ∃s ∈S s 0 ≈ s
Outline
4 Conformance Testing
5 Machine Identification
√
1 Determine the final state
homing sequence: a testcase to reveal the final state
√
1 Determine the final state
homing sequence: a testcase to reveal the final state
√
2 State identification (identify the initial state)
adaptive distinguishing sequence
√
1 Determine the final state
homing sequence: a testcase to reveal the final state
√
2 State identification (identify the initial state)
adaptive distinguishing sequence
3 Conformance testing (is blackbox A equivalent to the FSM?)
√
1 Determine the final state
homing sequence: a testcase to reveal the final state
√
2 State identification (identify the initial state)
adaptive distinguishing sequence
3 Conformance testing (is blackbox A equivalent to the FSM?)
4 Machine identification (derive the FSM from a blackbox)
Basic Idea
Specification: FSM A
Basic Idea
Specification: FSM A
Example
a/0
specification: s0
Example
a/0
specification: s0
Example
a/0
specification: s0
s0
suppose that sequence a n is the testcase a/0
(the answer to the conformance testing
problem) n
a/0
sn
a/1
for any n, some incorrect implementation
may pass the test: sn
Simplifying Assumptions
rst/0
Assumptions on A
s0
strongly connected: (testcase long
enough ⇒ each state visited) t/1
rst/0 t/0
reduced: (equivalence: interesting /
efficient on reduced FSMs)
s1
Simplifying Assumptions
Assumptions on A
strongly connected: (testcase long
enough ⇒ each state visited) rst/0
set(0)/0 status/0
reduced: (equivalence: interesting /
efficient on reduced FSMs) s0
Simplifying Assumptions
Assumptions on B
constant FSM
(should not change; should be finite)
at most | SA | states
(an upper bound is needed;
here, only transfer and output faults tested
no new states due to faults)
Fault Model
rst/0
rst/0 set(0)/0 status/0 rst/0
set(0)/0 status/0 set(0)/0 status/0
s0
s0
s0
s1 s1 s1
Basic Algorithm
Basic Algorithm
Example
testcase:
set(0), status, status, status, rst, status, t, status, set(1), status,
status, status, t, status, set(1), rst, status, set(1), set(0), status
rst/0
set(0)/0 status/0
s0
set(0) t/1
set(1)
rst/0 t/0
/0 /0
s1
status/1 set(1)/0
Specification
0,0, 0,0, 0, 0, 1, 1, 0,1,
1,1, 0, 0, 0,0,0, 0,0,0
Example
testcase:
set(0), status, status, status, rst, status, t, status, set(1), status,
status, status, t, status, set(1), rst, status, set(1), set(0), status
rst/0
rst/0 set(0)/0 status/0 rst/0
set(0)/0 status/0 set(0)/0 status/0
s0
s0
s0
s1 s1 s1
Example
testcase:
set(0), status, status, status, rst, status, t, status, set(1), status,
status, status, t, status, set(1), rst, status, set(1), set(0), status
rst/0
rst/0 set(0)/0 status/0 rst/0
set(0)/0 status/0 set(0)/0 status/0
s0
s0
s0
s1 s1 s1
Example
testcase:
set(0), status, status, status, rst, status, t, status, set(1), status,
status, status, t, status, set(1), rst, status, set(1), set(0), status
rst/0
rst/0 set(0)/0 status/0 rst/0
set(0)/0 status/0 set(0)/0 status/0
s0
s0
s0
s1 s1 s1
Transfer Sequence
Example
“Status”, Realistic?
Example
rst/0 rst/0
s0 s0
t/1 t/1
rst/0 t/0 rst/0 t/1
s1 s1
Example
testcase: first supply HS = rst, output = 0 (no other choice!), then supply
the state tour: t , t, then start testing t , t , rst , t , t , t , rst , t
rst/0 rst/0
s0 s0
t/1 t/1
rst/0 t/0 rst/0 t/1
s1 s1
0, 1, 0,
1, 0, 0, 1, 0,1 0, 1
Example
testcase: first supply HS = rst, output = 0 (no other choice!), then supply
the state tour: t , t, then start testing t , t , rst , t , t , t , rst , t
rst/0 rst/0
s0 s0
t/1 t/1
rst/0 t/0 rst/0 t/1
s1 s1
0, 1, 0, 0, 1, 1,
1, 0, 0, 1, 0,1 0, 1 1, 1, 0,1, 1, 1, 0, 1
Example
s0 s0 b/1
a/0 a/0
a/1 a/1
b/1
s1 s2 s1 s2
a/0 a/0
Solution
Homing sequence: ba
observed output 00 01 10
target state s2 s0 s2
Adaptive distinguishing sequences:
DS (s0 ) = aa, output (s0 , aa ) = 00
DS (s1 ) = aa, output (s1 , aa ) = 01
DS (s2 ) = a, output (s2 , a ) = 1
Outline
4 Conformance Testing
5 Machine Identification
Basic Idea
Simple solution
State-space explosion:
with n states, p inputs and q outputs, (nq)np /n! machines
2 states, 2 inputs, 2 outputs, 256 machines!
Possible Solutions:
Run all possible machines simultaneously (construct “direct sum”
machines)
Use machine learning: have an oracle which provides a test-case for
each failure
Outline
4 Conformance Testing
5 Machine Identification
UIO sequence
A UIO sequence for a state s is a walk ρ such that ρ produces different
output sequence from s than from any other state s 0 .
UIO sequence
A UIO sequence for a state s is a walk ρ such that ρ produces different
output sequence from s than from any other state s 0 .
UIO sequence
A UIO sequence for a state s is a walk ρ such that ρ produces different
output sequence from s than from any other state s 0 .
General Idea
Once a UIO sequence for a given state is found, one can construct UIOs
for other states by taking transitions backwards.
General Idea
Once a UIO sequence for a given state is found, one can construct UIOs
for other states by taking backward transitions.
General Idea
Once a UIO sequence for a given state is found, one can construct UIOs
for other states by taking backward transitions.
Empirical Evidence
In 89% of the cases, UIOs can be constructed using invertible sequences
from the UIO of a state. [Hierons and Turker, IEEE TSE’15]
Ongoing Work