Hybrid System Falsification and Reinforcement Learning Formal - - PowerPoint PPT Presentation

hybrid system falsification and reinforcement learning
SMART_READER_LITE
LIVE PREVIEW

Hybrid System Falsification and Reinforcement Learning Formal - - PowerPoint PPT Presentation

Hybrid System Falsification and Reinforcement Learning Formal Method for Cyber-Physical Systems Clovis Eberhart David Sprunger National Institute of Technology, Japan SOKENDAI lesson, July 1, 8, and 22 1 / 50 Lecture structure Lectures


slide-1
SLIDE 1

Hybrid System Falsification and Reinforcement Learning

Formal Method for Cyber-Physical Systems

Clovis Eberhart David Sprunger

National Institute of Technology, Japan

SOKENDAI lesson, July 1, 8, and 22

1 / 50

slide-2
SLIDE 2

Lecture structure

Lectures

1st: falsification (problem, framework, logics. . . ), by me 2nd: deep learning for falsification (learning, reinforcement learning, application to falsification. . . ), by David 3rd: advanced techniques in falsification and reinforcement learning, by David and me

Evaluation

Easy practical assignment (in Python).

Questions?

Ask them during the lesson. Find me at my desk (Palaceside building). clovis.eberhart@gmail.com

2 / 50

slide-3
SLIDE 3

First lecture overview

1

Formal methods landscape

2

Framework

3

Hybrid systems

4

Formulas

5

Optimisation

3 / 50

slide-4
SLIDE 4

Table of Contents

1

Formal methods landscape

2

Framework

3

Hybrid systems

4

Formulas

5

Optimisation

4 / 50

slide-5
SLIDE 5

Formal method landscape

Kapinski, Deshmukh, Jin, Ito, Butts, Simulation-Based Approaches for Verification of Embedded Control Systems, IEEE Control Magazine, 2010

5 / 50

slide-6
SLIDE 6

Testing

Testing

Given: a system S, a property ϕ. Goal: generate a test suite {ti}i∈I.

6 / 50

slide-7
SLIDE 7

Testing

Testing

Given: a system S, a property ϕ. Goal: generate a test suite {ti}i∈I.

Characteristics

simple (run tests) black-box (unknown systems) versatile (guarantees, explainable failures. . . ) no formal guarantee too general

6 / 50

slide-8
SLIDE 8

Verification

Verification

Given: a model M, a property ϕ. Goal: automatically prove that M ϕ.

7 / 50

slide-9
SLIDE 9

Verification

Verification

Given: a model M, a property ϕ. Goal: automatically prove that M ϕ.

Characteristics

complex (design model, use specific techniques, so typically not used by engineers) white-box (known systems only) formal proof (strong guarantee) ill-suited to CPS (continuous systems)

7 / 50

slide-10
SLIDE 10

Verification

Verification

Given: a model M, a property ϕ. Goal: automatically prove that M ϕ.

Characteristics

complex (design model, use specific techniques, so typically not used by engineers) white-box (known systems only) formal proof (strong guarantee) ill-suited to CPS (continuous systems)

Theorem proving

Given: a model M, a property ϕ. Goal: prove that M ϕ.

7 / 50

slide-11
SLIDE 11

Falsification

Falsification

Given: a system S, a property ϕ. Goal: generate a counterexample to S ϕ.

8 / 50

slide-12
SLIDE 12

Falsification

Falsification

Given: a system S, a property ϕ. Goal: generate a counterexample to S ϕ.

Characteristics

particular case of testing black-box (unknown systems) relatively simple no proof (no formal guarantee)

8 / 50

slide-13
SLIDE 13

Verification versus falsification

Verification:

finds a proof: system verifies property, finds nothing:

Falsification:

finds a counterexample: system violates property, finds nothing:

9 / 50

slide-14
SLIDE 14

Verification versus falsification

Verification:

finds a proof: system verifies property, finds nothing: nothing can be said.

Falsification:

finds a counterexample: system violates property, finds nothing: nothing can be said.

9 / 50

slide-15
SLIDE 15

Verification versus falsification

Verification:

finds a proof: system verifies property, finds nothing: nothing can be said.

Falsification:

finds a counterexample: system violates property, finds nothing: nothing can be said.

Interaction: verification for falsification: constraining state space by reachability analysis, falsification for verification: coverage-based falsification techniques.

9 / 50

