93
0/31 Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨ at des Saarlandes, Saarbr¨ ucken

Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

Embed Size (px)

Citation preview

Page 1: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

0/31

Model Checking

Andreas ZellerLehrstuhl SoftwaretechnikUniversitat des Saarlandes, Saarbrucken

Page 2: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

1/31

Ubersicht

• Motivation

• Temporale Logik

• Model Checking

• Binary Decision Diagrams

• Boolesche Programme

Page 3: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

2/31

Ein Mikrowellen-Herd

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

Page 4: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

3/31

Ein Mikrowellen-Herd (2)

Offene Fragen:

• Folgt auf den Zustand Start stets der Zustand Heat?

• Kann Heat vor Close auftreten?

• Kann Start nach Error auftreten?

Page 5: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

4/31

Temporale Logik

Zur Beschreibung von Ablaufen in der Zeit setzt mantemporale Logik ein.

Semantisches Modell: Zustandsubergange werden in einenunendlichen Baum (

”Berechnungsbaum“) entflochten

p, q

q, r r

s0

s1 s2

Page 6: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

4/31

Temporale Logik

Zur Beschreibung von Ablaufen in der Zeit setzt mantemporale Logik ein.

Semantisches Modell: Zustandsubergange werden in einenunendlichen Baum (

”Berechnungsbaum“) entflochten

p, q

q, r r

s0

s1 s2

p, q

q, r r

p, q rr

Page 7: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

4/31

Temporale Logik

Zur Beschreibung von Ablaufen in der Zeit setzt mantemporale Logik ein.

Semantisches Modell: Zustandsubergange werden in einenunendlichen Baum (

”Berechnungsbaum“) entflochten

p, q

q, r r

s0

s1 s2

p, q

q, r r

p, q rr

Uber die Pfade des Berechnungsbaums lassen sich Aussagentreffen – mit der Computation Tree Logic (CTL)

Page 8: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

5/31

CTL – Syntax

Eine Formel g in CTL ist aufgebaut wie folgt:

g ::=T |g|¬g|g1 ∨ g2|g1 ∧ g2

Page 9: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

5/31

CTL – Syntax

Eine Formel g in CTL ist aufgebaut wie folgt:

g ::=T |g|¬g|g1 ∨ g2|g1 ∧ g2

EX g g gilt in einem Folgezustand (”next“)

AX g g gilt in allen Folgezustanden

Page 10: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

5/31

CTL – Syntax

Eine Formel g in CTL ist aufgebaut wie folgt:

g ::=T |g|¬g|g1 ∨ g2|g1 ∧ g2

EX g g gilt in einem Folgezustand (”next“)

AX g g gilt in allen Folgezustanden

EF g g gilt irgendwann in einem Pfad (”finally“)

AF g g gilt irgendwann in allen Pfaden

Page 11: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

5/31

CTL – Syntax

Eine Formel g in CTL ist aufgebaut wie folgt:

g ::=T |g|¬g|g1 ∨ g2|g1 ∧ g2

EX g g gilt in einem Folgezustand (”next“)

AX g g gilt in allen Folgezustanden

EF g g gilt irgendwann in einem Pfad (”finally“)

AF g g gilt irgendwann in allen Pfaden

EG g g gilt stets in einem Pfad (”globally“)

AG g g gilt stets in allen Pfaden

Page 12: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

5/31

CTL – Syntax

Eine Formel g in CTL ist aufgebaut wie folgt:

g ::=T |g|¬g|g1 ∨ g2|g1 ∧ g2

EX g g gilt in einem Folgezustand (”next“)

AX g g gilt in allen Folgezustanden

EF g g gilt irgendwann in einem Pfad (”finally“)

AF g g gilt irgendwann in allen Pfaden

EG g g gilt stets in einem Pfad (”globally“)

AG g g gilt stets in allen Pfaden

E(f U g) f gilt in einem Pfad, bis g gilt (”until“)

A(f U g) f gilt in allen Pfaden, bis g gilt

Page 13: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

6/31

Die wichtigsten CTL-Idiome

(in Klammern: alternative Schreibweise aus Modallogik)

.

.

.

.

.

.

.

.

....

.

.

.

M, s0 î EF f(M, s0 î ∃♦ f )

Page 14: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

6/31

Die wichtigsten CTL-Idiome

(in Klammern: alternative Schreibweise aus Modallogik)

.

.

.

.

.

.

.

.

....

.

.

.

M, s0 î EF f(M, s0 î ∃♦ f )

.

.

.

.

.

.

.

.

....

.

.

.

M, s0 î AF f(M, s0 î ∀♦ f )

Page 15: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

6/31

Die wichtigsten CTL-Idiome

