• Keine Ergebnisse gefunden

Vorlesung 11 vom 13.01.2014: Modelchecking with LTL and CTL

N/A
N/A
Protected

Academic year: 2022

Aktie "Vorlesung 11 vom 13.01.2014: Modelchecking with LTL and CTL"

Copied!
3
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Systeme Hoher Qualität und Sicherheit

Vorlesung 11 vom 13.01.2014: Modelchecking with LTL and CTL

Christoph Lüth & Christian Liguda

Universität Bremen Wintersemester 2013/14

Rev. 2432 1 [23]

Organisatorisches

I Noch ein Übungsblatt?

I Prüfungen — KW 06 (4./5. Feb.)

2 [23]

Where are we?

I Lecture 1: Concepts of Quality

I Lecture 2: Concepts of Safety and Security, Norms and Standards I Lecture 3: Quality of the Software Development Process I Lecture 4: Requirements Analysis

I Lecture 5: High-Level Design & Formal Modelling

I Lecture 6: Detailed Specification, Refinement & Implementation I Lecture 7: Testing

I Lecture 8: Program Analysis

I Lecture 9: Verification with Floyd-Hoare Logic I Lecture 10: Verification Condition Generation I Lecture 11: Model-Checking with LTL and CTL I Lecture 12: NuSMV and Spin

I Lecture 13: Conclusions

3 [23]

Introduction

I Last lectures: verifying program properties with theFloyd-Hoare calculus

I In the Floyd-Hoare calculus, program verification is reduced to a deductiveproblem by translating the program into logic (specifically, state change becomes substitution).

I Model-checking takes a different approach: the system is modelled directly by a finite-state machine, and properties are expressed in some logic for FSM. Program verification reduces to state enumeration, which can be done automatically.

I The logics we will considere here are temporal logic: linear temporal logic (LTL) and branching temporal logic (CTL)

4 [23]

The Model-Checking Problem

The Basic Question

Given a modelM, and a propertyφ, we want to know whether M |=φ

I What isM?Finite state machines

I What isφ?Temporal logic

I How to prove it? Enumerating states —model checking

5 [23]

Finite State Machines

Finite State Machine (FSM) A FSM is given byM=hΣ,→iwhere I Σis a finite set ofstates, and

I → ⊆Σ×Σis atransition relation, such that→is left-total:

∀s∈Σ.∃s0∈Σ.ss0

I Many variations of this definition exists, e.g. sometimes we have state variables or labelled transitions.

I Note there is nofinalstate, and no input or output (this is the key difference to automata).

I If→is a function, the FSM isdeterministic, otherwise it is non-deterministic.

6 [23]

The Railway Crossing

Train

Car

Gates

7 [23]

Modelling the Railway Crossing

States of the train:

xing away

lvng appr

gate= closd

States of the car:

xing away

lvng appr

gate= open gate = closed

States of the gate:

closd open

train = appr

train = lvng train = lvng train= appr

8 [23]

(2)

The FSM

I The states here are a map from variablesCar,Train,Gateto the domains

ΣCar = {appr,xing,lvng,away}

ΣTrain = {appr,xing,lvng,away}

ΣGate = {open,clsd}

or alternatively, a three-tupleS∈Σ = ΣCar×ΣTrain×ΣGate.

I The transition relation is given by e.g.

haway,open,awayi → happr,open,awayi happr,open,awayi → hxing,open,awayi . . .

9 [23]

Railway Crossing — Safety Properties

I Now we want to express safety (or security)properties, such as the following:

ICars and trains never cross at the same time.

IThe car can always leave the crossing

IApproaching trains may eventually cross.

IThere are cars crossing the tracks.

I We distinguishsafetyproperties fromlivenessproperties:

ISafety: something bad never happens.

ILiveness: something good will (eventually) happen.

I To express these properties, we need to talk about sequences of states in an FSM.

10 [23]

Linear Temporal Logic (LTL) and Paths

I LTL allows us to talk aboutpathsin a FSM, where a path is a sequence of states connected by the transition relation.

I We first define the syntax of formula,

I then what it means for a path to satisfy the formula, and I from that we derive the notion of a model for an LTL formula.

Paths