slide-16
SLIDE 16

Table of Contents

1

Formal methods landscape

2

Framework

3

Hybrid systems

4

Formulas

5

Optimisation

10 / 50

slide-17
SLIDE 17

General framework

Reminder

Given: a system S, a property ϕ. Goal: generate a counterexample to S ϕ.

11 / 50

slide-18
SLIDE 18

General framework

Reminder

Given: a system S, a property ϕ. Goal: generate a counterexample to S ϕ.

Questions

What is a system?

11 / 50

slide-19
SLIDE 19

General framework

Reminder

Given: a system S, a property ϕ. Goal: generate a counterexample to S ϕ.

Questions

What is a system? hybrid system

11 / 50

slide-20
SLIDE 20

General framework

Reminder

Given: a system S, a property ϕ. Goal: generate a counterexample to S ϕ.

Questions

What is a system? hybrid system What is a property?

11 / 50

slide-21
SLIDE 21

General framework

Reminder

Given: a system S, a property ϕ. Goal: generate a counterexample to S ϕ.

Questions

What is a system? hybrid system What is a property? logical formula

11 / 50

slide-22
SLIDE 22

General framework

Reminder

Given: a system S, a property ϕ. Goal: generate a counterexample to S ϕ.

Questions

What is a system? hybrid system What is a property? logical formula What is a counterexample?

11 / 50

slide-23
SLIDE 23

General framework

Reminder

Given: a system S, a property ϕ. Goal: generate a counterexample to S ϕ.

Questions

What is a system? hybrid system What is a property? logical formula What is a counterexample? an input (and output) signal to the system that violates the property

11 / 50

slide-24
SLIDE 24

General framework

Reminder

Given: a system S, a property ϕ. Goal: generate a counterexample to S ϕ.

Questions

What is a system? hybrid system What is a property? logical formula What is a counterexample? an input (and output) signal to the system that violates the property

Challenges

infinite (and high-dimensional) search space non-linear dynamics

11 / 50

slide-25
SLIDE 25

The falsification loop

S

ϕ

ϕ

checker generator

σout ϕ σoutϕ σin σoutϕ σin/(σin,σout)

falsification

12 / 50

slide-26
SLIDE 26

The falsification loop

S

ϕ

ϕ

checker generator

σout ϕ σoutϕ σin σoutϕ σin/(σin,σout)

falsification

12 / 50

slide-27
SLIDE 27

The falsification algorithm

Input: A system S, a formula ϕ, a satisfaction predicate , and a timeout tmax Output: A signal σin such that S(σin) ϕ found = false; while not(found) and t < tmax do σin = generate(); σout = S(σin); found = σout ϕ; end if found then return σin else return “timeout” end

13 / 50

slide-28
SLIDE 28

Optimisation-based falsification

S

ϕ

ϕ

checker generator

σout ϕ ρ(σout,ϕ)≥0 σin ρ(σout,ϕ)<0 σin/(σin,σout)

falsification

14 / 50

slide-29
SLIDE 29

Optimisation-based falsification

S

ϕ

ϕ

checker generator

σout ϕ ρ(σout,ϕ)≥0 σin ρ(σout,ϕ)<0 σin/(σin,σout)

falsification

14 / 50

slide-30
SLIDE 30

The optimisation-based falsification algorithm

Input: A system S, a formula ϕ, a robustness function ρ, and a timeout tmax Output: A signal σin such that S(σin) ϕ found = false; while not(found) and t < tmax do σin = search minimum(ρ); σout = S(σin); found = ρ(σout, ϕ) < 0; end if found then return σin else return “timeout” end Required: ρ(σ, ϕ) ≥ 0 ⇐ ⇒ σ ϕ

15 / 50

slide-31
SLIDE 31

Table of Contents

1

Formal methods landscape

2

Framework

3

Hybrid systems

4

Formulas

5

Optimisation

16 / 50

slide-32
SLIDE 32

Hybrid systems

Definition

A hybrid system is a dynamical system that exhibits both continuous and discrete dynamic behavior – a system that can both flow (described by a differential equation) and jump (described by a state machine or automaton). Wikipedia

Fehnker, Ivanˇ ci´ c, Benchmarks for Hybrid Systems Verification, Hybrid Systems: Computation and Control, pp 326–341

17 / 50

slide-33
SLIDE 33

Hybrid system: definition

Hybrid system

