• Non ci sono risultati.

Introduction to Formal Methods Chapter 03: Temporal Logics

N/A
N/A
Protected

Academic year: 2021

Condividi "Introduction to Formal Methods Chapter 03: Temporal Logics"

Copied!
99
0
0

Testo completo

(1)

Introduction to Formal Methods Chapter 03: Temporal Logics

Roberto Sebastiani

DISI, Università di Trento, Italy – roberto.sebastiani@unitn.it URL: http://disi.unitn.it/rseba/DIDATTICA/fm2020/

Teaching assistant:Enrico Magnago– enrico.magnago@unitn.it

CDLM in Informatica, academic year 2019-2020

last update: Monday 18thMay, 2020, 14:48

Copyright notice: some material (text, figures) displayed in these slides is courtesy of R. Alur, M. Benerecetti, A. Cimatti, M.

Di Natale, P. Pandya, M. Pistore, M. Roveri, and S.Tonetta, who detain its copyright. Some exampes displayed in these slides are taken from [Clarke, Grunberg & Peled, “Model Checking”, MIT Press], and their copyright is detained by the authors. All the other material is copyrighted by Roberto Sebastiani. Every commercial use of this material is strictly forbidden by the copyright laws without the authorization of the authors. No copy of these slides can be displayed in public

(2)

Outline

1 Some background on Boolean Logic

2 Generalities on temporal logics

3 Linear Temporal Logic – LTL

4 Some LTL Model Checking Examples

5 Computation Tree Logic – CTL

6 Some CTL Model Checking Examples

7 LTL vs. CTL

8 Fairness & Fair Kripke Models

9 Exercises

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 2 / 108

(3)

Some background on Boolean Logic

Boolean logic

(4)

Some background on Boolean Logic

Basic notation & definitions

Boolean formula

>, ⊥ are formulas

Apropositional atomA1,A2,A3, ...is a formula;

if ϕ1and ϕ2are formulas, then

¬ϕ1, ϕ1∧ ϕ2, ϕ1∨ ϕ2, ϕ1→ ϕ2, ϕ1← ϕ2, ϕ1↔ ϕ2 are formulas.

Atoms(ϕ): the set {A1, ...,AN} of atoms occurring in ϕ.

Literal: a propositional atom Ai (positive literal) or its negation ¬Ai (negative literal)

Notation: if l := ¬Ai, then ¬l := Ai Clause: a disjunction of literalsW

jlj (e.g.,(A1∨ ¬A2∨ A3∨ ...)) Cube:a conjunction of literalsV

jlj(e.g.,(A1∧ ¬A2∧ A3∧ ...))

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 5 / 108

(5)

Some background on Boolean Logic

Semantics of Boolean operators

Truth table:

ϕ1 ϕ2 ¬ϕ1 ϕ1∧ ϕ2 ϕ1∨ ϕ2 ϕ1→ ϕ2 ϕ1← ϕ2 ϕ1↔ ϕ2

> > > >

> > > >

> > >

> > > > > > >

Note

∧, ∨ and ↔ are commutative:

1∧ ϕ2) ⇐⇒ (ϕ2∧ ϕ1) 1∨ ϕ2) ⇐⇒ (ϕ2∨ ϕ1) 1↔ ϕ2) ⇐⇒ (ϕ2↔ ϕ1)

∧ and ∨ are associative:

((ϕ1∧ ϕ2) ∧ ϕ3) ⇐⇒ 1∧ (ϕ2∧ ϕ3)) ⇐⇒ 1∧ ϕ2∧ ϕ3) ((ϕ1∨ ϕ2) ∨ ϕ3) ⇐⇒ 1∨ (ϕ2∨ ϕ3)) ⇐⇒ 1∨ ϕ2∨ ϕ3)

(6)

Some background on Boolean Logic

Syntactic Properties of Boolean Operators

¬¬ϕ1 ⇐⇒ ϕ1

1∨ ϕ2) ⇐⇒ ¬(¬ϕ1∧ ¬ϕ2)

¬(ϕ1∨ ϕ2) ⇐⇒ (¬ϕ1∧ ¬ϕ2) 1∧ ϕ2) ⇐⇒ ¬(¬ϕ1∨ ¬ϕ2)