(in Klammern: alternative Schreibweise aus Modallogik)

.

.

.

.

.

.

.

.

....

.

.

.

M, s0 î EF f(M, s0 î ∃♦ f )

.

.

.

.

.

.

.

.

....

.

.

.

M, s0 î AF f(M, s0 î ∀♦ f )

.

.

.

.

.

.

.

.

....

.

.

.

M, s0 î EG f(M, s0 î ∃� f )

Page 16: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

6/31

Die wichtigsten CTL-Idiome

(in Klammern: alternative Schreibweise aus Modallogik)

.

.

.

.

.

.

.

.

....

.

.

.

M, s0 î EF f(M, s0 î ∃♦ f )

.

.

.

.

.

.

.

.

....

.

.

.

M, s0 î AF f(M, s0 î ∀♦ f )

.

.

.

.

.

.

.

.

....

.

.

.

M, s0 î EG f(M, s0 î ∃� f )

.

.

.

.

.

.

.

.

....

.

.

.

M, s0 î AG f(M, s0 î ∀� f )

M, s î f : f gilt im Modell M im Zustand s

Page 17: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

7/31

CTL – Beispiele

AG (¬p)”p gilt nie“

Page 18: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

7/31

CTL – Beispiele

AG (¬p)”p gilt nie“

AF A(p U q)”p gilt immer, bis q gilt“

Page 19: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

7/31

CTL – Beispiele

AG (¬p)”p gilt nie“

AF A(p U q)”p gilt immer, bis q gilt“

EF (p)”Irgendwo wird irgendwann p gelten“

Page 20: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

7/31

CTL – Beispiele

AG (¬p)”p gilt nie“

AF A(p U q)”p gilt immer, bis q gilt“

EF (p)”Irgendwo wird irgendwann p gelten“

AG (Start → AF Heat)”Aus Start folgt stets Heat“

Page 21: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

7/31

CTL – Beispiele

AG (¬p)”p gilt nie“

AF A(p U q)”p gilt immer, bis q gilt“

EF (p)”Irgendwo wird irgendwann p gelten“

AG (Start → AF Heat)”Aus Start folgt stets Heat“

AF (AG Deadlock)”Stets gibt es irgendwann einen

Deadlock, der fur immer anhalt“

Page 22: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

7/31

CTL – Beispiele

AG (¬p)”p gilt nie“

AF A(p U q)”p gilt immer, bis q gilt“

EF (p)”Irgendwo wird irgendwann p gelten“

AG (Start → AF Heat)”Aus Start folgt stets Heat“

AF (AG Deadlock)”Stets gibt es irgendwann einen

Deadlock, der fur immer anhalt“