A Hybrid system is a tuple H = (Q, X, GUARD, JUMP, U, FLOW)

  • f:

a finite set of modes Q, a family of continuous state spaces X = {Xq ⊆ Rnq | q ∈ Q}, GUARDq,q′ ⊆ Xq is the set of states in Xq that can transition to mode q′, JUMPq,q′ : Xq → Xq′ describes the transition from q to q′, U is the input space, FLOWq, is a set of differential equations in Xq and U, seen as a function Xq × U × R≥0 → Xq,

18 / 50

slide-34
SLIDE 34

Example of hybrid system: thermostat

q0

dT dt = −KT

T ≥ T0 q1

dT dt = K(h−T)

T ≤ T1

T=T0 | · T=T1 | ·

19 / 50

slide-35
SLIDE 35

Example of hybrid system: thermostat

q0

dT dt = −KT

T ≥ T0 q1

dT dt = K(h−T)

T ≤ T1

T=T0 | · T=T1 | ·

Q = {q0, q1},

19 / 50

slide-36
SLIDE 36

Example of hybrid system: thermostat

q0

dT dt = −KT

T ≥ T0 q1

dT dt = K(h−T)

T ≤ T1

T=T0 | · T=T1 | ·

Q = {q0, q1}, Xq0 = {T ∈ R | T ≥ T0},

19 / 50

slide-37
SLIDE 37

Example of hybrid system: thermostat

q0

dT dt = −KT

T ≥ T0 q1

dT dt = K(h−T)

T ≤ T1

T=T0 | · T=T1 | ·

Q = {q0, q1}, Xq0 = {T ∈ R | T ≥ T0}, Xq1 = {T ∈ R | T ≤ T1},

19 / 50

slide-38
SLIDE 38

Example of hybrid system: thermostat

q0

dT dt = −KT

T ≥ T0 q1

dT dt = K(h−T)

T ≤ T1

T=T0 | · T=T1 | ·

Q = {q0, q1}, Xq0 = {T ∈ R | T ≥ T0}, Xq1 = {T ∈ R | T ≤ T1}, GUARDq0,q1 = {m}

19 / 50

slide-39
SLIDE 39

Example of hybrid system: thermostat

q0

dT dt = −KT

T ≥ T0 q1

dT dt = K(h−T)

T ≤ T1

T=T0 | · T=T1 | ·

Q = {q0, q1}, Xq0 = {T ∈ R | T ≥ T0}, Xq1 = {T ∈ R | T ≤ T1}, GUARDq0,q1 = {m} GUARDq1,q0 = {M}

19 / 50

slide-40
SLIDE 40

Example of hybrid system: thermostat

q0

dT dt = −KT

T ≥ T0 q1

dT dt = K(h−T)

T ≤ T1

T=T0 | · T=T1 | ·

Q = {q0, q1}, Xq0 = {T ∈ R | T ≥ T0}, Xq1 = {T ∈ R | T ≤ T1}, GUARDq0,q1 = {m} GUARDq1,q0 = {M} JUMPq,q′(T) = T

19 / 50

slide-41
SLIDE 41

Example of hybrid system: thermostat

q0

dT dt = −KT

T ≥ T0 q1

dT dt = K(h−T)

T ≤ T1

T=T0 | · T=T1 | ·

Q = {q0, q1}, Xq0 = {T ∈ R | T ≥ T0}, Xq1 = {T ∈ R | T ≤ T1}, GUARDq0,q1 = {m} GUARDq1,q0 = {M} JUMPq,q′(T) = T U = ∅

19 / 50

slide-42
SLIDE 42

Example of hybrid system: thermostat

q0

dT dt = −KT

T ≥ T0 q1

dT dt = K(h−T)

T ≤ T1

T=T0 | · T=T1 | ·

Q = {q0, q1}, Xq0 = {T ∈ R | T ≥ T0}, Xq1 = {T ∈ R | T ≤ T1}, GUARDq0,q1 = {m} GUARDq1,q0 = {M} JUMPq,q′(T) = T U = ∅ FLOWq0 = ( dT

dt = −KT)

19 / 50

slide-43
SLIDE 43

Example of hybrid system: thermostat

q0

dT dt = −KT

T ≥ T0 q1

dT dt = K(h−T)

T ≤ T1

T=T0 | · T=T1 | ·