¬(ϕ1∧ ϕ2) ⇐⇒ (¬ϕ1∨ ¬ϕ2) 1→ ϕ2) ⇐⇒ (¬ϕ1∨ ϕ2)

¬(ϕ1→ ϕ2) ⇐⇒ (ϕ1∧ ¬ϕ2) 1← ϕ2) ⇐⇒ (ϕ1∨ ¬ϕ2)

¬(ϕ1← ϕ2) ⇐⇒ (¬ϕ1∧ ϕ2)

1↔ ϕ2) ⇐⇒ ((ϕ1→ ϕ2) ∧ (ϕ1← ϕ2))

⇐⇒ ((¬ϕ1∨ ϕ2) ∧ (ϕ1∨ ¬ϕ2))

¬(ϕ1↔ ϕ2) ⇐⇒ (¬ϕ1↔ ϕ2)

⇐⇒ (ϕ1↔ ¬ϕ2)

⇐⇒ ((ϕ1∨ ϕ2) ∧ (¬ϕ1∨ ¬ϕ2))

Boolean logic can be expressed in terms of {¬, ∧} (or {¬, ∨}) only

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 7 / 108

(7)

Some background on Boolean Logic

TREE and DAG representation of formulas: example

Formulas can be represented either as trees or as DAGS:

DAG representation can be up to exponentially smaller (A1↔ A2) ↔ (A3↔ A4)

(((A1↔ A2) → (A3↔ A4))∧

((A3↔ A4) → (A1↔ A2)))

(((A1→ A2) ∧ (A2→ A1)) → ((A3→ A4) ∧ (A4→ A3)))∧

(((A3→ A4) ∧ (A4→ A3)) → (((A1→ A2) ∧ (A2→ A1))))

(8)

Some background on Boolean Logic

TREE and DAG representation of formulas: example (cont)

Tree Representation

DAG Representation

A1 A2 A2 A1 A3 A4 A4 A3 A3 A4 A4 A3 A1 A2 A2 A1

A2

A1 A3 A4

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 9 / 108

(9)

Some background on Boolean Logic

Basic notation & definitions (cont)

Total truth assignmentµfor ϕ:

µ :Atoms(ϕ) 7−→ {>, ⊥}.

Partial Truth assignmentµfor ϕ:

µ : A 7−→ {>, ⊥}, A ⊂ Atoms(ϕ).

Set and formula representation of an assignment:

µcan be represented as a set of literals:

EX:{µ(A1) := >, µ(A2) := ⊥} =⇒ {A1, ¬A2} µcan be represented as a formula (cube):

EX:{µ(A1) := >, µ(A2) := ⊥} =⇒ (A1∧ ¬A2)

(10)

Some background on Boolean Logic

Basic notation & definitions (cont)

atotaltruth assignmentµsatisfies ϕ(µ |= ϕ):

µ |=Ai ⇐⇒ µ(Ai) = >

µ |= ¬ϕ ⇐⇒not µ |= ϕ

µ |= ϕ1∧ ϕ2⇐⇒ µ |= ϕ1and µ |= ϕ2 µ |= ϕ1∨ ϕ2⇐⇒ µ |= ϕ1or µ |= ϕ2 µ |= ϕ1→ ϕ2⇐⇒ if µ |= ϕ1, then µ |= ϕ2 µ |= ϕ1↔ ϕ2⇐⇒ µ |= ϕ1iff µ |= ϕ2

apartialtruth assignmentµsatisfies ϕiff it makes ϕ evaluate to true (Ex: {A1} |= (A1∨ A2))

=⇒ if µ satisfies ϕ, then all its total extensions satisfy ϕ (Ex:{A1,A2} |= (A1∨ A2)and{A1, ¬A2} |= (A1∨ A2)) ϕissatisfiableiff µ |= ϕ for some µ

ϕ1entails ϕ21|= ϕ2): ϕ1|= ϕ2iff µ |= ϕ1=⇒ µ |= ϕ2for every µ ϕis valid(|= ϕ): |= ϕ iff µ |= ϕ for every µ

Property

ϕis valid ⇐⇒ ¬ϕ is not satisfiable

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 11 / 108

(11)

Some background on Boolean Logic

Equivalence and equi-satisfiability

