61
Modelling and Analysis (and towards Synthesis) Marta Kwiatkowska Department of Computer Science, University of Oxford Dagstuhl meeting 15041, 19-23 rd Jan 2015

Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

Modelling and Analysis(and towards Synthesis)

Marta Kwiatkowska

Department of Computer Science, University of Oxford

Dagstuhl meeting 15041, 19-23rd Jan 2015

Page 2: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

2

Outline

• Introduction

− The context: role of models in software engineering

− Probabilistic models and quantitative verification

− The PRISM model checker

• A taste of quantitative modelling, verification and synthesis

− Markov decision process model

− Goals and objectives in temporal logic

− How to do verification and strategy synthesis

• Quantitative runtime verification

− Verification meets autonomic computing

• Challenges and future directions

Page 3: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

33

Software everywhere

• Users expect: predictability & high integrity in presence of

− component failure

− environmental uncertainty

− conflicting requirements

• Probability useful to quantify

− unreliability

− uncertainty

• Quantitative properties

− reliability, performance, quality of service, …

− “the probability of an airbag failing to deploy within 0.02s”

• How to ensure safety, dependability, performance?

− complex scenarios, recovery from faults, limited resources, …

Page 4: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

4

What is self-aware computing?

• Best effort description: self-adaptive

− continuously interacts with its environment

• including other components or human users

− can monitor state of (internal and environmental) parameters

− has goals/objectives

• expressed formally in e.g. temporal logic

• often quantitative

• may conflict

− takes decisions based on current state and external events

− able to adapt/reconfigure so as to maintain the satisfaction of the objectives

• NB reactive, parametric systems (no reflection)

− but multi-agent systems in AI have a notion of self

Page 5: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

5

Rigorous software engineering

• Verification and validation (V&V)

− Derive model, or extract from software artefacts

− Verify correctness, validate if fit for purpose

ModelFormalspecification

SystemValidation

Verification

Ab

str

act R

efin

e

Form

alise

Simulation

Informalrequirements

Page 6: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

6

Model-centric approach

• Employ (quantitative) formal models

− rigorous, unambiguous

− can be derived or extracted from code

− can also be used at runtime

• Specify goals/objectives/properties in temporal logic:

− energy efficiency, performance, resource usage, …

− (energy) “maximum expected energy consumption in 1 hr is at most 10mA”

− (performance) “the packet will be delivered with high probability in 10ms”

• Focus on automated, tool-supported methodologies

− design-time verification via model checking

− runtime verification

− synthesis from specifications

Page 7: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

7

Model checking

Finite-statemodel

Temporal logicspecification

ResultSystem

Counter-example

Systemrequire-ments

¬EF fail

Model checkere.g. SMV, Spin

Page 8: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

8

Design-time quantitative verification

Probabilistic modele.g. Markov chain

Probabilistictemporal logicspecificatione.g. PCTL, LTL

Result

Quantitativeresults

System

Counter-example

Systemrequire-ments

P<0.1 [ F fail ]

0.5

0.1

0.4

Probabilisticmodel checker

e.g. PRISM

Page 9: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

9

Historical perspective

• First algorithms proposed in 1980s

− [Vardi, Courcoubetis, Yannakakis, …]

− algorithms [Hansson, Jonsson, de Alfaro] & first implementations

• 2000: tools ETMCC (MRMC) & PRISM released

− PRISM: efficient extensions of symbolic model checking [Kwiatkowska, Norman, Parker, …]

− ETMCC (now MRMC): model checking for continuous-time Markov chains [Baier, Hermanns, Haverkort, Katoen, …]

• Now mature area, of industrial relevance

− successfully used by non-experts for many application domains, but full automation and good tool support essential

• distributed algorithms, communication protocols, security protocols, biological systems, quantum cryptography, planning…

− genuine flaws found and corrected in real-world systems

Page 10: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

10

Tool support: PRISM

• PRISM: Probabilistic symbolic model checker

− developed at Birmingham/Oxford University, since 1999

− free, open source software (GPL), runs on all major OSs

• Support for:

− models: DTMCs, CTMCs, MDPs, PTAs, SMGs, …

− properties: PCTL/PCTL*, CSL, LTL, rPATL, costs/rewards, …

• Features:

− simple but flexible high-level modelling language