Q = {q0, q1}, Xq0 = {T ∈ R | T ≥ T0}, Xq1 = {T ∈ R | T ≤ T1}, GUARDq0,q1 = {m} GUARDq1,q0 = {M} JUMPq,q′(T) = T U = ∅ FLOWq0 = ( dT

dt = −KT)

FLOWq1 = ( dT

dt = K(h−T))

19 / 50

slide-44
SLIDE 44

Example of hybrid system: timed automata

q0 q1 q2 y ≤ 5 y ≤ 8 push? x := 0 y := 0 x ≥ 1 push? x := 0 cup! y = 5 coffee! y = 8

20 / 50

slide-45
SLIDE 45

Example of hybrid system: timed automata

q0 q1 q2 y ≤ 5 y ≤ 8 push? x := 0 y := 0 x ≥ 1 push? x := 0 cup! y = 5 coffee! y = 8 Q = {q0, q1, q2},

20 / 50

slide-46
SLIDE 46

Example of hybrid system: timed automata

q0 q1 q2 y ≤ 5 y ≤ 8 push? x := 0 y := 0 x ≥ 1 push? x := 0 cup! y = 5 coffee! y = 8 Q = {q0, q1, q2}, Xq0 = R2,

20 / 50

slide-47
SLIDE 47

Example of hybrid system: timed automata

q0 q1 q2 y ≤ 5 y ≤ 8 push? x := 0 y := 0 x ≥ 1 push? x := 0 cup! y = 5 coffee! y = 8 Q = {q0, q1, q2}, Xq0 = R2, Xq1 =

  • (x, y) ∈ R2

y ≤ 5

  • ,

20 / 50

slide-48
SLIDE 48

Example of hybrid system: timed automata

q0 q1 q2 y ≤ 5 y ≤ 8 push? x := 0 y := 0 x ≥ 1 push? x := 0 cup! y = 5 coffee! y = 8 Q = {q0, q1, q2}, Xq0 = R2, Xq1 =

  • (x, y) ∈ R2

y ≤ 5

  • ,

GUARDq0,q1 = R2

20 / 50

slide-49
SLIDE 49

Example of hybrid system: timed automata

q0 q1 q2 y ≤ 5 y ≤ 8 push? x := 0 y := 0 x ≥ 1 push? x := 0 cup! y = 5 coffee! y = 8 Q = {q0, q1, q2}, Xq0 = R2, Xq1 =

  • (x, y) ∈ R2

y ≤ 5

  • ,

GUARDq0,q1 = R2 GUARDq1,q2 = R × {5}

20 / 50

slide-50
SLIDE 50

Example of hybrid system: timed automata

q0 q1 q2 y ≤ 5 y ≤ 8 push? x := 0 y := 0 x ≥ 1 push? x := 0 cup! y = 5 coffee! y = 8 Q = {q0, q1, q2}, Xq0 = R2, Xq1 =

  • (x, y) ∈ R2

y ≤ 5

  • ,

GUARDq0,q1 = R2 GUARDq1,q2 = R × {5} JUMPq0,q1(x, y) = (0, 0)

20 / 50

slide-51
SLIDE 51

Example of hybrid system: timed automata

q0 q1 q2 y ≤ 5 y ≤ 8 push? x := 0 y := 0 x ≥ 1 push? x := 0 cup! y = 5 coffee! y = 8 Q = {q0, q1, q2}, Xq0 = R2, Xq1 =

  • (x, y) ∈ R2

y ≤ 5

  • ,

GUARDq0,q1 = R2 GUARDq1,q2 = R × {5} JUMPq0,q1(x, y) = (0, 0) JUMPq1,q1(x, y) = (0, y)

20 / 50

slide-52
SLIDE 52

Example of hybrid system: timed automata

q0 q1 q2 y ≤ 5 y ≤ 8 push? x := 0 y := 0 x ≥ 1 push? x := 0 cup! y = 5 coffee! y = 8 Q = {q0, q1, q2}, Xq0 = R2, Xq1 =

  • (x, y) ∈ R2

y ≤ 5

  • ,

GUARDq0,q1 = R2 GUARDq1,q2 = R × {5} JUMPq0,q1(x, y) = (0, 0) JUMPq1,q1(x, y) = (0, y) U = ∅

20 / 50

slide-53
SLIDE 53

Example of hybrid system: timed automata

