Predicate Abstraction with SATABS Version 1.0, 2010 Outline - - PowerPoint PPT Presentation

predicate abstraction with satabs
SMART_READER_LITE
LIVE PREVIEW

Predicate Abstraction with SATABS Version 1.0, 2010 Outline - - PowerPoint PPT Presentation

Predicate Abstraction with SATABS Version 1.0, 2010 Outline Introduction Existential Abstraction Predicate Abstraction for Software Counterexample-Guided Abstraction Refinement Computing Existential Abstractions of Programs Checking the


slide-1
SLIDE 1

Predicate Abstraction with SATABS

Version 1.0, 2010

slide-2
SLIDE 2

Outline

Introduction Existential Abstraction Predicate Abstraction for Software Counterexample-Guided Abstraction Refinement Computing Existential Abstractions of Programs Checking the Abstract Model Simulating the Counterexample Refining the Abstraction

Predicate Abstraction with SATABS – http://www.cprover.org/ 2

slide-3
SLIDE 3

“Things like even software verification, this has been the Holy Grail of computer science for many decades, but now in some very key areas, for example, driver verification we’re building tools that can do actual proof about the software and how it works in order to guarantee the reliability.”

Bill Gates, April 18, 2002 Keynote address at WinHec 2002

Predicate Abstraction with SATABS – http://www.cprover.org/ 3

slide-4
SLIDE 4

“One of the least visible ways that Microsoft Research contributed to Vista, but something I like to talk about, is the work we did on what’s called the Static Driver

  • Verifier. People who develop device drivers for Vista can

verify the properties of their drivers before they ever even attempt to test that. What’s great about this technology is there is no testing involved. For the properties that it is proving, they are either true or false. You don’t have to ask yourself “Did I come up with a good test case or not?”

Rick Rashid, Microsoft Research chief father of CMU’s Mach Operating System (Mac OS X) news.cnet.com interview, 2008

Predicate Abstraction with SATABS – http://www.cprover.org/ 4

slide-5
SLIDE 5

Model Checking with Predicate Abstraction

◮ A heavy-weight formal analysis technique ◮ Recent successes in software verification,

e.g., SLAM at Microsoft

◮ The abstraction reduces the size of the model

by removing irrelevant detail

Predicate Abstraction with SATABS – http://www.cprover.org/ 5

slide-6
SLIDE 6

Model Checking with Predicate Abstraction

◮ Goal: make the abstract model small enough for an

analysis with a BDD-based Model Checker

◮ Idea: only track predicates on data,

and remove data variables from model

◮ Mostly works with control-flow dominated properties

Predicate Abstraction with SATABS – http://www.cprover.org/ 6

slide-7
SLIDE 7

Notation for Abstractions Abstract Domain

Approximate representation of sets of concrete values

S

α − → ← − γ

ˆ S

Predicate Abstraction with SATABS – http://www.cprover.org/ 7

slide-8
SLIDE 8

Predicate Abstraction as Abstract Domain

◮ We are given a set of predicates over S,

denoted by Π1, . . . , Πn.

◮ An abstract state is a valuation of the predicates:

ˆ S = Bn

◮ The abstraction function:

α(s) = Π1(s), . . . , Πn(s)

Predicate Abstraction with SATABS – http://www.cprover.org/ 8

slide-9
SLIDE 9

Predicate Abstraction: the Basic Idea

Concrete states over variables x, y: x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

slide-10
SLIDE 10

Predicate Abstraction: the Basic Idea

Concrete states over variables x, y: x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0 Predicates:

p1 ⇐ ⇒ x > y p2 ⇐ ⇒ y = 0

slide-11
SLIDE 11

Predicate Abstraction: the Basic Idea

Concrete states over variables x, y: x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

p1, p2 ¬p1, ¬p2 p1, ¬p2 ¬p1, p2

Predicates:

p1 ⇐ ⇒ x > y p2 ⇐ ⇒ y = 0

Predicate Abstraction with SATABS – http://www.cprover.org/ 9

slide-12
SLIDE 12

Predicate Abstraction: the Basic Idea

Concrete states over variables x, y: x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

p1, p2 ¬p1, ¬p2 p1, ¬p2 ¬p1, p2

Predicates:

p1 ⇐ ⇒ x > y p2 ⇐ ⇒ y = 0

Abstract Transitions?

Predicate Abstraction with SATABS – http://www.cprover.org/ 9

slide-13
SLIDE 13

Existential Abstraction1 Definition (Existential Abstraction)

A model ˆ M = ( ˆ S, ˆ S0, ˆ T) is an existential abstraction of M = (S, S0, T) with respect to α : S → ˆ S iff

◮ ∃s ∈ S0. α(s) = ˆ

s ⇒ ˆ s ∈ ˆ S0 and

◮ ∃(s, s′) ∈ T. α(s) = ˆ

s ∧ α(s′) = ˆ s′ ⇒ (ˆ s, ˆ s′) ∈ ˆ T.

1Clarke, Grumberg, Long: Model Checking and Abstraction,

ACM TOPLAS, 1994

Predicate Abstraction with SATABS – http://www.cprover.org/ 10

slide-14
SLIDE 14

Minimal Existential Abstractions

There are obviously many choices for an existential abstraction for a given α.

Definition (Minimal Existential Abstraction)

A model ˆ M = ( ˆ S, ˆ S0, ˆ T) is the minimal existential abstraction of M = (S, S0, T) with respect to α : S → ˆ S iff

◮ ∃s ∈ S0. α(s) = ˆ

s ⇐ ⇒ ˆ s ∈ ˆ S0 and

◮ ∃(s, s′) ∈ T. α(s) = ˆ

s ∧ α(s′) = ˆ s′ ⇐ ⇒ (ˆ s, ˆ s′) ∈ ˆ T. This is the most precise existential abstraction.

Predicate Abstraction with SATABS – http://www.cprover.org/ 11

slide-15
SLIDE 15

Existential Abstraction

We write α(π) for the abstraction of a path π = s0, s1, . . .: α(π) = α(s0), α(s1), . . .

Predicate Abstraction with SATABS – http://www.cprover.org/ 12

slide-16
SLIDE 16

Existential Abstraction

We write α(π) for the abstraction of a path π = s0, s1, . . .: α(π) = α(s0), α(s1), . . .

Lemma

Let ˆ M be an existential abstraction of M. The abstraction of every path (trace) π in M is a path (trace) in ˆ M. π ∈ M ⇒ α(π) ∈ ˆ M Proof by induction. We say that ˆ M overapproximates M.

Predicate Abstraction with SATABS – http://www.cprover.org/ 12

slide-17
SLIDE 17

Abstracting Properties

Reminder: we are using

◮ a set of atomic propositions (predicates) A, and ◮ a state-labelling function L : S → P(A)

in order to define the meaning of propositions in our properties.

Predicate Abstraction with SATABS – http://www.cprover.org/ 13

slide-18
SLIDE 18

Abstracting Properties

We define an abstract version of it as follows:

◮ First of all, the negations are pushed into the atomic

propositions. E.g., we will have x = 0 ∈ A and x = 0 ∈ A

Predicate Abstraction with SATABS – http://www.cprover.org/ 14

slide-19
SLIDE 19

Abstracting Properties

◮ An abstract state ˆ

s is labelled with a ∈ A iff all of the corresponding concrete states are labelled with a. a ∈ ˆ L(ˆ s) ⇐ ⇒ ∀s|α(s) = ˆ

  • s. a ∈ L(s)

◮ This also means that an abstract state may have neither

the label x = 0 nor the label x = 0 – this may happen if it concretizes to concrete states with different labels!

