introduction to temporal logic
play

Introduction to Temporal Logic Mads Dam Theoretical Computer - PowerPoint PPT Presentation

Introduction to Temporal Logic Mads Dam Theoretical Computer Science KTH, 2015 About the Course Lecturers Content Examination Lecture material Registration What is TL About? Formalised properties of time-varying systems


  1. Introduction to Temporal Logic Mads Dam Theoretical Computer Science KTH, 2015

  2. About the Course • Lecturers • Content • Examination • Lecture material • Registration

  3. What is TL About? Formalised properties of time-varying systems • What time-varying systems? • What properties? • Algorithms This is why we think formalisation pays off • Proof systems Some form of tractability Our tasks: • Show we can do useful stuff with this • Understand and compare set-ups for expressiveness and tractability

  4. What Time-Varying Systems? • Continuous real-valued functions? • Discrete program traces? • Execution trees? • Automata? • Markov chains? • Java code? • Distributed processes? • Real time? Or implicit time? • Histories or future? • Finite or infinite? • Linear or branching? Tree shaped? Graph shaped?

  5. Default Choice – Traces/Paths/Runs Time is discrete Starts at 0 Goes on forever … … 0 1 2 3 n -1 n n +1 Time points decorated by events a b a d foo a bar … … 0 1 2 3 n -1 n n +1 Or conditions/truth assignments/valuations P, ¬ Q ¬ P, ¬ Q ¬ P, Q ¬ P, ¬ Q P,Q P,Q P,Q … … 0 1 2 3 n -1 n n +1 Or execution traces x=5 x=0 x=1 x=8 x=3 x=0 x=0 y=2 y=0 y=0 y=0 y=1 y=0 y=0 … … 0 1 2 3 n -1 n n +1

  6. How Are Traces Produced? • Maximal runs through a transition system/automaton – (Q,R,Q 0 ) – Q set of states – R ⊆ Q × Q transition relation, total – Q 0 ⊆ Q initial states – Traces/runs w = q 0 R q 1 R … R q n-1 R q n R … In practice: • Take your favourite programming/modeling language • Equip it with discrete transition semantics • Determine what should be observable events / conditions / execution states • (Add looping at the end to get traces to be infinite) • Off you go

  7. Example - Concurrent While Language Commands: Cmd ::= skip | x := e | Cmd;Cmd | if e Cmd Cmd | while e Cmd | await e Cmd | spawn Cmd | Cmd || Cmd Stores σ ∈ x � fin v ∈ Val Configurations c ::= σ | <Cmd, σ >

  8. Example II Transitions: • σ -> σ ( … just to get looping … ) • <skip, σ > -> σ • <x:=e, σ > -> σ [x � ||e|| σ ] • <Cmd 1 ;Cmd 2 , σ > -> <Cmd 1 ’;Cmd 2 , σ ’> if <Cmd 1 , σ > -> <Cmd 1 ’, σ ’> • <Cmd 1 ;Cmd 2 , σ > -> <Cmd 2 , σ ’> if <Cmd 1 , σ > -> σ ’ • ( … remaining rules in class … ) Conditions: Boolean/FO expressions in dom( σ ι ) Traces: c 0 -> c 1 -> c 2 -> … -> c n-1 -> c n -> …

  9. Linear Time Temporal Logic, LTL Logic of temporal relations between events in a trace: – Invariably (along this execution) x · y + z – Sometime (along this execution) an acknowledgement packet is sent – If thread T is infinitely often enabled (along this execution) then T is eventually executed By no means the last word: – Last packet received along channel a (along this execution) had the shape (b,c,d) ( past ) – For all executions (from this state) there is an execution along which a reply is eventually sent ( branching ) – No matter what choice B made in the past, it would necessarily come to pass that ψ ( historical necessity )

  10. LTL Syntax: φ ::= P | : φ | φ Æ φ | F φ | G φ | φ U φ | O φ Intuitive semantics: – P: Propositional constant P holds now/at the current time instant – F φ : At some future time instant φ is true – G φ : For all future time instants φ is true – φ U ψ : φ is true until ψ becomes true – O φ : φ is true at the next time instant

  11. Pictorially F φ : … … … … … ... φ G φ : φ φ φ φ φ φ φ φ U ψ : … ... φ φ φ φ ψ O φ : … ... ... φ ... ... ... ...

  12. Semantics Run w Satisfaction relation w ² φ Assume valuation v v(P): Set of states for which P holds w k : k’th suffix of w w ² P iff w(0) 2 v(P) w ² : φ iff not w ² φ w ² φ Æ ψ iff w ² φ and w ² ψ w ² F φ iff exists k ≥ 0. w k ² φ w ² G φ iff for all k ≥ 0. w k ² φ w ² φ U ψ iff exists k ≥ 0. w k ² ψ and for all i: 0 · i < k. w i ² φ w ² O φ iff w 1 ² φ For transition system T = (Q,R,Q 0 ) and all valuations v: T ² φ iff for all runs w of T, w ² φ

  13. Some LTL Formulas • φ Ç ψ = :(: φ Æ : ψ ) • φ ! ψ = : φ Ç ψ • F φ = true U φ • G φ = :F: φ • φ V ψ = [] ψ Ç ( ψ U ( φ Æ ψ )) – (sometimes called ”release”) • FG φ – φ holds from some point forever = φ holds almost always • GF φ – φ holds infinitely often (i.o.) • GF φ ! GF ψ – if φ holds infinitely often then so does ψ – Is this the same as G(F φ → F ψ )? As GF( φ → ψ )? As FG ¬ φ ∨ GF( φ∧ F ψ )?

  14. Spring Example release release q 0 q 1 q 2 pull extended extended malfunction Conditions: extended, malfunction Sample paths: • q 0 q 1 q 0 q 1 q 2 q 2 q 2 ... • q 0 q 1 q 2 q 2 q 2 ... • q 0 q 1 q 0 q 1 q 0 q 1 ...

  15. Satisfaction by Single Path release release w = q 0 q 1 q 0 q 1 q 2 q 2 q 2 ... q 0 q 1 q 2 pull extended extended malfunction For r: extended ? GF extended ? O extended ? extended U malfunction ? (: extended ) U extended ? OO extended ? (F extended ) U malfunction ? F extended ? (F: extended ) U malfunction ? G extended ? G(: extended ! O extended ) FG extended ? FG malfunction ?

  16. Satisfaction by Transition System release release T: q 0 q 1 q 2 pull extended extended malfunction For T: extended ? GF extended ? O extended ? extended U malfunction ? (: extended ) U extended ? OO extended ? (F extended ) U malfunction ? F extended ? (F: extended ) U malfunction ? G extended ? G(: extended ! O extended ) FG extended ? FG malfunction ?

  17. Example: Mutex Assume there are 2 processes, P l and P r State assertions: – tryCS i : Process i is trying to enter critical section E.g. tryCS l : pc l = l 4 – inCS i : Process i is inside its critical section E.g. inCS l : pc l = l 5 Ç pc l = l 6 Mutual exclusion: G(:(inCS l Æ inCS r )) Responsiveness: G(tryCS i ! F inCS i ) Process keeps trying until access is granted: G(tryCS i ! ((tryCS i U inCS i ) Ç GtryCS i ))

  18. Example: Fairness States: Pairs (q, α ) α label of last transition taken, so q! α q’ (q, β ) ! α (q’, α ) Σ : Finite set of labels partitioned into subsets P P: ”(finite) set of labels of some process” State assertions: – en P : Some transition labelled α 2 P is enabled i.e. (q, β )2 v(en α ) iff 9 q’.q! α q’ – exec P : Label of last executed transition is in P i.e. (q, α )2 v(exec P ) iff α 2 P Note: en P $ Ç α 2 P en { α } and exec P $ Ç α 2 P exec { α }

  19. Fairness Conditions Weak transition fairness: Æ α 2 Σ :FG(en { α } Æ : exec { α } ) Or equivalently Æ α 2 Σ (FGen { α } ! GFexec { α } ) Strong transition fairness: Æ α 2 Σ (GFen { α } ! GFexec { α } ) Weak process fairness: Æ P :FG(en P Æ : exec P ) Strong process fairness: Æ P (GFen P ! GFexec P ) (Many other variants are possible) Exercise: Figure out which implications hold between these four fairness conditions. Draw a picture

  20. Branching Time Logic Sets of paths? Or computation tree? . . . . . . . . . . . . . . . . . . . .

  21. Computation Tree Logic - CTL Syntax: φ ::= P | : φ | φ Æ φ | AF φ | AG φ | A( φ U φ ) | AX φ Formulas hold of states, not paths A: Path quantifier, along all paths from this state So: – AF φ : Along all paths, at some future time instant φ is true – AG φ : Along all paths, for all future time instants φ is true – A( φ U ψ ) : Along all paths, φ is true until ψ becomes true – AX φ : φ is true for all next states Note: CTL is closed under negation so also express dual modalities EF, EG, EU, EX (E is existential path quantifier). Check!

  22. CTL, Semantics Valuation v: P � Q’ µ Q as before q ² P iff q 2 v(P) q ² : φ iff not q ² φ q ² φ Æ ψ iff q ² φ and q ² ψ q ² AF φ iff for all w such that w(0)=q exists k2N such that w(k) ² φ q ² AG φ iff for all w such that w(0)=q, for all k2N, w(k) ² φ q ² A( φ U ψ ) iff for all w such that w(0)=q, exists k2N such that w(k) ² ψ and for all i: 0 · i < k. w(i) ² φ q ² AX φ iff for all w such that w(0) = q, w(1) ² φ (iff for all q’ such that q ! q’, q’ ² φ ) For transition system T = (Q,R,Q 0 ): T ² φ iff for all q 0 2 Q 0 , q 0 ² φ

  23. CTL – LTL: Brief Comparison LTL in branching time framework: – φ � A φ ( φ to hold for all paths) CTL * LTL: EF φ not expressible in LTL LTL * CTL: FGP not expressible in CTL CTL*: Extension of CTL with free alternation A, F, G, U, X Advantages and disadvantages: – LTL often ”more natural” – Satisfiability: LTL: PSPACE complete, CTL: DEXPTIME complete – Model checking: LTL: PSPACE complete, CTL: In P

  24. Adding Past Add to LTL pasttime versions of the LTL future time modalities Previously, some time in the past, always in the past, since Theorem (Gabbay’s separation theorem): Every formula in LTL + past is equivalent to a boolean combination of ”pure pasttime” or ”pure future time” formulas Note: This applies regardless of whether time starts at 0 or at - ∞ Theorem (Elimination of past): Pasttime modalities do not add expressive power to LTL But: Theorem (Succinctness, LMS’02): LTL + past is exponentially more succinct than LTL

Recommend


More recommend