q0 q1 q2 y ≤ 5 y ≤ 8 push? x := 0 y := 0 x ≥ 1 push? x := 0 cup! y = 5 coffee! y = 8 Q = {q0, q1, q2}, Xq0 = R2, Xq1 =

  • (x, y) ∈ R2

y ≤ 5

  • ,

GUARDq0,q1 = R2 GUARDq1,q2 = R × {5} JUMPq0,q1(x, y) = (0, 0) JUMPq1,q1(x, y) = (0, y) U = ∅ FLOWq = ( dx

dt = dy dt = 1)

20 / 50

slide-54
SLIDE 54

Example of hybrid system: navigation

Q = {(i, j) | i, j ∈ [0..4]} X:

X(i,j) = [0, 1] × [0, 1] × R × R (i, j ∈ [1..3]) X(0,j) = (−∞, 1] × [0, 1] × R × R (j ∈ [1..3]) X(4,j) = [0, ∞) × [0, 1] × R × R (j ∈ [1..3]) X(i,0) = [0, 1] × (−∞, 1] × R × R (i ∈ [1..3]) X(i,4) = [0, 1] × [0, ∞) × R × R (i ∈ [1..3]) X(0,0) = (−∞, 1] × (−∞, 1] × R × R . . .

21 / 50

slide-55
SLIDE 55

Example of hybrid system: navigation

GUARD:

GUARD(i,j),(i−1,j) = {(0, y, vx, vy)} GUARD(i,j),(i+1,j) = {(1, y, vx, vy)} GUARD(i,j),(i,j−1) = {(x, 0, vx, vy)} GUARD(i,j),(i,j+1) = {(x, 1, vx, vy)}

JUMP:

JUMP(i,j),(i−1,j)(x, y, vx, vy) = (x + 1, y, vx, vy) JUMP(i,j),(i+1,j)(x, y, vx, vy) = (x − 1, y, vx, vy) JUMP(i,j),(i,j−1)(x, y, vx, vy) = (x, y + 1, vx, vy) JUMP(i,j),(i,j+1)(x, y, vx, vy) = (x, y − 1, vx, vy)

22 / 50

slide-56
SLIDE 56

Example of hybrid system: navigation

U = ([−0.1, 0.1]R≥0)2 FLOWi,j:

dx dt = vx + ux(t), dy dt = vy + uy(t), dvx dt = 0.1(vy − v (i,j) y

) − 1.2(vx − v (i,j)

x

),

dvx dt = 0.1(vx − v (i,j) x

) − 1.2(vy − v (i,j)

y

),

where

(ux, uy) ∈ U, v (i,j)

x

and v (i,j)

y

are constants.

23 / 50

slide-57
SLIDE 57

Run of a hybrid automaton

Run

Finite or infinite sequence (q0, x0) →t0 (q1, x1) →t1 . . . such that, for each i ∈ [1..n − 1]: yi ∈ GUARD(qi, qi+1), JUMPqi,qi+1(yi) = xi+1, where yi = FLOWqi(xi, u, ti − ti−1). ((1, 2), x0) →t0 ((2, 2), x1) →t1 ((2, 1), x2) →t2 ((2, 0), x3) ((0, 1), x′

0) →t′

0 ((0, 0), x′

1) →t′

1 ((1, 0), x′

2) →t′

2 ((2, 0), x′

3)

24 / 50

slide-58
SLIDE 58

Runs as signals

It is often more practical to consider runs of a hybrid system as timed signals.

Signal

A signal on a set of variables {xi | i ∈ [1..n]}, where each xi takes values in Xi, is a function R≥0 → n

i=1 Xi.

Translation

In the case where all Xq’s are subspaces of a given X, the following signal corresponds to the run ρ = (q0, x0) →t0 (q1, x1) →t1 . . . of a hybrid automaton under input signal u: σρ : [0, n

i=1 ti)

→ Q × X k

i=1 ti

  • + t

→ (qk, FLOWqk(xk, u, t)), where t < tk+1.

25 / 50

slide-59
SLIDE 59

Signals in practice

Time-boundedness

Since simulation cannot be run for an infinite amount of time, so all considered signals are time-bounded: they are not functions R≥0 → U but [0, T) → U for some T ∈ R.

Finite representation of input signals

We must also stick to classes of signals that can be represented by finite means, e.g., piecewise constant signals, piecewise affine signals, spline (piecewise polynomial) signals. . . Control points (those points between which the function is interpolated) can be chosen equidistant, or according to other policies.