Predicate Abstraction with SATABS – http://www.cprover.org/ 15

slide-20
SLIDE 20

Conservative Abstraction

The keystone is that existential abstraction is conservative for certain properties:

Theorem (Clarke/Grumberg/Long 1994)

Let φ be a ∀CTL* formula where all negations are pushed into the atomic propositions, and let ˆ M be an existential abstraction

  • f M. If φ holds on ˆ

M, then it also holds on M. ˆ M | = φ ⇒ M | = φ We say that an existential abstraction is conservative for ∀CTL*

  • properties. The same result can be obtained for LTL properties.

The proof uses the lemma and is by induction on the structure

  • f φ. The converse usually does not hold.

Predicate Abstraction with SATABS – http://www.cprover.org/ 16

slide-21
SLIDE 21

Conservative Abstraction

We hope: computing ˆ M and checking ˆ M | = φ is easier than checking M | = φ.

Predicate Abstraction with SATABS – http://www.cprover.org/ 17

slide-22
SLIDE 22

Back to the Example

x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

p1, p2 ¬p1, ¬p2 p1, ¬p2 ¬p1, p2

slide-23
SLIDE 23

Back to the Example

x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

p1, p2 ¬p1, ¬p2 p1, ¬p2 ¬p1, p2

slide-24
SLIDE 24

Back to the Example

x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

p1, p2 ¬p1, ¬p2 p1, ¬p2 ¬p1, p2

slide-25
SLIDE 25

Back to the Example

x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

p1, p2 ¬p1, ¬p2 p1, ¬p2 ¬p1, p2

slide-26
SLIDE 26

Back to the Example

x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

p1, p2 ¬p1, ¬p2 p1, ¬p2 ¬p1, p2

slide-27
SLIDE 27

Back to the Example

x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

p1, p2 ¬p1, ¬p2 p1, ¬p2 ¬p1, p2

Predicate Abstraction with SATABS – http://www.cprover.org/ 18

slide-28
SLIDE 28

Let’s try a Property

x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

p1, p2 ¬p1, ¬p2 p1, ¬p2 ¬p1, p2

Property: x > y ∨ y = 0 ⇐ ⇒ p1 ∨ ¬p2

slide-29
SLIDE 29

Let’s try a Property

x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

p1, p2 ¬p1, ¬p2 p1, ¬p2 ¬p1, p2

✔ ✔ ✔

Property: x > y ∨ y = 0 ⇐ ⇒ p1 ∨ ¬p2

Predicate Abstraction with SATABS – http://www.cprover.org/ 19

slide-30
SLIDE 30

Another Property

x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

p1, p2 ¬p1, ¬p2 p1, ¬p2 ¬p1, p2

Property: x > y ⇐ ⇒ p1

slide-31
SLIDE 31

Another Property

x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

p1, p2 ¬p1, ¬p2 p1, ¬p2 ¬p1, p2

✔ ✔

Property: x > y ⇐ ⇒ p1

slide-32
SLIDE 32

Another Property

x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

p1, p2 ¬p1, ¬p2 p1, ¬p2 ¬p1, p2

✔ ✔ ✘

Property: x > y ⇐ ⇒ p1

Predicate Abstraction with SATABS – http://www.cprover.org/ 20

slide-33
SLIDE 33

Another Property

x = 1 y = 0 x = 1 y = 1 x = 1 y = 2 x = 2 y = 0 x = 2 y = 1 x = 0 y = 0

p1, p2 ¬p1, ¬p2 p1, ¬p2 ¬p1, p2

✔ ✔ ✘

Property: x > y ⇐ ⇒ p1 But: the counterexample is spurious

Predicate Abstraction with SATABS – http://www.cprover.org/ 20

slide-34
SLIDE 34

SLAM

◮ Microsoft blames most Windows crashes on third party

device drivers

◮ The Windows device driver API is quite complicated ◮ Drivers are low level C code ◮ SLAM: Tool to automatically check device drivers for

certain errors

◮ SLAM is shipped with Device Driver Development Kit ◮ Full detail available at

http://research.microsoft.com/slam/

Predicate Abstraction with SATABS – http://www.cprover.org/ 21

slide-35
SLIDE 35

SLIC

◮ Finite state language for defining properties

◮ Monitors behavior of C code ◮ Temporal safety properties (security automata) ◮ familiar C syntax

◮ Suitable for expressing control-dominated properties

◮ e.g., proper sequence of events ◮ can track data values Predicate Abstraction with SATABS – http://www.cprover.org/ 22

slide-36
SLIDE 36

SLIC Example

unlocked locked acq rel

state { enum {Locked , Unlocked} s = Unlocked ; } KeAcquireSpinLock . entry { i f ( s==Locked ) abort ; else s = Locked ; } KeReleaseSpinLock . entry { i f ( s==Unlocked ) abort ; else s = Unlocked ; }

slide-37
SLIDE 37

SLIC Example

unlocked locked acq rel error rel acq

state { enum {Locked , Unlocked} s = Unlocked ; } KeAcquireSpinLock . entry { i f ( s==Locked ) abort ; else s = Locked ; } KeReleaseSpinLock . entry { i f ( s==Unlocked ) abort ; else s = Unlocked ; }

Predicate Abstraction with SATABS – http://www.cprover.org/ 23

slide-38
SLIDE 38

Refinement Example

do {

KeAcquireSpinLock ();

nPacketsOld = nPackets; if (request) { request = request−>Next;

KeReleaseSpinLock ();

nPackets++; } } while(nPackets != nPacketsOld);

KeReleaseSpinLock ();

Predicate Abstraction with SATABS – http://www.cprover.org/ 24

slide-39
SLIDE 39

Refinement Example

do {

KeAcquireSpinLock ();

nPacketsOld = nPackets; if (request) { request = request−>Next;

KeReleaseSpinLock ();

nPackets++; } } while(nPackets != nPacketsOld);

KeReleaseSpinLock (); Does this code

  • bey the locking

rule?

Predicate Abstraction with SATABS – http://www.cprover.org/ 24

slide-40
SLIDE 40

Refinement Example

do {

KeAcquireSpinLock ();

if (∗) {

KeReleaseSpinLock ();

} } while(∗);

KeReleaseSpinLock ();

Predicate Abstraction with SATABS – http://www.cprover.org/ 25

slide-41
SLIDE 41

Refinement Example

do {

KeAcquireSpinLock ();

if (∗) {

KeReleaseSpinLock ();

} } while(∗);

KeReleaseSpinLock (); U L L L U U U E L L U

Predicate Abstraction with SATABS – http://www.cprover.org/ 25

slide-42
SLIDE 42

Refinement Example

do {

KeAcquireSpinLock ();

if (∗) {

KeReleaseSpinLock ();

} } while(∗);

KeReleaseSpinLock (); U L L L U U U E L L U U L L L U U U E

Predicate Abstraction with SATABS – http://www.cprover.org/ 25

slide-43
SLIDE 43

Refinement Example

do {

KeAcquireSpinLock ();

if (∗) {

KeReleaseSpinLock ();

} } while(∗);

KeReleaseSpinLock (); U L L L U U U E L L U U L L L U U U E Is this path concretizable?

Predicate Abstraction with SATABS – http://www.cprover.org/ 25

slide-44
SLIDE 44

Refinement Example

do {

KeAcquireSpinLock ();

nPacketsOld = nPackets; if (request) { request = request−>Next;

KeReleaseSpinLock ();

nPackets++; } } while(nPackets != nPacketsOld);

KeReleaseSpinLock (); U L L L U U U E L L U U L L L U U U E