AG (floor = 2∧ direction = up ∧ ButtonPressed5 →(direction = up U floor = 5)

”Der Aufzug andert seine Richtung nicht, bis er den 5. Stock

erreicht hat.“

Page 23: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

8/31

CTL – Semantik

(M: Modell, s: Zustand; L(S): Gultige Aussagen in s)

M, s î >,M, s 6î ⊥ fur alle Zustande sM, s î p a p ∈ L(s)M, s î ¬f a M, s 6î fM, s î f1 ∧ f2 a M, s î f1 und M, s î f2

M, s î f1 ∨ f2 a M, s î f1 oder M, s î f2

M, s î f1 → f2 a M, s 6î f1 oder M, s î f2

Page 24: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

9/31

CTL – Semantik (2)

(M: Modell, s: Zustand)

M, s î AX f a ∀s1|s → s1 ·M, s1 î fM, s î EX f a ∃s1|s → s1 ·M, s1 î fM, s1 î AG f a ∀π = (s1 → s2 → . . . ) · ∀si ·M, si î fM, s1 î EG f a ∃π = (s1 → s2 → . . . ) · ∀si ·M, si î fM, s1 î AF f a ∀π = (s1 → s2 → . . . ) · ∃si ·M, si î fM, s1 î EF f a ∃π = (s1 → s2 → . . . ) · ∃si ·M, si î fM, s1 î A(f1 U f2) a ∀π = (s1 → s2 → . . . )·

∃si · (M, si î f2)∧(∀j < i · (M, sj î f1)

)M, s1 î E(f1 U f2) a ∃π = (s1 → s2 → . . . )·

∃si · (M, si î f2)∧(∀j < i · (M, sj î f1)

)

Page 25: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

10/31

CTL – Einige Aquivalenzen

• f ∨ g ≡ ¬(¬f ∧¬g)• f → g ≡ ¬(f ∧¬g)• EG f ≡ ¬AF¬f• AG f ≡ ¬EF¬f• ¬AX f ≡ ¬AX¬f• AF f ≡ A(> U f)

• EF f ≡ E(> U f)

• A(f U g) ≡ ¬(E(¬g U (¬f ∧¬g))∨ EG¬g

)Tatsachlich reichen die Operatoren AF , E U und EX zusammenmit ∧ und ¬ aus, um alle CTL-Formeln zu schreiben (Ubung).

Page 26: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

11/31

Was gilt?

p, q

q, r r

s0

s1 s2

M, s0 î p ∧ q

Page 27: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

11/31

Was gilt?

p, q

q, r r

s0

s1 s2

M, s0 î p ∧ q jaM, s0 î ¬r

Page 28: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

11/31

Was gilt?

p, q

q, r r

s0

s1 s2

M, s0 î p ∧ q jaM, s0 î ¬r jaM, s0 î >

Page 29: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

11/31

Was gilt?

p, q

q, r r

s0

s1 s2

M, s0 î p ∧ q jaM, s0 î ¬r jaM, s0 î > jaM, s0 î EX (q ∧ r)

Page 30: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

11/31

Was gilt?

p, q

q, r r

s0

s1 s2

M, s0 î p ∧ q jaM, s0 î ¬r jaM, s0 î > jaM, s0 î EX (q ∧ r) jaM, s0 î ¬AX (q ∧ r)

Page 31: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

11/31

Was gilt?

p, q

q, r r

s0

s1 s2

M, s0 î p ∧ q jaM, s0 î ¬r jaM, s0 î > jaM, s0 î EX (q ∧ r) jaM, s0 î ¬AX (q ∧ r) jaM, s0 î ¬EF (p ∧ r)

Page 32: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

11/31

Was gilt?

p, q

q, r r

s0

s1 s2

M, s0 î p ∧ q jaM, s0 î ¬r jaM, s0 î > jaM, s0 î EX (q ∧ r) jaM, s0 î ¬AX (q ∧ r) jaM, s0 î ¬EF (p ∧ r) jaM, s2 î EG r

Page 33: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

11/31

Was gilt?

p, q

q, r r

s0

s1 s2

M, s0 î p ∧ q jaM, s0 î ¬r jaM, s0 î > jaM, s0 î EX (q ∧ r) jaM, s0 î ¬AX (q ∧ r) jaM, s0 î ¬EF (p ∧ r) jaM, s2 î EG r jaM, s2 î AG r

Page 34: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

11/31

Was gilt?

p, q

q, r r

s0

s1 s2

M, s0 î p ∧ q jaM, s0 î ¬r jaM, s0 î > jaM, s0 î EX (q ∧ r) jaM, s0 î ¬AX (q ∧ r) jaM, s0 î ¬EF (p ∧ r) jaM, s2 î EG r jaM, s2 î AG r jaM, s0 î AF r

Page 35: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

11/31

Was gilt?

p, q

q, r r

s0

s1 s2

M, s0 î p ∧ q jaM, s0 î ¬r jaM, s0 î > jaM, s0 î EX (q ∧ r) jaM, s0 î ¬AX (q ∧ r) jaM, s0 î ¬EF (p ∧ r) jaM, s2 î EG r jaM, s2 î AG r jaM, s0 î AF r jaM, s0 î E

((p ∧ q) U r)

Page 36: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

11/31

Was gilt?

p, q

q, r r

s0

s1 s2

M, s0 î p ∧ q jaM, s0 î ¬r jaM, s0 î > jaM, s0 î EX (q ∧ r) jaM, s0 î ¬AX (q ∧ r) jaM, s0 î ¬EF (p ∧ r) jaM, s2 î EG r jaM, s2 î AG r jaM, s0 î AF r jaM, s0 î E

((p ∧ q) U r) ja

M, s0 î A(p U r)

Page 37: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

11/31

Was gilt?

p, q

q, r r

s0

s1 s2

M, s0 î p ∧ q jaM, s0 î ¬r jaM, s0 î > jaM, s0 î EX (q ∧ r) jaM, s0 î ¬AX (q ∧ r) jaM, s0 î ¬EF (p ∧ r) jaM, s2 î EG r jaM, s2 î AG r jaM, s0 î AF r jaM, s0 î E

((p ∧ q) U r) ja

M, s0 î A(p U r) ja

Page 38: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

12/31

Anwendung: CORBA-Protokoll

(Kamel, Leue, Holzmann et al 1998)

After sending an SRequest, the GIOP agent should eventuallyreceive a corresponding SReply

AG (SRequest → AF SReply)

The agent should never receive an SReply for a request that isnot outstanding

AF SReply → A(¬SReply U (SRequest ∧¬SReply)

)

Page 39: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

13/31

Anwendung: CORBA-Protokoll (2)

Servers may only issue CloseConnection messages whenReply messages have been sent in response to all receivedRequest messages that require replies

AF close →(AG (request → A(A(¬close U reply) U close))

)

Page 40: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

13/31

Anwendung: CORBA-Protokoll (2)

Servers may only issue CloseConnection messages whenReply messages have been sent in response to all receivedRequest messages that require replies

AF close →(AG (request → A(A(¬close U reply) U close))

)Was passiert bei π = request, request, reply, close?

Page 41: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

13/31

Anwendung: CORBA-Protokoll (2)

Servers may only issue CloseConnection messages whenReply messages have been sent in response to all receivedRequest messages that require replies

AF close →(AG (request → A(A(¬close U reply) U close))

)Was passiert bei π = request, request, reply, close?

Verbesserte Fassung:

AF close →(AG (request → A(A(¬close U reply) U close))

)∧N

mit N ≡ #(request) = #(reply)

Page 42: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

14/31

Model Checking

Gegeben:

• Modell M als endlicher Automat mit Ursprungszustand s0

• CTL-Formel f (Spezifikation)

Model Checking pruft, ob alle Pfade durch den Automaten(= des Berechnungsbaums) die Spezifikation erfullen(M, s0 î f )

Falls M, s0 6î f , wird Gegenbeispiel konstruiert

Page 43: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

15/31

Vorgehensweise

Wir bestimmen alle Zustande si aus M, die f erfullen.(Ist s0 in diesen Zustanden, so gilt M, s0 î f )

Ubersicht:

1. Wir schreiben die CTL-Formel so um, daß nur AF , E U undEX zusammen mit ∧ und ¬ auftreten.

2. Wir attribuieren die Zustande des Modells mit erfulltenTeilformeln von f .

Page 44: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

16/31

Attribuierung

Wir arbeiten die Formel f rekursiv durch – bottom up von denTeilformeln f1, f2, . . . zur Gesamtformel:

Hat f die Form

• ⊥ – Keine Zustande werden attribuiert

• p – Attribuiere s mit p wenn p ∈ L(s)• f1 ∧ f2 – Attribuiere s mit f1 ∧ f2, wenn s mit f1 und f2

attribuiert ist

• ¬f1 – Attribuiere s mit ¬f1, wenn s nicht mit f1 attribuiertist

• EX f1 – Attribuiere jeden Zustand mit EX f1, dessenNachfolger mit f1 attribuiert ist

Page 45: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

17/31

Attribuierung (2)

Hat f die Form AF f1:

• Ist irgendein Zustand mit f1 attribuiert, attribuiere ihn mitAF f1

• Attribuiere jeden Zustand, dessen Nachfolger mit AF f1

attribuiert sind, ebenfalls mit AF f1 – bis keine Anderungmehr auftritt

AF f1

AF f1

AF f1

AF f1

AF f1

AF f1

AF f1

Page 46: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

18/31

Attribuierung (3)

Hat f die Form E(f1 U f2):

• Ist irgendein Zustand mit f2 attribuiert, attribuiere ihn mitE(f1 U f2)

• Attribuiere jeden Zustand, der mit f1 attribuiert ist, mitE(f1 U f2), wenn einer seiner Nachfolger mit E(f1 U f2)attribuiert ist – bis keine Anderung mehr auftritt

E(f1 U f2)

f1

E(f1 U f2)

f1E(f1 U f2)

Page 47: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

19/31

Attribuierung (4)

Nachdem f und alle Unterformeln bearbeitet wurden, erfullengenau die Zustande f , die mit f attribuiert sind.

Komplexitat des Verfahrens: O(f · V · (V + E)) mitf = Anzahl der Operatoren,V = Anzahl der Zustande (Knoten),E = Anzahl der Ubergange (Kanten)

Page 48: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

19/31

Attribuierung (4)

Nachdem f und alle Unterformeln bearbeitet wurden, erfullengenau die Zustande f , die mit f attribuiert sind.

Komplexitat des Verfahrens: O(f · V · (V + E)) mitf = Anzahl der Operatoren,V = Anzahl der Zustande (Knoten),E = Anzahl der Ubergange (Kanten)

Effizientere Variante in O(f · (V + E))

• Basiert auf EG statt AF

• Benutzt Breitensuche auf Modell, um E zu berechnen

• Benutzt stark zusammenhangende Komponenten(= Subgraph, in dem es von jedem Knoten einen Pfad zujedem anderen Knoten gibt), um EG effizient zu berechnen.

Page 49: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

20/31

Beispiel: Mikrowellen-Herd

Kommt nach dem Start stets Hitze (f = AG (Start → AF Heat))?

Page 50: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

20/31

Beispiel: Mikrowellen-Herd

Kommt nach dem Start stets Hitze (f = AG (Start → AF Heat))?

Umformung nachf = AG (¬Start ∨ AF Heat)= ¬EF (Start ∧¬AF Heat)= ¬E(> U (Start ∧¬AF Heat)

Page 51: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

20/31

Beispiel: Mikrowellen-Herd

Kommt nach dem Start stets Hitze (f = AG (Start → AF Heat))?

Umformung nachf = AG (¬Start ∨ AF Heat)= ¬EF (Start ∧¬AF Heat)= ¬E(> U (Start ∧¬AF Heat)

Wir definieren:f1 = AF Heat

Page 52: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

20/31

Beispiel: Mikrowellen-Herd

Kommt nach dem Start stets Hitze (f = AG (Start → AF Heat))?

Umformung nachf = AG (¬Start ∨ AF Heat)= ¬EF (Start ∧¬AF Heat)= ¬E(> U (Start ∧¬AF Heat)

Wir definieren:f1 = AF Heatf2 = ¬f1

Page 53: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

20/31

Beispiel: Mikrowellen-Herd

Kommt nach dem Start stets Hitze (f = AG (Start → AF Heat))?

Umformung nachf = AG (¬Start ∨ AF Heat)= ¬EF (Start ∧¬AF Heat)= ¬E(> U (Start ∧¬AF Heat)

Wir definieren:f1 = AF Heatf2 = ¬f1

f3 = Start ∧ f2

Page 54: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

20/31

Beispiel: Mikrowellen-Herd

Kommt nach dem Start stets Hitze (f = AG (Start → AF Heat))?

Umformung nachf = AG (¬Start ∨ AF Heat)= ¬EF (Start ∧¬AF Heat)= ¬E(> U (Start ∧¬AF Heat)

Wir definieren:f1 = AF Heatf2 = ¬f1

f3 = Start ∧ f2

f4 = E(> U f3)

Page 55: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

20/31

Beispiel: Mikrowellen-Herd

Kommt nach dem Start stets Hitze (f = AG (Start → AF Heat))?

Umformung nachf = AG (¬Start ∨ AF Heat)= ¬EF (Start ∧¬AF Heat)= ¬E(> U (Start ∧¬AF Heat)

Wir definieren:f1 = AF Heatf2 = ¬f1

f3 = Start ∧ f2

f4 = E(> U f3)f = ¬f4

Page 56: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

20/31

Beispiel: Mikrowellen-Herd

Kommt nach dem Start stets Hitze (f = AG (Start → AF Heat))?

Umformung nachf = AG (¬Start ∨ AF Heat)= ¬EF (Start ∧¬AF Heat)= ¬E(> U (Start ∧¬AF Heat)

Wir definieren:f1 = AF Heatf2 = ¬f1

f3 = Start ∧ f2

f4 = E(> U f3)f = ¬f4

Annahme: SAT(f ) berechnet Menge der Zustande, die mit fattribuiert sind (Ubung): M,1 î f a 1 ∈ SAT(f )

Page 57: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

21/31

Beispiel: Mikrowellen-Herd (2)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Heatf2 = ¬f1

f3 = Start ∧ f2

f4 = E(> U f3)f = ¬f4

SAT(f1) =

Page 58: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

21/31

Beispiel: Mikrowellen-Herd (2)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Heatf2 = ¬f1

f3 = Start ∧ f2

f4 = E(> U f3)f = ¬f4

SAT(f1) = {4,6,7}SAT(f2) =

Page 59: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

21/31

Beispiel: Mikrowellen-Herd (2)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Heatf2 = ¬f1

f3 = Start ∧ f2

f4 = E(> U f3)f = ¬f4

SAT(f1) = {4,6,7}SAT(f2) = {1,2,3,5}SAT(f3) =

Page 60: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

21/31

Beispiel: Mikrowellen-Herd (2)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Heatf2 = ¬f1

f3 = Start ∧ f2

f4 = E(> U f3)f = ¬f4

SAT(f1) = {4,6,7}SAT(f2) = {1,2,3,5}SAT(f3) = {2,5}SAT(f4) =

Page 61: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

21/31

Beispiel: Mikrowellen-Herd (2)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Heatf2 = ¬f1

f3 = Start ∧ f2

f4 = E(> U f3)f = ¬f4

SAT(f1) = {4,6,7}SAT(f2) = {1,2,3,5}SAT(f3) = {2,5}SAT(f4) = {1,2,5}SAT(f ) =

Page 62: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

21/31

Beispiel: Mikrowellen-Herd (2)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Heatf2 = ¬f1

f3 = Start ∧ f2

f4 = E(> U f3)f = ¬f4

SAT(f1) = {4,6,7}SAT(f2) = {1,2,3,5}SAT(f3) = {2,5}SAT(f4) = {1,2,5}SAT(f ) = {3,4,6,7}

Page 63: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

21/31

Beispiel: Mikrowellen-Herd (2)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Heatf2 = ¬f1

f3 = Start ∧ f2

f4 = E(> U f3)f = ¬f4

SAT(f1) = {4,6,7}SAT(f2) = {1,2,3,5}SAT(f3) = {2,5}SAT(f4) = {1,2,5}SAT(f ) = {3,4,6,7}

1 6∈ SAT(f ) !

Page 64: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

22/31

Beispiel: Mikrowellen-Herd (3)

Kommt die Hitze stets, nachdem die Tur geschlossen ist(f = A(¬Heat U Close))?

Page 65: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

22/31

Beispiel: Mikrowellen-Herd (3)

Kommt die Hitze stets, nachdem die Tur geschlossen ist(f = A(¬Heat U Close))?

Umformung nachf = ¬

(E(¬Close U (Heat ∧¬Close))∨ EG¬Close)

= ¬(E(¬Close U (Heat ∧¬Close))∨¬AF Close)

Page 66: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

22/31

Beispiel: Mikrowellen-Herd (3)

Kommt die Hitze stets, nachdem die Tur geschlossen ist(f = A(¬Heat U Close))?

Umformung nachf = ¬

(E(¬Close U (Heat ∧¬Close))∨ EG¬Close)

= ¬(E(¬Close U (Heat ∧¬Close))∨¬AF Close)

Wir definieren:f1 = AF Close

Page 67: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

22/31

Beispiel: Mikrowellen-Herd (3)

Kommt die Hitze stets, nachdem die Tur geschlossen ist(f = A(¬Heat U Close))?

Umformung nachf = ¬

(E(¬Close U (Heat ∧¬Close))∨ EG¬Close)

= ¬(E(¬Close U (Heat ∧¬Close))∨¬AF Close)

Wir definieren:f1 = AF Closef2 = ¬f1

Page 68: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

22/31

Beispiel: Mikrowellen-Herd (3)

Kommt die Hitze stets, nachdem die Tur geschlossen ist(f = A(¬Heat U Close))?

Umformung nachf = ¬

(E(¬Close U (Heat ∧¬Close))∨ EG¬Close)

= ¬(E(¬Close U (Heat ∧¬Close))∨¬AF Close)

Wir definieren:f1 = AF Closef2 = ¬f1

f3 = Heat ∧¬Close

Page 69: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

22/31

Beispiel: Mikrowellen-Herd (3)

Kommt die Hitze stets, nachdem die Tur geschlossen ist(f = A(¬Heat U Close))?

Umformung nachf = ¬

(E(¬Close U (Heat ∧¬Close))∨ EG¬Close)

= ¬(E(¬Close U (Heat ∧¬Close))∨¬AF Close)

Wir definieren:f1 = AF Closef2 = ¬f1

f3 = Heat ∧¬Closef4 = E(¬Close U f3))

Page 70: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

22/31

Beispiel: Mikrowellen-Herd (3)

Kommt die Hitze stets, nachdem die Tur geschlossen ist(f = A(¬Heat U Close))?

Umformung nachf = ¬

(E(¬Close U (Heat ∧¬Close))∨ EG¬Close)

= ¬(E(¬Close U (Heat ∧¬Close))∨¬AF Close)

Wir definieren:f1 = AF Closef2 = ¬f1

f3 = Heat ∧¬Closef4 = E(¬Close U f3))f5 = ¬f4

Page 71: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

22/31

Beispiel: Mikrowellen-Herd (3)

Kommt die Hitze stets, nachdem die Tur geschlossen ist(f = A(¬Heat U Close))?

Umformung nachf = ¬

(E(¬Close U (Heat ∧¬Close))∨ EG¬Close)

= ¬(E(¬Close U (Heat ∧¬Close))∨¬AF Close)

Wir definieren:f1 = AF Closef2 = ¬f1

f3 = Heat ∧¬Closef4 = E(¬Close U f3))f5 = ¬f4

f = f5 ∨ f2

Page 72: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

23/31

Beispiel: Mikrowellen-Herd (4)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Closef2 = ¬f1

f3 = Heat ∧¬Closef4 = E(¬Close U f3))f5 = ¬f4

f = f5 ∨ f2

Page 73: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

23/31

Beispiel: Mikrowellen-Herd (4)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Closef2 = ¬f1

f3 = Heat ∧¬Closef4 = E(¬Close U f3))f5 = ¬f4

f = f5 ∨ f2

SAT(f1) =

Page 74: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

23/31

Beispiel: Mikrowellen-Herd (4)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Closef2 = ¬f1

f3 = Heat ∧¬Closef4 = E(¬Close U f3))f5 = ¬f4

f = f5 ∨ f2

SAT(f1) = {1,2, . . . ,7}SAT(f2) =

Page 75: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

23/31

Beispiel: Mikrowellen-Herd (4)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Closef2 = ¬f1

f3 = Heat ∧¬Closef4 = E(¬Close U f3))f5 = ¬f4

f = f5 ∨ f2

SAT(f1) = {1,2, . . . ,7}SAT(f2) = ∅SAT(f3) =

Page 76: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

23/31

Beispiel: Mikrowellen-Herd (4)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Closef2 = ¬f1

f3 = Heat ∧¬Closef4 = E(¬Close U f3))f5 = ¬f4

