Title: Computing with Finite Automata
1Computing with Finite Automata
290N The Unknown Component Problem Lecture 9
2Outline
- Problem solving flow
- Example of a traffic light controller
- Representation of automata
- Simple operations
- Complementing (complement)
- Completing (complete)
- Filtering states
- Making prefix closed (prefix)
- Progressive (progressive)
- Moore-reduction (moore)
- State minimization (minimize)
- Reachability analysis
- Product computation (product)
- Verification by language containment (check)
- Determinization by subset construction
(determinize) - Dont-care minimization (dcmin)
3Problem Solving Flow
- Determine the interaction topology
- Specify the fixed part and the spec as automata,
FSMs, or multi-level multi-valued networks - Create the script, which implements the flow
- Special attention should be paid to projection
and lifting of variables (command support)
because it is closely related to the selected
topology - Run the script on MVSIS and debug it if necessary
- Analyze the resulting solution
- Is it prefix closed and progressive? (commands
prefix, progressive) - Is it deterministic as an FSM? (command
check_nd) - Is it state-minimum? (command minimize)
- Compare the language of this solution with other
solutions if available (command volume) - Make conclusions
- Formulate and prove new theorems
- Create new examples
4Example Traffic Light Controller
General Topology
This example
Specification
Specification
S
S
I
O
z
Fixed
Fixed
F
F
U
V
v
Unknown
Unknown
X
X
5Traffic Light Controller (fixed part)
- .model fixed
- .inputs v z
- .outputs Acc
- .mv v 2 wait go
- .mv z 3 red green yellow
- .mv CS, NS 3 Fr Fg Fy
- .latch NS CS
- .reset CS
- Fr
- .table -gtAcc
- 1
- .table v z CS -gtNS
- wait red Fr Fr
- go red Fr Fg
- wait green Fg Fg
- go green Fg Fy
- wait yellow Fy Fy
- go yellow Fy Fr
- .end
z red, green, yellow v wait, go
6Traffic Light Controller (spec)
- .model spec
- .inputs z
- .outputs Acc
- .mv z 3 red green yellow
- .mv CS,NS 4 S1 S2 S3 S4
- .table -gtAcc
- 1
- .latch NS CS
- .reset CS
- S1
- .table z CS -gtNS
- red S1 S2
- red S2 S3
- green S3 S4
- yellow S4 S1
- .end
7Traffic Light Controller (script)
- echo "Synthesis ..."
- determinize -lci spec.mva spec_dci.mva
- support v(2),z(3) spec_dci.mva spec_dci_supp.mva
- support v(2),z(3) fixed.mva fixed_supp.mva
- product -l fixed_supp.mva spec_dci_supp.mva p.mva
- support v(2) p.mva p_supp.mva
- determinize -lci p_supp.mva p_dci.mva
- progressive -i 0 p_dci.mva x.mva
- echo "Verification ..."
- support v(2),z(3) x.mva x_supp.mva
- product x_supp.mva fixed_supp.mva prod.mva
- support v(2),z(3) spec.mva spec_supp.mva
- check prod.mva spec_supp.mva
8Traffic Light Controller (solution)
- .model solution
- .inputs v
- .outputs Acc
- .mv v 2 wait go
- .mv CS, NS 4 \
- FrS1 FrS2 FgS3 FyS4
- .latch NS CS
- .reset CS
- FrS1
- .table -gtAcc
- 1
- .table v CS -gtNS
- wait FrS1 FrS2
- go FrS2 FgS3
- go FgS3 FyS4
- go FyS4 FrS1
- .end
9Traffic Light Controller (script2)
- echo "Synthesis ..."
- determinize -lci spec.mva spec_dci.mva
- support v(2),z(3) spec_dci.mva spec_dci_supp.mva
- support v(2),z(3) fixed.mva fixed_supp.mva
- product -l fixed_supp.mva spec_dci_supp.mva p.mva
- support z(3),v(2) p.mva p_supp.mva
- determinize -lci p_supp.mva p_dci.mva
- progressive -i 1 p_dci.mva x.mva
- echo "Verification ..."
- support v(2),z(3) x.mva x_supp.mva
- product x_supp.mva fixed_supp.mva prod.mva
- support v(2),z(3) spec.mva spec_supp.mva
- check prod.mva spec_supp.mva
10Further Experiments
- Run both scripts and see how solution differs
- Make Spec non-deterministic and see what happens
- Make Fixed non-deterministic and see what happens
- Try more complex Fixed
- For example, make Fixed depend on an additional
variable s, which shifts it from one set of
states to another set of states - In one set, Fixed behaves as before
- In other set, Fixed already behaves according to
the spec
11An Extension of Fixed
Old states
New states
12Two Topologies to Try
s
s
13Outline
- Problem solving flow
- Example of a traffic light controller
- Representation of automata
- Simple operations
- Complementing (complement)
- Completing (complete)
- Filtering states
- Making prefix closed (prefix)
- Progressive (progressive)
- Moore-reduction (moore)
- State minimization (minimize)
- Reachability analysis
- Product computation (product)
- Verification by language containment (check)
- Determinization by subset construction
(determinize) - Dont-care minimization (dcmin)
14Representation of Automata
- Completely explicit (MVSIS package au)
- Both STG and transition conditions are
represented explicitly (STG is a graph
conditions are SOPs) - Completely implicit (monolithic) (MVSIS package
lang) - Automaton is represented by a single transition
relation and char functions of accepting states - Completely implicit (partitioned) (MVSIS package
mvn (mvnSolve.c)) - Can only be used for automata derived from
multi-level networks - Automaton is represented by a set of partitions
(one partition for each latch excitation
function) - Hybrid representation (MVSIS package aut)
- STG is represented explicitly (as a graph)
- Transition conditions are represented implicitly
as BDDs
15Simple Operations
- Complementing
- swap the sets of accepting and non-accepting
states - deterministic automata only!
- Completing
- For each state, compute the input domain when the
transitions are defined - If this domain is constant 1 for all states, the
automaton is complete - Otherwise
- create a new non-accepting state (DC state) with
the self-loop under all inputs - create transitions from each incompletely
specified state into the DC state, under the
previously undefined condition
16Filtering States
- Prefix-closed
- Removes all the non-accepting states
- Removes the accepting states not reachable from
the initial state - Progressive (I-progressive)
- Iteratively removes all the states whose I/O
behavior represented as a multi-output relation
is not well-defined - Moore-reduction
- Given an arbitrary Mealy machine, reduce it to a
Moore machine
17Example of Prefixed Close
18Example of Progressive
19Example of Moore-Reduction
CSF computed after splitting latches of
benchmark dk27.blif
The results of Moore-reduction Number of inputs
3.
20Outline
- Problem solving flow
- Example of a traffic light controller
- Representation of automata
- Simple operations
- Complementing (complement)
- Completing (complete)
- Filtering states
- Making prefix closed (prefix)
- Progressive (progressive)
- Moore-reduction (moore)
- State minimization (minimize)
- Reachability analysis
- Product computation (product)
- Verification by language containment (check)
- Determinization by subset construction
(determinize) - Dont-care minimization (dcmin)
21State Minimization of FA
- Requirements for the automaton
- Deterministic (if not, first determinize)
- Complete (if not, first complete)
- Definition of state equivalence
- Two ways of computing equivalence classes
- Implicit
- Explicit
- The explicit algorithm in detail
- Example
22State Equivalence of FA
- Definition. A string is accepted by the
automation in state s iff it drives the automaton
into an accepting state. - Definition. Two states s1 and s2 are
distinguishable iff there exists a string, which
is accepted in state s1 and not accepted in state
s2. - Definition. States s1 and s2 are equivalent if
they are not distinguishable. - Example
- States A and C are distinguishable
- States B and C are equivalent
23Outline of the Algorithm
- The automaton is given by
- State transition graph
- The set of accepting states
- Compute the set of distance-0 distinguishable
pairs by combining each accepting state with each
non-accepting state - For each pair, find all the pairs reachable in
backward traversal from the distinguishable
pairs, under all input combinations - Collect these pairs and explore them until no new
pairs can be found - The remaining pairs are pairs of equivalent
states - Reduce the automaton by replacing each state by
one selected representative of its equivalence
class
24Implicit Implementation
- The automaton is given by
- Transition relation R(x,cs,ns)
- Characteristic function of accepting states A(cs)
- Compute the set of distance-0 distinguishable
pairs (when one state is accepting while the
other is not) - D0(cs,cs) A(cs) ? A(cs)
- Compute the pair transition relation
- P(cs,cs,ns,ns) ?x R(x,cs,ns) R(x,cs,ns)
- Starting from the distance-0 distinguishable
pairs, iteratively compute distance-k
distinguishable pairs, until convergence - Di1(cs,cs) ?ns,ns P(cs,cs,ns,ns)
Di(ns,ns) - The equivalence relation is
- E(cs,cs) NOTDi1(cs,cs)
- Reduce the automaton by replacing each state by
one representative taken from its equivalence
class - P(cs,cs) CompatibleProjection( E(cs,cs), cs
) - R(x,cs,ns) ?cs,ns R(x,cs,ns) P(cs,cs)
P(ns,ns)
25Explicit Implementation
- The automaton
- The linked list of states
- The accepting states are marked
- Additional data structures
- Q The FIFO queue of distinguishable state pairs
to be explored - H The hash table hashing every pair into
visited, not visited - Initialization
- for each accepting state s
- for each non-accepting state s
- insert pair (s,s) into Q and H
- Computation
- while Q is not empty, extract one pair (s,s)
from Q - for each pair (t,t), which transits into
(s,s) under some input - if (t,t) is not in H (that is, (t,t)
has not been visited) - insert pair (t,t) into Q and
into H
26Reducing the Automaton
- The automaton
- The linked list of states
- The accepting states are marked
- The equivalence relation
- Maps pair (s,s) into distinguishable,
equivalent - The same as hash table H visited
distinguishable not visited equivalent - Computation
- Construct the equivalence classes of states using
the equivalence relation - Select one representative state from each
equivalence class - Create the mapping of each state in the original
automaton into the representative state from its
equivalence class - start the new automaton
- add a new state for each representative state of
the old automaton - for all representative states s1
- for each transition (s1-gts2) from the
representative state s1 into some other state s2 - add transition from the new state corresponding
to s1 into the new state corresponding to s2 - Set the new initial state to be the new state
corresponding to the representative of the class,
to which the original initial state belongs
27Example of State Minimization
- Distinguishable pairs after initialization
- (A,DC), (C,DC), (B,DC)
- Computed distinguishable pairs
- (A,DC) ? (A,C)
- (A,DC) ? (A,B)
- Remaining equivalent pairs
- (B,C)
- The derived reduced graph