Predicate Abstraction with SATABS – http://www.cprover.org/ 26

slide-45
SLIDE 45

Refinement Example

do {

KeAcquireSpinLock ();

nPacketsOld = nPackets; if (request) { request = request−>Next;

KeReleaseSpinLock ();

nPackets++; } } while(nPackets != nPacketsOld);

KeReleaseSpinLock (); U L L L U U U E L L U U L L L U U U E This path is spurious!

Predicate Abstraction with SATABS – http://www.cprover.org/ 26

slide-46
SLIDE 46

Refinement Example

do {

KeAcquireSpinLock ();

nPacketsOld = nPackets; if (request) { request = request−>Next;

KeReleaseSpinLock ();

nPackets++; } } while(nPackets != nPacketsOld);

KeReleaseSpinLock (); U L L L U U U E L L U U L L L U U U E

Let’s add the predicate nPacketsOld==nPackets

Predicate Abstraction with SATABS – http://www.cprover.org/ 26

slide-47
SLIDE 47

Refinement Example

do {

KeAcquireSpinLock ();

nPacketsOld = nPackets; if (request) { request = request−>Next;

KeReleaseSpinLock ();

nPackets++; } } while(nPackets != nPacketsOld);

KeReleaseSpinLock (); U L L L U U U E L L U U L L L U U U E

Let’s add the predicate nPacketsOld==nPackets b=true;

Predicate Abstraction with SATABS – http://www.cprover.org/ 26

slide-48
SLIDE 48

Refinement Example

do {

KeAcquireSpinLock ();

nPacketsOld = nPackets; if (request) { request = request−>Next;

KeReleaseSpinLock ();

nPackets++; } } while(nPackets != nPacketsOld);

KeReleaseSpinLock (); U L L L U U U E L L U U L L L U U U E

Let’s add the predicate nPacketsOld==nPackets b=true; !b b=b?false:∗;

Predicate Abstraction with SATABS – http://www.cprover.org/ 26

slide-49
SLIDE 49

Refinement Example

do {

KeAcquireSpinLock ();

b=true; if (∗) {

KeReleaseSpinLock ();

b=b?false:∗; } } while( !b );

KeReleaseSpinLock (); U L L L U U U E L L U

Predicate Abstraction with SATABS – http://www.cprover.org/ 27

slide-50
SLIDE 50

Refinement Example

do {

KeAcquireSpinLock ();

b=true; if (∗) {

KeReleaseSpinLock ();

b=b?false:∗; } } while( !b );

KeReleaseSpinLock (); U L L L U U U E L L U b

Predicate Abstraction with SATABS – http://www.cprover.org/ 27

slide-51
SLIDE 51

Refinement Example

do {

KeAcquireSpinLock ();

b=true; if (∗) {

KeReleaseSpinLock ();

b=b?false:∗; } } while( !b );

KeReleaseSpinLock (); U L L L U U U E L L U b b b b

Predicate Abstraction with SATABS – http://www.cprover.org/ 27

slide-52
SLIDE 52

Refinement Example

do {

KeAcquireSpinLock ();

b=true; if (∗) {

KeReleaseSpinLock ();

b=b?false:∗; } } while( !b );

KeReleaseSpinLock (); U L L L U U U E L L U b b b b b b !b

Predicate Abstraction with SATABS – http://www.cprover.org/ 27

slide-53
SLIDE 53

Refinement Example

do {

KeAcquireSpinLock ();

b=true; if (∗) {

KeReleaseSpinLock ();

b=b?false:∗; } } while( !b );

KeReleaseSpinLock (); U L L L U U U E L L U b b b b b b !b

Predicate Abstraction with SATABS – http://www.cprover.org/ 27

slide-54
SLIDE 54

Refinement Example

do {

KeAcquireSpinLock ();

b=true; if (∗) {

KeReleaseSpinLock ();

b=b?false:∗; } } while( !b );

KeReleaseSpinLock (); U L L L U U U E L L U b b b b b b !b The property holds!

Predicate Abstraction with SATABS – http://www.cprover.org/ 27

slide-55
SLIDE 55

Counterexample-guided Abstraction Refinement

◮ ”CEGAR” ◮ An iterative method to compute a sufficiently precise

abstraction

◮ Initially applied in the context of hardware [Kurshan]

Predicate Abstraction with SATABS – http://www.cprover.org/ 28

slide-56
SLIDE 56

CEGAR Overview 1.) Compute Abstraction 2.) Check Abstraction 3.) Check Feasibility 4.) Refine Predicates [no error] OK [feasible] report counterexample C program

Predicate Abstraction with SATABS – http://www.cprover.org/ 29

slide-57
SLIDE 57

Counterexample-guided Abstraction Refinement

Claims:

  • 1. This never returns a false error.
  • 2. This never returns a false proof.
  • 3. This is complete for finite-state models.
  • 4. But: no termination guarantee in case of infinite-state

systems

Predicate Abstraction with SATABS – http://www.cprover.org/ 30

slide-58
SLIDE 58

Computing Existential Abstractions of Programs 1.) Compute Abstraction 2.) Check Abstraction 3.) Check Feasibility 4.) Refine Predicates [no error] OK [feasible] report counterexample C program

Predicate Abstraction with SATABS – http://www.cprover.org/ 31

slide-59
SLIDE 59

Computing Existential Abstractions of Programs

int main ( ) { int i ; i =0; while ( even ( i ) ) i ++; } void main ( ) { bool p1 , p2 ; p1=TRUE; p2=TRUE; while ( p2 ) { p1= p1 ? FALSE : * ; p2= !p2 ; } }

C Program

Predicate Abstraction with SATABS – http://www.cprover.org/ 32

slide-60
SLIDE 60

Computing Existential Abstractions of Programs

int main ( ) { int i ; i =0; while ( even ( i ) ) i ++; }

+

p1 ⇐ ⇒ i = 0 p2 ⇐ ⇒ even(i)

void main ( ) { bool p1 , p2 ; p1=TRUE; p2=TRUE; while ( p2 ) { p1= p1 ? FALSE : * ; p2= !p2 ; } }

C Program Predicates

Predicate Abstraction with SATABS – http://www.cprover.org/ 32

slide-61
SLIDE 61

Computing Existential Abstractions of Programs

int main ( ) { int i ; i =0; while ( even ( i ) ) i ++; }

+

p1 ⇐ ⇒ i = 0 p2 ⇐ ⇒ even(i)

void main ( ) { bool p1 , p2 ; p1=TRUE; p2=TRUE; while ( p2 ) { p1= p1 ? FALSE : * ; p2= !p2 ; } }

C Program Predicates Boolean Program

Predicate Abstraction with SATABS – http://www.cprover.org/ 32

slide-62
SLIDE 62

Computing Existential Abstractions of Programs

int main ( ) { int i ; i =0; while ( even ( i ) ) i ++; }

+

p1 ⇐ ⇒ i = 0 p2 ⇐ ⇒ even(i)

void main ( ) { bool p1 , p2 ; p1=TRUE; p2=TRUE; while ( p2 ) { p1= p1 ? FALSE : * ; p2= !p2 ; } }

C Program Predicates Boolean Program Minimal?

Predicate Abstraction with SATABS – http://www.cprover.org/ 32

slide-63
SLIDE 63

Predicate Images