Given a FSMM=hΣ,→i, apathinMis an (infinite) sequence hs1,s2,s3, . . .isuch thatsi∈Σandsisi+1for alli.

I For a pathp=hs1,s2,s3, . . .i, we writepiforsi(selection) andpifor hsi,si+1, . . .i(the suffix starting ati).

11 [23]

Linear Temporal Logic (LTL)

φ::= > | ⊥ |p — True, false, atomic

| ¬φ|φ1φ2|φ1φ2|φ1−→φ2 — Propositional formulae

| Xφ — Next state

| Fφ — Some Future State

| Gφ — All future states (Globally)

| φ12 — Until

I Operator precedence: Unary operators; thenU; then∧,∨; then−→.

I An atomic formulapabove denotes astate predicate. Note that different FSMs have different states, so the notion of whether an atomic formula is satisfied depends on the FSM in question. A different (but equivalent) approach is to label states with atomic propositions.

I From these, we can define other operators, such asφRψ(release) or φWψ(weak until).

12 [23]

Satifsaction and Models of LTL

Given a pathpand an LTL formulaφ, thesatisfaction relationp|=φ is defined inductively as follows:

p |= True p 6|= False p |= piffp(p1) p |= ¬φiffp6|=φ

p |= φ∧ψiffp|=φandp|=ψ p |= φ∨ψiffp|=φorp|=ψ

p |= φ−→ψiff wheneverp|=φthenp|=ψ

p |= Xφiffp2|=φ

p |= Gφiff for alli, we havepi|=φ p |= Fφiff there isisuch thatpi|=φ

p |= φUψiff there isi pi|=ψand for allj=1, . . . ,i−1, pj|=φ

Models of LTL formulae

A FSMMsatisfies an LTL formulaφ,M |=φ, iff every pathpinM satisfiesφ.

13 [23]

The Railway Crossing

I Cars and trains never cross at the same time.

G¬(car=xingtrain=xing)

I A car can always leave the crossing:

G(car=xing−→F(car=lvng))

I Approaching trains may eventually cross:

G(train=appr−→F(train=xing))

I There are cars crossing the tracks:

F(car=xing)meanssomething else!

ICan not express this in LTL!

14 [23]

Computational Tree Logic (CTL)

I LTL does not allow us the quantify over paths, e.g. assert the existance of a path satisfying a particular property.

I To a limited degree, we can solve this problem by negation: instead of asserting a propertyφ, we check wether¬φis satisfied; if that is not the case,φholds. But this does not work for mixtures of universal and existential quantifiers.

I Computational Tree Logic (CTL) is an extension of LTL which allows this by adding universal and existential quantifiers to the modal operators.

I The name comes from considering paths in thecomputational tree obtained byunwindingthe FSM.

15 [23]

CTL Formulae

φ::= > | ⊥ |p — True, false, atomic

| ¬φ|φ1φ2|φ1φ2|φ1−→φ2 — Propositional formulae

| AXφ|EXφ — All or some next state

| AFφ|EFφ — All or some future states

| AGφ|EGφ — All or some global future

| A[φ12]|E[φ12] — Until all or some

16 [23]

(3)

Satifsfaction

I Note that CTL formulae can be considered to be a LTL formulae with a ’modality’ (AorE) added on top of each temporal operator.

I Generally speaking, theAmodality says the temporal operator holds for all paths, and theEmodality says the temporal operator only holds for all least one path.

I Of course, that strictly speaking is not true, because the arguments of the temporal operators are in turn CTL forumulae, so we need recursion.

I This all explains why we do not define a satisfaction for a single path p, but satisfaction with respect to a specificstatein an FSM.

17 [23]

Satisfaction for CTL

Given an FSMM=hΣ,→i,s∈Σand a CTL formulaφ, then M,s|=φis defined inductively as follows:

M,s |= True M,s 6|= False M,s |= piffp(s)

M,s |= φψiffM,s|=φandM,s|=ψ M,s |= φψiffM,s|=φorM,s|=ψ

M,s |= φ−→ψiff wheneverM,s|=φthenM,s|=ψ . . .

18 [23]

Satisfaction for CTL (c’ed)

Given an FSMM=hΣ,→i,s∈Σand a CTL formulaφ, then M,s|=φis defined inductively as follows:

