Probability space - Example β’ Paths where sending fails the first time 1 β Ο = s 0 s 1 s 2 {fail} β C( Ο ) = all paths starting s 0 s 1 s 2 β¦ s 2 0.01 {try} β P s0 ( Ο ) = P(s 0 ,s 1 ) Β· P(s 1 ,s 2 ) s 0 s 1 1 0.98 = 1 Β· 0.01 = 0.01 1 s 3 β Pr s0 (C( Ο )) = P s0 ( Ο ) = 0.01 {succ} 0.01 β’ Paths which are eventually successful and with no failures β C(s 0 s 1 s 3 ) βͺ C(s 0 s 1 s 1 s 3 ) βͺ C(s 0 s 1 s 1 s 1 s 3 ) βͺ β¦ β Pr s0 ( C(s 0 s 1 s 3 ) βͺ C(s 0 s 1 s 1 s 3 ) βͺ C(s 0 s 1 s 1 s 1 s 3 ) βͺ β¦ ) = P s0 (s 0 s 1 s 3 ) + P s0 (s 0 s 1 s 1 s 3 ) + P s0 (s 0 s 1 s 1 s 1 s 3 ) + β¦ = 1Β·0.98 + 1Β·0.01Β·0.98 + 1Β·0.01Β·0.01Β·0.98 + β¦ = 0.9898989898β¦ = 98/99 23
Overview (Part 2) β’ Discrete-time Markov chains (DTMCs) β’ PCTL: A temporal logic for DTMCs β’ PCTL model checking β’ Other properties: LTL, costs and rewards β’ Case study: Bluetooth device discovery 24
PCTL β’ Temporal logic for describing properties of DTMCs β PCTL = Probabilistic Computation Tree Logic [HJ94] β essentially the same as the logic pCTL of [ASB+95] β’ Extension of (non-probabilistic) temporal logic CTL β key addition is probabilistic operator P β quantitative extension of CTLβs A and E operators β’ Example β send β P β₯ 0.95 [ true U β€ 10 deliver ] β βif a message is sent, then the probability of it being delivered within 10 steps is at least 0.95β 25
PCTL syntax Ο is true with β’ PCTL syntax: probability ~p β Ο ::= true | a | Ο β§ Ο | Β¬ Ο | P ~p [ Ο ] (state formulas) β Ο ::= X Ο | Ο U β€ k Ο | Ο U Ο (path formulas) βbounded βnextβ βuntilβ untilβ β where a is an atomic proposition, used to identify states of interest, p β [0,1] is a probability, ~ β {<,>, β€ , β₯ }, k β β β’ A PCTL formula is always a state formula β path formulas only occur inside the P operator 26
PCTL semantics for DTMCs β’ PCTL formulas interpreted over states of a DTMC β s β¨ Ο denotes Ο is βtrue in state sβ or βsatisfied in state sβ β’ Semantics of (non-probabilistic) state formulas: β for a state s of the DTMC (S,s init ,P,L): β s β¨ a β a β L(s) β s β¨ Ο 1 β§ Ο 2 β s β¨ Ο 1 and s β¨ Ο 2 β s β¨ Β¬ Ο β s β¨ Ο is false 1 {fail} β’ Examples s 2 0.01 {try} β s 3 β¨ succ s 0 s 1 1 0.98 β s 1 β¨ try β§ Β¬fail 1 s 3 {succ} 0.01 27
PCTL semantics for DTMCs β’ Semantics of path formulas: β for a path Ο = s 0 s 1 s 2 β¦ in the DTMC: β Ο β¨ X Ο β s 1 β¨ Ο β Ο β¨ Ο 1 U β€ k Ο 2 β β i β€ k such that s i β¨ Ο 2 and β j<i, s j β¨ Ο 1 β Ο β¨ Ο 1 U Ο 2 β β k β₯ 0 such that Ο β¨ Ο 1 U β€ k Ο 2 β’ Some examples of satisfying paths: β X succ {try} {succ} {succ} {succ} 1 {fail} s 1 s 3 s 3 s 3 s 2 0.01 {try} β Β¬fail U succ s 0 s 1 1 0.98 1 s 3 {try} {try} {succ} {succ} s 0 s 1 s 1 s 3 s 3 {succ} 0.01 28
PCTL semantics for DTMCs β’ Semantics of the probabilistic operator P β informal definition: s β¨ P ~p [ Ο ] means that βthe probability, from state s, that Ο is true for an outgoing path satisfies ~pβ β example: s β¨ P <0.25 [ X fail ] β βthe probability of atomic proposition fail being true in the next state of outgoing paths from s is less than 0.25β β formally: s β¨ P ~p [ Ο ] β Prob(s, Ο ) ~ p β where: Prob(s, Ο ) = Pr s { Ο β Path(s) | Ο β¨ Ο } β (sets of paths satisfying Ο are always measurable [Var85]) Β¬ Ο s Ο Prob(s, Ο ) ~ p ? 29
More PCTLβ¦ β’ Usual temporal logic equivalences: β false β‘ Β¬true (false) β Ο 1 β¨ Ο 2 β‘ Β¬(Β¬ Ο 1 β§ Β¬ Ο 2 ) (disjunction) β Ο 1 β Ο 2 β‘ Β¬ Ο 1 β¨ Ο 2 (implication) β F Ο β‘ β Ο β‘ true U Ο (eventually, βfutureβ) β G Ο β‘ β‘ Ο β‘ Β¬(F Β¬ Ο ) (always, βgloballyβ) β bounded variants: F β€ k Ο , G β€ k Ο β’ Negation and probabilities β e.g. Β¬P >p [ Ο 1 U Ο 2 ] β‘ P β€ p [ Ο 1 U Ο 2 ] β e.g. P >p [ G Ο ] β‘ P <1-p [ F Β¬ Ο ] 30
Qualitative vs. quantitative properties β’ P operator of PCTL can be seen as a quantitative analogue of the CTL operators A (for all) and E (there exists) β’ A PCTL property P ~p [ Ο ] isβ¦ β qualitative when p is either 0 or 1 {heads} β quantitative when p is in the range (0,1) 1 s 1 0.5 β’ P >0 [ F Ο ] is identical to EF Ο 1 s 0 β there exists a finite path to a Ο -state s 2 0.5 {tails} β’ P β₯ 1 [ F Ο ] is (similar to but) weaker than AF Ο β e.g. AF βtailsβ (CTL) β P β₯ 1 [ F βtailsβ ] (PCTL) 31
Quantitative properties β’ Consider a PCTL formula P ~p [ Ο ] β if the probability is unknown, how to choose the bound p? β’ When the outermost operator of a PTCL formula is P β we allow the form P =? [ Ο ] β βwhat is the probability that path formula Ο is true?β β’ Model checking is no harder: compute the values anyway β’ Useful to spot patterns, trends β’ Example β P =? [ F err/total>0.1 ] β βwhat is the probability β¨ that 10% of the NAND β¨ gate outputs are erroneous?β 32
Some real PCTL examples reliability β’ NAND multiplexing system β P =? [ F err/total>0.1 ] β βwhat is the probability that 10% of the NAND gate outputs are erroneous?β performance β’ Bluetooth wireless communication protocol β P =? [ F β€ t reply_count=k ] β βwhat is the probability that the sender has received k acknowledgements within t clock-ticks?β fairness β’ Security: EGL contract signing protocol β P =? [ F (pairs_a=0 & pairs_b>0) ] β βwhat is the probability that the party B gains an unfair advantage during the execution of the protocol?β 33
Overview (Part 2) β’ Discrete-time Markov chains (DTMCs) β’ PCTL: A temporal logic for DTMCs β’ PCTL model checking β’ Other properties: LTL, costs and rewards β’ Case study: Bluetooth device discovery 34
PCTL model checking for DTMCs β’ Algorithm for PCTL model checking [CY88,HJ94,CY95] β inputs: DTMC D=(S,s init ,P,L), PCTL formula Ο β output: Sat( Ο ) = { s β S | s β¨ Ο } = set of states satisfying Ο β’ What does it mean for a DTMC D to satisfy a formula Ο ? β sometimes, want to check that s β¨ Ο β s β S, i.e. Sat( Ο ) = S β sometimes, just want to know if s init β¨ Ο , i.e. if s init β Sat( Ο ) β’ Sometimes, focus on quantitative results β e.g. compute result of P=? [ F error ] β e.g. compute result of P=? [ F β€ k error ] for 0 β€ k β€ 100 35
PCTL model checking for DTMCs β’ Basic algorithm proceeds by induction on parse tree of Ο β example: Ο = (Β¬fail β§ try) β P >0.95 [ Β¬fail U succ ] β’ For the non-probabilistic operators: β Sat(true) = S β β Sat(a) = { s β S | a β L(s) } β Sat(Β¬ Ο ) = S \ Sat( Ο ) β§ P >0.95 [ Β· U Β· ] β Sat( Ο 1 β§ Ο 2 ) = Sat( Ο 1 ) β© Sat( Ο 2 ) β’ For the P ~p [ Ο ] operator Β¬ try Β¬ succ β need to compute the β¨ probabilities Prob(s, Ο ) β¨ fail fail for all states s β S β focus here on βuntilβ β¨ case: Ο = Ο 1 U Ο 2 36
PCTL until for DTMCs β’ Computation of probabilities Prob(s, Ο 1 U Ο 2 ) for all s β S β’ First, identify all states where the probability is 1 or 0 β S yes = Sat(P β₯ 1 [ Ο 1 U Ο 2 ]) β S no = Sat(P β€ 0 [ Ο 1 U Ο 2 ]) β’ Then solve linear equation system for remaining states β’ We refer to the first phase as βprecomputationβ β two algorithms: Prob0 (for S no ) and Prob1 (for S yes ) β algorithms work on underlying graph (probabilities irrelevant) β’ Important for several reasons β reduces the set of states for which probabilities must be computed numerically (which is more expensive) β gives exact results for the states in S yes and S no (no round-off) β for P ~p [Β·] where p is 0 or 1, no further computation required 37
PCTL until - Linear equations β’ Probabilities Prob(s, Ο 1 U Ο 2 ) can now be obtained as the unique solution of the following set of linear equations: β can be reduced to a system in |S ? | unknowns instead of |S| where S ? = S \ (S yes βͺ S no ) β’ This can be solved with (a variety of) standard techniques β direct methods, e.g. Gaussian elimination β iterative methods, e.g. Jacobi, Gauss-Seidel, β¦ β¨ (preferred in practice due to scalability) 38
PCTL until - Example β’ Example: P >0.8 [Β¬a U b ] 1 0.3 a 0.6 1 3 5 0.3 0.7 0.4 0.1 0.1 b 0 2 4 0.9 0.5 1 0.1 39
PCTL until - Example β’ Example: P >0.8 [Β¬a U b ] S no = Sat(P β€ 0 [Β¬a U b ]) 1 0.3 a 0.6 1 3 5 S yes = 0.3 0.7 0.4 0.1 0.1 Sat(P β₯ 1 [Β¬a U b ]) b 0 2 4 0.9 0.5 1 0.1 40
PCTL until - Example β’ Example: P >0.8 [Β¬a U b ] S no = Sat(P β€ 0 [Β¬a U b ]) β’ Let x s = Prob(s, Β¬a U b) 1 0.3 a 0.6 β’ Solve: 1 3 5 S yes = 0.3 0.7 0.4 0.1 0.1 Sat(P β₯ 1 [Β¬a U b ]) x 4 = x 5 = 1 b 0 2 4 x 1 = x 3 = 0 0.9 0.5 1 0.1 x 0 = 0.1x 1 +0.9x 2 = 0.8 x 2 = 0.1x 2 +0.1x 3 +0.3x 5 +0.5x 4 = 8/9 Prob(Β¬a U b) = x = [0.8, 0, 8/9, 0, 1, 1] Sat(P >0.8 [ Β¬a U b ]) = { s 2 ,s 4 ,s 5 } 41
PCTL model checking - Summary β’ Computation of set Sat( Ξ¦ ) for DTMC D and PCTL formula Ξ¦ β recursive descent of parse tree β combination of graph algorithms, numerical computation β’ Probabilistic operator P: β X Ξ¦ : one matrix-vector multiplication, O(|S| 2 ) β Ξ¦ 1 U β€ k Ξ¦ 2 : k matrix-vector multiplications, O(k|S| 2 ) β Ξ¦ 1 U Ξ¦ 2 : linear equation system, at most |S| variables, O(|S| 3 ) β’ Complexity: β linear in | Ξ¦ | and polynomial in |S| 42
Overview (Part 2) β’ Discrete-time Markov chains (DTMCs) β’ PCTL: A temporal logic for DTMCs β’ PCTL model checking β’ Other properties: LTL, costs and rewards β’ Case study: Bluetooth device discovery 43
Limitations of PCTL β’ PCTL, although useful in practice, has limited expressivity β essentially: probability of reaching states in X, passing only through states in Y (and within k time-steps) β’ More expressive logics can be used, for example: β LTL [Pnu77] β (non-probabilistic) linear-time temporal logic β PCTL* [ASB+95,BdA95] - which subsumes both PCTL and LTL β both allow path operators to be combined β (in PCTL, P ~p [β¦] always contains a single temporal operator) β’ Another direction: extend DTMCs with costs and rewardsβ¦ 44
LTL - Linear temporal logic β’ LTL syntax (path formulae only) β Ο ::= true | a | Ο β§ Ο | Β¬ Ο | X Ο | Ο U Ο β where a β AP is an atomic proposition β usual equivalences hold: F Ο β‘ true U Ο , G Ο β‘ Β¬(F Β¬ Ο ) β evaluated over paths of a model β’ Examples β (F tmp_fail 1 ) β§ (F tmp_fail 2 ) β βboth servers suffer temporary failures at some pointβ β GF ready β βthe server always eventually returns to a ready-stateβ β FG error β βan irrecoverable error occursβ β G (req β X ack) β βrequests are always immediately acknowledgedβ 45
LTL for DTMCs β’ Same idea as PCTL: probabilities of sets of path formulae β for a state s of a DTMC and an LTL formula Ο : β Prob(s, Ο ) = Pr s { Ο β Path(s) | Ο β¨ Ο } β all such path sets are measurable [Var85] β’ A (probabilistic) LTL specification often comprises β¨ an LTL (path) formula and a probability bound β e.g. P β₯ 1 [ GF ready ] β βwith probability 1, the server always eventually returns to a ready-stateβ β e.g. P <0.01 [ FG error ] β βwith probability at most 0.01, an irrecoverable error occursβ β’ PCTL* subsumes both LTL and PCTL β e.g. P >0.5 [ GF crit 1 ] β§ P >0.5 [ GF crit 2 ] 46
Fundamental property of DTMCs β’ Strongly connected component (SCC) β maximally strongly connected set of states β’ Bottom strongly connected component (BSCC) β SCC T from which no state outside T is reachable from T 0.5 β’ Fundamental property of DTMCs: 0.25 s 1 β βwith probability 1, β¨ s 0 s 2 0.5 a BSCC will be reached β¨ 0.5 and all of its states β¨ 0.25 1 1 visited infinitely oftenβ s 4 s 5 s 3 1 1 β’ Formally: β Pr s { Ο β Path(s) | β i β₯ 0, β BSCC T such that β¨ β j β₯ i Ο (i) β T and β¨ β sβ β T Ο (k) = s' for infinitely many k } = 1 47
LTL model checking for DTMCs β’ Steps for model checking LTL property Ο on DTMC D β i.e. computing Prob D (s, Ο ) β’ 1. Build a deterministic Rabin automaton (DRA) A for Ο β i.e. a DRA A over alphabet 2 AP accepting Ο -satisfying traces β’ 2. Build the βproductβ DTMC D β A β records state of A for path through D so far β’ 3. Identify states T acc in βacceptingβ BSCCs of D β A β i.e. those that meet the acceptance condition of A β’ 4. Compute probability of reaching T acc in D β A β which gives Prob D (s, Ο ), as required 48
Example: LTL for DTMCs DTMC D DRA A Ο for Ο = GΒ¬b β§ GF a {b} {a} a β§ Β¬b 0.1 0.5 s 0 s 1 s 2 q 0 q 1 a β§ Β¬b 0.6 0.2 0.3 0.1 Β¬a β§ Β¬b 1 b 0.3 b Β¬a β§ Β¬b 0.9 1 q 2 Acc ={ ({},{q 1 }) } s 3 s 4 s 5 true 1 {a} {a} Product DTMC D β A Ο Prob D (s, Ο ) 0.1 0.5 s 0 q 0 s 1 q 2 s 2 q 2 = Prob D β A Ο (F T 1 ) 0.6 0.2 T 1 T 2 0.3 0.1 = 3/4. 0.3 1 0.9 1 1 s 4 q 0 s 4 q 2 s 3 q 1 s 3 q 2 s 5 q 2 T 3 {k 1 } 1 1 49
Costs and rewards β’ We augment DTMCs with rewards (or, conversely, costs) β real-valued quantities assigned to states and/or transitions β these can have a wide range of possible interpretations β’ Some examples: β elapsed time, power consumption, size of message queue, number of messages successfully delivered, net profit, β¦ β’ Costs? or rewards? β mathematically, no distinction between rewards and costs β when interpreted, we assume that it is desirable to minimise costs and to maximise rewards β we will consistently use the terminology βrewardsβ regardless 50
Reward-based properties β’ Properties of DTMCs augmented with rewards β allow a wide range of quantitative measures of the system β basic notion: expected value of rewards β formal property specifications will be in an extension of PCTL β’ More precisely, we use two distinct classes of propertyβ¦ β’ Instantaneous properties β the expected value of the reward at some time point β’ Cumulative properties β the expected cumulated reward over some period 51
DTMC reward structures β’ For a DTMC (S,s init ,P,L), a reward structure is a pair ( Ο , ΞΉ ) β Ο : S β β β₯ 0 is the state reward function (vector) β ΞΉ : S Γ S β β β₯ 0 is the transition reward function (matrix) β’ Example (for use with instantaneous properties) β βsize of message queueβ: Ο maps each state to the number of jobs in the queue in that state, ΞΉ is not used β’ Examples (for use with cumulative properties) β βtime-stepsβ: Ο returns 1 for all states and ΞΉ is zero (equivalently, Ο is zero and ΞΉ returns 1 for all transitions) β βnumber of messages lostβ: Ο is zero and ΞΉ maps transitions corresponding to a message loss to 1 β βpower consumptionβ: Ο is defined as the per-time-step energy consumption in each state and ΞΉ as the energy cost of each transition 52
PCTL and rewards β’ Extend PCTL to incorporate reward-based properties β add an R operator, which is similar to the existing P operator expected reward is ~r β Ο ::= β¦ | P ~p [ Ο ] | R ~r [ I =k ] | R ~r [ C β€ k ] | R ~r [ F Ο ] βinstantaneousβ βcumulativeβ βreachabilityβ β where r β β β₯ 0 , ~ β {<,>, β€ , β₯ }, k β β β’ R ~r [ Β· ] means βthe expected value of Β· satisfies ~rβ 53
Types of reward formulas β’ Instantaneous: R ~r [ I =k ] β βthe expected value of the state reward at time-step k is ~rβ β e.g. βthe expected queue size after exactly 90 secondsβ β’ Cumulative: R ~r [ C β€ k ] β βthe expected reward cumulated up to time-step k is ~rβ β e.g. βthe expected power consumption over one hourβ β’ Reachability: R ~r [ F Ο ] β βthe expected reward cumulated before reaching a state satisfying Ο is ~rβ β e.g. βthe expected time for the algorithm to terminateβ 54
Reward formula semantics β’ Formal semantics of the three reward operators β based on random variables over (infinite) paths β’ Recall: β s β¨ P ~p [ Ο ] β Pr s { Ο β Path(s) | Ο β¨ Ο } ~ p β’ For a state s in the DTMC: β s β¨ R ~r [ I =k ] β Exp(s, X I=k ) ~ r β s β¨ R ~r [ C β€ k ] β Exp(s, X C β€ k ) ~ r β s β¨ R ~r [ F Ξ¦ ] β Exp(s, X F Ξ¦ ) ~ r where: Exp(s, X) denotes the expectation of the random variable X : Path(s) β β β₯ 0 with respect to the probability measure Pr s 55
Reward formula semantics β’ Definition of random variables: β for an infinite path Ο = s 0 s 1 s 2 β¦ β where k Ο =min{ j | s j β¨ Ο } 56
Model checking reward properties β’ Instantaneous: R ~r [ I =k ] β’ Cumulative: R ~r [ C β€ t ] β variant of the method for computing bounded until probabilities β solution of recursive equations β’ Reachability: R ~r [ F Ο ] β similar to computing until probabilities β precomputation phase (identify infinite reward states) β then reduces to solving a system of linear equation β’ For more details, see e.g. [KNP07a] 57
Overview (Part 2) β’ Discrete-time Markov chains (DTMCs) β’ PCTL: A temporal logic for DTMCs β’ PCTL model checking β’ Other properties: LTL, costs and rewards β’ Case study: Bluetooth device discovery 58
The PRISM tool β’ PRISM: Probabilistic symbolic model checker β developed at Birmingham/Oxford University, since 1999 β free, open source (GPL), runs on all major OSs β’ Support for: β discrete-/continuous-time Markov chains (D/CTMCs) β Markov decision processes (MDPs) β probabilistic timed automata (PTAs) β PCTL, CSL, LTL, PCTL*, costs/rewards, β¦ β’ Multiple efficient model checking engines β mostly symbolic (BDDs) (up to 10 10 states, 10 7 -10 8 on avg.) β’ Successfully applied to a wide range of case studies β communication protocols, security protocols, dynamic power management, cell signalling pathways, β¦ β’ See: http://www.prismmodelchecker.org/ 59
Bluetooth device discovery β’ Bluetooth: short-range low-power wireless protocol β widely available in phones, PDAs, laptops, ... β open standard, specification freely available β’ Uses frequency hopping scheme β to avoid interference (uses unregulated 2.4GHz band) β pseudo-random selection over 32 of 79 frequencies β’ Formation of personal area networks (PANs) β piconets (1 master, up to 7 slaves) β self-configuring: devices discover themselves β’ Device discovery β mandatory first step before any communication possible β relatively high power consumption so performance is crucial β master looks for devices, slaves listens for master 60
Master (sender) behaviour β’ 28 bit free-running clock CLK, ticks every 312.5Β΅s β’ Frequency hopping sequence determined by clock: β freq = [CLK 16-12 +k+ (CLK 4-2,0 - β¨ CLK 16-12 ) mod 16] mod 32 β 2 trains of 16 frequencies β¨ (determined by offset k), β¨ 128 times each, swap between β¨ every 2.56s β’ Broadcasts βinquiry packetsβ on β¨ two consecutive frequencies, β¨ then listens on the same two 61
Slave (receiver) behaviour β’ Listens (scans) on frequencies for inquiry packets β must listen on right frequency at right time β cycles through frequency sequence at much slower speed (every 1.28s) β¨ β’ On hearing packet, pause, send reply and then wait for a random delay before listening for subsequent packets β avoid repeated collisions with other slaves 62
Bluetooth β PRISM model β’ Modelled/analysed using PRISM model checker [DKNP06] β model scenario with one sender and one receiver β synchronous (clock speed defined by Bluetooth spec) β model at lowest-level (one clock-tick = one transition) β randomised behaviour so model as a DTMC β use real values for delays, etc. from Bluetooth spec β’ Modelling challenges β complex interaction between sender/receiver β combination of short/long time-scales β cannot scale down β sender/receiver not initially synchronised, so huge number of possible initial configurations (17,179,869,184) 63
Bluetooth - Results β’ Huge DTMC β initially, model checking infeasible β partition into 32 scenarios, i.e. 32 separate DTMCs β on average, approx. 3.4 x 10 9 states (536,870,912 initial) β can be built/analysed with PRISM's MTBDD engine β’ We compute: β R=? [ F replies=K {βinitβ}{max} ] β βworst-case expected time to hear K replies over all possible initial configurationsβ β’ Also look at: β how many initial states for each possible expected time β cumulative distribution function (CDF) for time, assuming equal probability for each initial state 64
Bluetooth - Time to hear 1 reply β’ Worst-case expected time = 2.5716 sec β in 921,600 possible initial states β best-case = 635 Β΅s 65
Bluetooth - Time to hear 2 replies β’ Worst-case expected time = 5.177 sec β in 444 possible initial states β compare actual CDF with derived version which assumes times to reply to first/second messages are independent 66
Bluetooth - Results β’ Other results: (see [DKNP06]) β compare versions 1.2 and 1.1 of Bluetooth, confirm 1.1 slower β power consumption analysis (using costs + rewards) β’ Conclusions: β successful analysis of complex real-life model β detailed model, actual parameters used β exhaustive analysis: best/worst-case values β’ can pinpoint scenarios which give rise to them β’ not possible with simulation approaches β model still relatively simple β’ consider multiple receivers? β’ combine with simulation? 67
Summary (Parts 1 & 2) β’ Probabilistic model checking β automated quantitative verification of stochastic systems β to model randomisation, failures, β¦ β’ Discrete-time Markov chains (DTMCs) β state transition systems + discrete probabilistic choice β probability space over paths through a DTMC β’ Property specifications β probabilistic extensions of temporal logic, e.g. PCTL, LTL β also: expected value of costs/rewards β’ Model checking algorithms β combination of graph-based algorithms, numerical computation, automata constructions β’ Next: Markov decision processes (MDPs) 68
Part 3 Markov decision processes
Overview β’ Lectures 1 and 2: β 1 β Introduction β 2 β Discrete-time Markov chains β 3 β Markov decision processes β 4 β Compositional probabilistic verification β’ Course materials available here: β http://www.prismmodelchecker.org/courses/sfm11connect/ β lecture slides, reference list, tutorial chapter, lab session 70
Probabilistic models Fully probabilisti tic Nondete terministi tic Discrete-time Markov decision Discrete Di te Markov chains processes (MDPs) time ti (DTMCs) (probabilistic automata) Probabilistic timed automata (PTAs) Continuous-time Conti tinuous Markov chains time ti (CTMCs) CTMDPs/IMCs 71
Overview (Part 3) β’ Markov decision processes (MDPs) β’ Adversaries & probability spaces β’ Properties of MDPs: The temporal logic PCTL β’ PCTL model checking for MDPs β’ Case study: Firewire root contention 72
Recap: Discrete-time Markov chains β’ Discrete-time Markov chains (DTMCs) β state-transition systems augmented with probabilities β’ Formally: DTMC D = (S, s init , P, L) where: β S is a set of states and s init β S is the initial state β P : S Γ S β [0,1] is the transition probability matrix β L : S β 2 AP labels states with atomic propositions β define a probability space Pr s over paths Path s 1 {fail} β’ Properties of DTMCs s 2 0.01 {try} β can be captured by the logic PCTL s 0 s 1 0.98 1 1 β e.g. send β P β₯ 0.95 [ F deliver ] s 3 β key question: what is the probability β¨ {succ} 0.01 of reaching states T β S from state s? β reduces to graph analysis + linear equation system 73
Nondeterminism β’ Some aspects of a system may not be probabilistic and should not be modelled probabilistically; for example: β’ Concurrency - scheduling of parallel components β e.g. randomised distributed algorithms - multiple probabilistic processes operating asynchronously β’ Underspecification - unknown model parameters β e.g. a probabilistic communication protocol designed for message propagation delays of between d min and d max β’ Unknown environments β e.g. probabilistic security protocols - unknown adversary 74
Markov decision processes β’ Markov decision processes (MDPs) β extension of DTMCs which allow nondeterministic choice β’ Like DTMCs: β discrete set of states representing possible configurations of the system being modelled β transitions between states occur in discrete time-steps β’ Probabilities and nondeterminism {heads} s 2 β in each state, a nondeterministic β¨ {init} a 0.5 a 1 choice between several discrete β¨ 1 s 0 s 1 c 1 probability distributions over β¨ a s 3 0.7 successor states b 0.5 0.3 {tails} 75
Markov decision processes β’ Formally, an MDP M is a tuple (S,s init , Ξ± , Ξ΄ ,L) where: {heads} β S is a set of states (βstate spaceβ) s 2 {init} a 0.5 β s init β S is the initial state a 1 1 s 0 s 1 c β Ξ± is an alphabet of action labels 1 a s 3 0.7 b β Ξ΄ β S Γ Ξ± Γ Dist(S) is the transition β¨ 0.5 0.3 probability relation, where Dist(S) is the set β¨ {tails} of all discrete probability distributions over S β L : S β 2 AP is a labelling with atomic propositions β’ Notes: β we also abuse notation and use Ξ΄ as a function β i.e. Ξ΄ : S β 2 Ξ±Γ Dist(S) where Ξ΄ (s) = { (a,Β΅) | (s,a,Β΅) β Ξ΄ } β we assume Ξ΄ (s) is always non-empty, i.e. no deadlocks β MDPs, here, are identical to probabilistic automata [Segala] 76
Simple MDP example β’ A simple communication protocol β after one step, process starts trying to send a message β then, a nondeterministic choice between: (a) waiting a step because the channel is unready; (b) sending the message β if the latter, with probability 0.99 send successfully and stop β and with probability 0.01, message sending fails, restart restart {fail} 1 s 2 {try} 0.01 start send s 0 s 1 1 stop 0.99 s 3 1 wait 1 {succ} 77
Example - Parallel composition 1 Asynchronous parallel β¨ 0.5 t 0 t 1 t 2 1 composition of two β¨ 0.5 3-state DTMCs 1 0.5 Action labels β¨ s 0 s 0 t 0 s 0 t 1 1 s 0 t 2 0.5 omitted here 0.5 0.5 0.5 0.5 1 1 1 1 1 0.5 s 1 s 1 t 0 s 1 t 1 s 1 t 2 0.5 1 0.5 0.5 0.5 0.5 1 0.5 s 2 s 2 t 0 s 2 t 1 s 2 t 2 0.5 1 1 1 1 1 78
Paths and probabilities β’ A (finite or infinite) path through an MDP M β is a sequence of states and action/distribution pairs β e.g. s 0 (a 0 ,Β΅ 0 )s 1 (a 1 ,Β΅ 1 )s 2 β¦ β such that (a i ,Β΅ i ) β Ξ΄ (s i ) and Β΅ i (s i+1 ) > 0 for all i β₯ 0 β represents an execution (i.e. one possible behaviour) of the system which the MDP is modelling β note that a path resolves both types of choices: nondeterministic and probabilistic β Path M,s (or just Path s ) is the set of all infinite paths starting from state s in MDP M; the set of finite paths is PathFin s β’ To consider the probability of some behaviour of the MDP β first need to resolve the nondeterministic choices β β¦which results in a DTMC β β¦for which we can define a probability measure over paths 79
Overview (Part 3) β’ Markov decision processes (MDPs) β’ Adversaries & probability spaces β’ Properties of MDPs: The temporal logic PCTL β’ PCTL model checking for MDPs β’ Case study: Firewire root contention 80
Adversaries β’ An adversary resolves nondeterministic choice in an MDP β also known as βschedulersβ, βstrategiesβ or βpoliciesβ β’ Formally: β an adversary Ο of an MDP is a function mapping every finite path Ο = s 0 (a 0 ,Β΅ 0 )s 1 ...s n to an element of Ξ΄ (s n ) β’ Adversary Ο restricts the MDP to certain paths β Path s Ο β Path s Ο and PathFin s Ο β PathFin s Ο β’ Adversary Ο induces a probability measure Pr s Ο over paths β constructed through an infinite state DTMC (PathFin s Ο , s, P s Ο ) β states of the DTMC are the finite paths of Ο starting in state s β initial state is s (the path starting in s of length 0) β P s Ο ( Ο , Ο β)=Β΅(s) if Ο β= Ο (a,Β΅)s and Ο ( Ο )=(a,Β΅) β P s Ο ( Ο , Ο β)=0 otherwise 81
Adversaries - Examples β’ Consider the simple MDP below β note that s 1 is the only state for which | Ξ΄ (s)| > 1 β i.e. s 1 is the only state for which an adversary makes a choice β let Β΅ b and Β΅ c denote the probability distributions associated with actions b and c in state s 1 {heads} β’ Adversary Ο 1 s 2 {init} a 0.5 a 1 β picks action c the first time 1 s 0 s 1 c 1 β Ο 1 (s 0 s 1 )=(c,Β΅ c ) a s 3 0.7 b 0.5 0.3 {tails} β’ Adversary Ο 2 β picks action b the first time, then c β Ο 2 (s 0 s 1 )=(b,Β΅ b ), Ο 2 (s 0 s 1 s 1 )=(c,Β΅ c ), Ο 2 (s 0 s 1 s 0 s 1 )=(c,Β΅ c ) 82
Adversaries - Examples β’ Fragment of DTMC for adversary Ο 1 β Ο 1 picks action c the first time {heads} s 2 {init} 0.5 a a 1 1 s 0 s 1 c 1 a s 3 0.7 b 0.5 0.3 {tails} 1 0.5 s 0 s 1 s 2 s 0 s 1 s 2 s 2 1 s 0 s 0 s 1 s 0 s 1 s 3 s 0 s 1 s 3 s 3 0.5 1 83
Adversaries - Examples {heads} β’ Fragment of DTMC for adversary Ο 2 s 2 β Ο 2 picks action b, then c {init} 0.5 a a 1 1 s 0 s 1 c 1 a s 3 0.7 b 0.5 0.3 {tails} 0.5 s 0 s 1 s 0 s 1 s 2 1 s 0 s 1 s 0 s 0 s 1 s 0 s 1 0.7 s 0 s 1 s 0 s 1 s 3 0.5 1 s 0 s 1 s 0 1 0.5 s 0 s 1 s 1 s 2 s 0 s 1 s 1 s 2 s 2 0.3 s 0 s 1 s 1 s 0 s 1 s 1 s 3 s 0 s 1 s 1 s 3 s 3 0.5 1 84
Memoryless adversaries β’ Memoryless adversaries always pick same choice in a state β also known as: positional, simple, Markov β formally, for adversary Ο : β Ο (s 0 (a 0 ,Β΅ 0 )s 1 ...s n ) depends only on s n β resulting DTMC can be mapped to a |S|-state DTMC β’ From previous example: β adversary Ο 1 (picks c in s 1 ) is memoryless, Ο 2 is not {heads} {heads} s 2 s 2 Ο 1 {init} {init} 0.5 a 0.5 a a 1 a 1 1 1 s 0 s 1 c s 0 s 1 c 1 1 a a s 3 s 3 0.7 b 0.5 0.5 0.3 {tails} {tails} 85
Overview (Part 3) β’ Markov decision processes (MDPs) β’ Adversaries & probability spaces β’ Properties of MDPs: The temporal logic PCTL β’ PCTL model checking for MDPs β’ Case study: Firewire root contention 86
PCTL β’ Temporal logic for properties of MDPs (and DTMCs) β extension of (non-probabilistic) temporal logic CTL β key addition is probabilistic operator P β quantitative extension of CTLβs A and E operators β’ PCTL syntax: β Ο ::= true | a | Ο β§ Ο | Β¬ Ο | P ~p [ Ο ] (state formulas) β Ο ::= X Ο | Ο U β€ k Ο | Ο U Ο (path formulas) β where a is an atomic proposition, used to identify states of interest, p β [0,1] is a probability, ~ β {<,>, β€ , β₯ }, k β β β’ Example: send β P β₯ 0.95 [ true U β€ 10 deliver ] 87
PCTL semantics for MDPs β’ PCTL formulas interpreted over states of an MDP β s β¨ Ο denotes Ο is βtrue in state sβ or βsatisfied in state sβ β’ Semantics of (non-probabilistic) state formulas: β for a state s of the MDP (S,s init , Ξ± , Ξ΄ ,L): β s β¨ a β a β L(s) β s β¨ Ο 1 β§ Ο 2 β s β¨ Ο 1 and s β¨ Ο 2 β s β¨ Β¬ Ο β s β¨ Ο is false β’ Semantics of path formulas: β for a path Ο = s 0 (a 0 ,Β΅ 0 )s 1 (a 1 ,Β΅ 1 )s 2 β¦ in the MDP: β Ο β¨ X Ο β s 1 β¨ Ο β Ο β¨ Ο 1 U β€ k Ο 2 β β i β€ k such that s i β¨ Ο 2 and β j<i, s j β¨ Ο 1 β Ο β¨ Ο 1 U Ο 2 β β k β₯ 0 such that Ο β¨ Ο 1 U β€ k Ο 2 88
PCTL semantics for MDPs β’ Semantics of the probabilistic operator P β can only define probabilities for a specific adversary Ο β s β¨ P ~p [ Ο ] means βthe probability, from state s, that Ο is true for an outgoing path satisfies ~p for all adversaries Ο β β formally s β¨ P ~p [ Ο ] β Pr s Ο ( Ο ) ~ p for all adversaries Ο β where we use Pr s Ο ( Ο ) to denote Pr s Ο { Ο β Path s Ο | Ο β¨ Ο } Β¬ Ο s Pr s Ο ( Ο ) ~ p Ο β’ Some equivalences: β F Ο β‘ β Ο β‘ true U Ο (eventually, βfutureβ) β G Ο β‘ β‘ Ο β‘ Β¬(F Β¬ Ο ) (always, βgloballyβ) 89
Minimum and maximum probabilities β’ Letting: β Pr s max ( Ο ) = sup Ο Pr s Ο ( Ο ) β Pr s min ( Ο ) = inf Ο Pr s Ο ( Ο ) β’ We have: β if ~ β { β₯ ,>}, then s β¨ P ~p [ Ο ] β Pr s min ( Ο ) ~ p β if ~ β {<, β€ }, then s β¨ P ~p [ Ο ] β Pr s max ( Ο ) ~ p β’ Model checking P ~p [ Ο ] reduces to the computation over all adversaries of either: β the minimum probability of Ο holding β the maximum probability of Ο holding β’ Crucial result for model checking PCTL on MDPs β memoryless adversaries suffice, i.e. there are always memoryless adversaries Ο min and Ο max for which: β Pr s Ο min ( Ο ) = Pr s min ( Ο ) and Pr s Ο max ( Ο ) = Pr s min ( Ο ) 90
Quantitative properties β’ For PCTL properties with P as the outermost operator β quantitative form (two types): P min=? [ Ο ] and P max=? [ Ο ] β i.e. βwhat is the minimum/maximum probability (over all adversaries) that path formula Ο is true?β β corresponds to an analysis of best-case or worst-case behaviour of the system β model checking is no harder since compute the values of β¨ Pr s min ( Ο ) or Pr s max ( Ο ) anyway β useful to spot patterns/trends β’ Example: CSMA/CD protocol β βmin/max probability that a message is sent within the deadlineβ 91
Other classes of adversary β’ A more general semantics for PCTL over MDPs β parameterise by a class of adversaries Adv β’ Only change is: β s β¨ Adv P ~p [ Ο ] β Pr s Ο ( Ο ) ~ p for all adversaries Ο β Adv β’ Original semantics obtained by taking Adv to be the set of all adversaries for the MDP β’ Alternatively, take Adv to be the set of all fair adversaries β path fairness: if a state is occurs on a path infinitely often, then each non-deterministic choice occurs infinite often β see e.g. [BK98] 92
Some real PCTL examples β’ Byzantine agreement protocol β P min=? [ F (agreement β§ rounds β€ 2) ] β βwhat is the minimum probability that agreement is reached within two rounds?β β’ CSMA/CD communication protocol β P max=? [ F collisions=k ] β βwhat is the maximum probability of k collisions?β β’ Self-stabilisation protocols β P min=? [ F β€ t stable ] β βwhat is the minimum probability of reaching a stable state within k steps?β 93
Overview (Part 3) β’ Markov decision processes (MDPs) β’ Adversaries & probability spaces β’ Properties of MDPs: The temporal logic PCTL β’ PCTL model checking for MDPs β’ Case study: Firewire root contention 94
PCTL model checking for MDPs β’ Algorithm for PCTL model checking [BdA95] β inputs: MDP M=(S,s init , Ξ± , Ξ΄ ,L), PCTL formula Ο β output: Sat( Ο ) = { s β S | s β¨ Ο } = set of states satisfying Ο β’ Basic algorithm same as PCTL model checking for DTMCs β proceeds by induction on parse tree of Ο β non-probabilistic operators (true, a, Β¬, β§ ) straightforward β’ Only need to consider P ~p [ Ο ] formulas β reduces to computation of Pr s min ( Ο ) or Pr s max ( Ο ) for all s β S β dependent on whether ~ β { β₯ ,>} or ~ β {<, β€ } β these slides cover the case Pr s min ( Ο 1 U Ο 2 ), i.e. ~ β { β₯ ,>} β case for maximum probabilities is very similar β next (X Ο ) and bounded until ( Ο 1 U β€ k Ο 2 ) are straightforward extensions of the DTMC case 95
PCTL until for MDPs β’ Computation of probabilities Pr s min ( Ο 1 U Ο 2 ) for all s β S β’ First identify all states where the probability is 1 or 0 β βprecomputationβ algorithms, yielding sets S yes , S no β’ Then compute (min) probabilities for remaining states (S ? ) β either: solve linear programming problem β or: approximate with an iterative solution method β or: use policy iteration 0.5 {a} 0.4 Example: s 2 s 1 P β₯ p [ F a ] 1 0.1 β‘ 1 1 1 0.5 P β₯ p [ true U a ] s 0 s 3 0.25 96 0.25
PCTL until - Precomputation β’ Identify all states where Pr s min ( Ο 1 U Ο 2 ) is 1 or 0 β S yes = Sat(P β₯ 1 [ Ο 1 U Ο 2 ]), S no = Sat(Β¬ P >0 [ Ο 1 U Ο 2 ]) β’ Two graph-based precomputation algorithms: β algorithm Prob1A computes S yes β’ for all adversaries the probability of satisfying Ο 1 U Ο 2 is 1 β algorithm Prob0E computes S no β’ there exists an adversary for which the probability is 0 0.5 S yes = Sat(P β₯ 1 [ F a ]) {a} 0.4 s 1 s 2 Example: 1 0.1 P β₯ p [ F a ] 1 1 1 0.5 s 0 s 3 0.25 S no = Sat( Β¬P >0 [ F a ]) 0.25 97
Method 1 - Linear programming β’ Probabilities Pr s min ( Ο 1 U Ο 2 ) for remaining states in the set S ? = S \ (S yes βͺ S no ) can be obtained as the unique solution of the following linear programming (LP) problem: maximize x s subject to the constraints : β s β S ? x s β€ Β΅ (s') β x s' + Β΅ (s') β β s' β S ? s' β S yes for all s β S ? and for all (a, Β΅ ) β Ξ΄ (s) β’ Simple case of a more general problem known as the stochastic shortest path problem [BT91] β’ This can be solved with standard techniques β e.g. Simplex, ellipsoid method, branch-and-cut 98
Example - PCTL until (LP) 0.5 Let x i = Pr si min (F a) S yes {a} S yes : x 2 =1, S no : x 3 =0 0.4 s 1 s 2 For S ? = {x 0 , x 1 } : 1 0.1 Maximise x 0 +x 1 subject to constraints: 1 1 β x 0 β€ x 1 1 0.5 s 3 s 0 β x 0 β€ 0.25Β·x 0 + 0.5 0.25 β x 1 β€ 0.1Β·x 0 + 0.5Β·x 1 + 0.4 S no 0.25 99
Example - PCTL until (LP) 0.5 Let x i = Pr si min (F a) S yes {a} S yes : x 2 =1, S no : x 3 =0 0.4 s 1 s 2 For S ? = {x 0 , x 1 } : 1 0.1 Maximise x 0 +x 1 subject to constraints: 1 1 β x 0 β€ x 1 1 0.5 s 3 s 0 β x 0 β€ 2/3 0.25 β x 1 β€ 0.2Β·x 0 + 0.8 S no 0.25 x 1 x 1 x 1 1 1 1 x 0 β€ x 1 0.8 x 0 β€ 2/3 x 1 β€ 0.2Β·x 0 + 0.8 x 0 x 0 x 0 0 0 0 2/3 0 1 0 1 0 1 100
Recommend
More recommend