Reminder: Image(X) = {s′ ∈ S | ∃s ∈ X. T(s, s′)} We need

  • Image( ˆ

X) = {ˆ s′ ∈ ˆ S | ∃ˆ s ∈ ˆ

  • X. ˆ

T(ˆ s, ˆ s′)}

  • Image( ˆ

X) is equivalent to {ˆ s, ˆ s′ ∈ ˆ S2 | ∃s, s′ ∈ S2. α(s) = ˆ s ∧ α(s′) = ˆ s′ ∧ T(s, s′)} This is called the predicate image of T.

Predicate Abstraction with SATABS – http://www.cprover.org/ 33

slide-64
SLIDE 64

Enumeration

◮ Let’s take existential abstraction seriously ◮ Basic idea: with n predicates, there are 2n · 2n possible

abstract transitions

◮ Let’s just check them!

Predicate Abstraction with SATABS – http://www.cprover.org/ 34

slide-65
SLIDE 65

Enumeration: Example

Predicates

p1 ⇐ ⇒ i = 1 p2 ⇐ ⇒ i = 2 p3 ⇐ ⇒ even(i)

slide-66
SLIDE 66

Enumeration: Example

Predicates

p1 ⇐ ⇒ i = 1 p2 ⇐ ⇒ i = 2 p3 ⇐ ⇒ even(i)

Basic Block

i++;

slide-67
SLIDE 67

Enumeration: Example

Predicates

p1 ⇐ ⇒ i = 1 p2 ⇐ ⇒ i = 2 p3 ⇐ ⇒ even(i)

Basic Block

i++;

T

i′ = i + 1

slide-68
SLIDE 68

Enumeration: Example

Predicates

p1 ⇐ ⇒ i = 1 p2 ⇐ ⇒ i = 2 p3 ⇐ ⇒ even(i)

Basic Block

i++;

T

i′ = i + 1 p1 p2 p3 1 1 1 1 1 1 1 1 1 1 1 1 p′

1

p′

2

p′

3

1 1 1 1 1 1 1 1 1 1 1 1

slide-69
SLIDE 69

Enumeration: Example

Predicates

p1 ⇐ ⇒ i = 1 p2 ⇐ ⇒ i = 2 p3 ⇐ ⇒ even(i)

Basic Block

i++;

T

i′ = i + 1 p1 p2 p3 1 1 1 1 1 1 1 1 1 1 1 1 p′

1

p′

2

p′

3

1 1 1 1 1 1 1 1 1 1 1 1

?

slide-70
SLIDE 70

Enumeration: Example

Predicates

p1 ⇐ ⇒ i = 1 p2 ⇐ ⇒ i = 2 p3 ⇐ ⇒ even(i)

Basic Block

i++;

T

i′ = i + 1 p1 p2 p3 1 1 1 1 1 1 1 1 1 1 1 1 p′

1

p′

2

p′

3

1 1 1 1 1 1 1 1 1 1 1 1

?

Query to Solver

i = 1 ∧ i = 2 ∧ even(i)∧ i′ = i + 1∧ i′ = 1 ∧ i′ = 2 ∧ even(i′)

Predicate Abstraction with SATABS – http://www.cprover.org/ 35

slide-71
SLIDE 71

Enumeration: Example

Predicates

p1 ⇐ ⇒ i = 1 p2 ⇐ ⇒ i = 2 p3 ⇐ ⇒ even(i)

Basic Block

i++;

T

i′ = i + 1 p1 p2 p3 1 1 1 1 1 1 1 1 1 1 1 1 p′

1

p′

2

p′

3

1 1 1 1 1 1 1 1 1 1 1 1

Query to Solver

i = 1 ∧ i = 2 ∧ even(i)∧ i′ = i + 1∧ i′ = 1 ∧ i′ = 2 ∧ even(i′)

Predicate Abstraction with SATABS – http://www.cprover.org/ 35

slide-72
SLIDE 72

Enumeration: Example

Predicates

p1 ⇐ ⇒ i = 1 p2 ⇐ ⇒ i = 2 p3 ⇐ ⇒ even(i)

Basic Block

i++;

T

i′ = i + 1 p1 p2 p3 1 1 1 1 1 1 1 1 1 1 1 1 p′

1

p′

2

p′

3

1 1 1 1 1 1 1 1 1 1 1 1

?

Query to Solver

i = 1 ∧ i = 2 ∧ even(i)∧ i′ = i + 1∧ i′ = 1 ∧ i′ = 2 ∧ even(i′)

Predicate Abstraction with SATABS – http://www.cprover.org/ 35

slide-73
SLIDE 73

Enumeration: Example

Predicates

p1 ⇐ ⇒ i = 1 p2 ⇐ ⇒ i = 2 p3 ⇐ ⇒ even(i)

Basic Block

i++;

T

i′ = i + 1 p1 p2 p3 1 1 1 1 1 1 1 1 1 1 1 1 p′

1

p′

2

p′

3

1 1 1 1 1 1 1 1 1 1 1 1

Query to Solver

i = 1 ∧ i = 2 ∧ even(i)∧ i′ = i + 1∧ i′ = 1 ∧ i′ = 2 ∧ even(i′)

Predicate Abstraction with SATABS – http://www.cprover.org/ 35

slide-74
SLIDE 74

Enumeration: Example

Predicates

p1 ⇐ ⇒ i = 1 p2 ⇐ ⇒ i = 2 p3 ⇐ ⇒ even(i)

Basic Block

i++;

T

i′ = i + 1 p1 p2 p3 1 1 1 1 1 1 1 1 1 1 1 1 p′

1

p′

2

p′

3

1 1 1 1 1 1 1 1 1 1 1 1

Query to Solver

. . . and so on . . .

Predicate Abstraction with SATABS – http://www.cprover.org/ 35

slide-75
SLIDE 75

Predicate Images

✘ Computing the minimal existential abstraction can be way too slow

◮ Use an over-approximation instead

✔ Fast(er) to compute ✘ But has additional transitions

◮ Examples:

◮ Cartesian approximation (SLAM) ◮ FastAbs (SLAM) ◮ Lazy abstraction (Blast) ◮ Predicate partitioning (VCEGAR) Predicate Abstraction with SATABS – http://www.cprover.org/ 36

slide-76
SLIDE 76

Checking the Abstract Model 1.) Compute Abstraction 2.) Check Abstraction 3.) Check Feasibility 4.) Refine Predicates [no error] OK [feasible] report counterexample C program

Predicate Abstraction with SATABS – http://www.cprover.org/ 37

slide-77
SLIDE 77

Checking the Abstract Model

◮ No more integers! ◮ But:

◮ All control flow constructs, including function calls ◮ (more) non-determinism

✔ BDD-based model checking now scales

Predicate Abstraction with SATABS – http://www.cprover.org/ 38

slide-78
SLIDE 78

Finite-State Model Checkers: SMV

① Variables

VAR b0 argc ge 1 : boolean ; − − argc >= 1 VAR b1 argc le 2147483646 : boolean ; − − argc <= 2147483646 VAR b2 : boolean ; − − argv [ argc ] == NULL VAR b3 nmemb ge r : boolean ; − − nmemb >= r VAR b4 : boolean ; − − p1 == &array [ 0 ] VAR b5 i ge 8 : boolean ; − − i >= 8 VAR b6 i ge s : boolean ; − − i >= s VAR b7 : boolean ; − − 1 + i >= 8 VAR b8 : boolean ; − − 1 + i >= s VAR b9 s gt 0 : boolean ; − − s > 0 VAR b10 s gt 1 : boolean ; − − s > 1 . . .

Predicate Abstraction with SATABS – http://www.cprover.org/ 39

slide-79
SLIDE 79

Finite-State Model Checkers: SMV

②Control Flow