f = f5 ∨ f2

SAT(f1) = {1,2, . . . ,7}SAT(f2) = ∅SAT(f3) = ∅SAT(f4) =

Page 77: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

23/31

Beispiel: Mikrowellen-Herd (4)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Closef2 = ¬f1

f3 = Heat ∧¬Closef4 = E(¬Close U f3))f5 = ¬f4

f = f5 ∨ f2

SAT(f1) = {1,2, . . . ,7}SAT(f2) = ∅SAT(f3) = ∅SAT(f4) = ∅SAT(f5) =

Page 78: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

23/31

Beispiel: Mikrowellen-Herd (4)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Closef2 = ¬f1

f3 = Heat ∧¬Closef4 = E(¬Close U f3))f5 = ¬f4

f = f5 ∨ f2

SAT(f1) = {1,2, . . . ,7}SAT(f2) = ∅SAT(f3) = ∅SAT(f4) = ∅SAT(f5) = {1,2, . . . ,7}SAT(f ) =

Page 79: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

23/31

Beispiel: Mikrowellen-Herd (4)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Closef2 = ¬f1

f3 = Heat ∧¬Closef4 = E(¬Close U f3))f5 = ¬f4

f = f5 ∨ f2

SAT(f1) = {1,2, . . . ,7}SAT(f2) = ∅SAT(f3) = ∅SAT(f4) = ∅SAT(f5) = {1,2, . . . ,7}SAT(f ) = {1,2, . . . ,7}

Page 80: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

23/31

Beispiel: Mikrowellen-Herd (4)

~Start~Close~Heat~Error

Start~Close~HeatError

~StartClose~Heat~Error

~StartCloseHeat

~Error

StartClose~HeatError

StartClose~Heat~Error

StartCloseHeat

~Error

start oven

open door

open door

open door

close door

done

start cooking

warmup

reset

start ovenclose door

cook

1

2 3 4

5 6 7

f1 = AF Closef2 = ¬f1

f3 = Heat ∧¬Closef4 = E(¬Close U f3))f5 = ¬f4

f = f5 ∨ f2

SAT(f1) = {1,2, . . . ,7}SAT(f2) = ∅SAT(f3) = ∅SAT(f4) = ∅SAT(f5) = {1,2, . . . ,7}SAT(f ) = {1,2, . . . ,7}

1 ∈ SAT(f ) !

Page 81: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

24/31

Alternative Logiken

LTL (Linear Time Logic) Formeln beziehen sich nicht aufZustandsbaum, sondern auf (alle) Pfade des Systems.

Pfadquantoren E,A aus CTL entfallen; dafur konnenBoolesche Verknupfungen und Temporaloperatorenbeliebig verschachtelt werden:

G F p → F q”gilt p immer, dann auch irgendwann q“.