− user interface: editors, simulator, experiments, graph plotting

− multiple efficient model checking engines (e.g. symbolic)

• Many import/export options, tool connections

− MRMC, INFAMY, DSD, Petri nets, Matlab, …

• See: http://www.prismmodelchecker.org/

Page 11: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

11

Probabilistic models: discrete time

• Discrete-time Markov chains (DTMCs)

− discrete states + discrete probability

− for: randomisation, unreliable communication media, …

• Markov decision processes (MDPs)

− discrete states + discrete probability + nondeterminism (e.g. for concurrency, control)

− for: randomised distributed algorithms, security protocols, …

• Stochastic multi-player games (SMGs)

− discrete states + discrete probability + player nondeterminism(e.g. for collaboration and competition)

− for: team working, coalitions, user-centric networks, smartgrid protocols, …

NB all supported by PRISM

Page 12: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

12

Probabilistic models: continuous time

• Continuous-time Markov chains (CTMCs)

− discrete states + exponentially distributed delays

− for: component failures, job arrivals, molecular reactions, …

• Interactive Markov chains (CTMCs)

− discrete states + exponentially distributed delays+ nondeterminism

− for: job arrivals in a distributed environment

• Probabilistic timed automata (PTAs)

− discrete probability, nondeterminism + real-time

− for wireless comm. protocols, embedded control systems, …

NB Shown in grey not supported by PRISM

Page 13: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

13

Probabilistic models: continuous space

• Labelled Markov processes (LMPs)

− continuous states + stochastically distributed jumps

− for: aircraft controllers, search and rescue,…

• Probabilistic hybrid automata (PHAs)

− discrete probability, nondeterminism + continuous flows (ODEs)

− for embedded control systems, automotive controllers, …

− Supported by tool chain PHAVER+PRISM

• Stochastic hybrid systems (PHAs)

− continuous probability, nondeterminism + continuous flows

− for embedded control systems, automotive controllers, …

Page 14: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

14

Probability elsewhere

• In performance modelling

− pioneered by Erlang, in telecommunications, ca 1910

− models: typically continuous time Markov chains

− emphasis on steady-state and transient probabilities

• In stochastic planning and decision support

− cf Bellman equations, ca 1950s

− models: Markov decision processes

− emphasis on finding optimum policies

• In control engineering

− models: stochastic hybrid systems

− emphasis on finding optimal controllers

• Our focus distinctive, on automated verification

− temporal logic specifications

− automata-theoretic techniques

Page 15: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

15

Model derivation techniques

• Models are typically state-transition systems (automata)

• Manual construction

− derive a model from description

• e.g. IEEE standards document

− express in high-level language, then build

• Automated extraction

− extract a model from software

• using e.g. abstract interpretation, slicing, static analysis…

− build a control flow graph

− implemented in CProver + PRISM

• Challenges

− state space explosion, infinite state systems

− need to consider augmenting with additional information

• action labels, state labels, time, probability, rate, etc

Model

Page 16: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

16

Probabilistic programs

Probabilistic programbool fail = false;

int c = 0;

int main ()

{

// nondeterministic

c = user-input (3);

while (! fail && c > 0)

{

// probabilistic

fail = Bernoulli (0.1);

c --;

}

}

Page 17: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

17

Probabilistic program as MDP

Probabilistic program MDP semantics

minimum/maximum probability of the program terminating with failbeing true is 0 and 0.19, respectively

Page 18: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

18

PRISM – Property specification

• Temporal logic-based property specification language

− subsumes PCTL, CSL, probabilistic LTL, PCTL*, …

• Simple examples:

− P≤0.01 [ F “crash” ] – “the probability of a crash is at most 0.01”

− Pmax>0.999 [ F<10.5 “send” ] – “the maximum probability of eventually sending in 10.5 time units is>0.999” (QoS)

• Usually focus on quantitative (numerical) properties:

− P=? [ F “crash” ]“what is the probabilityof a crash occurring?”

− then analyse trends inquantitative propertiesas system parameters vary

Page 19: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

19

PRISM – Underlying techniques

• Construction and analysis of finite probabilistic models

− specified in high-level modelling formalisms

• Basic ingredients

− graph-based algorithms, e.g. reachability, qualitative verif.

− numerical solution techniques, e.g. probability computation