− − program counter : 56 i s the ” terminating ” PC VAR PC: 0 . . 5 6 ; ASSIGN i n i t (PC) : = 0 ; − − i n i t i a l PC ASSIGN next (PC) : = case PC=0: 1; − − other PC=1: 2; − − other . . . PC=19: case − − goto ( with guard ) guard19 : 26; 1: 20; esac ; . . .

Predicate Abstraction with SATABS – http://www.cprover.org/ 40

slide-80
SLIDE 80

Finite-State Model Checkers: SMV

Data

TRANS (PC=0) − > next ( b0 argc ge 1 )= b0 argc ge 1 & next ( b1 argc le 213646 )= b1 argc le 21646 & next ( b2)=b2 & ( ! b30 | b36 ) & ( ! b17 | ! b30 | b42 ) & ( ! b30 | ! b42 | b48 ) & ( ! b17 | ! b30 | ! b42 | b54 ) & ( ! b54 | b60 ) TRANS (PC=1) − > next ( b0 argc ge 1 )= b0 argc ge 1 & next ( b1 argc le 214646 )= b1 argc le 214746 & next ( b2)=b2 & next ( b3 nmemb ge r )= b3 nmemb ge r & next ( b4)=b4 & next ( b5 i ge 8 )= b5 i ge 8 & next ( b6 i ge s )= b6 i ge s . . .

Predicate Abstraction with SATABS – http://www.cprover.org/ 41

slide-81
SLIDE 81

Finite-State Model Checkers: SMV

④ Property

− − the s p e c i f i c a t i o n − − f i l e main . c l i n e 20 column 12 − − function c : : very buggy function SPEC AG ( (PC=51) − > ! b23 )

Predicate Abstraction with SATABS – http://www.cprover.org/ 42

slide-82
SLIDE 82

Finite-State Model Checkers: SMV

◮ If the property holds, we can terminate ◮ If the property fails, SMV generates a counterexample with

an assignment for all variables, including the PC

Predicate Abstraction with SATABS – http://www.cprover.org/ 43

slide-83
SLIDE 83

Simulating the Counterexample 1.) Compute Abstraction 2.) Check Abstraction 3.) Check Feasibility 4.) Refine Predicates [no error] OK [feasible] report counterexample C program

Predicate Abstraction with SATABS – http://www.cprover.org/ 44

slide-84
SLIDE 84

Lazy Abstraction

◮ The progress guarantee is only valid if the minimal

existential abstraction is used.

◮ Thus, distinguish spurious transitions from spurious

prefixes.

◮ Refine spurious transitions separately to obtain minimal

existential abstraction

◮ SLAM: Constrain

Predicate Abstraction with SATABS – http://www.cprover.org/ 45

slide-85
SLIDE 85

Lazy Abstraction

◮ One more observation:

each iteration only causes only minor changes in the abstract model

◮ Thus, use “incremental Model Checker”, which retains the

set of reachable states between iterations (BLAST)

Predicate Abstraction with SATABS – http://www.cprover.org/ 46

slide-86
SLIDE 86

Example Simulation

int main() { int x, y; y=1; x=1; if (y>x) y−−; else y++; assert(y>x); }

Predicate:

y>x main() {

bool b0; // y>x b0=*; b0=*;

if (b0)

b0=*;

else

b0=*;

assert(b0); }

slide-87
SLIDE 87

Example Simulation

int main() { int x, y; y=1; x=1; if (y>x) y−−; else y++; assert(y>x); }

Predicate:

y>x main() {

bool b0; // y>x b0=*; b0=*;

if (b0)

b0=*;

else

b0=*;

assert(b0); }

Predicate Abstraction with SATABS – http://www.cprover.org/ 47

slide-88
SLIDE 88

Example Simulation

int main() { int x, y; y=1; x=1; if (y>x) y−−; else y++; assert(y>x); }

Predicate Abstraction with SATABS – http://www.cprover.org/ 48

slide-89
SLIDE 89

Example Simulation

int main() { int x, y; y=1; x=1; if (y>x) y−−; else y++; assert(y>x); }

We now do a path test, so convert to SSA.

Predicate Abstraction with SATABS – http://www.cprover.org/ 48

slide-90
SLIDE 90

Example Simulation

int main() { int x, y; y1=1; x1=1; if (y1>x1) y2=y1−1; else y++; assert(y2>x1 ); }

Predicate Abstraction with SATABS – http://www.cprover.org/ 49

slide-91
SLIDE 91

Example Simulation

int main() { int x, y; y1=1; x1=1; if (y1>x1) y2=y1−1; else y++; assert(y2>x1 ); }

y1 = 1 ∧ x1 = 1 ∧ y1 > x1 ∧ y2 = y1 − 1 ∧ ¬(y2 > x0)

Predicate Abstraction with SATABS – http://www.cprover.org/ 49

slide-92
SLIDE 92

Example Simulation

int main() { int x, y; y1=1; x1=1; if (y1>x1) y2=y1−1; else y++; assert(y2>x1 ); }

y1 = 1 ∧ x1 = 1 ∧ y1 > x1 ∧ y2 = y1 − 1 ∧ ¬(y2 > x0) This is UNSAT, so ˆ π is spurious.

Predicate Abstraction with SATABS – http://www.cprover.org/ 49

slide-93
SLIDE 93

Refining the Abstraction 1.) Compute Abstraction 2.) Check Abstraction 3.) Check Feasibility 4.) Refine Predicates [no error] OK [feasible] report counterexample C program

Predicate Abstraction with SATABS – http://www.cprover.org/ 50

slide-94
SLIDE 94

Manual Proof!

int main() { int x, y; y=1; x=1; if (y>x) y−−; else y++; assert(y>x); }

Predicate Abstraction with SATABS – http://www.cprover.org/ 51

slide-95
SLIDE 95

Manual Proof!

int main() { int x, y; y=1;

{y = 1}

x=1; if (y>x) y−−; else y++; assert(y>x); }

Predicate Abstraction with SATABS – http://www.cprover.org/ 51

slide-96
SLIDE 96

Manual Proof!

int main() { int x, y; y=1;

{y = 1}

x=1;

{x = 1 ∧ y = 1}

if (y>x) y−−; else y++; assert(y>x); }

Predicate Abstraction with SATABS – http://www.cprover.org/ 51

slide-97
SLIDE 97

Manual Proof!

int main() { int x, y; y=1;

{y = 1}

x=1;

{x = 1 ∧ y = 1}

if (y>x) y−−; else

{x = 1 ∧ y = 1 ∧ ¬y > x}

y++; assert(y>x); }

Predicate Abstraction with SATABS – http://www.cprover.org/ 51

slide-98
SLIDE 98

Manual Proof!

int main() { int x, y; y=1;

{y = 1}

x=1;

{x = 1 ∧ y = 1}

if (y>x) y−−; else

{x = 1 ∧ y = 1 ∧ ¬y > x}

y++;

{x = 1 ∧ y = 2 ∧ y > x}

assert(y>x); }

This proof uses strongest post-conditions

Predicate Abstraction with SATABS – http://www.cprover.org/ 51

slide-99
SLIDE 99

An Alternative Proof

int main() { int x, y; y=1; x=1; if (y>x) y−−; else y++; assert(y>x); }

Predicate Abstraction with SATABS – http://www.cprover.org/ 52

slide-100
SLIDE 100

An Alternative Proof

int main() { int x, y; y=1; x=1; if (y>x) y−−; else y++;

{y > x}

assert(y>x); }

Predicate Abstraction with SATABS – http://www.cprover.org/ 52

slide-101
SLIDE 101

An Alternative Proof