ϕ1and ϕ2areequivalent iff, for every µ, µ |= ϕ1iff µ |= ϕ2 ϕ1and ϕ2areequi-satisfiableiff

exists µ1s.t. µ1|= ϕ1iff exists µ2s.t. µ2|= ϕ2 ϕ1, ϕ2equivalent

⇓ 6⇑

ϕ1, ϕ2equi-satisfiable EX:ϕ1

def= ψ1∨ ψ2andϕ2

def= (ψ1∨ ¬A3) ∧ (A3∨ ψ2)s.t.A3not in ψ1∨ ψ2, are equi-satisfiable but not equivalent:

µ |= (ψ1∨ ¬A3) ∧ (A3∨ ψ2)=⇒µ |= ψ1∨ ψ2

µ0|= ψ1∨ ψ2=⇒µ0∧ A3|= (ψ1∨ ¬A3) ∧ (A3∨ ψ2)or µ0∧ ¬A3|= (ψ1∨ ¬A3) ∧ (A3∨ ψ2)1, ϕ2equi-satisfiable]

µ06|= ψ1andµ0|= ψ2=⇒µ0∧ A3|= ψ1∨ ψ2and

µ0∧ A36|= (ψ1∨ ¬A3) ∧ (A3∨ ψ2)1, ϕ2not equivalent]

Typically used when ϕ2is the result of applying some transformation T to ϕ1: ϕ2def=T (ϕ1):

we say that T isvalidity-preserving[satisfiability-preserving] iff

(12)

Some background on Boolean Logic

Complexity

For N variables, there are up to 2N truth assignments to be checked.

The problem of deciding the satisfiability of a propositional formula isNP-complete

The most important logical problems (validity,inference,

entailment,equivalence, ...) can be straightforwardly reduced to satisfiability, and are thus(co)NP-complete.

No existing worst-case-polynomial algorithm.

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 13 / 108

(13)

Some background on Boolean Logic

POLARITY of subformulas

Positive/negative occurrences ϕoccurs positively in ϕ;

if ¬ϕ1occurs positively [negatively] in ϕ, then ϕ1occurs negatively [positively] in ϕ

if ϕ1∧ ϕ2or ϕ1∨ ϕ2occur positively [negatively] in ϕ, then ϕ1and ϕ2occur positively [negatively] in ϕ;

if ϕ1→ ϕ2occurs positively [negatively] in ϕ,

then ϕ1occurs negatively [positively] in ϕ and ϕ2occurs positively [negatively] in ϕ;

if ϕ1↔ ϕ2occurs in ϕ,

then ϕ1and ϕ2occur positively and negatively in ϕ;

EX:

ϕ1occurs positively in ¬(ϕ1→ ϕ2) ϕ2occurs negatively in ¬(ϕ1→ ϕ2)

intuition: ϕ1occurs positively [negatively] in ϕ iff it occurs under the scope of an (implicit) even [odd] number of negations.

=⇒ Polarity: the number of nested negations modulo 2.

(14)

Some background on Boolean Logic

Substitution

Properties

If ϕ1is equivalent to ϕ2, then ϕ[ϕ12]is equivalent to ϕ:

|= (ϕ1↔ ϕ2)

|= ϕ[ϕ12] ↔ ϕ

If ϕ2entails ϕ1and ϕ1occurs only positively in ϕ, then ϕ[ϕ12] entails ϕ:

ϕ2|= ϕ1

ϕ[ϕ12] |= ϕ dual case for negative occurrence

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 15 / 108

(15)

Some background on Boolean Logic

Negative normal form (NNF)

ϕis inNegative normal formiff it is given only by the recursive applications of ∧, ∨ to literals.

every ϕ can be reduced into NNF:

(i) substituting all →’s and ↔’s:

ϕ1→ ϕ2 =⇒ ¬ϕ1∨ ϕ2

ϕ1↔ ϕ2 =⇒ (¬ϕ1∨ ϕ2) ∧ (ϕ1∨ ¬ϕ2) (ii) pushing down negations recursively:

¬(ϕ1∧ ϕ2) =⇒ ¬ϕ1∨ ¬ϕ2

¬(ϕ1∨ ϕ2) =⇒ ¬ϕ1∧ ¬ϕ2

