Revisiting AI and Testing Methods to Infer FSM Models of Black-Box - - PowerPoint PPT Presentation

revisiting ai and testing methods to infer fsm models of
SMART_READER_LITE
LIVE PREVIEW

Revisiting AI and Testing Methods to Infer FSM Models of Black-Box - - PowerPoint PPT Presentation

Revisiting AI and Testing Methods to Infer FSM Models of Black-Box Systems Roland Groz, Nicolas Bremond, Catherine Oriat, U. Grenoble Alpes, France Adenilso Simao, U. So Paulo, Brasil Global context: inferring models thru testing n


slide-1
SLIDE 1

Revisiting AI and Testing Methods to Infer FSM Models of Black-Box Systems

Roland Groz, Nicolas Bremond, Catherine Oriat, U.

Grenoble Alpes, France

Adenilso Simao, U. São Paulo, Brasil

slide-2
SLIDE 2

Global context: inferring models thru testing

2

Method: Testing a system is LEARNING the behaviour of a system è Use “ML” techniques to learn model

n Model-based testing is good (systematic) n But often NO model available n Goal: keep benefits of MBT when no model

Problem: learn correct & “complete” behaviour of Black Box systems that cannot be reset

slide-3
SLIDE 3

Motivational example

  • Reverse-engineer models of Web applications to detect

security vulnerabilities using Learning algos (e.g. L*)

  • E-Health app provided by Siemens as a Virtual Machine

3

Learner

  • single I/O RTT over LAN: < 1 ms
  • reset=reboot VM: ~1 minute
  • Timewise: reset is O(105) RTT in example
  • Many systems CANNOT be reset AT ALL.
slide-4
SLIDE 4

Key difficulties when no reset

n How can we know in which state seq is applied ? n No backtrack possible to check other sequence n Losing track: we no longer know from where we

apply an input

4

slide-5
SLIDE 5

Existing algorithms without reset

n Rivest & Schapire 1993

¨ Homing sequence: ersatz for resetting in one of several states ¨ Then use a copy of L* for each homed state

n LocW (Groz & al. 2015)

¨ Assume W-set known (identifying sequences) ¨ Localize in an identifiable state with nested W

n Constraint-solving (Petrenko & al. 2017)

¨ Assume bound n on #states.

n NEW (this paper): hW inference

¨ No assumption ! Discovers h(oming) and W (characterizing)

5

slide-6
SLIDE 6

Results on random machines

(log-log)

6

10 100 1000 10000 100000 1x106 1x107 10 100 1000 length of trace (symbols) number of states relationship between length of trace and number of state hW Rivest and Schapire Constraints solver LocW

slide-7
SLIDE 7

Homing seq and W-sets

n h=a is homing sequence:

¨ After a/0 or a/1, final state=2,

(in this case h is a reset because single final state) n W={a,b} is a characterizing set

¨ a/1, b/1 : characterize state 1 ¨ a/0, b/0 : characterize state 2 ¨ a/0, b/1 : characterize state 3

Note: single homing sequence, but most machines require |W|> 1

7

2 3

a/1 b/0 a/0 b/1 b/1 a/0

1

slide-8
SLIDE 8

hW inference: core loop for h=a W={a, b}

n Repeatedly apply h, an input and wk

to progressively learn transitions

¨ More generally hαxwk , α transfer seq., x input

n h/1.w1/0 h/0. w1/0 h/0. w2/0

¨ At this point we know that tail state of h/0 is state

characterized by {a/0,b/0} (and we are now in state 1)

n h/1: we are again in tail state h/1, apply w2 n b/0: now we know tail state h/1 is {a/0,b/0}

8

2 3

a/1 b/0 a/0 b/1 b/1 a/0

1

slide-9
SLIDE 9

hW inference: cont’d h=a W={a, b}

n Known

¨ h/0 -> {a/0,b/0} ¨ h/1 -> {a/0,b/0}

n (and we are in 1). Apply h: a/1. We are

now in a known state {a/0,b/0}

n So we learn a transition from it:

¨ a/0 so we know the output on a is 0 ¨ And tail state answers w1/0.

9

{a0,b0}

a/0 a/0

2 3

a/1 b/0 a/0 b/1 b/1 a/0

1

slide-10
SLIDE 10

hW inference: cont’d h=a W={a, b}

n Known

¨ h/0 -> {a/0,b/0} ; h/1 -> {a/0,b/0} ¨ Partial transition

n We reapply h/0. So now we can complete

knowledge of transition: a/0 b/0

n So we have completely learnt transition n Going on, we learn the full FSM

10

{a0,b0}

a/0 a/0 b/0

{a0,b0}

a/0

2 3

a/1 b/0 a/0 b/1 b/1 a/0

1

slide-11
SLIDE 11

Learning with unknown h, W Key idea: use putative h, W

n Start with any (incorrect) h and W

¨ E.g. empty sequence and set ¨ Different states will be confused (merged) ¨ So this will lead to apparent NonDeterminism (ND)

n ND: reapplying a transition x/0, we see x/1

¨ Depending on context, we can either extend h to hx or

W to W∪{x}

n Progressively extending h and W until they are