int main() { int x, y; y=1; x=1; if (y>x) y−−; else

{y + 1 > x}

y++;

{y > x}

assert(y>x); }

Predicate Abstraction with SATABS – http://www.cprover.org/ 52

slide-102
SLIDE 102

An Alternative Proof

int main() { int x, y; y=1; x=1;

{¬y > x ⇒ y + 1 > x}

if (y>x) y−−; else

{y + 1 > x}

y++;

{y > x}

assert(y>x); }

Predicate Abstraction with SATABS – http://www.cprover.org/ 52

slide-103
SLIDE 103

An Alternative Proof

int main() { int x, y; y=1;

{¬y > 1 ⇒ y + 1 > 1}

x=1;

{¬y > x ⇒ y + 1 > x}

if (y>x) y−−; else

{y + 1 > x}

y++;

{y > x}

assert(y>x); }

Predicate Abstraction with SATABS – http://www.cprover.org/ 52

slide-104
SLIDE 104

An Alternative Proof

int main() { int x, y; y=1;

{¬y > 1 ⇒ y + 1 > 1}

x=1;

{¬y > x ⇒ y + 1 > x}

if (y>x) y−−; else

{y + 1 > x}

y++;

{y > x}

assert(y>x); }

We are using weakest pre-conditions here

wp(x:=E, P) = P[x/E] wp(S;T, Q) = wp(S, wp(T, Q)) wp(if(c) A else B, P) = (B ⇒ wp(A, P))∧ (¬B ⇒ wp(B, P))

The proof for the ”true” branch is missing

Predicate Abstraction with SATABS – http://www.cprover.org/ 52

slide-105
SLIDE 105

Refinement Algorithms

Using WP

  • 1. Start with failed guard G
  • 2. Compute wp(G) along the path

Using SP

  • 1. Start at beginning
  • 2. Compute sp(. . .) along the path

◮ Both methods eliminate the trace ◮ Advantages/disadvantages?

Predicate Abstraction with SATABS – http://www.cprover.org/ 53

slide-106
SLIDE 106

Predicate Localization

Example:

int x, y; x=10; y=x+10; y=y+10; assert(y==30);

  • riginal program
slide-107
SLIDE 107

Predicate Localization

Example:

int x, y; x=10; y=x+10; y=y+10; assert(y==30);

  • riginal program

+

x = 10 y = 20 y = 30 predicates

slide-108
SLIDE 108

Predicate Localization

Example:

int x, y; x=10; y=x+10; y=y+10; assert(y==30);

  • riginal program

+

x = 10 y = 20 y = 30 predicates

=

bool x10, y20, y30; x10=1; y20,y30=x10?1:∗,∗; y20,y30=∗,y20?1:∗; assert(y30);

abstraction

Predicate Abstraction with SATABS – http://www.cprover.org/ 54

slide-109
SLIDE 109

Predicate Localization

Example:

int x, y; x=10;

{x = 10}

y=x+10;

{y = 20}

y=y+10;

{y = 30}

assert(y==30);

  • riginal program

+

x = 10 y = 20 y = 30 predicates

=

bool x10, y20, y30; x10=1; y20,y30=x10?1:∗,∗; y20,y30=∗,y20?1:∗; assert(y30);

abstraction

Predicate Abstraction with SATABS – http://www.cprover.org/ 54

slide-110
SLIDE 110

Predicate Localization

Example:

int x, y; x=10;

{x = 10}

y=x+10;

{y = 20}

y=y+10;

{y = 30}

assert(y==30);

  • riginal program

+

x = 10 y = 20 y = 30 predicates

=

bool x10, y20, y30; x10=1; y20,y30=x10?1:∗,∗; y20,y30=∗,y20?1:∗; assert(y30);

abstraction We really only want to track specific predicates at each location!

Predicate Abstraction with SATABS – http://www.cprover.org/ 54

slide-111
SLIDE 111

Predicate Localization

◮ Track a separate set of predicates for each location

✔ Makes predicate image easier ✔ Makes simulation of transitions easier ✔ Makes the check of the abstract model easier

Predicate Abstraction with SATABS – http://www.cprover.org/ 55

slide-112
SLIDE 112

Predicate Refinement for Paths

Recall the decision problem we build for simulating paths: x1 = 10 ∧ y1 = x1 + 10 ∧ y2 = y1 + 10 ∧ y2 = 30

slide-113
SLIDE 113

Predicate Refinement for Paths

Recall the decision problem we build for simulating paths: x1 = 10 ∧ y1 = x1 + 10 ∧ y2 = y1 + 10 ∧ y2 = 30 ⇒ x1 = 10

slide-114
SLIDE 114

Predicate Refinement for Paths

Recall the decision problem we build for simulating paths: x1 = 10 ∧ y1 = x1 + 10 ∧ y2 = y1 + 10 ∧ y2 = 30 ⇒ x1 = 10 ⇒ y1 = 20

slide-115
SLIDE 115

Predicate Refinement for Paths

Recall the decision problem we build for simulating paths: x1 = 10 ∧ y1 = x1 + 10 ∧ y2 = y1 + 10 ∧ y2 = 30 ⇒ x1 = 10 ⇒ y1 = 20 ⇒ y2 = 30

slide-116
SLIDE 116

Predicate Refinement for Paths

Recall the decision problem we build for simulating paths: x1 = 10 ∧ y1 = x1 + 10 ∧ y2 = y1 + 10 ∧ y2 = 30 ⇒ x1 = 10 ⇒ y1 = 20 ⇒ y2 = 30 ⇒ false

slide-117
SLIDE 117

Predicate Refinement for Paths

Recall the decision problem we build for simulating paths: x1 = 10 ∧ y1 = x1 + 10 ∧ y2 = y1 + 10 ∧ y2 = 30 ⇒ x1 = 10 ⇒ y1 = 20 ⇒ y2 = 30 ⇒ false A1 A2

  • A3
  • A4
slide-118
SLIDE 118

Predicate Refinement for Paths

Recall the decision problem we build for simulating paths: x1 = 10 ∧ y1 = x1 + 10 ∧ y2 = y1 + 10 ∧ y2 = 30 ⇒ x1 = 10 ⇒ y1 = 20 ⇒ y2 = 30 ⇒ false A1 A2

  • A3
  • A4

A′

1

A′

2

A′

3

A′

4

Predicate Abstraction with SATABS – http://www.cprover.org/ 56

slide-119
SLIDE 119

Predicate Refinement for Paths

For a path with n steps: A1 A2 A3 . . . An true ⇒A′

1

⇒A′

2

⇒A′

3

⇒A′

n−1

⇒false

Predicate Abstraction with SATABS – http://www.cprover.org/ 57

slide-120
SLIDE 120

Predicate Refinement for Paths

For a path with n steps: A1 A2 A3 . . . An true ⇒A′

1

⇒A′

2

⇒A′

3

⇒A′

n−1

⇒false

◮ Given A1, . . . , An with i Ai = false ◮ A′ 0 = true and A′ n = false ◮ (A′ i−1 ∧ Ai) ⇒ A′ i for i ∈ {1, . . . , n}

Predicate Abstraction with SATABS – http://www.cprover.org/ 57

slide-121
SLIDE 121

Predicate Refinement for Paths

For a path with n steps: A1 A2 A3 . . . An true ⇒A′

1

⇒A′

2

⇒A′

3

⇒A′

n−1

⇒false

◮ Given A1, . . . , An with i Ai = false ◮ A′ 0 = true and A′ n = false ◮ (A′ i−1 ∧ Ai) ⇒ A′ i for i ∈ {1, . . . , n} ◮ Finally, Vars(A′ i) ⊆ (Vars(A1 . . . Ai) ∩ Vars(Ai+1 . . . An))