Page 82: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

24/31

Alternative Logiken

LTL (Linear Time Logic) Formeln beziehen sich nicht aufZustandsbaum, sondern auf (alle) Pfade des Systems.

Pfadquantoren E,A aus CTL entfallen; dafur konnenBoolesche Verknupfungen und Temporaloperatorenbeliebig verschachtelt werden:

G F p → F q”gilt p immer, dann auch irgendwann q“.

CTL∗ Kombination aus LTL und CTL; CTL∗ ⊇ LTL∪ CTL

Pfadquantoren und Temporaloperatoren konnen wie in LTLbeliebig verschachtelt werden:

E(G F p)”Es gibt einen Pfad, in dem p unendlich oft

wahr wird“

Erstaunlicherweise keine erhohte Komplexitat!

Page 83: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

25/31

Problem: Zustandsexplosion

Auch wenn wir ein Modell effizient prufen konnen, kann dasModell selbst immer noch sehr groß sein.

Beispiel: 100 (boolesche) Variablen ⇒ 2100 Zustande

Losung: Ordered Binary Decision Diagram (OBDD) –ermoglicht geteilte Darstellung von Formeln

Page 84: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

26/31

Zwei-Bit-Vergleicher

Problem: Zwei Bitfolgen a1a2 und b1b2 vergleichen

f(a1, b1, a2, b2) = (a1 ↔ b1)∧ (a2 ↔ b2)

Page 85: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

26/31

Zwei-Bit-Vergleicher

Problem: Zwei Bitfolgen a1a2 und b1b2 vergleichen

f(a1, b1, a2, b2) = (a1 ↔ b1)∧ (a2 ↔ b2)

b20 1

b20 1

b20 1

b20 1

b20 1

b20 1

b20 1

b20 1

a2

0 1

a2

0 1

a2

0 1

a2

0 1

b1

0 1

b1

0 1

a10 1

0 0 0 0 0 0 0 0 0 0 0 01 1 1 1

Als Entscheidungsbaum

Page 86: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

26/31

Zwei-Bit-Vergleicher

Problem: Zwei Bitfolgen a1a2 und b1b2 vergleichen

f(a1, b1, a2, b2) = (a1 ↔ b1)∧ (a2 ↔ b2)

b20 1

b20 1

b20 1

b20 1

b20 1

b20 1

b20 1

b20 1

a2

0 1

a2

0 1

a2

0 1

a2

0 1

b1

0 1

b1

0 1

a10 1

0 0 0 0 0 0 0 0 0 0 0 01 1 1 1

Als Entscheidungsbaum

b1 b1

a1

0 1