¬¬ϕ1 =⇒ ϕ1

The reduction islinearif a DAG representation is used.

Preserves theequivalenceof formulas.

(16)

Some background on Boolean Logic

NNF: example

(A1↔ A2) ↔ (A3↔ A4)

((((A1→ A2) ∧ (A1← A2)) → ((A3→ A4) ∧ (A3← A4)))∧

(((A1→ A2) ∧ (A1← A2)) ← ((A3→ A4) ∧ (A3← A4))))

((¬((¬A1∨ A2) ∧ (A1∨ ¬A2)) ∨ ((¬A3∨ A4) ∧ (A3∨ ¬A4)))∧

(((¬A1∨ A2) ∧ (A1∨ ¬A2)) ∨ ¬((¬A3∨ A4) ∧ (A3∨ ¬A4))))

((((A1∧ ¬A2) ∨ (¬A1∧ A2)) ∨ ((¬A3∨ A4) ∧ (A3∨ ¬A4)))∧

(((¬A1∨ A2) ∧ (A1∨ ¬A2)) ∨ ((A3∧ ¬A4) ∨ (¬A3∧ A4))))

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 17 / 108

(17)

Some background on Boolean Logic

NNF: example (cont)

A1 −A2 −A1 A2 −A3 A4A3 −A4 −A1 A2 A1 −A2 A3 −A4−A3 A4

−B1 B2 B1 −B2

A1 −A2 −A1 A2 −A3 A4A3 −A4

−B1 B2 B1 −B2

Tree Representation

DAG Representation

Note

For each non-literal subformula ϕ, ϕ and ¬ϕ have different representations =⇒ they are not shared.

(18)

Some background on Boolean Logic

Optimized polynomial representations

And-Inverter Graphs,Reduced Boolean Circuits,Boolean Expression Diagrams

Maximize the sharing in DAG representations:

{∧, ↔, ¬}-only, negations on arcs, sorting of subformulae, lifting of

¬’s over ↔’s,...

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 19 / 108

(19)

Some background on Boolean Logic

Conjunctive Normal Form (CNF)

ϕis inConjunctive normal formiff it is a conjunction of disjunctions of literals:

L

^

i=1 Ki

_

ji=1

lji

the disjunctions of literalsWKi

ji=1lji are calledclauses Easier to handle: list of lists of literals.

=⇒no reasoning on the recursive structure of the formula

(20)

Some background on Boolean Logic

Classic CNF Conversion CNF (ϕ)

Every ϕ can be reduced into CNFby, e.g., (i) converting it into NNF (not indispensible);

(ii) applying recursively the DeMorgan’s Rule:

1∧ ϕ2) ∨ ϕ3 =⇒ 1∨ ϕ3) ∧ (ϕ2∨ ϕ3) Worst-caseexponential.

Atoms(CNF (ϕ)) = Atoms(ϕ).

CNF (ϕ) isequivalentto ϕ.

Rarely used in practice.

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 21 / 108

(21)

Some background on Boolean Logic

Labeling CNF conversion CNFlabel(ϕ)

Every ϕ can be reduced into CNFby, e.g., applying recursively bottom-up the rules:

ϕ =⇒ ϕ[(li∨ lj)|B] ∧ CNF (B ↔ (li∨ lj)) ϕ =⇒ ϕ[(li∧ lj)|B] ∧ CNF (B ↔ (li∧ lj)) ϕ =⇒ ϕ[(li ↔ lj)|B] ∧ CNF (B ↔ (li ↔ lj)) li,lj being literals and B being a “new” variable.

Worst-caselinear.

Atoms(CNFlabel(ϕ)) ⊇Atoms(ϕ).

CNFlabel(ϕ)isequi-satisfiablew.r.t. ϕ.

More used in practice.

(22)

Some background on Boolean Logic

Labeling CNF conversion CNFlabel(ϕ) (cont.)

CNF (B ↔ (li∨ lj)) ⇐⇒ (¬B ∨ li∨ lj)∧

(B ∨ ¬li)∧

(B ∨ ¬lj) CNF (B ↔ (li∧ lj)) ⇐⇒ (¬B ∨ li)∧

(¬B ∨ lj)∧