. . .

M,s |= AXφiff for alls1withss1, we have M,s1|=φ M,s |= EXφiff for somes1withss1, we haveM,s1|=φ M,s |= AGφiff for all pathspwithp1=s,

we haveM,pi|=φfor alli≥2 M,s |= EGφiff there is a pathpwithp1=sand

we haveM,pi|=φfor alli≥2 M,s |= AFφiff for all pathspwithp1=s

we haveM,pi|=φfor somei M,s |= EFφiff there is a pathpwithp1=sand

we have;M,pi|=φfor somei M,s |= A[φUψ]iff for all pathspwithp1=s, there isi

withM,pi|=ψand for allj<i,M,pj|=φ M,s |= E[φUψ]iff there is a pathpwithp1=sand there isi

withM,pi|=ψand for allj<i,M,pj|=φ

19 [23]

Patterns of Specification

I Something bad (p) cannot happen: AG¬p

I poccurs infinitly often: AG(AFp)

I poccurs eventually: AFp

I In the future,pwill hold eventually forever: AF AGp

I Wheneverpwill hold in the future,qwill hold eventually:

AG(p−→AFq)

I In all states,pis always possible: AG(EFp)

20 [23]

LTL and CTL

I We have seen that CTL is more expressive than LTL, but (surprisingly), there are properties which we can formalise in LTL but not in CTL!

I Example: all paths which have apalong them also have aqalong them.

I LTL: Fp−→Fq

I CTL:NotAFp−→AFq(would mean: if all paths havep, then all paths haveq), neither AG(p−→AFq)(which means: if there is ap, it will be followed by aq).

I The logicCTLcombines both LTL and CTL (but we will not consider it further here).

21 [23]

State Explosion and Complexity

I The basic problem of model checking isstate explosion.

I Even our small railway crossing has

|Σ|=|ΣCar×ΣTrain×ΣGate|=|ΣCar| · |ΣTrain| · |ΣGate|=4·4·2=32 states. Add one integer variable with 232states, and this gets intractable.

I Theoretically, there is not much hope. The basic problem of deciding wether a particular formula holds is known as the satisfiability problem, and for the temporal logics we have seen, its complexity is as follows:

ILTL withoutUisNP-complete.

ILTL isPSPACE-complete.

ICTL isEXPTIME-complete.

I The good news is that at least it isdecidable. Practically,state abstractionis the key technique. E.g. instead of considering all possible integer values, consider only wetheriis zero or larger than zero.

22 [23]

Summary

I Model-checking allows us to show to show properties of systems by enumerating the system’s states, by modelling systems asfinite state machines, and expressing properties in temporal logic.

I We considered Linear Temporal Logic (LTL) and Computational Tree Logic (CTL). LTL allows us to express properties of single paths, CTL allows quantifications over all possible paths of an FSM.

I The basic problem: the system state can quickly gethuge, and the basic complexity of the problem ishorrendous. Use of abstraction and state compression techniques make model-checking bearable.

I Next lecture: practical experiments with model-checkers (NuSMV and/or Spin)

23 [23]

Referenzen

ÄHNLICHE DOKUMENTE

 Model-checking allows us to show to show properties of systems by enumerating the system’s states, by modelling systems as finite state machines, and expressing properties

I Model-checking allows us to show to show properties of systems by enumerating the system’s states, by modelling systems as finite state machines, and expressing properties in

I Model-checking allows us to show to show properties of systems by enumerating the system’s states, by modelling systems as finite state machines, and expressing properties in

I Model-checking allows us to show to show properties of systems by enumerating the system’s states, by modelling systems as finite state machines, and expressing properties in

Rimantadine does not show scavenging properties and its antioxi- dant effect observed in vivo, is not a result of its direct action on the processes of lipid peroxidation

agriculture systems ... Population and economic development ... Technological Change and Investments ... Environment and agricultural productl.on ... International relationships

TABLE 2 | Output from Boosted Regression Trees (BRTs); The explained (cross-validated, CV) variance of the models, and the relative influences of predictor variables (INT:

Long-Range Energy Transport in Single Supramolecular Nanofibres at Room Temperature NIBT periphery with subsequent PL (orange arrow), or to the next ordered domain of the