Predicate Abstraction with SATABS – http://www.cprover.org/ 57

slide-122
SLIDE 122

Predicate Refinement for Paths

Special case n = 2:

◮ A ∧ B = false ◮ A ⇒ A′ ◮ A′ ∧ B = false ◮ Vars(A′) ⊆ (Vars(A) ∩ Vars(B))

Predicate Abstraction with SATABS – http://www.cprover.org/ 58

slide-123
SLIDE 123

Predicate Refinement for Paths

Special case n = 2:

◮ A ∧ B = false ◮ A ⇒ A′ ◮ A′ ∧ B = false ◮ Vars(A′) ⊆ (Vars(A) ∩ Vars(B))

  • W. Craig’s Interpolation theorem (1957):

such an A′ exists for any first-order, inconsistent A and B.

Predicate Abstraction with SATABS – http://www.cprover.org/ 58

slide-124
SLIDE 124

Predicate Refinement with Craig Interpolants

✔ For propositional logic, a propositional Craig Interpolant can be extracted from a resolution proof (→ SAT!) in linear time ✔ Interpolating solvers available for linear arithmetic over the reals and integer difference logic with uninterpreted functions ✘ Not possible for every fragment of FOL: x = 2y and x = 2z + 1 with x, y, z ∈ Z

Predicate Abstraction with SATABS – http://www.cprover.org/ 59

slide-125
SLIDE 125

Predicate Refinement with Craig Interpolants

✔ For propositional logic, a propositional Craig Interpolant can be extracted from a resolution proof (→ SAT!) in linear time ✔ Interpolating solvers available for linear arithmetic over the reals and integer difference logic with uninterpreted functions ✘ Not possible for every fragment of FOL: x = 2y and x = 2z + 1 with x, y, z ∈ Z The interpolant is “x is even”

Predicate Abstraction with SATABS – http://www.cprover.org/ 59

slide-126
SLIDE 126

Craig Interpolation for Linear Inequalities

0 ≤ x 0 ≤ y 0 ≤ c1x + c2y with 0 ≤ c1, c2

◮ “Cutting-planes” ◮ Naturally arise in Fourier-Motzkin or Simplex

Predicate Abstraction with SATABS – http://www.cprover.org/ 60

slide-127
SLIDE 127

Example

A = (0 ≤ x − y) ∧ (0 ≤ y−z−1) B = (0 ≤ z−x)

slide-128
SLIDE 128

Example

A = (0 ≤ x − y) ∧ (0 ≤ y−z−1) B = (0 ≤ z−x) 0 ≤ y−z−1 0 ≤ z−x

slide-129
SLIDE 129

Example

A = (0 ≤ x − y) ∧ (0 ≤ y−z−1) B = (0 ≤ z−x) 0 ≤ y−z−1 0 ≤ z−x 0 ≤ y−x−1

slide-130
SLIDE 130

Example

A = (0 ≤ x − y) ∧ (0 ≤ y−z−1) B = (0 ≤ z−x) 0 ≤ y−z−1 0 ≤ z−x 0 ≤ y−x−1 0 ≤ x−y 0 ≤ −1

slide-131
SLIDE 131

Example

A = (0 ≤ x − y) ∧ (0 ≤ y−z−1) B = (0 ≤ z−x) 0 ≤ y−z−1 0 ≤ z−x 0 ≤ y−x−1 0 ≤ x−y 0 ≤ −1 0 ≤ y−z−1 0 ≤ 0 0 ≤ y−z−1 0 ≤ x−y 0 ≤ x−z−1

slide-132
SLIDE 132

Example

A = (0 ≤ x − y) ∧ (0 ≤ y−z−1) B = (0 ≤ z−x) 0 ≤ y−z−1 0 ≤ z−x 0 ≤ y−x−1 0 ≤ x−y 0 ≤ −1 0 ≤ y−z−1 0 ≤ 0 0 ≤ y−z−1 0 ≤ x−y 0 ≤ x−z−1 ⇐ ⇒ z−x ≤ −1

Predicate Abstraction with SATABS – http://www.cprover.org/ 61

slide-133
SLIDE 133

Example

A = (0 ≤ x − y) ∧ (0 ≤ y−z−1) B = (0 ≤ z−x) 0 ≤ y−z−1 0 ≤ z−x 0 ≤ y−x−1 0 ≤ x−y 0 ≤ −1 0 ≤ y−z−1 0 ≤ 0 0 ≤ y−z−1 0 ≤ x−y 0 ≤ x−z−1 ⇐ ⇒ z−x ≤ −1 Just sum the inequalities from A , and you get an interpolant!

Predicate Abstraction with SATABS – http://www.cprover.org/ 61

slide-134
SLIDE 134

Approximating Loop Invariants: SP

int x , y ; x=y=0; while ( x !=10) { x++; y++; } assert ( y ==10);

The SP refinement results in sp(x=y=0, true) = x = 0 ∧ y = 0

Predicate Abstraction with SATABS – http://www.cprover.org/ 62

slide-135
SLIDE 135

Approximating Loop Invariants: SP

int x , y ; x=y=0; while ( x !=10) { x++; y++; } assert ( y ==10);

The SP refinement results in sp(x=y=0, true) = x = 0 ∧ y = 0 sp(x++; y++, . . .) = x = 1 ∧ y = 1

Predicate Abstraction with SATABS – http://www.cprover.org/ 62

slide-136
SLIDE 136

Approximating Loop Invariants: SP

int x , y ; x=y=0; while ( x !=10) { x++; y++; } assert ( y ==10);

The SP refinement results in sp(x=y=0, true) = x = 0 ∧ y = 0 sp(x++; y++, . . .) = x = 1 ∧ y = 1 sp(x++; y++, . . .) = x = 2 ∧ y = 2

Predicate Abstraction with SATABS – http://www.cprover.org/ 62

slide-137
SLIDE 137

Approximating Loop Invariants: SP

int x , y ; x=y=0; while ( x !=10) { x++; y++; } assert ( y ==10);

The SP refinement results in sp(x=y=0, true) = x = 0 ∧ y = 0 sp(x++; y++, . . .) = x = 1 ∧ y = 1 sp(x++; y++, . . .) = x = 2 ∧ y = 2 sp(x++; y++, . . .) = x = 3 ∧ y = 3 . . . ✘ 10 iterations required to prove the property. ✘ It won’t work if we replace 10 by n.

Predicate Abstraction with SATABS – http://www.cprover.org/ 62

slide-138
SLIDE 138

Approximating Loop Invariants: WP

int x , y ; x=y=0; while ( x !=10) { x++; y++; } assert ( y ==10);

The WP refinement results in wp(x==10, y = 10) = y = 10 ∧ x = 10

Predicate Abstraction with SATABS – http://www.cprover.org/ 63

slide-139
SLIDE 139

Approximating Loop Invariants: WP

int x , y ; x=y=0; while ( x !=10) { x++; y++; } assert ( y ==10);

The WP refinement results in wp(x==10, y = 10) = y = 10 ∧ x = 10 wp(x++; y++, . . .) = y = 9 ∧ x = 9

Predicate Abstraction with SATABS – http://www.cprover.org/ 63

slide-140
SLIDE 140

Approximating Loop Invariants: WP

int x , y ; x=y=0; while ( x !=10) { x++; y++; } assert ( y ==10);

The WP refinement results in wp(x==10, y = 10) = y = 10 ∧ x = 10 wp(x++; y++, . . .) = y = 9 ∧ x = 9 wp(x++; y++, . . .) = y = 8 ∧ x = 8