− usually rely on iterative methods: uniformisation-based for transient properties, Gauss-Seidel/etc. for linear equations

− Monte Carlo simulation

− simulation-based approximate model checking

• Symbolic implementation

− data structures based on binary decision diagrams

− fast construction + compact storage of huge models possible

− exploit structure, regularity in high-level model

− usually: up to 107-108 states; sometimes: up to 1010 states

Page 20: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

20

Approximate (statistical) model checking

• Approximate (statistical) probabilistic model checking

− discrete event (Monte Carlo) simulation + sampling

• Two distinct approaches (both implemented in PRISM)

• Estimation [Hérault et al.]

− approximate result for quantitative query such as P=? [ φ ]

− plus a probabilistic guarantee regarding result precision

− Prob( |pactual-pestimated| ≤ ǫ ) ≥ 1-δ

− can also generate corresponding confidence intervals

• Hypothesis testing/acceptance sampling [Younes/Simmons]

− applied to boolean-valued queries such as P∼p [ φ ]

− basic idea: stop sampling as soon as the result can be shown to be either true or false with high probability

− sensitive to distance between bound p and actual answer

− also extended to Bayesian approaches [Jha et al.]

Page 21: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

21

Approximate (statistical) model checking

• Advantages

− much more scalable that conventional (numerical computation based) probabilistic model checking

− (almost no scalability issues – no need to build model)

− wider range of model types (anything that can be effectively simulated) and property types

• Disadvantages

− nondeterminism difficult to handle

− loss of precision: only approximate answers

− lose ability to definitively establish causal relationships and identify best/worst-case scenarios

− speed: possibly very high number of samples required to generate suitable accurate approximations

− may be hard to estimate likelihood of rare events

Page 22: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

22

Quantitative verification in action

• DNA transducer gate [Lakin et al, 2012]

− DNA computing with a restricted class of DNA strand displacement structures

− transducer design due to Cardelli

− automatically found and fixed design error, using Microsoft’s DSD and PRISM

• Microgrid demand management protocol [TACAS12,FMSD13]

− designed for households to actively manage demand while accessing a variety of energy sources

− found and fixed a flaw in the protocol, due tolack of punishment for selfish behaviour

− implemented in PRISM-games

Page 23: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

23

Quantitative verification – Status

• Tools/techniques widely applicable, since real software/systems are quantitative

− extensions/adaptations of model-based frameworks

− new application domains

• Analysis “quantitative” & “exhaustive”

− strength of mathematical proof

− best/worst-case scenarios, notpossible with simulation

− identifying trends and anomalies

• But

− the modelling phase time-consuming and error prone

− potential ‘disconnect’ between model and the artefact

− scalability continues to be hard to overcome

Page 24: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

24

From verification to synthesis

• Shift towards quantitative model synthesis from speciication

− begin with simpler problems: strategy synthesis, template-based synthesis, etc

− advantage: correct-by-construction

• Here consider the problem of strategy (controller) synthesis

− i.e. “can we construct a strategy to guarantee that a given quantitative property is satisfied?”

− instead of “does the model satisfy a given quantitative property?”

− also parameter synthesis: “find optimal value for parameter to satisfy quantitative objective”

• Many application domains

− robotics (controller synthesis from LTL/PCTL)

− dynamic power management (optimal policy synthesis)

Page 25: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

25

Markov decision processes (MDPs)

• Model nondeterministic as well as probabilistic behaviour− e.g. for concurrency, under-specification, abstraction…

− extension of discrete-time Markov chains

− nondeterministic choice between probability distributions

• Formally, an MDP is a tuple− (S, sinit, Act, δ, L)

• where:− S is a set of states

− sinit ∈ S is the initial state

− δ : S x Act → Dist(S) is a (partial) transition probability function

− L : S → 2AP is a labelling function

− Act is a set of actions, AP is a set of atomic propositions

− Dist(S) is the set of discrete probability distributions over S

s1s0

s2

s3

0.5

0.50.7

1

1

{heads}

{tails}

{init}

0.3

1a

b

c

a

a

Page 26: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

26

Paths and strategies

• A (finite or infinite) path through an MDP

− is a sequence (s0...sn) of (connected) states

− represents an execution of the system

− resolves both the probabilistic andnondeterministic choices

• A strategy σ (aka. “adversary” or “policy”) of an MDP