(B ∨ ¬li¬lj) CNF (B ↔ (li ↔ lj)) ⇐⇒ (¬B ∨ ¬li∨ lj)∧

(¬B ∨ li∨ ¬lj)∧

(B ∨ li∨ lj)∧

(B ∨ ¬li∨ ¬lj)

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 23 / 108

(23)

Some background on Boolean Logic

Labeling CNF conversion CNFlabel – example

−A3 A1 A5 −A4 −A3 A4 A2 −A6 A1 A4 A3 −A5 −A2 A6 A1 −A4

B1 B2 B3 B4 B5 B6 B7 B8

B9 B10 B11 B12

B13 B14

B15

CNF (B1↔ (¬A3∨ A1))

...

CNF (B8↔ (A1∨ ¬A4)) CNF (B9↔ (B1↔ B2))

...

CNF (B12↔ (B7∧ B8)) CNF (B13↔ (B9∨ B10)) CNF (B14↔ (B11∨ B12)) CNF (B15↔ (B13∧ B14)) B15

(24)

Some background on Boolean Logic

Labeling CNF conversion CNFlabel (variant)

As in the previous case, applying instead the rules:

ϕ =⇒ ϕ[(li∨ lj)|B] ∧ CNF (B → (li∨ lj)) if (li∨ lj)pos.

ϕ =⇒ ϕ[(li∨ lj)|B] ∧ CNF ((li∨ lj) →B) if (li∨ lj)neg.

ϕ =⇒ ϕ[(li∧ lj)|B] ∧ CNF (B → (li∧ lj)) if (li∧ lj)pos.

ϕ =⇒ ϕ[(li∧ lj)|B] ∧ CNF ((li∧ lj) →B) if (li∧ lj)neg.

ϕ =⇒ ϕ[(li ↔ lj)|B] ∧ CNF (B → (li ↔ lj)) if (li ↔ lj)pos.

ϕ =⇒ ϕ[(li ↔ lj)|B] ∧ CNF ((li ↔ lj) →B) if (li ↔ lj)neg.

Pro: smaller in size:

CNF (B → (li∨ lj)) = (¬B ∨ li∨ lj)

CNF (((li∨ lj) →B)) = (¬li∨ B) ∧ (¬lj∨ B) Con: looses backward propagation:

unlike with CNF (B ↔ (li∨ lj)), with CNF (B → (li∨ lj))we can no more infer that B is true from the fact that li is true or lj is true.

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 25 / 108

(25)

Some background on Boolean Logic

Labeling CNF conversion CNFlabel(ϕ) (cont.)

CNF (B → (li∨ lj)) ⇐⇒ (¬B ∨ li∨ lj) CNF (B ← (li∨ lj)) ⇐⇒ (B ∨ ¬li)∧

(B ∨ ¬lj) CNF (B → (li∧ lj)) ⇐⇒ (¬B ∨ li)∧

(¬B ∨ lj) CNF (B ← (li∧ lj)) ⇐⇒ (B ∨ ¬li¬lj) CNF (B → (li ↔ lj)) ⇐⇒ (¬B ∨ ¬li∨ lj)∧

(¬B ∨ li∨ ¬lj) CNF (B ← (li ↔ lj)) ⇐⇒ (B ∨ li∨ lj)∧

(B ∨ ¬li∨ ¬lj)

(26)

Some background on Boolean Logic

Labeling CNF conversion CNFlabel – example

−A3 A1 A5 −A4 −A3 A4 A2 −A6 A1 A4 A3 −A5 −A2 A6 A1 −A4

B1 B2 B3 B4 B5 B6 B7 B8

B9 B10 B11 B12

B13 B14

B15

Basic Improved

CNF (B1↔ (¬A3∨ A1))

...

CNF (B8↔ (A1∨ ¬A4)) CNF (B9↔ (B1↔ B2))

...

CNF (B12↔ (B7∧ B8)) CNF (B13↔ (B9∨ B10)) CNF (B14↔ (B11∨ B12)) CNF (B15↔ (B13∧ B14)) B15

CNF (B1↔ (¬A3∨ A1))

...

CNF (B8→ (A1∨ ¬A4)) CNF (B9→ (B1↔ B2))

...

