active automata learning
play

Active automata learning Based on: Bernhard Steffen, Falk Howar und - PowerPoint PPT Presentation

Active automata learning Based on: Bernhard Steffen, Falk Howar und Maik Merten: Introduction to Active Automata Learning from a Practical Perspective. SFM 2011: 256-296. Motivation We want to apply model-based techniques. But: often


  1. Example button/ ✷ clean/ � [ ǫ ] water/ � pod/ � button/ ✷ [ pod ] [ water ] pod/ � water/ � water/ � pod/ � button/ K [ podwater ] [ podwaterbutton ] Σ \ { clean } / ✷ { water, pod } / � button/ ✷ [ button ] Σ / ✷

  2. Example button/ ✷ clean/ � [ ǫ ] water/ � pod/ � clean/ � button/ ✷ [ pod ] [ water ] pod/ � water/ � water/ � pod/ � button/ K [ podwater ] [ podwaterbutton ] Σ \ { clean } / ✷ { water, pod } / � button/ ✷ [ button ] Σ / ✷

  3. Consequences (I) We will call P regular if ≡ P has finite index, i.e., if there is a corresponding Mealy machine M P .

  4. Consequences (I) We will call P regular if ≡ P has finite index, i.e., if there is a corresponding Mealy machine M P . Corollary (Minimality) For regular P , M P is minimal.

  5. Consequences (I) We will call P regular if ≡ P has finite index, i.e., if there is a corresponding Mealy machine M P . Corollary (Minimality) For regular P , M P is minimal. Proof: ◮ Every state of a Mealy machine M belongs to one class of ≡ � M � .

  6. Consequences (I) We will call P regular if ≡ P has finite index, i.e., if there is a corresponding Mealy machine M P . Corollary (Minimality) For regular P , M P is minimal. Proof: ◮ Every state of a Mealy machine M belongs to one class of ≡ � M � . ◮ M � M � has exactly one state per class of ≡ � M � .

  7. Consequences (II) Corollary (Bounded reachability) For regular P , every transition of M P can be covered by a sequence of length at most n from the initial state. ( n : number of states of M P )

  8. Consequences (II) Corollary (Bounded reachability) For regular P , every transition of M P can be covered by a sequence of length at most n from the initial state. ( n : number of states of M P ) Especially: For every Mealy machine with N states, all transitions of its mininmal equivalent Mealy machine can be covered by sequences of length at most N .

  9. Canonical Mealy machines

  10. Minimizing automata Question: How can we minimize non-minimal automata / proof minimality?

  11. Minimizing automata Question: How can we minimize non-minimal automata / proof minimality? First idea: merge states based on equivalence of words: s ≡ s ′ ⇔ ∀ v ∈ Σ + . λ ∗ ( s, v ) = λ ∗ ( s ′ , v )

  12. Minimizing automata Question: How can we minimize non-minimal automata / proof minimality? First idea: merge states based on equivalence of words: s ≡ s ′ ⇔ ∀ v ∈ Σ + . λ ∗ ( s, v ) = λ ∗ ( s ′ , v ) But: it may be hard to argue about all future behaviors. ⇒ exchange quantifier!

  13. k-distinguishability Definition (k-distinguishability) Two states s, s ′ ∈ S of some Mealy machine M are k-distinguishable, iff there is a word w ∈ Σ ∗ of length k or shorter, for which λ ∗ ( s, w ) � = λ ∗ ( s ′ , w ) .

  14. k-distinguishability Definition (k-distinguishability) Two states s, s ′ ∈ S of some Mealy machine M are k-distinguishable, iff there is a word w ∈ Σ ∗ of length k or shorter, for which λ ∗ ( s, w ) � = λ ∗ ( s ′ , w ) . How big can k get?

  15. k-distinguishability Definition (k-distinguishability) Two states s, s ′ ∈ S of some Mealy machine M are k-distinguishable, iff there is a word w ∈ Σ ∗ of length k or shorter, for which λ ∗ ( s, w ) � = λ ∗ ( s ′ , w ) . How big can k get? Proposition In a Mealy machine of size n , states s �≡ s ′ ∈ S are n -distinguishable.

  16. Naive minimization 1. Compute spanning tree for M , (size n )

  17. Naive minimization 1. Compute spanning tree for M , (size n ) 2. Associate every state with path to it in spanning tree (from root), its access sequence

  18. Naive minimization 1. Compute spanning tree for M , (size n ) 2. Associate every state with path to it in spanning tree (from root), its access sequence 3. For every state construct T s : Σ ≤ n �→ Ω by T s ( v ) = def � M � ( uv ) where u is access sequence to s and v ∈ Σ ≤ n

  19. Naive minimization 1. Compute spanning tree for M , (size n ) 2. Associate every state with path to it in spanning tree (from root), its access sequence 3. For every state construct T s : Σ ≤ n �→ Ω by T s ( v ) = def � M � ( uv ) where u is access sequence to s and v ∈ Σ ≤ n 4. Merge states s, s ′ , whenever T s = T s ′

  20. Naive minimization 1. Compute spanning tree for M , (size n ) 2. Associate every state with path to it in spanning tree (from root), its access sequence 3. For every state construct T s : Σ ≤ n �→ Ω by T s ( v ) = def � M � ( uv ) where u is access sequence to s and v ∈ Σ ≤ n 4. Merge states s, s ′ , whenever T s = T s ′ Complexity for comparing states: O ( n 2 · | Σ | n )

  21. Partition refinement

  22. λ valuation Definition For a Mealy machine M and some state s in M , the λ valuation of s is a mapping λ s : Σ �→ Ω , with λ s ( α ) = def λ ( s, α )

  23. Partition refinement (algorithm) Input: A Mealy machine M = � S, s 0 , Σ , Ω , δ, λ � Output: A partition P on S , the set of states of the Mealy machine 1: i := 1 2: put all s ∈ S with the same λ valuation into the same class p of partition P i 3: loop 4: for all p ∈ P i do 5: for all s ∈ p do 6: construct mapping sig : Σ → P i : sig ( α ) = p ′ such that δ ( s, α ) ∈ p ′ 7: S i sig := S i 8: sig ∪ s 9: end for sig S i 10: P i +1 := � sig 11: end for 12: if P i = P i +1 then 13: return P i 14: end if 15: i := i + 1 16: end loop

  24. Partition refinement (algorithm) Input: A Mealy machine M = � S, s 0 , Σ , Ω , δ, λ � Output: A partition P on S , the set of states of the Mealy machine 1: i := 1 2: put all s ∈ S with the same λ valuation into the same class p of partition P i 3: loop 4: for all p ∈ P i do 5: for all s ∈ p do 6: construct mapping sig : Σ → P i : sig ( α ) = p ′ such that δ ( s, α ) ∈ p ′ 7: S i sig := S i 8: sig ∪ s 9: end for sig S i 10: P i +1 := � sig 11: end for 12: if P i = P i +1 then 13: return P i 14: end if 15: i := i + 1 16: end loop

  25. Partition refinement (algorithm) Input: A Mealy machine M = � S, s 0 , Σ , Ω , δ, λ � Output: A partition P on S , the set of states of the Mealy machine 1: i := 1 2: put all s ∈ S with the same λ valuation into the same class p of partition P i 3: loop 4: for all p ∈ P i do 5: for all s ∈ p do 6: construct mapping sig : Σ → P i : sig ( α ) = p ′ such that δ ( s, α ) ∈ p ′ 7: S i sig := S i 8: sig ∪ s 9: end for sig S i 10: P i +1 := � sig 11: end for 12: if P i = P i +1 then 13: return P i 14: end if 15: i := i + 1 16: end loop

  26. Partition refinement (algorithm) Input: A Mealy machine M = � S, s 0 , Σ , Ω , δ, λ � Output: A partition P on S , the set of states of the Mealy machine 1: i := 1 2: put all s ∈ S with the same λ valuation into the same class p of partition P i 3: loop 4: for all p ∈ P i do 5: for all s ∈ p do 6: construct mapping sig : Σ → P i : sig ( α ) = p ′ such that δ ( s, α ) ∈ p ′ 7: S i sig := S i 8: sig ∪ s 9: end for sig S i 10: P i +1 := � sig 11: end for 12: if P i = P i +1 then 13: return P i 14: end if 15: i := i + 1 16: end loop

  27. Partition refinement (algorithm) Input: A Mealy machine M = � S, s 0 , Σ , Ω , δ, λ � Output: A partition P on S , the set of states of the Mealy machine 1: i := 1 2: put all s ∈ S with the same λ valuation into the same class p of partition P i 3: loop 4: for all p ∈ P i do 5: for all s ∈ p do 6: construct mapping sig : Σ → P i : sig ( α ) = p ′ such that δ ( s, α ) ∈ p ′ 7: S i sig := S i 8: sig ∪ s 9: end for sig S i 10: P i +1 := � sig 11: end for 12: if P i = P i +1 then 13: return P i 14: end if 15: i := i + 1 16: end loop

  28. Partition refinement (complexity) ◮ Initial computation of λ valuations: ( n · | Σ | ) ◮ Computation of sig objects per rounds: ( n · | Σ | ) ◮ Maximum number of rounds n . Overall complexity: O ( n 2 · | Σ | )

  29. Partition refinement (example) button/ ✷ clean/ � a water/ � pod/ � clean/ � button/ ✷ b c pod/ � water/ � water/ � pod/ � button/ K button/ K d ′ d e Σ \ { clean } / ✷ { water, pod } / � { water, pod } / � button/ ✷ f Σ / ✷

  30. Partition refinement (example) button/ ✷ clean/ � a water/ � pod/ � clean/ � P 1 = { a, b, c } , { d, d ′ } , { e } , { f } button/ ✷ c b pod/ � water/ � water/ � pod/ � button/ K button/ K d ′ e d Σ \ { clean } ( esp. water ) / ✷ { water, pod } / � { water, pod } / � button/ ✷ f Σ( esp. clean ) / ✷

  31. Partition refinement (example) button/ ✷ clean/ � a water/ � pod/ � clean/ � P 1 = { a, b, c } , { d, d ′ } , { e } , { f } button/ ✷ c b pod/ � water/ � water/ � pod/ � P 2 = { a } , { b } , { c } , { d, d ′ } , { e } , { f } button/ K button/ K d ′ e d Σ \ { clean } / ✷ { water, pod } / � { water, pod } / � button/ ✷ f Σ / ✷

  32. Partition refinement (example) button/ ✷ clean/ � a water/ � pod/ � clean/ � P 1 = { a, b, c } , { d, d ′ } , { e } , { f } button/ ✷ c b pod/ � water/ � water/ � pod/ � P 2 = { a } , { b } , { c } , { d, d ′ } , { e } , { f } button/ K button/ K d ′ e d Σ \ { clean } / ✷ { water, pod } / � { water, pod } / � P 3 = { a } , { b } , { c } , { d, d ′ } , { e } , { f } button/ ✷ f Σ / ✷

  33. Minimized Mealy machine button/ ✷ a clean/ � water/ � pod/ � clean/ � button/ ✷ c b pod/ � water/ � water/ � pod/ � button/ K e d { water, pod } / � Σ \ { clean } / ✷ button/ ✷ f Σ / ✷

  34. Extension to black-boxes

  35. Scenario ◮ System under learning (SUL) is a black-box ◮ No knowledge about (number of) internal states ◮ Input alphabet given ◮ Tests can be executed on SUL, output can be recorded

  36. Scenario ◮ System under learning (SUL) is a black-box ◮ No knowledge about (number of) internal states ◮ Input alphabet given ◮ Tests can be executed on SUL, output can be recorded Try to produce complete and correct behavioral model of (interface-)behavior

  37. Naive learning Bad news: in general impossible! The possibility that one has not tested enough will always remain.

  38. Naive learning Bad news: in general impossible! The possibility that one has not tested enough will always remain. ◮ Assume maximum number of states to be N . ◮ Modify naive minimization

  39. Naive minimization 1. Compute prefix tree for depth N .

  40. Naive minimization 1. Compute prefix tree for depth N . 2. Associate every state with path to it in prefix tree (from root)

  41. Naive minimization 1. Compute prefix tree for depth N . 2. Associate every state with path to it in prefix tree (from root) 3. For every state construct T s : Σ ≤ N �→ Ω by T s ( v ) = def � M � ( uv ) where u is access sequence to s and v ∈ Σ ≤ N

  42. Naive minimization 1. Compute prefix tree for depth N . 2. Associate every state with path to it in prefix tree (from root) 3. For every state construct T s : Σ ≤ N �→ Ω by T s ( v ) = def � M � ( uv ) where u is access sequence to s and v ∈ Σ ≤ N 4. Merge states s, s ′ , whenever T s = T s ′

  43. Naive minimization 1. Compute prefix tree for depth N . 2. Associate every state with path to it in prefix tree (from root) 3. For every state construct T s : Σ ≤ N �→ Ω by T s ( v ) = def � M � ( uv ) where u is access sequence to s and v ∈ Σ ≤ N 4. Merge states s, s ′ , whenever T s = T s ′ Complexity for comparing states: O ( | Σ | N · | Σ | N ) = O ( | Σ | 2 N )

  44. Summarizing ◮ States can be represented by access sequences ◮ States can be distinguished by suffixes

  45. Summarizing ◮ States can be represented by access sequences ◮ States can be distinguished by suffixes Open questions: ◮ Can we extend the partition refinement pattern to produce suffixes? ◮ Can the partition refinement pattern be applied in the black box scenario?

  46. The ID learning algorithm

  47. Identifying states Definition (Output-signature) For a SUL and some word u in Σ ∗ , the output-signature of u in SUL is a mapping � SUL � D u : D �→ Ω with D ⊂ Σ ∗ , and � SUL � u ( v ) = def � SUL � ( uv )

  48. ID learning algorithm Input: A SUL with inputs Σ , a set U ⊂ Σ ∗ of access sequences to all states of SUL Output: A Mealy machine M = � S, s 0 , Σ , Ω , δ, λ � for SUL 1: i := 1 , D := Σ , S := U ∪ U × Σ 2: start: 3: compute � SUL � D u for all u ∈ S 4: put u, u ′ ∈ S into the same class p of partition P i if � SUL � D u = � SUL � D u ′ 5: for all p ∈ P i do 6: for all α ∈ Σ do for all u, u ′ ∈ p ∩ U do 7: if uα ∈ p ′ ∧ u ′ α / ∈ p ′ then 8: Let v ∈ D be s.t. � SUL � D uα ( v ) � = � SUL � D 9: u ′ α ( v ) 10: D := D ∪ { αv } , i := i + 1 11: goto start 12: end if 13: end for 14: end for 15: end for 16: construct M � SUL � from P i

  49. ID learning algorithm Input: A SUL with inputs Σ , a set U ⊂ Σ ∗ of access sequences to all states of SUL Output: A Mealy machine M = � S, s 0 , Σ , Ω , δ, λ � for SUL 1: i := 1 , D := Σ , S := U ∪ U × Σ 2: start: 3: compute � SUL � D u for all u ∈ S 4: put u, u ′ ∈ S into the same class p of partition P i if � SUL � D u = � SUL � D u ′ 5: for all p ∈ P i do 6: for all α ∈ Σ do for all u, u ′ ∈ p ∩ U do 7: if uα ∈ p ′ ∧ u ′ α / ∈ p ′ then 8: Let v ∈ D be s.t. � SUL � D uα ( v ) � = � SUL � D 9: u ′ α ( v ) 10: D := D ∪ { αv } , i := i + 1 11: goto start 12: end if 13: end for 14: end for 15: end for 16: construct M � SUL � from P i

  50. ID learning algorithm Input: A SUL with inputs Σ , a set U ⊂ Σ ∗ of access sequences to all states of SUL Output: A Mealy machine M = � S, s 0 , Σ , Ω , δ, λ � for SUL 1: i := 1 , D := Σ , S := U ∪ U × Σ 2: start: 3: compute � SUL � D u for all u ∈ S 4: put u, u ′ ∈ S into the same class p of partition P i if � SUL � D u = � SUL � D u ′ 5: for all p ∈ P i do 6: for all α ∈ Σ do for all u, u ′ ∈ p ∩ U do 7: if uα ∈ p ′ ∧ u ′ α / ∈ p ′ then 8: Let v ∈ D be s.t. � SUL � D uα ( v ) � = � SUL � D 9: u ′ α ( v ) 10: D := D ∪ { αv } , i := i + 1 11: goto start 12: end if 13: end for 14: end for 15: end for 16: construct M � SUL � from P i

  51. ID learning algorithm Input: A SUL with inputs Σ , a set U ⊂ Σ ∗ of access sequences to all states of SUL Output: A Mealy machine M = � S, s 0 , Σ , Ω , δ, λ � for SUL 1: i := 1 , D := Σ , S := U ∪ U × Σ 2: start: 3: compute � SUL � D u for all u ∈ S 4: put u, u ′ ∈ S into the same class p of partition P i if � SUL � D u = � SUL � D u ′ 5: for all p ∈ P i do 6: for all α ∈ Σ do for all u, u ′ ∈ p ∩ U do 7: if uα ∈ p ′ ∧ u ′ α / ∈ p ′ then 8: Let v ∈ D be s.t. � SUL � D uα ( v ) � = � SUL � D 9: u ′ α ( v ) 10: D := D ∪ { αv } , i := i + 1 11: goto start 12: end if 13: end for 14: end for 15: end for 16: construct M � SUL � from P i

  52. ID learning algorithm Input: A SUL with inputs Σ , a set U ⊂ Σ ∗ of access sequences to all states of SUL Output: A Mealy machine M = � S, s 0 , Σ , Ω , δ, λ � for SUL 1: i := 1 , D := Σ , S := U ∪ U × Σ 2: start: 3: compute � SUL � D u for all u ∈ S 4: put u, u ′ ∈ S into the same class p of partition P i if � SUL � D u = � SUL � D u ′ 5: for all p ∈ P i do 6: for all α ∈ Σ do for all u, u ′ ∈ p ∩ U do 7: if uα ∈ p ′ ∧ u ′ α / ∈ p ′ then 8: Let v ∈ D be s.t. � SUL � D uα ( v ) � = � SUL � D 9: u ′ α ( v ) 10: D := D ∪ { αv } , i := i + 1 11: goto start 12: end if 13: end for 14: end for 15: end for 16: construct M � SUL � from P i

  53. Model construction from final P i We will construct a Mealy machine from final P i by: Let M � SUL � = � S, s 0 , Σ , Ω , δ, λ � : ◮ S is given by the classes of P i .

  54. Model construction from final P i We will construct a Mealy machine from final P i by: Let M � SUL � = � S, s 0 , Σ , Ω , δ, λ � : ◮ S is given by the classes of P i . ◮ s 0 is given by p that contains ǫ .

  55. Model construction from final P i We will construct a Mealy machine from final P i by: Let M � SUL � = � S, s 0 , Σ , Ω , δ, λ � : ◮ S is given by the classes of P i . ◮ s 0 is given by p that contains ǫ . ◮ the transition function is defined by δ ( p, α ) = p ′ if exists u ∈ p ∩ U with uα ∈ p ′

  56. Model construction from final P i We will construct a Mealy machine from final P i by: Let M � SUL � = � S, s 0 , Σ , Ω , δ, λ � : ◮ S is given by the classes of P i . ◮ s 0 is given by p that contains ǫ . ◮ the transition function is defined by δ ( p, α ) = p ′ if exists u ∈ p ∩ U with uα ∈ p ′ ◮ the output function can be defined as λ ( p, α ) = o if exists u ∈ p ∩ U with � SUL � D u ( α ) = o

  57. Model construction from final P i We will construct a Mealy machine from final P i by: Let M � SUL � = � S, s 0 , Σ , Ω , δ, λ � : ◮ S is given by the classes of P i . ◮ s 0 is given by p that contains ǫ . ◮ the transition function is defined by δ ( p, α ) = p ′ if exists u ∈ p ∩ U with uα ∈ p ′ ◮ the output function can be defined as λ ( p, α ) = o if exists u ∈ p ∩ U with � SUL � D u ( α ) = o M � SUL � is well-defined and has semantic functional � SUL � if U contains access sequences to all classes of � SUL � .

Recommend


More recommend