26 / 50

slide-60
SLIDE 60

Discretisation of signals

Discretisation of output signals

Output signals may not be finitely representable, so they are discretised.

Attention

Discretisation of signals can lead to: false positives: e.g., for formula F ϕ, if σ(ti) ϕ, but σ(t) ϕ for some ti < t < ti+1, the algorithm will return σ as a (wrong) counterexample, false negatives: for dual reasons.

27 / 50

slide-61
SLIDE 61

Initial position and signals

Two kinds of falsifications: falsification on initial position, falsification on signals. Differences: An initial position can be seen as a constant signal, so falsification on initial positions is easier. Many falsification methods incrementally modify the shape of the signal (learning approaches, Monte-Carlo Tree Search. . . ), so they are ill-suited to falsification on initial positions.

28 / 50

slide-62
SLIDE 62

Table of Contents

1

Formal methods landscape

2

Framework

3

Hybrid systems

4

Formulas

5

Optimisation

29 / 50

slide-63
SLIDE 63

Signal temporal logic

Syntax

ϕ ::= ⊤ | f ∼ 0 | ¬ϕ | ϕ ∧ ϕ | ϕ UI ϕ where I = [a, ∞) or [a, b] for a < b, f : S → R, and ∼∈ {>, =} is a comparison operator.

Syntactic sugar

⊥ = ¬⊤, ϕ ∨ ψ = ¬(¬ϕ ∧ ¬ψ). . . f ≥ 0 = f > 0 ∨ f = 0, f ≤ 0 = ¬f > 0. . . FI ϕ = ⊤ UI ϕ, GI ϕ = ¬ FI ¬ϕ U ϕ = U[0,∞) ϕ. . .

30 / 50

slide-64
SLIDE 64

STL examples

To avoid awkward notations, f ∼ 0 is never written as a function, but as a computation on states. Thus, if f : (q, x, y, vx, vy) → x2 + y2 − 1, f < 0 would be written x2 + y2 − 1 < 0 or x2 + y2 < 1.

Examples

q = (3, 1) U q = (1, 3) G (gear = 2 → ¬ F[0,ε] (gear = 2 ∧ F[0,τ] gear = 2)) (q = qi ∧ x ∈ [x−

i , x+ i ]) ∧ F[0,T] (q = qf ∧ x ∈ [x− f , x+ f ])

(q = qi ∧ x ∈ [x−

i , x+ i ]) ∧ G[0,T] ¬(q = qf ∧ x ∈ [x− f , x+ f ])

G (danger → F[0,t] ¬danger) with danger = (q = qd ∧ x ∈ [x−

d , x+ d ])

31 / 50

slide-65
SLIDE 65

Boolean semantics of STL

The semantics of STL formulas is defined over timed signals:

Boolean semantics

σ, t ⊤ ⇐ ⇒ ⊤ σ, t f ∼ 0 ⇐ ⇒ f (σ(t)) ∼ 0 σ, t ¬ϕ ⇐ ⇒ σ, t ϕ σ, t ϕ ∧ ψ ⇐ ⇒ σ, t ϕ and σ, t ψ σ, t ϕ U[a,b] ψ ⇐ ⇒ there is t′ ∈ [a, b] such that σ, t′ ψ and for all t′′ ∈ [a, t′), σ, t′′ ϕ σ ϕ stands for σ, 0 ϕ.

32 / 50

slide-66
SLIDE 66

Robustness semantics of STL

We can define a robustness semantics, whose value is not a boolean, but a real:

Robustness semantics

ρ(σ, ⊤, t) = ∞ ρ(σ, f > 0, t) = f (σ(t)) ρ(σ, f = 0, t) = −|f (σ(t))| ρ(σ, ¬ϕ, t) = −ρ(σ, ϕ, t) ρ(σ, ϕ ∧ ψ, t) = min(ρ(σ, ϕ, t), ρ(σ, ψ, t)) ρ(σ, ϕ U[a,b] ψ, t) = sup

t′∈[a,b]

min

  • ρ(σ, ψ, t′),

inf

t′′∈[a,t′) ρ(σ, ϕ, t′′)

  • ρ(σ, ϕ) stands for ρ(σ, ϕ, 0).

33 / 50

slide-67
SLIDE 67

Soundness of robustness semantics