CNF (B12→ (B7∧ B8)) CNF (B13→ (B9∨ B10)) CNF (B14→ (B11∨ B12)) CNF (B15→ (B13∧ B14)) B15

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 27 / 108

(27)

Some background on Boolean Logic

Labeling CNF conversion CNFlabel – further optimizations

Do not apply CNFlabel when not necessary:

(e.g.,CNFlabel1∧ ϕ2) =⇒CNFlabel1) ∧ ϕ2, if ϕ2already in CNF)

Apply Demorgan’s rules where it is more effective: (e.g.,

CNFlabel1∧(A → (B ∧C))) =⇒ CNFlabel1)∧(¬A∨B)∧(¬A∨C) exploit the associativity of ∧’s and ∨’s:

... (A1∨ (A2∨ A3))

| {z }

B

... =⇒ ...CNF (B ↔ (A1∨ A2∨ A3))...

before applying CNFlabel, rewrite the initial formula so that to maximize the sharing of subformulas (RBC, BED)

...

(28)

Generalities on temporal logics

Computation tree vs. computation paths

Consider the following Kripke structure:

done

!done

Its execution can be seen as:

an infinite set of computation paths

done done done

!done

!done

!done

!done

done done

done

!done !done

!done !done !done

!done

...

an infinite computation tree

done

done

done done done

done

!done

!done

!done

!done

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 30 / 108

(29)

Generalities on temporal logics

Temporal Logics

Express properties of “Reactive Systems”

nonterminating behaviours, without explicit reference to time.

Linear Temporal Logic (LTL)

interpreted over each path of the Kripke structure linear model of time

temporal operators

“Medieval”: “since birth, one’s destiny is set”.

Computation Tree Logic (CTL)

interpreted over computation tree of Kripke model branching model of time

temporal operators plus path quantifiers

“Humanistic”: “one makes his/her own destiny step-by-step”.

(30)

Linear Temporal Logic – LTL

Linear Temporal Logic (LTL): Syntax

Anatomic propositionis a LTL formula;

ifϕ1andϕ2are LTL formulae, then¬ϕ1, ϕ1∧ ϕ2, ϕ1∨ ϕ2, ϕ1→ ϕ2, ϕ1↔ ϕ2are LTL formulae;

ifϕ1andϕ2are LTL formulae, then1, ϕ12,1,1are LTL formulae, whereX, G, F, U are the “next”, “globally”,

“eventually”,“until” temporal operators respectively.

Another operatorR “releases” (the dual of U) is used sometimes.

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 33 / 108

(31)

Linear Temporal Logic – LTL

LTL semantics: intuitions

LTL is given by the standard boolean logic enhanced with the following temporal operators, which operate throughpaths hs0,s1, ...,sk, ...i:

“Next”X: Xϕ is true in st iff ϕ is true in st+1

“Finally” (or “eventually”)F: Fϕ is true in st iff ϕ is true insome st0 with t0≥ t

“Globally” (or “henceforth”)G: Gϕ is true in st iff ϕ is true inall st0 with t0≥ t

“Until”U: ϕUψ is true in st iff, for some state st0 s.t t0≥ t:

ψis true in st0 and

ϕis true in all states st00s.t. t ≤ t00<t0

“Releases”R: ϕRψ is true in st iff, for all states st0 s.t. t0 ≥ t:

ψis trueor

ϕis true in some states st00with t ≤ t00<t0

“ψ can become false only if ϕ becomes true first"

(32)

Linear Temporal Logic – LTL

LTL semantics: intuitions finally P

F P

globally P

G P

X P

next P P until q

P U q

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 35 / 108

(33)

Linear Temporal Logic – LTL

LTL: Some Noteworthy Examples

Safety: “it never happens that a train is arriving and the bar is up”

G(¬(train_arriving ∧ bar_up)) Liveness:“if input, then eventually output”

G(input → Foutput)

Releases:“the device is not working if you don’t first repair it”

(repair_deviceR ¬working_device) Fairness:“infinitely often send ”

GFsend

Strong fairness:“infinitely often send implies infinitely often recv.”

GFsend → GFrecv

(34)

Linear Temporal Logic – LTL

LTL Formal Semantics

π,si |= a iff a ∈ L(si)