− is a resolution of nondeterminism only

− is (formally) a mapping from finite paths to distributions

− induces a fully probabilistic model

− i.e. an (infinite-state) Markov chain over finite paths

− on which we can define a probability space over infinite paths

s1s0

s2

s3

0.5

0.50.7

1

1

{heads}

{tails}

{init}

0.3

1a

b

c

a

a

Page 27: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

27

Classification of strategies

• Strategies are classified according to

• randomisation:

− σ is deterministic (pure) if σ(s0...sn) is a point distribution, and randomised otherwise

• memory:

− σ is memoryless (simple) if σ(s0...sn) = σ(sn) for all s0...sn

− σ is finite memory if there are finitely many modes such as σ(s0...sn) depends only on sn and the current mode, which is updated each time an action is performed

− otherwise, σ is infinite memory

• A strategy σ induces, for each state s in the MDP:

− a set of infinite paths Pathσ (s)

− a probability space Prσs over Pathσ (s)

Page 28: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

28

Example strategy

• Fragment of induced Markov chain for strategy which picks b then c in s1

finite-memory, deterministic

s0

0.5

1

s0s1s0s1s2

s0s1s0s1s30.5s0s1

0.7s0s1s0

s0s1s1

0.3

1s0s1s0s1

0.5 s0s1s1s2

s0s1s1s30.5

1

1

s0s1s1s2s2

s0s1s1s3s3

s1s0

s2

s3

0.5

0.50.7

1

1

{heads}

{tails}

{init}

0.3

1a

b

c

a

a

Page 29: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

29

Running example

• Example MDP

− robot moving through terrain divided into 3 x 2 grid

s0

s4s3

0.5

east s1

south

0.8

0.1

{goal1}

s2

s5

{hazard}

0.1

{goal2}

{goal2}

south

0.5

0.6

0.4

stuck

east

stuck

0.4

0.6west

west

east0.1

0.9

north

States:

s0, s1, s2, s3, s4, s5

Actions:

north, east, south,west, stuck

Labels

(atomic propositions):

hazard, goal1, goal2

Page 30: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

30

Properties and objectives

• The syntax:

− φ ::= P~p [ ψ ] | R~r [ ρ ]

− ψ ::= true | a | ψ ∧ ψ | ¬ ψ | X ψ | ψ U≤k ψ | ψ U ψ

− ρ ::= F b | C | C≤k

− where b is an atomic proposition, used to identify states of interest, p ∈ [0,1] is a probability, ~ ∈ {<,>,≤,≥}, k ∈ ℕ, and r ∈ ℝ≥0

− F b ≡ true U b

• We refer to φ as property, ψ and ρ as objectives

− (branching time more challenging for synthesis)

“until”

ψ is true with probability ~p

“bounded until”

“next”

expected reward is ~r

“reachability” “cumulative”

Page 31: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

31

Properties and objectives

• Semantics of the probabilistic operator P

− can only define probabilities for a specific strategy σ

− s ⊨ P~p [ ψ ] means “the probability, from state s, that ψ is true for an outgoing path satisfies ~p for all strategies σ”

− formally s ⊨ P~p [ ψ ] ⇔ Prsσ(ψ) ~ p for all strategies σ

− where we use Prsσ(ψ) to denote Prs

σ { ω ∈ Pathsσ | ω ⊨ ψ }

• R~r [ · ] means “the expected value of · satisfies ~r”

• Some examples:

− P≥0.4 [ F “goal” ] “probability of reaching goal is at least 0.4”

− R<5 [ C≤60 ] “expected power consumption over one hour is below 5”

− R≤10 [ F “end” ] “expected time to termination is at most 10”

Page 32: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

32

Verification and strategy synthesis

• The verification problem is:

− Given an MDP M and a property φ, does M satisfy φ for all possible strategies σ?

• The synthesis problem is dual:

− Given an MDP M and a property φ, find, if it exists, a strategy σ such that M satisfies φ under σ

• Verification and strategy synthesis is achieved using the same techniques, namely computing optimal values for probability objectives, i.e. for φ = P~p [ ψ ]:

− Prsmin(ψ) = infσ Prs

σ (ψ)

− Prsmax(ψ) = supσ Prs

σ (ψ)

• Expectations (reward objectives R~r[ψ]) are similar, omitted