Theorem

If ρ(σ, ϕ) > 0, then σ ϕ. If ρ(σ, ϕ) < 0, then σ ϕ.

Proof.

Structural induction.

Remark

If ρ(σ, ϕ) = 0, nothing can be said: if σ(x)(0) = x0 for ϕ = (x = x0): ρ(σ, ϕ) = ρ(σ, ¬ϕ) = 0, but σ ϕ, σ ¬ϕ. Advantage: if functions f are continuous or smooth, we can use

  • ptimisation techniques to find the minimal robustness.

34 / 50

slide-68
SLIDE 68

Computing the robustness semantics

Computing ρ

Given: piecewise-constant σ (because discretised). Goal: compute ρ(σ, ϕ). Naive idea: compute ρ(σ, ϕ, t) inductively.

Problem

Complexity to compute ρ(σ, ϕ U[a,b] ψ, −) is O(number of control points×number of control points in [a, b])

35 / 50

slide-69
SLIDE 69

Efficiently computing ρ(σ, ϕ, −)

First step: get rid of UI : ϕ U[a,b] ψ ≡ F[a,b] ϕ ∧ G[0,a] (ϕ U ψ) ϕ U[a,∞) ψ ≡ G[0,a] (ϕ U ψ)

Goal

The function t → ρ(σ, ϕ, t) is a signal R≥0 → R denoted ρ(σ, ϕ, −). Our goal is to compute it from ρ(σ, ψ, −) for subformulas ψ of ϕ. Need to know how to recursively compute signals for ⊤, f ∼ 0, ¬ϕ, ϕ ∨ ψ, ϕ U ψ, and F[a,b] ϕ in O(number of control points).

36 / 50

slide-70
SLIDE 70

Computing ρ(σ, ϕ U ψ, −)

Without loss of generality, signals y and y′ representing ρ(σ, ϕ, −) and ρ(σ, ψ, −) have the same control points ti (otherwise, take the union of control points). Let z be the signal corresponding to ρ(σ, ϕ U ψ, −), then: z(ti) = sup

t∈[ti,∞)

min{y′(t), inf

[ti,t) y}

= max{min{y′(ti), y(ti)}, sup

t∈[ti+1,∞)

min{y′(t), inf

[ti,t) y}}

= max{min{y′(ti), y(ti)}, min{y(ti), sup

t∈[ti+1,∞)

min{y′(t), inf

[ti+1,t) y}}}

= min{y(ti), max{y′(ti), z(ti+1)}} Thus, there is an algorithm to compute ρ(σ, ϕ U ψ, −) from ρ(σ, ϕ, −) and ρ(σ, ϕ, −) whose complexity is linear in the number

  • f control points.

37 / 50

slide-71
SLIDE 71

Computing ρ(σ, F[a,b] ϕ, −)

We need to compute z(t) = supt+[a,b] y = maxti∈t+[a,b]{y(ti)}.

Idea

Compute M such that i ∈ M iff ti ∈ t + [a, b] and for all tj ∈ t + [a, b], y(tj) < y(ti). Thus: y(tmin M) = maxti∈t+[a,b]{y(ti)}.