π,si |= ¬ϕ iff π,si 6|= ϕ

π,si |= ϕ ∧ ψ iff π,si |= ϕ and

π,si |= ψ

π,si |= Xϕ iff π,si+1 |= ϕ

π,si |= Fϕ iff for some j ≥ i : π, sj |= ϕ π,si |= Gϕ iff for all j ≥ i : π, sj |= ϕ π,si |= ϕUψ iff for some j ≥ i : (π, sj |= ψ and

for all k s.t. i ≤ k < j : π, sk |= ϕ) π,si |= ϕRψ iff for all j ≥ i : (π, sj |= ψ or

for some k s.t. i ≤ k < j : π, sk |= ϕ)

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 37 / 108

(35)

Linear Temporal Logic – LTL

LTL Formal Semantics (cont.)

LTL properties are evaluated over paths, i.e., over infinite, linear sequences of states: π =s0→ s1→ · · · → st → st+1→ · · · Given an infinite sequence π = s0,s1,s2, . . .

π,si |= φ if φ is true in state si of π.

π |= φif φ is true in the initial state s0of π.

The LTL model checking problem M |= φ

check if π |= φ for every path π of the Kripke structure M (e.g., φ =Fdone)

done

!done !done done done done

!done

!done

!done

done done

done

!done !done

!done !done !done

!done

...

(36)

Linear Temporal Logic – LTL

The LTL model checking problem M |= φ: remark

The LTL model checking problem M |= φ

π |= φfor every path πof the Kripke structure M

Important Remark M 6|= φ 6=⇒ M |= ¬φ(!!)

E.g. if φ is a LTL formula and two paths π1and π2are s.t. π1|= φ and π2|= ¬φ.

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 39 / 108

(37)

Linear Temporal Logic – LTL

Example: M 6|= φ 6=⇒ M |= ¬φ

Let π1def= {s1}ω, π2= {sdef 2}ω. M 6|= Gp, in fact:

π16|= Gp π2|= Gp M 6|= ¬Gp, in fact:

π1|= ¬Gp π26|= ¬Gp

pq s0

¬p¬q s1

p¬q s2

(38)

Linear Temporal Logic – LTL

Syntactic properties of LTL operators

ϕ1∨ ϕ2 ⇐⇒ ¬(¬ϕ1∧ ¬ϕ2) ...

F ϕ1 ⇐⇒ >Uϕ1

G ϕ1 ⇐⇒ ⊥Rϕ1 1 ⇐⇒ ¬G¬ϕ1 1 ⇐⇒ ¬F¬ϕ1

¬Xϕ1 ⇐⇒ X¬ϕ1

ϕ12 ⇐⇒ ¬(¬ϕ1U¬ϕ2) ϕ12 ⇐⇒ ¬(¬ϕ1R¬ϕ2) Note

LTL can be defined in terms of ∧, ¬,X, U only

Exercise

Prove that ϕ12⇐⇒ Gϕ2∨ ϕ2U(ϕ1∧ ϕ2)

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 41 / 108

(39)

Linear Temporal Logic – LTL

Proof of ϕRψ ⇔ (Gψ ∨ ψU(ϕ ∧ ψ))

[Solution proposed by the student Samuel Valentini, 2016]

(All state indexes below are implicitly assumed to be ≥ 0.)

⇒: Let π be s.t. π, s0|= ϕRψ

If ∀j, π, sj |= ψ, then π, s0|= Gψ.

Otherwise, let sk be thefirststate s.t. π, sk 6|= ψ.

Since π, s0|= ϕRψ, then k > 0 and exists k0 <k s.t. π, Sk0 |= ϕ By construction, π, sk0 |= ϕ ∧ ψ and, for every w < k0, π, sw|= ψ, so that π, s0|= ψU(ϕ ∧ ψ).

Thus, π, s0|= Gψ ∨ ψU(ϕ ∧ ψ)

⇐: Let π be s.t. π, s0|= Gψ ∨ ψU(ϕ ∧ ψ)

If π, s0|= Gψ, then ∀j, π, sj |= ψ, so that π, s0|= ϕRψ.

Otherwise, π, s0|= ψU(ϕ ∧ ψ).

Let sk be thefirststate s.t. π, sk 6|= ψ.