0 1Prsmin(ψ) Prs

max(ψ)

Page 33: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

33

Verification and strategy synthesis

• The verification problem is:

− Given an MDP M and a property φ, does M satisfy φ for all possible strategies σ?

• The synthesis problem is dual:

− Given an MDP M and a property φ, find, if it exists, a strategy σ such that M satisfies φ under σ

• In particular, we have

− M satisfies φ = P≥q[ ψ ] iff Prsmin(ψ) ≥ q

− There exists a strategy satisfying φ = P≥q[ ψ ] iff Prsmax(ψ) ≥ q

− then take optimal strategy

q0 1Prs

min(ψ) Prsmax(ψ)

Page 34: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

34

Computing reachability for MDPs

• Computation of probabilities Prsmax(F b) for all s ∈ S

• Step 1: pre-compute all states where probability is 1 or 0

− graph-based algorithms, yielding sets Syes, Sno

• Step 2: compute probabilities for remaining states (S?)

− (i) solve linear programming problem

− (i) approximate with value iteration

− (iii) solve with policy (strategy) iteration

• 1. Precomputation (for Prsmax):

− algorithm Prob1E computes Syes

• there exists a strategy for which the probability of "F b" is 1

− algorithm Prob0A computes Sno

• for all strategies, the probability of satisfying "F b" is 0

Page 35: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

35

s0

s4s3

0.5

east s1

south

0.8

0.1

{goal1}

s2

s5

{hazard}

0.1

{goal2}

{goal2}

south

0.5

0.6

0.4

stuck

east

stuck

0.4

0.6 west

west

east0.1

0.9

north

Example goal:

P≥0.4 [ F goal1 ]

So compute:

Prsmax(F goal1)

Example - Reachability

Page 36: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

36

Syes

Sno

s0

s4s3

0.5

east s1

south

0.8

0.1

{goal1}

s2

s5

{hazard}

0.1

{goal2}

{goal2}

south

0.5

0.6

0.4

stuck

east

stuck

0.4

0.6west

west

east0.1

0.9

north

Example goal:

P≥0.4 [ F goal1 ]

So compute:

Prsmax(F goal1)

Example - Precomputation

Page 37: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

37

Reachability for MDPs

• 2. Numerical computation

− compute probabilities Prsmax(F b)

− for remaining states in S? = S \ (Syes ∪ Sno)

− obtained as the unique solution of the linear programming (LP) problem:

• This can be solved with standard techniques

− e.g. Simplex, ellipsoid method, branch-and-cut

minimize xs subject to the constraints:

s∈ S?∑

xs

≥ δ(s,a)(s’) ⋅ xs’

+

s’∈S?

∑ δ(s,a)(s’)

s’∈Syes

for all s ∈ S? and for all a ∈ A(s)

Page 38: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

38

Example – Reachability (LP)

s0

s4s3

0.5

east s1

south

0.8

0.1

{goal1}

s2

s5

{hazard}

0.1

{goal2}

{goal2}

south

0.5

0.6

0.4

stuck

east

stuck

0.4

0.6 west

west

east0.1

0.9

north

Let xi = Prsimax(F goal1)

Syes: x4=x5=1

Sno: x2=x3=0

For S? = {x0, x1} :

Minimise x0+x1 subject to:

● x0 ≥ 0.4·x0 + 0.6·x1 (east)

● x0 ≥ 0.1·x1 + 0.1 (south)

● x1 ≥ 0.5 (south)

● x1 ≥ 0 (east)

Example:

P≥0.4 [ F goal1 ]

So compute:

Prsmax(F goal1)

Page 39: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

39

Example - Reachability (LP)

x0

x1

00

1

1

x0 ≥ x1

x1 ≥ 0.5

x0

x1

00

1

1x0

x1

00

1

1

x0 ≥ 0.1·x1

+ 0.1

s0

s4s3

0.5

east s1

south

0.8

0.1

{goal1}

s2

s5

{hazard}

0.1

{goal2}

{goal2}

south

0.5

0.6

0.4

stuck

east

stuck

0.4

0.6west

west

east0.1

0.9

north

Let xi = Prsimax(F goal1)

Syes: x4=x5=1

Sno: x2=x3=0

For S? = {x0, x1} :

