SMT-Style Program Analysis with Value-based Refinements Vijay - - PowerPoint PPT Presentation

smt style program analysis with value based refinements
SMART_READER_LITE
LIVE PREVIEW

SMT-Style Program Analysis with Value-based Refinements Vijay - - PowerPoint PPT Presentation

SMT-Style Program Analysis SMT-Style Program Analysis with Value-based Refinements Vijay DSilva Leopold Haller Daniel Kr oning NSV-3 July 15, 2010 SMT-Style Program Analysis Outline Imprecision and Refinement in Abstract


slide-1
SLIDE 1

SMT-Style Program Analysis

SMT-Style Program Analysis with Value-based Refinements

Vijay D’Silva Leopold Haller Daniel Kr¨

  • ning

NSV-3 July 15, 2010

slide-2
SLIDE 2

SMT-Style Program Analysis

Outline

Imprecision and Refinement in Abstract Interpretation SAT Style Abstract Analysis Value-based Refinement for Intervals

slide-3
SLIDE 3

SMT-Style Program Analysis Imprecision and Refinement in AI

Imprecision in Abstract Interpretation

◮ Abstract interpretation sound but not complete. ◮ Incompleteness manifests in imprecision during the analysis.

slide-4
SLIDE 4

SMT-Style Program Analysis Imprecision and Refinement in AI

Imprecision in Abstract Interpretation

◮ Abstract interpretation sound but not complete. ◮ Incompleteness manifests in imprecision during the analysis.

⊥ [1, 1] [2, 2] [3, 3] [1, 2] [2, 3] [1, 3] ⊤ Example: Domain of Intervals

slide-5
SLIDE 5

SMT-Style Program Analysis Imprecision and Refinement in AI

Imprecisions in the Domain

Imprecision in join x:=*; if(x > 5) y := -1; else y := 1; assert(y != 0);

slide-6
SLIDE 6

SMT-Style Program Analysis Imprecision and Refinement in AI

Imprecisions in the Domain

Imprecision in join x:=*; if(x > 5) y := -1; else y := 1; assert(y != 0);

y ∈ [−1, −1], x ∈ [6, ∞]

slide-7
SLIDE 7

SMT-Style Program Analysis Imprecision and Refinement in AI

Imprecisions in the Domain

Imprecision in join x:=*; if(x > 5) y := -1; else y := 1; assert(y != 0);

y ∈ [−1, −1], x ∈ [6, ∞] y ∈ [1, 1], x ∈ [−∞, 5]

slide-8
SLIDE 8

SMT-Style Program Analysis Imprecision and Refinement in AI

Imprecisions in the Domain

Imprecision in join x:=*; if(x > 5) y := -1; else y := 1; assert(y != 0);

y ∈ [−1, −1], x ∈ [6, ∞] y ∈ [1, 1], x ∈ [−∞, 5] y ∈ [−1, 1]

The disjunction y = 1 ∨ y = −1 cannot be expressed as an interval.

slide-9
SLIDE 9

SMT-Style Program Analysis Imprecision and Refinement in AI

Imprecisions in the Domain

Imprecision in transformer x:=y; if(x > 5) assert(y > 5);

slide-10
SLIDE 10

SMT-Style Program Analysis Imprecision and Refinement in AI

Imprecisions in the Domain

Imprecision in transformer x:=y; if(x > 5) assert(y > 5); ⊤

slide-11
SLIDE 11

SMT-Style Program Analysis Imprecision and Refinement in AI

Imprecisions in the Domain

Imprecision in transformer x:=y; if(x > 5) assert(y > 5); ⊤ x ∈ [6, ∞]

slide-12
SLIDE 12

SMT-Style Program Analysis Imprecision and Refinement in AI

Imprecisions in the Domain

Imprecision in transformer x:=y; if(x > 5) assert(y > 5); ⊤ x ∈ [6, ∞] Intervals cannot express relational information.

slide-13
SLIDE 13

SMT-Style Program Analysis Imprecision and Refinement in AI

Imprecisions in the Analysis

Imprecision in widening while(x < 50000) { x++; if(y < x) y++; }

x ∈ [0, 0], y ∈ [0, 0] x ∈ [0, 1], y ∈ [0, 1] widening x ∈ [0, ∞], y ∈ [0, ∞] x ∈ [50000, 50000], y ∈ [0, ∞]

Precision can be lost in the the analysis Refinement of widening studied by, e.g., Gulavani et. al (TACAS 2008), Wang et al. (CAV 2007)

slide-14
SLIDE 14

SMT-Style Program Analysis Imprecision and Refinement in AI

Refining Abstract Domains

Global domain refinement

slide-15
SLIDE 15

SMT-Style Program Analysis Imprecision and Refinement in AI

Refining Abstract Domains

Global domain refinement More powerful domain Octagons Polyhedra . . .

slide-16
SLIDE 16

SMT-Style Program Analysis Imprecision and Refinement in AI

Refining Abstract Domains

Global domain refinement More powerful domain Octagons Polyhedra . . . Disjunctive completion ⊤ ≤ 0 = 0 ≥ 0 − + ⊥

slide-17
SLIDE 17

SMT-Style Program Analysis Imprecision and Refinement in AI

Refining Abstract Domains

Global domain refinement More powerful domain Octagons Polyhedra . . . Disjunctive completion ⊤ ≤ 0 = 0 ≥ 0 − + ⊥ Reduced product Cardinal power

◮ Global refinements potentially expensive. ◮ How can we locally refine an abstract domain?

slide-18
SLIDE 18

SMT-Style Program Analysis Imprecision and Refinement in AI

Trace Partitioning

◮ Trace partitioning allows for flexible and local refinement

slide-19
SLIDE 19

SMT-Style Program Analysis Imprecision and Refinement in AI

Trace Partitioning

◮ Trace partitioning allows for flexible and local refinement

◮ Consider separately different sets of traces through a program ◮ Similar to case splits in a mathematical proof.

slide-20
SLIDE 20

SMT-Style Program Analysis Imprecision and Refinement in AI

Trace Partitioning

◮ Trace partitioning allows for flexible and local refinement

◮ Consider separately different sets of traces through a program ◮ Similar to case splits in a mathematical proof.

Control-flow based trace partitioning

x := * [x > 5] [x <= 5] y := 1 y := -1 assert(y != 0)

slide-21
SLIDE 21

SMT-Style Program Analysis Imprecision and Refinement in AI

Trace Partitioning

◮ Trace partitioning allows for flexible and local refinement

◮ Consider separately different sets of traces through a program ◮ Similar to case splits in a mathematical proof.

Control-flow based trace partitioning

x := * [x > 5] [x <= 5] y := 1 y := -1 assert(y != 0)

y = −1

slide-22
SLIDE 22

SMT-Style Program Analysis Imprecision and Refinement in AI

Trace Partitioning

◮ Trace partitioning allows for flexible and local refinement

◮ Consider separately different sets of traces through a program ◮ Similar to case splits in a mathematical proof.

Control-flow based trace partitioning

x := * [x > 5] [x <= 5] y := 1 y := -1 assert(y != 0)

y = −1 y = 1

slide-23
SLIDE 23

SMT-Style Program Analysis Imprecision and Refinement in AI

Trace Partitioning

◮ Wide range of partitionings possible

◮ control flow, ◮ values of variables, ◮ number of iterations through a loop, etc.

slide-24
SLIDE 24

SMT-Style Program Analysis Imprecision and Refinement in AI

Trace Partitioning

◮ Wide range of partitionings possible

◮ control flow, ◮ values of variables, ◮ number of iterations through a loop, etc.

Value-based partitioning x:=y; if(x > 5) assert(y > 5);

slide-25
SLIDE 25

SMT-Style Program Analysis Imprecision and Refinement in AI

Trace Partitioning

◮ Wide range of partitionings possible

◮ control flow, ◮ values of variables, ◮ number of iterations through a loop, etc.

Value-based partitioning x:=y; if(x > 5) assert(y > 5); assume(y > 5);

y > 5

slide-26
SLIDE 26

SMT-Style Program Analysis Imprecision and Refinement in AI

Trace Partitioning

◮ Wide range of partitionings possible

◮ control flow, ◮ values of variables, ◮ number of iterations through a loop, etc.

Value-based partitioning x:=y; if(x > 5) assert(y > 5); assume(y > 5);

y > 5

assume(y <= 5);

slide-27
SLIDE 27

SMT-Style Program Analysis Imprecision and Refinement in AI

Finding Partitioning Functions

◮ Trace partitioning allows one to refine the precision of an analysis

down to explicit exploration of all traces.

slide-28
SLIDE 28

SMT-Style Program Analysis Imprecision and Refinement in AI

Finding Partitioning Functions

◮ Trace partitioning allows one to refine the precision of an analysis

down to explicit exploration of all traces. The main question is:

slide-29
SLIDE 29

SMT-Style Program Analysis Imprecision and Refinement in AI

Finding Partitioning Functions

◮ Trace partitioning allows one to refine the precision of an analysis

down to explicit exploration of all traces. The main question is: How can we find a good partitioning?

slide-30
SLIDE 30

SMT-Style Program Analysis Imprecision and Refinement in AI

Finding Partitioning Functions

◮ Trace partitioning allows one to refine the precision of an analysis

down to explicit exploration of all traces. The main question is: How can we find a good partitioning?

◮ Precise enough to prove the property, and ◮ abstract enough to be efficient.

slide-31
SLIDE 31

SMT-Style Program Analysis Imprecision and Refinement in AI

Finding Partitioning Functions

◮ Leino and Logozzo (APLAS 2005): Value-based trace partitionings

based on counter examples

◮ Gulavani et al. (TACAS 2008): DAG-based Exploration of

control-flow paths inside loops with splitting on demand.

◮ Gulwani et al. (PLDI 2009): Control-flow refinement for bounds

analysis.

◮ Harris et al. (POPL 2010): Satisfiability Modulo Path Programs

slide-32
SLIDE 32

SMT-Style Program Analysis SAT Style Abstract Analysis

Value-based Trace Partitionings

◮ If the abstract transformer ˆ

F is too imprecise, find a set of transformers ˆ F1, . . . , ˆ Fk, such that

  • 1≤i≤k

γ(µX. ˆ Fi(X)) ⊇ µX. F(X)

slide-33
SLIDE 33

SMT-Style Program Analysis SAT Style Abstract Analysis

Value-based Trace Partitionings

◮ If the abstract transformer ˆ

F is too imprecise, find a set of transformers ˆ F1, . . . , ˆ Fk, such that

  • 1≤i≤k

γ(µX. ˆ Fi(X)) ⊇ µX. F(X)

◮ This can be done by clipping the analysis by an abstract element:

ˆ Fi = ˆ F ⊓ ai

slide-34
SLIDE 34

SMT-Style Program Analysis SAT Style Abstract Analysis

Value-based Trace Partitionings

◮ If the abstract transformer ˆ

F is too imprecise, find a set of transformers ˆ F1, . . . , ˆ Fk, such that

  • 1≤i≤k

γ(µX. ˆ Fi(X)) ⊇ µX. F(X)

◮ This can be done by clipping the analysis by an abstract element:

ˆ Fi = ˆ F ⊓ ai

slide-35
SLIDE 35

SMT-Style Program Analysis SAT Style Abstract Analysis

Value-based Trace Partitionings

◮ If the abstract transformer ˆ

F is too imprecise, find a set of transformers ˆ F1, . . . , ˆ Fk, such that

  • 1≤i≤k

γ(µX. ˆ Fi(X)) ⊇ µX. F(X)

◮ This can be done by clipping the analysis by an abstract element:

ˆ Fi = ˆ F ⊓ ai

+

slide-36
SLIDE 36

SMT-Style Program Analysis SAT Style Abstract Analysis

Value-based Trace Partitionings

◮ If the abstract transformer ˆ

F is too imprecise, find a set of transformers ˆ F1, . . . , ˆ Fk, such that

  • 1≤i≤k

γ(µX. ˆ Fi(X)) ⊇ µX. F(X)

◮ This can be done by clipping the analysis by an abstract element:

ˆ Fi = ˆ F ⊓ ai

+ =

slide-37
SLIDE 37

SMT-Style Program Analysis SAT Style Abstract Analysis

Value-based Trace Partitionings

New question:

slide-38
SLIDE 38

SMT-Style Program Analysis SAT Style Abstract Analysis

Value-based Trace Partitionings

New question: How can we find such a set of elements a1, . . . , ak?

slide-39
SLIDE 39

SMT-Style Program Analysis SAT Style Abstract Analysis

Value-based Trace Partitionings

New question: How can we find such a set of elements a1, . . . , ak? Use the search architecture of a SAT solver!

slide-40
SLIDE 40

SMT-Style Program Analysis SAT Style Abstract Analysis

DPLL framework

DPLL procedure

decide propagate Conflict learn backtrack

slide-41
SLIDE 41

SMT-Style Program Analysis SAT Style Abstract Analysis

DPLL framework

DPLL procedure

decide propagate Conflict learn backtrack

◮ Main phases of the DPLL procedure:

slide-42
SLIDE 42

SMT-Style Program Analysis SAT Style Abstract Analysis

DPLL framework

DPLL procedure

decide propagate Conflict learn backtrack

◮ Main phases of the DPLL procedure:

Decision Assume a value for an undetermined variable

slide-43
SLIDE 43

SMT-Style Program Analysis SAT Style Abstract Analysis

DPLL framework

DPLL procedure

decide propagate Conflict learn backtrack

◮ Main phases of the DPLL procedure:

Decision Assume a value for an undetermined variable Propagation Deduce implied variable values

slide-44
SLIDE 44

SMT-Style Program Analysis SAT Style Abstract Analysis

DPLL framework

DPLL procedure

decide propagate Conflict learn backtrack

◮ Main phases of the DPLL procedure:

Decision Assume a value for an undetermined variable Propagation Deduce implied variable values Learning Learn reason for conflict and backtrack

slide-45
SLIDE 45

SMT-Style Program Analysis SAT Style Abstract Analysis

DPLL framework

DPLL procedure

decide propagate Conflict learn backtrack

◮ Main phases of the DPLL procedure:

Decision Assume a value for an undetermined variable Propagation Deduce implied variable values Learning Learn reason for conflict and backtrack

slide-46
SLIDE 46

SMT-Style Program Analysis SAT Style Abstract Analysis

DPLL Procedure

Is φ(x, y, z) satisfiable?

slide-47
SLIDE 47

SMT-Style Program Analysis SAT Style Abstract Analysis

DPLL Procedure

Decision Is φ(x, y, z) satisfiable? x = 1

slide-48
SLIDE 48

SMT-Style Program Analysis SAT Style Abstract Analysis

DPLL Procedure

Propagation Is φ(x, y, z) satisfiable? x = 1 z = 0

slide-49
SLIDE 49

SMT-Style Program Analysis SAT Style Abstract Analysis

DPLL Procedure

Decision Is φ(x, y, z) satisfiable? x = 1 z = 0 y = 1

slide-50
SLIDE 50

SMT-Style Program Analysis SAT Style Abstract Analysis

DPLL Procedure

Propagation Is φ(x, y, z) satisfiable? x = 1 z = 0 y = 1 z = 1

slide-51
SLIDE 51

SMT-Style Program Analysis SAT Style Abstract Analysis

DPLL Procedure

Propagation Is φ(x, y, z) satisfiable? x = 1 z = 0 y = 1 z = 1 Conflict

slide-52
SLIDE 52

SMT-Style Program Analysis SAT Style Abstract Analysis

DPLL Procedure

Learning Is φ(x, y, z) satisfiable? x = 1 z = 0 y = 1 z = 1

slide-53
SLIDE 53

SMT-Style Program Analysis SAT Style Abstract Analysis

DPLL Procedure

Learning Is φ(x, y, z) satisfiable? x = 0

slide-54
SLIDE 54

SMT-Style Program Analysis SAT Style Abstract Analysis

SAT-Style Program Analysis

SAT-Style Program Analysis

decide clipped fixpoint Safety proven generalize backtrack

slide-55
SLIDE 55

SMT-Style Program Analysis SAT Style Abstract Analysis

SAT-Style Program Analysis

SAT-Style Program Analysis

decide clipped fixpoint Safety proven generalize backtrack Decision Refine current element a by a′ ⊏ a

slide-56
SLIDE 56

SMT-Style Program Analysis SAT Style Abstract Analysis

SAT-Style Program Analysis

SAT-Style Program Analysis

decide clipped fixpoint Safety proven generalize backtrack Decision Refine current element a by a′ ⊏ a Propagation Compute clipped fixpoint µX. ˆ T(X) ⊓ a′

slide-57
SLIDE 57

SMT-Style Program Analysis SAT Style Abstract Analysis

SAT-Style Program Analysis

SAT-Style Program Analysis

decide clipped fixpoint Safety proven generalize backtrack Decision Refine current element a by a′ ⊏ a Propagation Compute clipped fixpoint µX. ˆ T(X) ⊓ a′ Learning Find a′′ ⊒ a′, such that µX.ˆ F(X) ⊓ a′′ is safe.

slide-58
SLIDE 58

SMT-Style Program Analysis SAT Style Abstract Analysis

SAT-Style Program Analysis

⊤ A1 A2 A3 A4 B1 B2 B3 B4 B5 C1 C2 C3 C4 ⊥ Decision ⊤ Initially, a = ⊤

slide-59
SLIDE 59

SMT-Style Program Analysis SAT Style Abstract Analysis

SAT-Style Program Analysis

⊤ A1 A2 A3 A4 B1 B2 B3 B4 B5 C1 C2 C3 C4 ⊥ Propagation ⊤ Initially, a = ⊤ µX.ˆ F(X) not safe

slide-60
SLIDE 60

SMT-Style Program Analysis SAT Style Abstract Analysis

SAT-Style Program Analysis

⊤ A1 A2 A3 A4 B1 B2 B3 B4 B5 C1 C2 C3 C4 ⊥ Decision ⊤ A1 Decision: refine a

slide-61
SLIDE 61

SMT-Style Program Analysis SAT Style Abstract Analysis

SAT-Style Program Analysis

⊤ A1 A2 A3 A4 B1 B2 B3 B4 B5 C1 C2 C3 C4 ⊥ Propagation ⊤ A1 Decision: refine a µX.(ˆ F(X) ⊓ A1) not safe

slide-62
SLIDE 62

SMT-Style Program Analysis SAT Style Abstract Analysis

SAT-Style Program Analysis

⊤ A1 A2 A3 A4 B1 B2 B3 B4 B5 C1 C2 C3 C4 ⊥ Decision ⊤ A1 B2 Decision: refine a

slide-63
SLIDE 63

SMT-Style Program Analysis SAT Style Abstract Analysis

SAT-Style Program Analysis

⊤ A1 A2 A3 A4 B1 B2 B3 B4 B5 C1 C2 C3 C4 ⊥ Propagation ⊤ A1 B2 Decision: refine a µX.(ˆ F(X) ⊓ B2) safe

slide-64
SLIDE 64

SMT-Style Program Analysis SAT Style Abstract Analysis

SAT-Style Program Analysis

⊤ A1 A2 A3 A4 B1 B2 B3 B4 B5 C1 C2 C3 C4 ⊥ Generalization A1 B2

slide-65
SLIDE 65

SMT-Style Program Analysis SAT Style Abstract Analysis

SAT-Style Program Analysis

⊤ A1 A2 A3 A4 B1 B2 B3 B4 B5 C1 C2 C3 C4 ⊥ Generalization A1 B2 A2 µX.ˆ F(X) ⊓ A2 safe

slide-66
SLIDE 66

SMT-Style Program Analysis SAT Style Abstract Analysis

SAT-Style Program Analysis

⊤ A1 A2 A3 A4 B1 B2 B3 B4 B5 C1 C2 C3 C4 ⊥ Generalization A1 B2 A2 µX.ˆ F(X) ⊓ A2 safe

slide-67
SLIDE 67

SMT-Style Program Analysis SAT Style Abstract Analysis

SAT-Style Program Analysis

⊤ A1 A2 A3 A4 B1 B2 B3 B4 B5 C1 C2 C3 C4 ⊥ Generalization A1 A2 B2 B3 C1 C2 C3 ⊥ Backtrack and continue

slide-68
SLIDE 68

SMT-Style Program Analysis SAT Style Abstract Analysis

Comments on Analysis

◮ When can we efficiently prove safety with this?

slide-69
SLIDE 69

SMT-Style Program Analysis SAT Style Abstract Analysis

Comments on Analysis

◮ When can we efficiently prove safety with this?

◮ When there is a small and finite number of elements a1, . . . , ak

such that the fixpoints µX.(ˆ F(X) ⊓ ai) can be put together to form a concrete postfixpoint.

slide-70
SLIDE 70

SMT-Style Program Analysis SAT Style Abstract Analysis

Comments on Analysis

◮ When can we efficiently prove safety with this?

◮ When there is a small and finite number of elements a1, . . . , ak

such that the fixpoints µX.(ˆ F(X) ⊓ ai) can be put together to form a concrete postfixpoint.

◮ Specific implementation issues:

◮ Generalization step ◮ Decision heuristic

slide-71
SLIDE 71

SMT-Style Program Analysis Value-based Refinement for Intervals

Value-based Refinement for Intervals

We have created a preliminary instantiation of this framework for the domain of intervals.

slide-72
SLIDE 72

SMT-Style Program Analysis Value-based Refinement for Intervals

Value-based Refinement for Intervals

We have created a preliminary instantiation of this framework for the domain of intervals. Decision: Choose an initial assignment for all variables

slide-73
SLIDE 73

SMT-Style Program Analysis Value-based Refinement for Intervals

Value-based Refinement for Intervals

We have created a preliminary instantiation of this framework for the domain of intervals. Decision: Choose an initial assignment for all variables Propagation: Compute forward interpretation for this initial value

slide-74
SLIDE 74

SMT-Style Program Analysis Value-based Refinement for Intervals

Value-based Refinement for Intervals

We have created a preliminary instantiation of this framework for the domain of intervals. Decision: Choose an initial assignment for all variables Propagation: Compute forward interpretation for this initial value Generalization and Learning: Generalize the result by locally generalizing intervals. Re- move generalized initial values from selection pool

slide-75
SLIDE 75

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 1

Decision [x > 5] [x<= 5] y:=-1 y:=1 assert(y!=0); Choose initial: x = 0, y = 0

slide-76
SLIDE 76

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 1

Propagation [x > 5] [x<= 5] y:=-1 y:=1 assert(y!=0); Choose initial: x = 0, y = 0 x = 0, y = 0 ⊥ x = 0, y = 1 x = 0, y = 1

slide-77
SLIDE 77

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 1

Generalization [x > 5] [x<= 5] y:=-1 y:=1 assert(y!=0); Choose initial: x = 0, y = 0 x = 0, y = 0 ⊥ x = 0, y = 1 ⊤

slide-78
SLIDE 78

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 1

Generalization [x > 5] [x<= 5] y:=-1 y:=1 assert(y!=0); Choose initial: x = 0, y = 0 x = 0, y = 0 ⊥ ⊤ y > 0

slide-79
SLIDE 79

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 1

Generalization [x > 5] [x<= 5] y:=-1 y:=1 assert(y!=0); Choose initial: x = 0, y = 0 x = 0, y = 0 ⊤ y > 0 ⊥

slide-80
SLIDE 80

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 1

Generalization [x > 5] [x<= 5] y:=-1 y:=1 assert(y!=0); Choose initial: x = 0, y = 0 ⊤ y > 0 ⊥ ⊤

slide-81
SLIDE 81

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 1

Generalization [x > 5] [x<= 5] y:=-1 y:=1 assert(y!=0); ⊤ y > 0 ⊥ ⊤ Generalized init: x ≤ 5

slide-82
SLIDE 82

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 1

Decision [x > 5] [x<= 5] y:=-1 y:=1 assert(y!=0); ¬ x ≤ 5 Choose initial: x = 8, y = 0

slide-83
SLIDE 83

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 1

Propagation [x > 5] [x<= 5] y:=-1 y:=1 assert(y!=0); ¬ x ≤ 5 Choose initial: x = 8, y = 0 ⊥ x = 8, y = 0 x = 8, y = −1 x = 8, y = −1

slide-84
SLIDE 84

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 1

Generalization [x > 5] [x<= 5] y:=-1 y:=1 assert(y!=0); ¬ x ≤ 5 Generalized init: x > 5 ⊥ ⊤ y < 0 ⊤

slide-85
SLIDE 85

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 1

Generalization [x > 5] [x<= 5] y:=-1 y:=1 assert(y!=0); ¬ x ≤ 5 ¬ x > 5

slide-86
SLIDE 86

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 2

Decision

x:=y [x<5] assert(y<5) [x>=5]

x = 0, y = 1

slide-87
SLIDE 87

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 2

Propagation

x:=y [x<5] assert(y<5) [x>=5]

x = 0, y = 1 x = 1, y = 1 x = 1, y = 1 x = 1, y = 1

slide-88
SLIDE 88

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 2

Generalization

x:=y [x<5] assert(y<5) [x>=5]

Generalized init: y < 5 y < 5 y < 5 ⊤

slide-89
SLIDE 89

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 2

Generalization

x:=y [x<5] assert(y<5) [x>=5]

¬y < 5

slide-90
SLIDE 90

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 2

Decision

x:=y [x<5] assert(y<5) [x>=5]

¬y < 5 x = 0, y = 6

slide-91
SLIDE 91

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 2

Propagation

x:=y [x<5] assert(y<5) [x>=5]

¬y < 5 x = 0, y = 6 x = 6, y = 6 ⊥ x = 6, y = 6

slide-92
SLIDE 92

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 2

Generalization

x:=y [x<5] assert(y<5) [x>=5]

¬y < 5 Generalized init: y ≥ 5 x ≥ 5 y < 5 ⊤

slide-93
SLIDE 93

SMT-Style Program Analysis Value-based Refinement for Intervals

Example 2

x:=y [x<5] assert(y<5) [x>=5]

¬y < 5 ¬y ≥ 5

slide-94
SLIDE 94

SMT-Style Program Analysis Value-based Refinement for Intervals

Notes on Implementation

◮ Initial values chosen by call to a SAT solver.

slide-95
SLIDE 95

SMT-Style Program Analysis Value-based Refinement for Intervals

Notes on Implementation

◮ Initial values chosen by call to a SAT solver. ◮ Generalization uses local repair (SMPP):

◮ Set every location to ⊤ ◮ For each invalid triple {pre} stmt {post} ◮ repair with {pre} from forward analysis. ◮ generalize using search on bounds.

slide-96
SLIDE 96

SMT-Style Program Analysis Value-based Refinement for Intervals

Notes on Implementation

◮ Initial values chosen by call to a SAT solver. ◮ Generalization uses local repair (SMPP):

◮ Set every location to ⊤ ◮ For each invalid triple {pre} stmt {post} ◮ repair with {pre} from forward analysis. ◮ generalize using search on bounds.

◮ Generalization step:

0 ≤ a ≤ 5, b > 5, c < 10 Repair using SAT solver assert(a <= 10 || a >= -10) b > 5

slide-97
SLIDE 97

SMT-Style Program Analysis Value-based Refinement for Intervals

Notes on Implementation

◮ Initial values chosen by call to a SAT solver. ◮ Generalization uses local repair (SMPP):

◮ Set every location to ⊤ ◮ For each invalid triple {pre} stmt {post} ◮ repair with {pre} from forward analysis. ◮ generalize using search on bounds.

◮ Generalization step:

Repair using SAT solver 0 ≤ a ≤ 5, b > 5, c < 10 Increase bounds by search assert(a <= 10 || a >= -10) b > 5

slide-98
SLIDE 98

SMT-Style Program Analysis Value-based Refinement for Intervals

Notes on Implementation

◮ Initial values chosen by call to a SAT solver. ◮ Generalization uses local repair (SMPP):

◮ Set every location to ⊤ ◮ For each invalid triple {pre} stmt {post} ◮ repair with {pre} from forward analysis. ◮ generalize using search on bounds.

◮ Generalization step:

Repair using SAT solver Increase bounds by search 0 ≤ a ≤ ∞, b > 5, c < 10 assert(a <= 10 || a >= -10) b > 5

slide-99
SLIDE 99

SMT-Style Program Analysis Value-based Refinement for Intervals

Notes on Implementation

◮ Initial values chosen by call to a SAT solver. ◮ Generalization uses local repair (SMPP):

◮ Set every location to ⊤ ◮ For each invalid triple {pre} stmt {post} ◮ repair with {pre} from forward analysis. ◮ generalize using search on bounds.

◮ Generalization step:

Repair using SAT solver Increase bounds by search 0 ≤ a ≤ ∞, b > 5, c < 10 assert(a <= 10 || a >= -10) b > 5

slide-100
SLIDE 100

SMT-Style Program Analysis Value-based Refinement for Intervals

Notes on Implementation

◮ Initial values chosen by call to a SAT solver. ◮ Generalization uses local repair (SMPP):

◮ Set every location to ⊤ ◮ For each invalid triple {pre} stmt {post} ◮ repair with {pre} from forward analysis. ◮ generalize using search on bounds.

◮ Generalization step:

Repair using SAT solver Increase bounds by search −10 ≤ a ≤ ∞, b > 5, c < 10 assert(a <= 10 || a >= -10) b > 5

slide-101
SLIDE 101

SMT-Style Program Analysis Value-based Refinement for Intervals

Preliminary benchmarks

◮ Selection of NEC Small Static Analysis Benchmarks (slightly

modified)

◮ Interval analysis too imprecise in all cases

slide-102
SLIDE 102

SMT-Style Program Analysis Value-based Refinement for Intervals

Preliminary benchmarks

◮ Selection of NEC Small Static Analysis Benchmarks (slightly

modified)

◮ Interval analysis too imprecise in all cases

Inst. # paths (SCC-decomp.) runtime (s) iterations inf1.c 36 * * inf2.c 12 0.7 5 inf3.c 16 0.9 4 inf4.c 1080 * * inf5.c 28 2.1 19 inf6.c 32 0.9 4 inf7.c 27 1.7 7 inf8.c 40 3.3 9

slide-103
SLIDE 103

SMT-Style Program Analysis Value-based Refinement for Intervals

Preliminary benchmarks

◮ Selection of NEC Small Static Analysis Benchmarks (slightly

modified)

◮ Interval analysis too imprecise in all cases

Inst. # paths (SCC-decomp.) runtime (s) iterations inf1.c 36 * * inf2.c 12 0.7 5 inf3.c 16 0.9 4 inf4.c 1080 * * inf5.c 28 2.1 19 inf6.c 32 0.9 4 inf7.c 27 1.7 7 inf8.c 40 3.3 9

◮ Does not work if fully relational information is required

(inf1.c,inf4.c) assume(x > y); assert(x > y);

slide-104
SLIDE 104

SMT-Style Program Analysis Value-based Refinement for Intervals

Current Work

◮ Extending the prototype into a tool

slide-105
SLIDE 105

SMT-Style Program Analysis Value-based Refinement for Intervals

Current Work

◮ Extending the prototype into a tool ◮ Move towards a fully SAT-style analyzer

slide-106
SLIDE 106

SMT-Style Program Analysis Value-based Refinement for Intervals

Current Work

◮ Extending the prototype into a tool ◮ Move towards a fully SAT-style analyzer ◮ Handling of floating-point numbers

slide-107
SLIDE 107

SMT-Style Program Analysis Value-based Refinement for Intervals

Current Work

◮ Extending the prototype into a tool ◮ Move towards a fully SAT-style analyzer ◮ Handling of floating-point numbers ◮ Move to more powerful domains

slide-108
SLIDE 108

SMT-Style Program Analysis Value-based Refinement for Intervals

Current Work

◮ Extending the prototype into a tool ◮ Move towards a fully SAT-style analyzer ◮ Handling of floating-point numbers ◮ Move to more powerful domains ◮ Use trace partitioning and SMT/SAT-style analysis as “glue“ to

combine a static analyzer with a bounded model checker.