homing & characterizing for the BB

11

slide-12
SLIDE 12

Does it work ?

n Yes !

¨ Naive, but turns out to converge fast

n Actually, enhanced with a number of heuristics not detailed

here

¨ Outperforms previous algorithms

n And even algorithms with reset, such as L*

¨ No initial knowledge needed (apart input set) ¨ Still needs an oracle to check equivalence in the end

(or get counterexample to refine)

n Oracle can just be random walk

12

slide-13
SLIDE 13

Does it help with s/w testing ?

n Example: a Heating Mngmt System

13

S21 ballon0/stoped - cold tickTime/stoped - cold depart_plancher35/stoped - cold ambiant20/stoped - cold ambiant15/stoped - cold S17 ballon50/stoped - cold S29 ambiant10/stoped - cold S16 depart_plancher0/stoped - cold ballon0/stoped - cold tickTime/stoped - cold ambiant15/stoped - cold ambiant20/stoped - cold ballon50/stoped - cold depart_plancher35/stoped - cold S20 ambiant10/stoped - cold S7 depart_plancher0/stoped - cold ambiant15/stoped - cold ambiant20/stoped - cold ballon0/stoped - cold depart_plancher35/stoped - cold ambiant10/stoped - cold ballon50/stoped - cold S31 tickTime/stoped - cold S25 depart_plancher0/stoped - cold depart_plancher35/stoped - cold depart_plancher0/stoped - cold ballon0/stoped - cold ambiant15/stoped - cold ambiant20/stoped - cold tickTime/stoped - cold ambiant10/stoped - cold ballon50/stoped - cold S2 ambiant20/stoped - cold ballon50/stoped - cold ambiant15/stoped - cold depart_plancher35/stoped - cold tickTime/stoped - cold S10 ambiant10/stoped - cold S9 depart_plancher0/stoped - cold S5 ballon0/stoped - cold ambiant15/stoped - cold ambiant20/stoped - cold ballon50/stoped - cold ambiant10/stoped - cold depart_plancher35/stoped - cold S14 tickTime/stoped - cold S13 depart_plancher0/stoped - cold S12 ballon0/stoped - cold depart_plancher35/stoped - cold tickTime/stoped - cold depart_plancher0/stoped - cold ambiant15/stoped - cold ambiant20/stoped - cold ballon50/stoped - cold S11 ballon0/stoped - cold ambiant10/stoped - cold ballon50/stoped - cold depart_plancher35/stoped - cold ballon0/stoped - cold tickTime/stoped - cold ambiant15/stoped - cold ambiant20/stoped - cold depart_plancher0/stoped - cold ambiant10/stoped - cold S15 ambiant20/stoped - cold ballon0/stoped - cold depart_plancher35/stoped - cold tickTime/stoped - cold ambiant15/stoped - cold ambiant10/stoped - cold S6 ballon50/pumping - keep postion S8 depart_plancher0/stoped - cold ambiant20/stoped - cold ballon50/pumping - keep postion ambiant15/pumping - keep postion ambiant10/pumping - keep postion depart_plancher35/pumping - keep postion S0 tickTime/pumping - cold S1 depart_plancher0/pumping - hot S19 ballon0/stoped - cold ambiant20/stoped - cold depart_plancher35/stoped - cold ballon0/stoped - cold tickTime/stoped - cold ambiant15/stoped - cold ambiant10/stoped - cold depart_plancher0/stoped - cold ballon50/pumping - hot ambiant20/stoped - cold ambiant15/stoped - cold ballon0/stoped - cold ambiant10/stoped - cold ballon50/stoped - cold depart_plancher35/stoped - cold S18 depart_plancher0/stoped - cold S27 tickTime/stoped - cold ambiant15/stoped - cold ambiant20/stoped - cold tickTime/stoped - cold ambiant10/stoped - cold depart_plancher35/stoped - cold ballon0/stoped - cold ballon50/stoped - cold S28 depart_plancher0/stoped - cold depart_plancher35/stoped - cold ambiant15/stoped - cold ambiant20/stoped - cold depart_plancher0/stoped - cold ballon0/stoped - cold ambiant10/stoped - cold ballon50/stoped - cold tickTime/stoped - cold S3 ambiant20/stoped - cold ambiant15/stoped - cold ambiant10/stoped - cold ballon0/stoped - cold tickTime/stoped - cold depart_plancher35/stoped - cold S4 depart_plancher0/stoped - cold ballon50/pumping - cold depart_plancher35/stoped - cold depart_plancher0/stoped - cold tickTime/stoped - cold ambiant10/stoped - cold ambiant15/stoped - cold ballon0/stoped - cold ambiant20/stoped - cold ballon50/pumping - hot ambiant20/stoped - cold ballon0/stoped - cold ambiant10/pumping - cold ambiant15/pumping - cold ballon50/pumping - cold depart_plancher35/pumping - cold tickTime/pumping - cold depart_plancher0/pumping - hot depart_plancher35/stoped - cold ballon0/stoped - cold ambiant10/stoped - cold depart_plancher0/stoped - cold ballon50/stoped - cold ambiant15/stoped - cold ambiant20/stoped - cold S26 tickTime/stoped - cold ambiant20/stoped - cold ambiant15/stoped - cold tickTime/pumping - keep postion ballon0/stoped - cold ballon50/stoped - cold depart_plancher35/stoped - cold ambiant10/stoped - cold depart_plancher0/stoped - cold ambiant20/stoped - cold ambiant15/stoped - cold tickTime/pumping - cold ballon50/stoped - cold depart_plancher35/stoped - cold ambiant10/stoped - cold S24 ballon0/stoped - cold S23 depart_plancher0/stoped - cold ambiant20/stoped - cold ambiant15/stoped - cold tickTime/stoped - cold ballon50/stoped - cold ballon0/stoped - cold depart_plancher35/stoped - cold ambiant10/stoped - cold S30 depart_plancher0/stoped - cold ambiant15/stoped - cold ambiant20/stoped - cold depart_plancher35/stoped - cold ambiant10/stoped - cold ballon50/stoped - cold depart_plancher0/stoped - cold tickTime/pumping - hot ballon0/stoped - cold ballon50/stoped - cold depart_plancher35/stoped - cold tickTime/stoped - cold ambiant20/stoped - cold ambiant15/stoped - cold ballon0/stoped - cold depart_plancher0/stoped - cold S22 ambiant10/stoped - cold depart_plancher35/pumping - keep postion ballon0/stoped - cold tickTime/pumping - hot depart_plancher0/pumping - hot ballon50/pumping - hot ambiant15/pumping - hot ambiant10/pumping - hot ambiant20/stoped - cold tickTime/stoped - cold depart_plancher35/stoped - cold ballon50/stoped - cold ambiant15/stoped - cold ambiant20/stoped - cold ballon0/stoped - cold ambiant10/stoped - cold depart_plancher0/stoped - cold depart_plancher35/stoped - cold ballon0/stoped - cold ambiant10/stoped - cold depart_plancher0/stoped - cold ambiant20/stoped - cold ballon50/stoped - cold ambiant15/stoped - cold tickTime/stoped - cold ambiant15/stoped - cold ambiant20/stoped - cold tickTime/stoped - cold ballon0/stoped - cold depart_plancher0/stoped - cold ambiant10/stoped - cold ballon50/stoped - cold depart_plancher35/stoped - cold depart_plancher35/stoped - cold ambiant15/stoped - cold ambiant20/stoped - cold tickTime/stoped - cold ballon0/stoped - cold ambiant10/stoped - cold ballon50/stoped - cold depart_plancher0/stoped - cold ballon50/stoped - cold ambiant20/stoped - cold ambiant15/stoped - cold tickTime/stoped - cold depart_plancher0/stoped - cold depart_plancher35/stoped - cold ambiant10/stoped - cold ballon0/stoped - cold ambiant20/stoped - cold ballon50/pumping - keep postion depart_plancher0/stoped - cold tickTime/stoped - cold ballon0/stoped - cold depart_plancher35/stoped - cold ambiant10/stoped - cold ambiant15/stoped - cold depart_plancher35/stoped - cold tickTime/pumping - hot ambiant15/stoped - cold ambiant20/stoped - cold ambiant10/stoped - cold ballon50/stoped - cold depart_plancher0/stoped - cold ballon0/stoped - cold ambiant15/stoped - cold ambiant20/stoped - cold tickTime/stoped - cold depart_plancher35/stoped - cold ballon50/stoped - cold ambiant10/stoped - cold depart_plancher0/stoped - cold ballon0/stoped - cold
  • C++ controller
  • 3 temperature inputs + timer ->