Predicate Abstraction with SATABS – http://www.cprover.org/ 63

slide-141
SLIDE 141

Approximating Loop Invariants: WP

int x , y ; x=y=0; while ( x !=10) { x++; y++; } assert ( y ==10);

The WP refinement results in wp(x==10, y = 10) = y = 10 ∧ x = 10 wp(x++; y++, . . .) = y = 9 ∧ x = 9 wp(x++; y++, . . .) = y = 8 ∧ x = 8 wp(x++; y++, . . .) = y = 7 ∧ x = 7

Predicate Abstraction with SATABS – http://www.cprover.org/ 63

slide-142
SLIDE 142

Approximating Loop Invariants: WP

int x , y ; x=y=0; while ( x !=10) { x++; y++; } assert ( y ==10);

The WP refinement results in wp(x==10, y = 10) = y = 10 ∧ x = 10 wp(x++; y++, . . .) = y = 9 ∧ x = 9 wp(x++; y++, . . .) = y = 8 ∧ x = 8 wp(x++; y++, . . .) = y = 7 ∧ x = 7 . . . ✘ Also requires 10 iterations. ✘ It won’t work if we replace 10 by n.

Predicate Abstraction with SATABS – http://www.cprover.org/ 63

slide-143
SLIDE 143

What do we really need?

Consider an SSA-unwinding with 3 loop iterations: x1 = 0 y1 = 0

slide-144
SLIDE 144

What do we really need?

Consider an SSA-unwinding with 3 loop iterations: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It.

slide-145
SLIDE 145

What do we really need?

Consider an SSA-unwinding with 3 loop iterations: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It.

slide-146
SLIDE 146

What do we really need?

Consider an SSA-unwinding with 3 loop iterations: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It. x3 = 10 x4 = x3+1 y4 = y3+1 3rd It.

slide-147
SLIDE 147

What do we really need?

Consider an SSA-unwinding with 3 loop iterations: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It. x3 = 10 x4 = x3+1 y4 = y3+1 3rd It. x4 = 10 y4 = 10 Assertion

slide-148
SLIDE 148

What do we really need?

Consider an SSA-unwinding with 3 loop iterations: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It. x3 = 10 x4 = x3+1 y4 = y3+1 3rd It. x4 = 10 y4 = 10 Assertion x1 = 0 y1 = 0

slide-149
SLIDE 149

What do we really need?

Consider an SSA-unwinding with 3 loop iterations: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It. x3 = 10 x4 = x3+1 y4 = y3+1 3rd It. x4 = 10 y4 = 10 Assertion x1 = 0 y1 = 0 x2 = 1 y2 = 1

slide-150
SLIDE 150

What do we really need?

Consider an SSA-unwinding with 3 loop iterations: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It. x3 = 10 x4 = x3+1 y4 = y3+1 3rd It. x4 = 10 y4 = 10 Assertion x1 = 0 y1 = 0 x2 = 1 y2 = 1 x3 = 2 y3 = 2

slide-151
SLIDE 151

What do we really need?

Consider an SSA-unwinding with 3 loop iterations: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It. x3 = 10 x4 = x3+1 y4 = y3+1 3rd It. x4 = 10 y4 = 10 Assertion x1 = 0 y1 = 0 x2 = 1 y2 = 1 x3 = 2 y3 = 2 x4 = 3 y4 = 3

Predicate Abstraction with SATABS – http://www.cprover.org/ 64

slide-152
SLIDE 152

What do we really need?

Consider an SSA-unwinding with 3 loop iterations: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It. x3 = 10 x4 = x3+1 y4 = y3+1 3rd It. x4 = 10 y4 = 10 Assertion x1 = 0 y1 = 0 x2 = 1 y2 = 1 x3 = 2 y3 = 2 x4 = 3 y4 = 3 ✘This proof will produce the same predicates as SP .

Predicate Abstraction with SATABS – http://www.cprover.org/ 64

slide-153
SLIDE 153

Split Provers

Idea: P1 P2 P3 . . . Pn

◮ Each prover Pi only knows Ai, but they exchange facts ◮ We require that each prover only exchanges facts with

common symbols

◮ Plus, we restrict the facts exchanged to some language L

Predicate Abstraction with SATABS – http://www.cprover.org/ 65

slide-154
SLIDE 154

Back to the Example

Restriction to language L = “no new constants”: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It. x3 = 10 x4 = x3+1 y4 = y3+1 3rd It. x4 = 10 y4 = 10 Assertion

slide-155
SLIDE 155

Back to the Example

Restriction to language L = “no new constants”: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It. x3 = 10 x4 = x3+1 y4 = y3+1 3rd It. x4 = 10 y4 = 10 Assertion x1 = 0 y1 = 0

slide-156
SLIDE 156

Back to the Example

Restriction to language L = “no new constants”: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It. x3 = 10 x4 = x3+1 y4 = y3+1 3rd It. x4 = 10 y4 = 10 Assertion x1 = 0 y1 = 0 x2 = 1 y2 = 1

Predicate Abstraction with SATABS – http://www.cprover.org/ 66

slide-157
SLIDE 157

Back to the Example

Restriction to language L = “no new constants”: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It. x3 = 10 x4 = x3+1 y4 = y3+1 3rd It. x4 = 10 y4 = 10 Assertion x1 = 0 y1 = 0 x2 = 1 y2 = 1 x3 = 2 y3 = 2

Predicate Abstraction with SATABS – http://www.cprover.org/ 66

slide-158
SLIDE 158

Back to the Example

Restriction to language L = “no new constants”: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It. x3 = 10 x4 = x3+1 y4 = y3+1 3rd It. x4 = 10 y4 = 10 Assertion x1 = 0 y1 = 0 x2 = 1 y2 = 1 x3 = 2 y3 = 2

Predicate Abstraction with SATABS – http://www.cprover.org/ 66

slide-159
SLIDE 159

Back to the Example

Restriction to language L = “no new constants”: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It. x3 = 10 x4 = x3+1 y4 = y3+1 3rd It. x4 = 10 y4 = 10 Assertion x1 = 0 y1 = 0 x2 = 1 y2 = 1 x3 = y3

Predicate Abstraction with SATABS – http://www.cprover.org/ 66

slide-160
SLIDE 160

Back to the Example

Restriction to language L = “no new constants”: x1 = 0 y1 = 0 x1 = 10 x2 = x1+1 y2 = y1+1 1st It. x2 = 10 x3 = x2+1 y3 = y2+1 2nd It. x3 = 10 x4 = x3+1 y4 = y3+1 3rd It. x4 = 10 y4 = 10 Assertion x1 = 0 y1 = 0 x2 = 1 y2 = 1 x3 = y3 x4 = y4

Predicate Abstraction with SATABS – http://www.cprover.org/ 66

slide-161
SLIDE 161

Invariants from Restricted Proofs

✔ The language restriction forces the solver to generalize!

◮ Algorithm: ◮ If the proof fails, increase L! ◮ If we fail to get a sufficiently strong

invariant, increase n. ✔ This does work if we replace 10 by n!

Predicate Abstraction with SATABS – http://www.cprover.org/ 67

slide-162
SLIDE 162

Invariants from Restricted Proofs

✔ The language restriction forces the solver to generalize!

◮ Algorithm: ◮ If the proof fails, increase L! ◮ If we fail to get a sufficiently strong

invariant, increase n. ✔ This does work if we replace 10 by n! ? Which L1, L2, . . . is complete for which programs?

Predicate Abstraction with SATABS – http://www.cprover.org/ 67