by construction, ∃k0such that π, Sk0 |= ϕ ∧ ψ

by the definition of k , we have that k0 <k and ∀w < k , π, Sw|= ψ.

Thus π, s |= ϕRψ

(40)

Linear Temporal Logic – LTL

Strength of LTL operators

Gϕ |= ϕ |= Fϕ Gϕ |= Xϕ |= Fϕ Gϕ |= XX...Xϕ |= Fϕ ϕUψ |= Fψ

Gψ |= ϕRψ

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 43 / 108

(41)

Linear Temporal Logic – LTL

LTL tableaux rules

Let ϕ1 and ϕ2 be LTL formulae:

1 ⇐⇒ (ϕ1∨ XFϕ1) 1 ⇐⇒ (ϕ1∧ XGϕ1)

ϕ12 ⇐⇒ (ϕ2∨ (ϕ1∧ X(ϕ12))) ϕ12 ⇐⇒ (ϕ2∧ (ϕ1∨ X(ϕ12)))

If applied recursively, rewrite an LTL formula in terms of atomic andX-formulas:

(pUq) ∧ (G¬p) =⇒ (q ∨ (p ∧ X(pUq))) ∧ (¬p ∧ XG¬p)

(42)

Linear Temporal Logic – LTL

Tableaux rules: a quote

“After all... tomorrow is another day."

[Scarlett O’Hara, “Gone with the Wind”]

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 45 / 108

(43)

Some LTL Model Checking Examples

Example 1: mutual exclusion (safety)

N1, N2 turn=0

turn=1 C1, T2

turn=1 T1, T2 T1, N2

turn=1

C1, N2 turn=1

T1, T2 turn=2 N = noncritical, T = trying, C = critical User 1 User 2

N1, T2 turn=2

T1, C2 turn=2

turn=2 N1, C2

M |=G¬(C1∧ C2)?

YES: There is no reachable state in which (C1∧ C2)holds!

(44)

Some LTL Model Checking Examples

Example 2: liveness

N1, N2 turn=0

turn=1 C1, T2

turn=1 T1, T2 T1, N2

turn=1

C1, N2 turn=1

T1, T2 turn=2 N = noncritical, T = trying, C = critical User 1 User 2

N1, T2 turn=2

T1, C2 turn=2

turn=2 N1, C2

M |=FC1?

NO: there is an infinite cyclic solution in which C1never holds!

Roberto Sebastiani Ch. 03: Temporal Logics Monday 18thMay, 2020 48 / 108

(45)

Some LTL Model Checking Examples

Example 3: liveness

N1, N2 turn=0

turn=1 C1, T2

turn=1 T1, T2 T1, N2

turn=1

C1, N2 turn=1

T1, T2 turn=2 N = noncritical, T = trying, C = critical User 1 User 2

N1, T2 turn=2

T1, C2 turn=2

turn=2 N1, C2

M |=G(T1→ FC1)?

YES: every path starting from each state where T1holds passes through a state where C1holds.

Riferimenti

Documenti correlati

handle temporal operators AX, EX by computing pre-images handle temporal operators AG, EG, AF, EF, AU, EU, by (implicitly) applying tableaux rules, until a fixpoint is reached..

Kripke structure encoded as Boolean formulas (OBDDs) All operations handled as (quantified) Boolean operations Avoids building the state graph explicitly. reduces dramatically the

(E.g., 300 Boolean vars =⇒ up to 2 300 ≈ 10 100 states!) State Space Explosion:.. too much

Copyright notice: some material (text, figures) displayed in these slides is courtesy of R..

Given a fair Kripke model M, a fair non-trivial SCC is an SCC with at least one edge that contains at least one state for every fair condition. =⇒ all states in a fair (non-trivial)

Example: although state 3 belongs to sat(¬heat Uclose), the path which loops forever in 3 does not satisfy ¬heatUclose, as close never holds in that path. We restrict the

[Alternatively: there is no positive U-subformula, so that we must add a AGAF&gt; fairness condition, which is equivalent to say that all states belong to the fairness

Given the following generalized Büchi automaton A def = hQ, Σ, δ, I, FT i, with two sets of accepting states FT def = {F 1, F 2} s.t.. Ex: