• Nie Znaleziono Wyników

Computer aided verification

N/A
N/A
Protected

Academic year: 2022

Share "Computer aided verification"

Copied!
78
0
0

Pełen tekst

(1)

Computer aided verification

Lecture 8:

Abstraction

Sławomir Lasota University of Warsaw

(2)

Abstraction

– Model M = (S, S0, L, R)

– Abstraction = reduction of the size of the model by removing irrelevant details

system

 //

M

 //

Mc

correctness property

 //

φ

.

n 77n n n n n n n n n n n n n

n

c

M  φ ?

(3)

Abstraction

– Model M = (S, S0, L, R)

– Abstraction = reduction of the size of the model by removing irrelevant details

system

 //

M

 //

Mc

correctness property

 //

φ

.

n 77n n n n n n n n n n n n n

n

c

M  φ ?

– We hope that computing cM and checking cM |= φ is cheaper than checking M |= φ.

(4)

Abstraction

– Model M = (S, S0, L, R)

– Abstraction = reduction of the size of the model by removing irrelevant details

system

 //

M

 //

Mc

correctness property

 //

φ

.

n 77n n n n n n n n n n n n n

n

c

M  φ ?

– We hope that computing cM and checking cM |= φ is cheaper than checking M |= φ.

– Abstract model cM = ( bS, cS0, bL, bR) (concrete model M = (S, S0, L, R))

(5)

Existential abstraction

(6)

Existential abstraction

[Clarke, Grumberg, Jha, Lu, Veith 2003]

(7)

Existential abstraction

[Clarke, Grumberg, Jha, Lu, Veith 2003]

– Abstraction function h : M → cM (h : S → bS)

(8)

Existential abstraction

[Clarke, Grumberg, Jha, Lu, Veith 2003]

– Abstraction function h : M → cM (h : S → bS) – Existential abstraction:

– ∃s ∈ S0. h(s) = bs =⇒ bs ∈ cS0

– ∃s, s ∈ S. R(s, s) ∧ h(s) = bs ∧ h(s) = bs =⇒ Rb(bs, bs)

(9)

Existential abstraction

[Clarke, Grumberg, Jha, Lu, Veith 2003]

– Abstraction function h : M → cM (h : S → bS) – Existential abstraction:

– ∃s ∈ S0. h(s) = bs =⇒ bs ∈ cS0

– ∃s, s ∈ S. R(s, s) ∧ h(s) = bs ∧ h(s) = bs =⇒ Rb(bs, bs)

(10)

Minimal existential abstraction

[Clarke, Grumberg, Jha, Lu, Veith 2003]

– Abstraction function h : M → cM (h : s → bS) – Minimal existential abstraction:

– ∃s ∈ S0. h(s) = bs ⇐⇒ sb∈ cS0

– ∃s, s ∈ S. R(s, s) ∧ h(s) = bs ∧ h(s) = bs ⇐⇒ Rb(bs, bs) – We say that cM overapproximates M.

(11)

Model

Hardware: M = (S, S0, L, R) V = {x1, . . . , xn} S = Dn R, S0, L represented by formulas

abstraction applies to representation of the model

Software: abstraction applies to program source running example: predicate abstraction

(12)

Predicate abstraction – basic idea

Example: Predicate x > 0

hx>0 : D → {true, false} hx>0(d) =

true d > 0 false d ≤ 0

(13)

Predicate abstraction – basic idea

Example: Predicate x > 0

hx>0 : D → {true, false} hx>0(d) =

true d > 0 false d ≤ 0

x = 0

_

x−−



false

_

x−−



x = −1 false

(14)

Predicate abstraction – basic idea

Example: Predicate x > 0

hx>0 : D → {true, false} hx>0(d) =

true d > 0 false d ≤ 0

x = 0

_

x−−



false

_

x−−



x = −1 false

x = 5

_

x−−



true

_

x−−



x = 4 true or false?

nondeterminism!

(15)

Boolean programs

h : Dn → {true, false}m

(16)

Correctness via simulation

(17)

Simulation game G

M c M

– players: Spoiler, Duplicator

(18)

Simulation game G

M c M

– players: Spoiler, Duplicator – configurations: hs, bsi

(19)

Simulation game G

M c M

– players: Spoiler, Duplicator – configurations: hs, bsi

– initial configuration: hs0, bs0i (assuming one initial state in M and cM)

(20)

Simulation game G

M c M

– players: Spoiler, Duplicator – configurations: hs, bsi

– initial configuration: hs0, bs0i (assuming one initial state in M and cM) – if L(s) 6= L(bs), Spoiler wins

(21)

Simulation game G

M c M

– players: Spoiler, Duplicator – configurations: hs, bsi

– initial configuration: hs0, bs0i (assuming one initial state in M and cM) – if L(s) 6= L(bs), Spoiler wins

– a round

– Spoiler chooses a transition s −→ r in M (assuming M total) – Duplicator answers with a transition bs −→ br in cM (assuming cM total) – the play continues from the configuration hr, bri

(22)

Simulation game G

M c M

– players: Spoiler, Duplicator – configurations: hs, bsi

– initial configuration: hs0, bs0i (assuming one initial state in M and cM) – if L(s) 6= L(bs), Spoiler wins

– a round

– Spoiler chooses a transition s −→ r in M (assuming M total) – Duplicator answers with a transition bs −→ br in cM (assuming cM total) – the play continues from the configuration hr, bri

– if the play is infinite, Duplicator wins

(23)

Simulation game G

M c M

– players: Spoiler, Duplicator – configurations: hs, bsi

– initial configuration: hs0, bs0i (assuming one initial state in M and cM) – if L(s) 6= L(bs), Spoiler wins

– a round

– Spoiler chooses a transition s −→ r in M (assuming M total) – Duplicator answers with a transition bs −→ br in cM (assuming cM total) – the play continues from the configuration hr, bri

– if the play is infinite, Duplicator wins

Question: How to adapt the definition for non-total models?

(24)

Simulation game G

M c M

– players: Spoiler, Duplicator – configurations: hs, bsi

– initial configuration: hs0, bs0i (assuming one initial state in M and cM) – if L(s) 6= L(bs), Spoiler wins

– a round

– Spoiler chooses a transition s −→ r in M (assuming M total) – Duplicator answers with a transition bs −→ br in cM (assuming cM total) – the play continues from the configuration hr, bri

– if the play is infinite, Duplicator wins

Question: How to adapt the definition for non-total models?

Question: How to adapt the definition for models with more initial states?

(25)

Simulation pre-order

Def.: M  cM ⇐⇒ Duplicator has a winning strategy in the game GM cM

Example:

GFED

@ABC

p, q

 ?>=<

89:;

p

}}|| || || || ||

C !!C C C C C C C C

7654

0123 ?>=< 89:;

q

6

GFED

@ABC

p, q

}}|| || || || |

C !!C C C C C C C C

?>=<

89:;

p



?>=<

89:;

p

 7654

0123 ?>=< 89:;

q

(26)

Correctness via simulation

Simulation preorder is conservative:

Thm.: M  cM =⇒ (∀φ ∈ ACTL. cM  φ =⇒ M  φ)

(27)

Correctness via simulation

Simulation preorder is conservative:

Thm.: M  cM =⇒ (∀φ ∈ ACTL. cM  φ =⇒ M  φ) Thm.: M  cM =⇒ (∀φ ∈ ECTL. M  φ =⇒ M  φ)c

(28)

Correctness via simulation

Simulation preorder is conservative:

Thm.: M  cM =⇒ (∀φ ∈ ACTL. cM  φ =⇒ M  φ) Thm.: M  cM =⇒ (∀φ ∈ ECTL. M  φ =⇒ M  φ)c

Def.: Simulation equivalence: ≃ =  ∩ 

Thm.: M ≃ cM =⇒ (∀φ ∈ ACTL. cM  φ ⇐⇒ M  φ)

(29)

Correctness of existential abstraction

[Clarke, Grumberg, Jha, Lu, Veith 2003]

Abstraction function h : M → cM

Thm.: M  cM, if h preserves the atomic properties

(30)

Fair simulation game G

M c M

– players: Spoiler, Duplicator – configurations: hs, bsi

– initial configuration: hs0, bs0i (assuming one initial state in M and cM) – if L(s) 6= L(bs), Spoiler wins

(31)

Fair simulation game G

M c M

– players: Spoiler, Duplicator – configurations: hs, bsi

– initial configuration: hs0, bs0i (assuming one initial state in M and cM) – if L(s) 6= L(bs), Spoiler wins

– a round

– Spoiler chooses a fair path s −→ s1 −→ s2 −→ . . . (assuming M total) – Duplicator answers with a fair path bs −→ bs1 −→ bs2 −→ . . .

– Spoiler chooses i

– the play continues from the configuration hsi, bsii

(32)

Fair simulation game G

M c M

– players: Spoiler, Duplicator – configurations: hs, bsi

– initial configuration: hs0, bs0i (assuming one initial state in M and cM) – if L(s) 6= L(bs), Spoiler wins

– a round

– Spoiler chooses a fair path s −→ s1 −→ s2 −→ . . . (assuming M total) – Duplicator answers with a fair path bs −→ bs1 −→ bs2 −→ . . .

– Spoiler chooses i

– the play continues from the configuration hsi, bsii – if the play is infinite, Duplicator wins

(33)

Summary

M  cM ∀φ ∈ ACTL. cM  φ =⇒ M  φ M F Mc ∀φ ∈ ACTL. cM F φ =⇒ M F φ M ≃ cM ∀φ ∈ ACTL. M  φ ⇐⇒ cM  φ M ≃F Mc ∀φ ∈ ACTL. M F φ ⇐⇒ cM F φ M ∼ cM ∀φ ∈ CTL. M  φ ⇐⇒ cM  φ M ∼F Mc ∀φ ∈ CTL. M F φ ⇐⇒ cM F φ Lω(M ) ⊆ Lω( cM) ∀φ ∈ LTL. cM  φ =⇒ M  φ Lω(M ) = Lω( cM) ∀φ ∈ LTL. M  φ ⇐⇒ cM  φ

(34)

CEGAR

(35)

CEGAR

Counter-example guided abstraction refinement (1) Compute initial abstraction

(36)

CEGAR

Counter-example guided abstraction refinement

(1) Compute initial abstraction (2) Repeat:

– verify the abstract model

– if the result positive – answer yes and stop

– if the result negative – abstract counterexample

(37)

CEGAR

Counter-example guided abstraction refinement

(1) Compute initial abstraction (2) Repeat:

– verify the abstract model

– if the result positive – answer yes and stop

– if the result negative – abstract counterexample – check feasibility of the counterexample

– if the counterexample feasible – answer no and stop

(38)

CEGAR

Counter-example guided abstraction refinement

(1) Compute initial abstraction (2) Repeat:

– verify the abstract model

– if the result positive – answer yes and stop

– if the result negative – abstract counterexample – check feasibility of the counterexample

– if the counterexample feasible – answer no and stop

– refine the abstraction to eliminate the unfeasible counterexample

(39)

CEGAR loop

M, φ

  

 

computation of

abstraction abstract model cM

//

 

 

verification Mc |= φ?

counterexample

 //

M  φ

 

 

abstraction refinement

OO

 

 

counterexample

simulation feasible

//

unfeasible

oo

M 6 φ

(40)

CEGAR loop

M, φ

  

 

computation of

abstraction abstract model cM

//

 

 

verification Mc |= φ?

counterexample

 //

M  φ

 

 

abstraction refinement

OO

 

 

counterexample

simulation feasible

//

unfeasible

oo

M 6 φ

– correctness: whenever CEGAR stops the answer is correct

(41)

CEGAR loop

M, φ

  

 

computation of

abstraction abstract model cM

//

 

 

verification Mc |= φ?

counterexample

 //

M  φ

 

 

abstraction refinement

OO

 

 

counterexample

simulation feasible

//

unfeasible

oo

M 6 φ

– correctness: whenever CEGAR stops the answer is correct

(42)

predicate abstraction in CEGAR

(instrumented) program

  

 

computation of abstraction

boolean program

//  



verification



counterexample = execution path

 //

 

 

predicate refinement

OO

 

 

counterexample

simulation feasible

//

unfeasible

oo

×

(43)

CEGAR: initial abstraction

[T. Ball, S. K. Rajamani 2000]

(44)

CEGAR example

[T. Ball, S. K. Rajamani 2000]

(45)

CEGAR example

[T. Ball, S. K. Rajamani 2000]

(46)

CEGAR example

[T. Ball, S. K. Rajamani 2000]

(47)

CEGAR example

[T. Ball, S. K. Rajamani 2000]

(48)

CEGAR example

[T. Ball, S. K. Rajamani 2000]

(49)

CEGAR example

[T. Ball, S. K. Rajamani 2000]

(50)

CEGAR: computation of abstraction

(instrumented) program

  

 

computation of abstraction

boolean program

//  



verification



counterexample = execution path

 //

 

 

predicate refinement

OO

 

 

counterexample

simulation feasible

//

unfeasible

oo

×

(51)

CEGAR: computation of abstraction

h : Dm → {true, false}n

(52)

CEGAR: computation of abstraction

h : Dm → {true, false}n

– bS = {true, false}n

(53)

CEGAR: computation of abstraction

h : Dm → {true, false}n

– bS = {true, false}n

– R(~b y, ~y) ≡ ∃~x, ~x. R(~x, ~x) ∧ ~y=h(~x) ∧ ~y=h(~x)

x1, . . . , xm

R

//

~

y=h(~x)



x1, . . . , xm

~

y=h(~x)



y1 . . . yn

Rb

//

y1, . . . , yn

(54)

CEGAR: computation of abstraction

h : Dm → {true, false}n

– bS = {true, false}n

– R(~b y, ~y) ≡ ∃~x, ~x. R(~x, ~x) ∧ ~y=h(~x) ∧ ~y=h(~x)

x1, . . . , xm

R

//

~

y=h(~x)



x1, . . . , xm

~

y=h(~x)



y1 . . . yn

Rb

//

y1, . . . , yn

– cS0(~y) ≡ ∃~x. S0(~x) ∧ ~y=h(~x)

(55)

CEGAR: computation of abstraction

– simple block: d := e; e++ 7→ d = e ∧ e = e + 1

(56)

CEGAR: computation of abstraction

– simple block: d := e; e++ 7→ d = e ∧ e = e + 1 – predicates: b1 = (e ≥ 0), b2 = (e ≤ 100)

(57)

CEGAR: computation of abstraction

– simple block: d := e; e++ 7→ d = e ∧ e = e + 1 – predicates: b1 = (e ≥ 0), b2 = (e ≤ 100)

– abstract transitions:

R(bb 1, b2, b1, b2) ≡

∃d0, e0, d1, e1.

d = e ∧ e = e + 1 ∧

b1 = (e ≥ 0) ∧ b2 = (e ≤ 100) ∧ b1 = (e ≥ 0) ∧ b2 = (e ≤ 100)

b1 b2 b1 b2

0 1 0 1

0 1 1 1

1 0 0 1

1 0 1 0

1 1 1 0

1 1 1 1

(58)

CEGAR: computation of abstraction

– simple block: d := e; e++ 7→ d = e ∧ e = e + 1 – predicates: b1 = (e ≥ 0), b2 = (e ≤ 100)

– abstract transitions:

R(bb 1, b2, b1, b2) ≡

∃d0, e0, d1, e1.

d = e ∧ e = e + 1 ∧

b1 = (e ≥ 0) ∧ b2 = (e ≤ 100) ∧ b1 = (e ≥ 0) ∧ b2 = (e ≤ 100)

b1 b2 b1 b2

0 1 0 1

0 1 1 1

1 0 0 1

1 0 1 0

1 1 1 0

1 1 1 1

– nondeterminism

(59)

CEGAR: computation of abstraction

– simple block: d := e; e++ 7→ d = e ∧ e = e + 1 – predicates: b1 = (e ≥ 0), b2 = (e ≤ 100)

– abstract transitions:

R(bb 1, b2, b1, b2) ≡

∃d0, e0, d1, e1.

d = e ∧ e = e + 1 ∧

b1 = (e ≥ 0) ∧ b2 = (e ≤ 100) ∧ b1 = (e ≥ 0) ∧ b2 = (e ≤ 100)

b1 b2 b1 b2

0 1 0 1

0 1 1 1

1 0 0 1

1 0 1 0

1 1 1 0

1 1 1 1

– nondeterminism

– calls to a prover or SMT-solver

(60)

CEGAR: computation of abstraction

– simple block: d := e; e++ 7→ d = e ∧ e = e + 1 – predicates: b1 = (e ≥ 0), b2 = (e ≤ 100)

– abstract transitions:

R(bb 1, b2, b1, b2) ≡

∃d0, e0, d1, e1.

d = e ∧ e = e + 1 ∧

b1 = (e ≥ 0) ∧ b2 = (e ≤ 100) ∧ b1 = (e ≥ 0) ∧ b2 = (e ≤ 100)

b1 b2 b1 b2

0 1 0 1

0 1 1 1

1 0 0 1

1 0 1 0

1 1 1 0

1 1 1 1

– nondeterminism

– calls to a prover or SMT-solver

– non-minimal abstraction (for minimal one, exponential number of calls)

(61)

CEGAR: computation of abstraction

– simple block: d := e; e++ 7→ d = e ∧ e = e + 1 – predicates: b1 = (e ≥ 0), b2 = (e ≤ 100)

– abstract transitions:

R(bb 1, b2, b1, b2) ≡

∃d0, e0, d1, e1.

d = e ∧ e = e + 1 ∧

b1 = (e ≥ 0) ∧ b2 = (e ≤ 100) ∧ b1 = (e ≥ 0) ∧ b2 = (e ≤ 100)

b1 b2 b1 b2

0 1 0 1

0 1 1 1

1 0 0 1

1 0 1 0

1 1 1 0

1 1 1 1

– nondeterminism

– calls to a prover or SMT-solver

– non-minimal abstraction (for minimal one, exponential number of calls)

(62)

CEGAR: computation of abstraction

– iteratively call SAT-solver:

– a satisfying valuation 7→ a blocking clause – bactracking to the highest decision level – the procedure stops when unsatisfiable

b1 b2 b1 b2

0 1 0 1

0 1 1 1

1 0 0 1

1 0 1 0

1 1 1 0

1 1 1 1

(63)

CEGAR: computation of abstraction

– control flow: if(e > 50) {goto l} else {goto l’}

– predicates: b1 = (e ≥ 0), b2 = (e ≤ 100)

(64)

CEGAR: computation of abstraction

– control flow: if(e > 50) {goto l} else {goto l’}

– predicates: b1 = (e ≥ 0), b2 = (e ≤ 100)

– abstract control flow: if(b1 ∨ ¬b2) {goto l} + if(b1 ∨ b2) {goto l’}

(65)

CEGAR: computation of abstraction

– control flow: if(e > 50) {goto l} else {goto l’}

– predicates: b1 = (e ≥ 0), b2 = (e ≤ 100)

– abstract control flow: if(b1 ∨ ¬b2) {goto l} + if(b1 ∨ b2) {goto l’}

– abstract guards not necessarily disjoint!

(66)

CEGAR: computation of abstraction

– control flow: if(e > 50) {goto l} else {goto l’}

– predicates: b1 = (e ≥ 0), b2 = (e ≤ 100)

– abstract control flow: if(b1 ∨ ¬b2) {goto l} + if(b1 ∨ b2) {goto l’}

– abstract guards not necessarily disjoint!

– typically if (while) guards are among predicates

(67)

CEGAR: verification

(instrumented) program

  

 

computation of abstraction

boolean program

//  



verification



counterexample = execution path

 //

 

 

predicate refinement

OO

 

 

counterexample

simulation feasible

//

unfeasible

oo

×

(68)

CEGAR: verification

– SMC may be convenieniently used (if no recursion nor dynamic allocation)

[Clarke, Kroening, Sharygina, Yorav 2004]

(69)

CEGAR: counterexample simulation

(instrumented) program

  

 

computation of abstraction

boolean program

//  



verification



counterexample = execution path

 //

 

 

predicate refinement

OO

 

 

counterexample

simulation feasible

//

unfeasible

oo

×

(70)

CEGAR: counterexample simulation

abstract counterexample b1 b2 b3 b4