Minimise x0+x1 subject to:

● x0 ≥ x1 (east)

● x0 ≥ 0.1·x1 + 0.1 (south)

● x1 ≥ 0.5 (south)

Page 40: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

40

Example - Reachability (LP)

x0

x1

00

1

1

min

Solution:

(x0, x1) = (0.5, 0.5)

i.e.

Prs0max(F goal1) = 0.5

s0

s4s3

0.5

east s1

south

0.8

0.1

{goal1}

s2

s5

{hazard}

0.1

{goal2}

{goal2}

south

0.5

0.6

0.4

stuck

east

stuck

0.4

0.6west

west

east0.1

0.9

north

Let xi = Prsimax(F goal1)

Syes: x4=x5=1

Sno: x2=x3=0

For S? = {x0, x1} :

Minimise x0+x1 subject to:

● x0 ≥ x1

● x0 ≥ 0.1·x1 + 0.1

● x1 ≥ 0.5

Page 41: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

41

Strategy synthesis

• Compute optimal probabilities Prsmax(F b) for all s ∈ S

• To compute the optimal strategy σ*, choose the locally optimal action in each state

− in general depends on the method used to compute the optimal probabilities

− i.e. policy iteration constructs the optimal strategy

− for max probabilities, adaptation of precomputation needed

• For reachability

− memoryless strategies suffice

• For step-bounded reachability

− need finite-memory strategies

− typically requires backward computation for a fixed number of steps

Page 42: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

42

Example - Strategy

s0

s4s3

0.5

east s1

south

0.8

0.1

{goal1}

s2

s5

{hazard}

0.1

{goal2}

{goal2}

south

0.5

0.6

0.4

stuck

east

stuck

0.4

0.6 west

west

east0.1

0.9

north

x0

x1

00

1

12/3

min

x0 ≥ x1

(east)

x1 ≥ 0.5

(south)

Optimal strategy:

s0 : east

s1 : south

s2 : -

s3 : -

s4 : east

s5 : -

Page 43: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

43

s0

s4s3

0.5

east s1

south

0.8

0.1

{goal1}

s2

s5

{hazard}

0.1

{goal2}

{goal2}

south

0.5

0.6

0.4

stuck

east

stuck

0.4

0.6 west

west

east0.1

0.9

north

Example:

Pmax=? [ F≤3 goal2 ]

So compute:

Prsmax(F≤3 goal2) = 0.99

Optimal strategy

is finite-memory:

s4 (after 1 step): east

s4 (after 2 steps): west

Example – Bounded reachability

Computation more involved

May need to choose a different action on successive visits

Page 44: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

44

Strategy synthesis for LTL objectives

• Reduce to the problem of reachability on the product of MDP M and an omega-automaton representing ψ

− for example, deterministic Rabin automaton (DRA)

• Need only consider computation of maximum probabilities Prs

max(ψ)

− since Prsmin(ψ) = 1 - Prs

max(¬ψ)

• To compute the optimal strategy σ*

− find memoryless deterministic strategy on the product

− convert to finite-memory strategy with one mode for each state of the DRA for ψ

Page 45: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

45

Example - LTL

• P≥0.05 [ (G ¬hazard) ∧ (GF goal1) ]

− avoid hazard and visit goal1 infinitely often

• Prs0max((G ¬hazard) ∧ (GF goal1)) = 0.1

s0

s4s3

0.5

east s1

south

0.8

0.1

{goal1}

s2

s5

{hazard}

0.1

{goal2}

{goal2}

south

0.5

0.6

0.4

stuck

east

stuck

0.4

0.6 west

west

east0.1

0.9

north

Optimal strategy:

(in this instance,

memoryless)

s0 : south

s1 : -

s2 : -

s3 : -

s4 : east

s5 : west

Page 46: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

46

Multi-objective strategy synthesis

• Consider conjunctions of probabilistic LTL formulas P~p [ψ]

− require all conjuncts to be satisfied

• Reduce to a multi-objective reachability problem on the product of MDP M and the omega-automata representing the conjuncts

− convert (by negation) to formulas with lower probability bounds (≥, >), then to DRA

− need to consider all combinations of objectives

• The problem can be solved using LP methods [TACAS07] or via approximations to Pareto curve [ATVA12]

− strategies may be finite memory and randomised