9 inputs

  • Inferred 36 states, in a few

minutes

slide-14
SLIDE 14

Results on HMS controller

n RQ1: does hW yield usable models on real

CPS ? Yes

n RQ2: testing efficiency / random testing

¨ 54 mutations

n 10 crashes without inputs (hW = RT) n 4 killed during inference – also by RT

but RT requires many more inputs to kill

n 35 model inferred: exposes mutation n 5 equivalent models (w.r.t. input abstraction)

14

slide-15
SLIDE 15

Conclusion

n New approach to learn FSM models of s/w

components without reset

n Full black box, no assumption n Works surprisingly well, scales up to

1000s states

n Also provides very systematic way of

testing reactive software

15

slide-16
SLIDE 16

Perspectives

n Potential breakthrough in Learning Based

Testing

¨ Resetting a system is a superfluous luxury ¨ hW is fast, scaling, does not require any

knowledge

n Check applicability on other types of s/w n Extension to EFSM (data inference)

16

slide-17
SLIDE 17

Thank you !

n Following: backup slides

17

slide-18
SLIDE 18

Inferring model of Black Box

Testing as a means of reverse-engineering a model of a BB

18

Scenario 1 Scenario 2

n Classical active inference algorithms assume BB

machine can be reset

¨ Essential to merge traces (scenarios) on a common basis

n Assume an oracle can provide counterexamples (CE)

¨ Essential to bring complexity down to polynomial in #states ¨ Example: L* (Angluin). Complexity is

O(#inputs CE_length #states2) = O(fmn2) queries (test seq.)

¨ So O(fmn2) resets