01

a2

b2 b2

0

0

0

01

1

1

1

011

Als OBDD

Page 87: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

27/31

OBDDs und Model Checking

Mit OBDDs konnen auch große Zustandsraume effizientabgelegt werden; gleichzeitig gibt es effiziente Operationenauf OBDDs

Symbolisches Model Checking stellt Modell(= Entscheidungsbaum) und Spezifikation (= logische Formel)als OBDDs dar und pruft, ob Formel im Modell enthalten ist.

⇒ Auch große (Software-)Systeme werden so modellierbar

Page 88: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

28/31

Anwendungen von Model Checking

• Hardware (routinemaßig)

• Protokollverifikation (AT&T, CORBA)

• Software (wenn Abstraktion zu endl. Automat existiert)

• Raumsonden (NASA)

• Testdatengenerierung (via Gegenbeispiel)

• Space Shuttle Resttungsprogramm (NASA)

Page 89: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

29/31

Boolesche Programme

Laßt sich Model Checking auch auf komplexe Programmeanwenden?

Grundidee: Abbildung des Programms in BooleschesProgramm:

• Alle Datentypen werden zu Booleans

• Alle Bedingungen werden zu Booleschen Pradikaten

Auf der so gewonnenen Abstraktion kann dann ModelChecking ausgefuhrt werden

Page 90: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

29/31

Boolesche Programme

Laßt sich Model Checking auch auf komplexe Programmeanwenden?

Grundidee: Abbildung des Programms in BooleschesProgramm:

• Alle Datentypen werden zu Booleans

• Alle Bedingungen werden zu Booleschen Pradikaten

Auf der so gewonnenen Abstraktion kann dann ModelChecking ausgefuhrt werden

Ansatz von Microsoft Research zum Verifizieren vonGeratetreibern (mit Andreas Podelski vom MPI)

Page 91: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

29/31

Boolesche Programme

Laßt sich Model Checking auch auf komplexe Programmeanwenden?

Grundidee: Abbildung des Programms in BooleschesProgramm:

• Alle Datentypen werden zu Booleans

• Alle Bedingungen werden zu Booleschen Pradikaten

Auf der so gewonnenen Abstraktion kann dann ModelChecking ausgefuhrt werden

Ansatz von Microsoft Research zum Verifizieren vonGeratetreibern (mit Andreas Podelski vom MPI)

Mehr in dessen Vorlesungen!

Page 92: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

30/31

Zusammenfassung

Model Checking

• ist ein effizientes Verfahren zur Verifikation endlicherModelle

• basiert auf spezieller Logik (CTL, LTL, CTL∗), in derAnfragen gestellt werden

• pruft Anfragen durch Attribuierung des Modells

• benutzt OBDDs, um Zustandsexplosion zu vermeiden

• findet breite industrielle Anwendung

Page 93: Model Checking - st.cs.uni-saarland.de · Model Checking Andreas Zeller Lehrstuhl Softwaretechnik Universit¨at des Saarlandes, ... (CTL) 5/31 CTL – Syntax Eine Formel g in CTL

31/31

Literatur

The SPIN Model Checker http://netlib.bell-labs.com/netlib/spin/whatispin.html

The SLAM Projecthttp://research.microsoft.com/projects/slam/

Model Checking (Clarke, Grumberg, Peled)