[Clarke, Grumberg, Jha, Lu, Veith 2003]

counterexample simulation (strongest post-condition)

S1 := S0 ∩ h−1( b1 ) Si := ~R(Si−1) ∩ h−1( bi )

(71)

CEGAR: spurious counterexample

abstract counterexample b1 b2 b3 b4

[Clarke, Grumberg, Jha, Lu, Veith 2003]

S4 = ~R(S3) ∩ h−1( b4 ) = ∅ S3 ∩ ~R−1(h−1( b4 )) = ∅

(72)

CEGAR: infinite counterexample

abstract counterexample bs1( bs2sb3)ω

[Clarke, Grumberg, Jha, Lu, Veith 2003]

– unfold the loop min{size( bs2), size( bs3)} times

(73)

CEGAR: predicate refinement

(instrumented) program

  

 

computation of abstraction

boolean program

//  



verification



counterexample = execution path

 //

 

 

predicate refinement

OO

 

 

counterexample

simulation feasible

//

unfeasible

oo

×

aim: elimination of the spurious counterexample

(74)

CEGAR: predicate refinement

– spurious counterexample:

R(~x1, ~x2) ∧ R(~x2, ~x3) ∧ . . . ∧ R(~xn−1, ~xn) unsatisfiable

(75)

CEGAR: predicate refinement

– spurious counterexample:

R(~x1, ~x2) ∧ R(~x2, ~x3) ∧ . . . ∧ R(~xn−1, ~xn) unsatisfiable

– Craig interpolation: exists a formula φ(~xi) such that – φ(~xi) only uses variables xi

– R(~x1, ~x2) ∧ . . . ∧ R(~xn−1, ~xi) =⇒ φ

– φ ∧ R(~xi, ~xi+1) ∧ . . . ∧ R(~xn−1, ~xn) unsatisfiable

(76)

CEGAR: predicate refinement

– spurious counterexample:

R(~x1, ~x2) ∧ R(~x2, ~x3) ∧ . . . ∧ R(~xn−1, ~xn) unsatisfiable

– Craig interpolation: exists a formula φ(~xi) such that – φ(~xi) only uses variables xi

– R(~x1, ~x2) ∧ . . . ∧ R(~xn−1, ~xi) =⇒ φ

– φ ∧ R(~xi, ~xi+1) ∧ . . . ∧ R(~xn−1, ~xn) unsatisfiable

– For propositional logic, extract Craig interpolant from SAT-solver output

(77)

CEGAR: BDD + SAT

(instrumented) program

  



SAT-solver



boolean program

//  



BDD



counterexample = execution path

 //

 



SAT-solver



OO

 



SAT-solver



feasible

//

unfeasible

oo

×

(78)

Software verification success story

– 85% of system crashes of Windows XP caused by bugs in third-party kernel-level device drivers (2003)

– one of reasons is the complexity of the Windows drivers API

– SLAM: automatically checks device drivers for certain correctness properties with respect to the Windows device drivers API

– now part of Windows Driver Development Kit, a toolset for drivers developers

Cytaty

Powiązane dokumenty

Sławomir Lasota University of Warsaw... such

• principal application: checking whether device drivers satisfy driver API usage

The numerical model created allowed us to analyze numbers of scenarios with different parameters during high accelerations without damaging measuring stand like in F1 car

Our data support a view that lipid bilayer undulation dynamics and corresponding bending rigidities κ can be tuned by directly inducing changes at the lipid acyl chains:

The current thesis presents the basics behind the (thermoplastic) impregnation process (Chapter 3) and concludes with the aspect necessary for designing an efficient and

17th IPHS Conference, Delft 2016 | HISTORY - URBANISM - RESILIENCE | VOlume 04 Planning and Heritage | Politics, Planning, Heritage and urban Space | Heritage

odbędą się XXXVI już z kolei międzynarodowe Dni Augustiańskie, organizowane co roku tradycyjnie przez Instytut Patrystyczny „Augusti- nianum&#34; w Rzymie,

Ja zawsze Bogu i Polsce tylko służę!» Tam przyjechawszy nie był zdrów, a trudy odbytego polowania na koniu znużyły go jeszcze bardziej i zapadł ciężej;