− continue as for single-objectives to compute the strategy σ*

− find memoryless deterministic strategy on the product

− convert to finite-memory strategy

Page 47: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

47

Example – Multi-objective

s0

s4s3

0.5

east s1

south

0.8

0.1

{goal1}

s2

s5

{hazard}

0.1

{goal2}

{goal2}

south

0.5

0.6

0.4

stuck

east

stuck

0.4

0.6 west

west

east0.1

0.9

north

• Multi-objective formula

− P≥0.7 [ G ¬hazard ] ∧ P≥0.2 [ GF goal1 ] ? True (achievable)

• Numerical query

− Pmax=? [ GF goal1 ] such that P≥0.7 [ G ¬hazard ] ? ~0.2278

• Pareto query

− for Pmax=? [ G ¬hazard ] ∧ Pmax=? [ GF goal1 ] ?

0.80.60.4 10.20 0

0.2

0.4

0.5

0.3

0.1

ψ1

ψ2

ψ1 = G ¬hazardψ2 = GF goal1

Page 48: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

48

Example – Multi-objective strategies

s0

s4s3

0.5

east s1

south

0.8

0.1

{goal1}

s2

s5

{hazard}

0.1

{goal2}

{goal2}

south

0.5

0.6

0.4

stuck

east

stuck

0.4

0.6west

west

east0.1

0.9

north

Strategy 1

(deterministic)

s0 : east

s1 : south

s2 : -

s3 : -

s4 : east

s5 : west

0.80.60.4 10.20 0

0.2

0.4

0.5

0.3

0.1

ψ1

ψ2

ψ1 = G ¬hazardψ2 = GF goal1

Page 49: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

49

Example – Multi-objective strategies

Strategy 2

(deterministic)

s0 : south

s1 : south

s2 : -

s3 : -

s4 : east

s5 : west

0.80.60.4 10.20 0

0.2

0.4

0.5

0.3

0.1

ψ1

ψ2

ψ1 = G ¬hazardψ2 = GF goal1

s0

s4s3

0.5

east s1

south

0.8

0.1

{goal1}

s2

s5

{hazard}

0.1

{goal2}

{goal2}

south

0.5

0.6

0.4

stuck

east

stuck

0.4

0.6 west

west

east0.1

0.9

north

Page 50: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

50

Example – Multi-objective strategies

Optimal strategy:

(randomised)

s0 : 0.3226 : east

0.6774 : south

s1 : 1.0 : south

s2 : -

s3 : -

s4 : 1.0 : east

s5 : 1.0 : west

0.80.60.4 10.20 0

0.2

0.4

0.5

0.3

0.1

ψ1

ψ2

ψ1 = G ¬hazardψ2 = GF goal1

s0

s4s3

0.5

east s1

south

0.8

0.1

{goal1}

s2

s5

{hazard}

0.1

{goal2}

{goal2}

south

0.5

0.6

0.4

stuck

east

stuck

0.4

0.6west

west

east0.1

0.9

north

Page 51: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

51

Case study: Dynamic power management

• Synthesis of dynamic power management schemes

− for an IBM TravelStar VP disk drive

− 5 different power modes: active, idle, idlelp, stby, sleep

− power manager controller bases decisions on current power mode, disk request queue, etc.

• Build controllers that

− minimise energyconsumption, subject toconstraints on e.g.

− probability that a requestwaits more than K steps

− expected number oflost disk requests

• See: http://www.prismmodelchecker.org/files/tacas11/

Page 52: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

52

Is design-time verification sufficient?

Over the last five years, […] 710 patient deaths linked to problems with the devices.

Some of those deaths involved patients who suffered drug overdoses accidentally, either because of incorrect dosageentered or because the device’s software malfunctioned.

Manufacturers […] issued 79 recalls, among the highest for any medical device.

52

Published: April 23, 2010

Pump producers now typically conduct ‘simulated’ testing of its devices by users.

F.D.A. Steps Up Oversight of Infusion Pumps

Page 53: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

5353

Quantitative runtime verification

• Autonomic systems (legacy systems, etc)

− require increasingly demanding non-functional requirements

• performance, dependability, utility, …

− need to adapt to changing scenarios

• workload, environment, objectives, …

• Key observations: offline qualitative verification methods do not suffice

• Instead integrate [ICSE09] [FASE09]:

