Minimization of finite state automata through partition aggregation

Minimization of finite state automata through
partition aggregation
Johanna Björklund
Loek Cleophas
LATA 2017, Umeå, Sweden
Finite state automata
A finite state automaton is a tuple M = (Q, Σ, δ, QI , QF ), where
• Q is a finite set of states
• Σ is an alphabet of input symbols
• δ = (δf )f ∈Σ is a family of transition functions δf : Q → P(Q);
• QI ⊆ Q is a set of initial states; and
• QF ⊆ Q is a set of final states.
The forward language of a state q is the set of all strings that take M
from q to a state in QF .
Partition refinement
• Minimisation is typically done through partition refinement.
• Intially assume that all states are equivalent, and refine partition
until it is “contradiction-free”.
• Leads to fast algorithms, but intermediate partitions do not preserve
language-equality.
Partition aggregation
• Minimisation can also be done through partition aggregation.
• Intially assume that all states are inequivalent, and merge partition
blocks until contradictions arise.
• Leads to slower algorithms, but intermediate partitions preserve
language-equality.
Scenario
• FSA to filter network traffic and detect intrusion attempts.
• Target patterns are added and updated over time.
• Run minimisation algorithm as a maintenence task in the
background.
• Minimisation can be stopped and restarted as convenient.
Bisimulation equivalence
Let E be a binary relation on Q. It is a bisimulation relation on M if for
every (p, q) ∈ E,
• p ∈ QF if and only if q ∈ QF ; and
• for every symbol f ∈ Σ,
∀p0 ∈ δf (p) ∃q 0 ∈ δf (q) s.t. (p0 , q 0 ) ∈ E
∀q 0 ∈ δf (q) ∃p0 ∈ δf (p) s.t. (p0 , q 0 ) ∈ E
A pinch of logic
The Boolean values B are written as > and ⊥, respectively.
Let L be a propositional logic over the logical variables V , and let
WF(L) be the set of well-formed formulas over L. An interpretation of L
is a partial function V 7→ B.
Given interpretations v and v 0 , we say that v 0 is an extension of v if
v 0 (π) = v(π) for all π ∈ dom (v). The set of all such extensions is written
Ext(v).
Interpretations are extended as usual to WF(L). The formula w is
resolved by v if v(w) ∈ {>, ⊥}, and v is a model for w if v(w) = >. The
set of models of w is denoted by Mod(w).
Relations as interpretations
Let VM = {hp, qi | p, q ∈ Q} be a set of propositional variables.
We associate with every interpretation v of VM a relation ∼v on VM ,
given by p ∼v q ⇐⇒ v(hp, qi) = >.
Characteristic formula
For π = hp, qi ∈ VM and f ∈ Σ, we denote by wπf the negation-free CNF
formula
^
_
^
_
hp0 , q 0 i
∧
hp0 , q 0 i
p0 ∈δf (p) q 0 ∈δf (q)
and by wπ the formula
V
q 0 ∈δf (q) p0 ∈δf (p)
f ∈Σ
Finally, wM is the conjunction
wπa .
V
π∈VM
π → wπ .
Maximal model
Let v and v 0 be interpretations of VM . Then v ∨ v 0 is the interpretation
of VM given by (v ∨ v 0 )(π) = v(π) ∨ v 0 (π), for every π ∈ VM .
The model v ∈ Mod(w) is maximal if v ∨ v 0 = v for every
v 0 ∈ Ext(v) ∩ Mod(w).
Lemma 1. Let v be a partial interpretation of VM . If v has an extension
that is a model of wM , then there is a v̂ ∈ Ext(v) that is a maximal
model for wM , and v̂ is unique.
Lemma 2.If ∼v is an equivalence relation, then so is ∼v̂ .
The coarsest bisimulation relation
Let v0 be the partial interpretation of VM such that
v0 (hp, pi)
v0 (hp, qi)
= > for every p ∈ Q
= ⊥ for every p, q ∈ Q with p ∈ QF 6≡ q ∈ QF
and v0 undefined on all other state pairs.
Lemma 3. v0 ∈ Mod(wM ) and ∼v0 is an equivalence relation.
Theorem 1. There is a unique maximal extension v̂ of v0 in Mod(wM ),
and ∼v̂ is the coarsest bisimulation relation on M .
Substitutions
A substitution is a set {x1 ← w1 , . . . , xn ← wn }, where each xi ∈ X is a
distinct variable and each wi ∈ WF(L) is a formula.
The application of θ to a formula w is denoted wθ and defined by
replacing every occurrence of each xi in w by the corresponding wi .
Let θ = {x1 ← w1 , . . . , xn ← wn } and σ = {y1 ← w10 , . . . , yk ← wk0 } be
two substitutions. Let X and Y be the sets of variables substituted for in
θ and σ, respectively. The composition of θ and σ is the substitution
θσ = {xi ← wi σ | xi ∈ X} ∪ {yj ← wj | yj ∈ Y \ X}.
Aggregation-based minimization algorithm
1:
2:
3:
4:
5:
6:
7:
8:
function minimize(M )
σ0 ::= {hp, pi ← > | p ∈ Q} ∪
{hp, qi ← ⊥ | (p ∈ QF ) 6≡ (q ∈ QF )}
for π ∈ VM \ dom (σi ) do
equiv (π, {π})
end for
return (M/ ∼σi )
end function
Point-wise computation of π ∈ VM
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
function equiv(π, S)
while ∃π 0 ∈ (var (wπ ) \ dom (σi )) \ S
and wπ σi is not resolved do
equiv (π 0 , S ∪ {π 0 })
end while
if wπ σi is resolved then
σi+1 ::= σi {π ← wπ σi }
else
σi+1 ::= σi {π ← wπ σi {π ← >}}
end if
end function
Aggregation-based minimization algorithm
1:
2:
3:
4:
5:
6:
7:
8:
function minimize(M )
σ0 ::= {hp, pi ← > | p ∈ Q} ∪
{hp, qi ← ⊥ | (p ∈ QF ) 6≡ (q ∈ QF )}
for π ∈ VM \ dom (σi ) do
equiv (π, {π})
end for
return (M/ ∼σi )
end function
Correctness
Theorem 2. The minimization algorithm terminates and outputs
(M/ ∼), where ∼ is the unique coarsest bisimulation equivalence on M .
Complexity
Theorem 3. The minimization algorithm is in O n2 d2 |Σ| , where n is
the number of states of the input automaton M , d is the maximal
outdegree in the transition graph for any combination of state and input
symbol, and |Σ| is the size of the input alphabet.
Thanks for listening!