Alexandre Donz´ e, Thomas Ferr` ere, Oded Maler, Efficient Robust Monitoring for STL, International Conference on Computer Aided Verification 2013

38 / 50

slide-72
SLIDE 72

Analysis

M can be implemented to have all operations in O(1) (doubly-linked list), all control points are popped at most once, in total, the number of comparisons (done when searching for elements to pop) is at most 2n, therefore, computing ρ(σ, F[a,b] ϕ, −) can be done in time linear with respect to the number of control points.

Overall complexity

The number of control points is at most dh(ϕ)|σ|, so the whole complexity is O(|ϕ|dh(ϕ)|σ|).

Generalisation

The same argument (but more complex) applies to more general signals (say, piecewise affine).

39 / 50

slide-73
SLIDE 73

Table of Contents

1

Formal methods landscape

2

Framework

3

Hybrid systems

4

Formulas

5

Optimisation

40 / 50

slide-74
SLIDE 74

Optimisation techniques

Falsification is based on a number of optimisation techniques: ant colony, CMA-ES, cross-entropy, gradient descent, hill-climbing, Nelder-Mead, simulated annealing, . . .

41 / 50

slide-75
SLIDE 75

Gradient descent

Goal: find a local minimum to a function f .

1 i = 0; 2 while continue do 3

xi+1 = xi − γi · ∇(f )(xi);

4

best = xi+1;

5

if f (xi+1) > f (xi) then

6

continue = false;

7

best = xi; end

8

i + +; end

9 return best

Finds a local minimum: may be useful in certain cases.

42 / 50

slide-76
SLIDE 76

Hill climbing

Goal: find a local maximum to a function f .

1 i = 0; 2 while continue do 3

for x′ ∈ neighbours(xi) do

4

if f (x′) > f (xi) then

5

xi+1 = x′;

6

break; end end

7

continue = xi+1 = xi;

8

i + +; end

9 return xi−1

Finds a local maximum: may be useful in certain cases. Simpler than gradient descent (no derivatives to compute), but less efficient.

43 / 50

slide-77
SLIDE 77

CMA-ES

CMA-ES: Covariance Matrix Adaptation Evolution Strategy

Goal: find the maximum of a function f on a space X.

1 while continue do 2

x1, . . . , xn = sample-multivariate-normal(m,σ2C);

3

x1, . . . , xn = sort(x1, . . . , xn,f );

4

m, σ, C = update(x1, . . . , xn,m,σ,C); end

5 return m

Wikipedia

44 / 50

slide-78
SLIDE 78

CMA-ES for falsification

Characteristics

evolutionary algorithm (the parameters evolve towards a better sampler) sampling-based no need to compute derivatives

Adaptation

Take X to be the space of signals σ and f to be −ρ(σ, ϕ).

Remark

This is a way to adapt sampling-based optimisation to falsification, so it works for other such algorithms, such as the cross-entropy method.

45 / 50

slide-79
SLIDE 79

Nelder-Mead method

Goal: find the maximum of a function f on a space X of dimension n.

1 x1, . . . , xn+1 = simplex(); 2 while continue do 3

xi = worst-vertex(x1, . . . , xn+1,f );

4

x′

i = reflect(xi,(xj)j=i);

end

5 return best-vertex(f )

1: the structure is just a simplex. 3: when reflecting a vertex, if the new value is much better than the previous one, we keep stretching, otherwise, we shrink.

Adaptation to falsification

Take X a subspace of signals of finite dimension (e.g., fix a shape and control points), and f = −ρ(σ, ϕ).

46 / 50

slide-80
SLIDE 80

Ant colony

Goal: find a path in a graph that maximises performance.

1 while continue do 2

foreach “ant” i in colony do

3

pi = construct-solution(i);

4

local-update-pheromones(i,f ); end

5

global-update-pheromones();

6

p = argmax(pi,f ) end

7 return p

3: ants walk randomly on the graph, choosing neighbours with more pheromone more often. 4: ants put pheromone on their chosen edge, making it more attractive; the better the ant’s solution (i.e., the smaller f (pi)), the more pheromone she puts. 5: pheromone gets put on all edges taken by the best solution.

47 / 50

slide-81
SLIDE 81

Ant colony for falsification

Adaptation

Take G to be the graph: whose vertices are input signals σ, there is an edge between σ and τ when they are “close enough”, say, σ − τ∞ < C, i.e., for all t < tmax and component x of U, |σ(t)(x) − τ(t)(x)| < C, and f (σ1 . . . σn) to be −ρ(σn, ϕ). The ant colony algorithm tries to find a path that maximises f , i.e., minimises ρ(σ, ϕ).

Remark

This is a way to adapt optimisation of a function on a graph to falsification, so it works for other optimisation algorithms that work on graphs, such as simulated annealing.

48 / 50

slide-82
SLIDE 82

Simulated annealing

Goal: find a global maximum of a function f on a space X. T = T0; i = 0; while T(i) > 0 do xi+1 = neighbour(xi); if E(xi+1) < E(xi) and rand() < P(E(xi+1), E(xi), T)) then xi+1 = xi; end i + +; end return xi−1 Avoids local minima by “cooling” the system down progressively. Many parameters adaptative, but tricky.

49 / 50

slide-83
SLIDE 83

Conclusion

Falsification:

method to find counterexamples to a property, useful in the world of formal methods, black-box method, relies on optimisation algorithms.

Hybrid system:

continuous and discrete parameters, non-linear behaviour, very expressive.

Formulas:

expressed in a temporal logic, boolean and robustness semantics.

50 / 50