− multi-objective quantitative runtime analysis

• rigorous exhaustive checks

− self-adaptive system capabilities

• adaptation decisions based on (non-linear) behaviour

Page 54: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

5454

Background: autonomic systems

System objectives

(policies)

monitor-analyse-plan-execute autonomic control loop

Page 55: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

5555

Integration

System objectives

(policies)

PRISM-drivenmonitor-analyse-plan-execute autonomic control loop

Page 56: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

5656

Integration

• Monitor

• Select subsetof models andconfigurations

• Carry outPRISM experi-ment

• Choose best con-figurationEnforce chosen configuration

System objectives

(policies)

Page 57: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

5757

How it works

• Development method: Qosmos, telemedicine appl [TSE 2011}

− assume exposed control parameters

− model-driven generation of adaptor code

− system objectives specified by administrator/designer

• e.g. minimise power consumption and maximise duration

− at runtime, monitor via quantitative verification and influence the system by modifying control parameters

− predict, select optimal configuration

− incorporate learning (KAMI) to improve predictive power

• Incremental techniques for better efficiency

− incremental model construction and model checking

− uses constraint solving and MILP

− implemented in PRISM (MDPs, SMGs)

Page 58: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

58

Quantitative verification - Trends

• Being ‘younger’, generally lags behind conventional verification

− much smaller model capacity

− compositional reasoning in infancy

− automation of model extraction/adaptation very limited

− runtime monitoring frameworks still limited

• Tool usage on the increase, in academic/industrial contexts

− real-time verification/synthesis in embedded systems

− probabilistic verification in security, reliability, performance

• Shift towards greater automation

− specification mining, model extraction, synthesis, verification, …

• But many challenges remain!

Page 59: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

59

Future directions

• Many challenges remain

− computational runtime steering, away from danger states, in addition to online model repair

− effective model abstraction/reduction techniques

− scalability of monolithic/runtime verification

− approximate methods

− sampling-based methods, combination with automata-based

• More challenges not covered in this lecture

− correct-by-construction model synthesis from specifications

− parameter synthesis

− more expressive models and logics

− code generation from models

− new application domains, …

• and more…

Page 60: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

60

Further material

• Projects

− PRISM www.prismmodelchecker.org

− ERC AdG VERIWARE www.veriware.org

− EPSRC programme grant Mobile Robotics (with Paul Newman)

• Reading

− [MDPs/LTL] Forejt, Kwiatkowska, Norman and Parker. Automated Verification Techniques for Probabilistic Systems. LNCS vol 6659, p53-113, Springer 2011.

− [DTMCs/CTMCs] Kwiatkowska, Norman and Parker. Stochastic Model Checking. LNCS vol 4486, p220-270, Springer 2007.

− [DTMCs/MDPs/LTL] Principles of Model Checking by Baier and Katoen, MIT Press 2008

− [Runtime] Calinescu, Grunske, Kwiatkowska, Mirandola and Tamburrelli. Dynamic QoS Management and Optimisation in Service-Based Systems.I EEE TSE 37(3), 387-409, 2011.

Page 61: Modelling and Analysis (and towards Synthesis)materials.dagstuhl.de/files/15/15041/15041.SWM1.Slides1.pdf · − Probabilistic models and quantitative verification − The PRISM model

61

Further material

• Recent work on controller synthesis

− Kwiatkowska and Parker. Automated Verification and Strategy Synthesis for Probabilistic Systems. In ATVA'13, LNCS, 2013.

− Draeger, Forejt, Kwiatkowska, Parker and Ujma. Permissive Controller Synthesis for Probabilistic Systems. In TACAS'14, LNCS, 2014.

− Brázdil, Chatterjee, Chmelík, Forejt, Křetínský, Kwiatkowska, Parker and Ujma. Verification of Markov Decision Processes using Learning Algorithms. In ATVA'14, LNCS, 2014.

− Chen, Kwiatkowska, Simaitis and Wiltsche. Synthesis for Multi-Objective Stochastic Games: An Application to Autonomous Urban Driving. In QEST 2013, IEEE CS, 2013.

− Basset, Kwiatkowska, Topcu and Wiltsche. Strategy Synthesis for Stochastic Games with Multiple Long-Run Objectives. In TACAS’15, LNCS, 2015.