Nonlinear Polynomials, Interpolants and Invariant Generation for - - PowerPoint PPT Presentation

nonlinear polynomials interpolants and invariant
SMART_READER_LITE
LIVE PREVIEW

Nonlinear Polynomials, Interpolants and Invariant Generation for - - PowerPoint PPT Presentation

Nonlinear Polynomials, Interpolants and Invariant Generation for System Analysis Deepak Kapur Department of Computer Science University of New Mexico Albuquerque, NM, USA with Rodriguez-Carbonell, Zhihai Zhang, Hengjun Zhao, Stephan Falke,


slide-1
SLIDE 1

Nonlinear Polynomials, Interpolants and Invariant Generation for System Analysis

Deepak Kapur

Department of Computer Science University of New Mexico Albuquerque, NM, USA

with Rodriguez-Carbonell, Zhihai Zhang, Hengjun Zhao, Stephan Falke, Naijun Zhan, Ting Gan, Bican Xia and others (work in progress)

slide-2
SLIDE 2

Outline

◮ Ideal-theoretic approach for generating nonlinear polynomial

equalities as invariants.

slide-3
SLIDE 3

Outline

◮ Ideal-theoretic approach for generating nonlinear polynomial

equalities as invariants.

◮ Quantifier Elimination Approach for Generating (Loop)

Invariants - Review with examples.

slide-4
SLIDE 4

Outline

◮ Ideal-theoretic approach for generating nonlinear polynomial

equalities as invariants.

◮ Quantifier Elimination Approach for Generating (Loop)

Invariants - Review with examples.

◮ Geometric and Local Quantifier Elimination Heuristic

slide-5
SLIDE 5

Outline

◮ Ideal-theoretic approach for generating nonlinear polynomial

equalities as invariants.

◮ Quantifier Elimination Approach for Generating (Loop)

Invariants - Review with examples.

◮ Geometric and Local Quantifier Elimination Heuristic

◮ Octagonal Invariants - simple Convex Linear Constraints

slide-6
SLIDE 6

Outline

◮ Ideal-theoretic approach for generating nonlinear polynomial

equalities as invariants.

◮ Quantifier Elimination Approach for Generating (Loop)

Invariants - Review with examples.

◮ Geometric and Local Quantifier Elimination Heuristic

◮ Octagonal Invariants - simple Convex Linear Constraints ◮ O(k ∗ n2) algorithm – strongest invariant, k:the number of

program paths and n: program variables

slide-7
SLIDE 7

Outline

◮ Ideal-theoretic approach for generating nonlinear polynomial

equalities as invariants.

◮ Quantifier Elimination Approach for Generating (Loop)

Invariants - Review with examples.

◮ Geometric and Local Quantifier Elimination Heuristic

◮ Octagonal Invariants - simple Convex Linear Constraints ◮ O(k ∗ n2) algorithm – strongest invariant, k:the number of

program paths and n: program variables

◮ Disjunctive Linear Invariants – max and min constraints

slide-8
SLIDE 8

Outline

◮ Ideal-theoretic approach for generating nonlinear polynomial

equalities as invariants.

◮ Quantifier Elimination Approach for Generating (Loop)

Invariants - Review with examples.

◮ Geometric and Local Quantifier Elimination Heuristic

◮ Octagonal Invariants - simple Convex Linear Constraints ◮ O(k ∗ n2) algorithm – strongest invariant, k:the number of

program paths and n: program variables

◮ Disjunctive Linear Invariants – max and min constraints

◮ Termination analysis using templates

slide-9
SLIDE 9

Outline

◮ Ideal-theoretic approach for generating nonlinear polynomial

equalities as invariants.

◮ Quantifier Elimination Approach for Generating (Loop)

Invariants - Review with examples.

◮ Geometric and Local Quantifier Elimination Heuristic

◮ Octagonal Invariants - simple Convex Linear Constraints ◮ O(k ∗ n2) algorithm – strongest invariant, k:the number of

program paths and n: program variables

◮ Disjunctive Linear Invariants – max and min constraints

◮ Termination analysis using templates ◮ Interpolant generation using quantifier elimination

slide-10
SLIDE 10

Outline

◮ Ideal-theoretic approach for generating nonlinear polynomial

equalities as invariants.

◮ Quantifier Elimination Approach for Generating (Loop)

Invariants - Review with examples.

◮ Geometric and Local Quantifier Elimination Heuristic

◮ Octagonal Invariants - simple Convex Linear Constraints ◮ O(k ∗ n2) algorithm – strongest invariant, k:the number of

program paths and n: program variables

◮ Disjunctive Linear Invariants – max and min constraints

◮ Termination analysis using templates ◮ Interpolant generation using quantifier elimination ◮ Generalization of IC 3, particularly showing completeness.

slide-11
SLIDE 11

Outline

◮ Ideal-theoretic approach for generating nonlinear polynomial

equalities as invariants.

◮ Quantifier Elimination Approach for Generating (Loop)

Invariants - Review with examples.

◮ Geometric and Local Quantifier Elimination Heuristic

◮ Octagonal Invariants - simple Convex Linear Constraints ◮ O(k ∗ n2) algorithm – strongest invariant, k:the number of

program paths and n: program variables

◮ Disjunctive Linear Invariants – max and min constraints

◮ Termination analysis using templates ◮ Interpolant generation using quantifier elimination ◮ Generalization of IC 3, particularly showing completeness. ◮ Saturation based approach for generating inductive invariants

– computing abductors

slide-12
SLIDE 12

Outline

◮ Ideal-theoretic approach for generating nonlinear polynomial

equalities as invariants.

◮ Quantifier Elimination Approach for Generating (Loop)

Invariants - Review with examples.

◮ Geometric and Local Quantifier Elimination Heuristic

◮ Octagonal Invariants - simple Convex Linear Constraints ◮ O(k ∗ n2) algorithm – strongest invariant, k:the number of

program paths and n: program variables

◮ Disjunctive Linear Invariants – max and min constraints

◮ Termination analysis using templates ◮ Interpolant generation using quantifier elimination ◮ Generalization of IC 3, particularly showing completeness. ◮ Saturation based approach for generating inductive invariants

– computing abductors

◮ Complexity barriers – localization (exploiting structure of

verification conditions) and geometric heuristics relating preconditions vs post conditions.

slide-13
SLIDE 13

Outline

◮ Ideal-theoretic approach for generating nonlinear polynomial

equalities as invariants.

◮ Quantifier Elimination Approach for Generating (Loop)

Invariants - Review with examples.

◮ Geometric and Local Quantifier Elimination Heuristic

◮ Octagonal Invariants - simple Convex Linear Constraints ◮ O(k ∗ n2) algorithm – strongest invariant, k:the number of

program paths and n: program variables

◮ Disjunctive Linear Invariants – max and min constraints

◮ Termination analysis using templates ◮ Interpolant generation using quantifier elimination ◮ Generalization of IC 3, particularly showing completeness. ◮ Saturation based approach for generating inductive invariants

– computing abductors

◮ Complexity barriers – localization (exploiting structure of

verification conditions) and geometric heuristics relating preconditions vs post conditions.

◮ Challenges for symbolic computation community.

slide-14
SLIDE 14

Invariants and Program Verification

◮ Building reliable and safe software is critical because of its use

everywhere, especially in critical applications.

slide-15
SLIDE 15

Invariants and Program Verification

◮ Building reliable and safe software is critical because of its use

everywhere, especially in critical applications.

◮ Static analysis of software plays an important role. Examples

are type checking, array bound check, null pointer check, ensuring behavioral specification, etc.

slide-16
SLIDE 16

Invariants and Program Verification

◮ Building reliable and safe software is critical because of its use

everywhere, especially in critical applications.

◮ Static analysis of software plays an important role. Examples

are type checking, array bound check, null pointer check, ensuring behavioral specification, etc.

◮ Automation and scalability are critical for success.

slide-17
SLIDE 17

Invariants: Integer Square Root

Example

x := 1 , y := 1 , z := 0; while ( x <= N) { x := x + y + 2; y := y + 2; z := z + 1 } r e t u r n z

slide-18
SLIDE 18

Invariants: Integer Square Root

Example

x := 1 , y := 1 , z := 0; while ( x <= N) { x := x + y + 2; y := y + 2; z := z + 1 } r e t u r n z x = (z + 1)2 is a loop invariant

slide-19
SLIDE 19

Invariants: Integer Square Root

Example

x := 1 , y := 1 , z := 0; while ( x <= N) { x := x + y + 2; y := y + 2; z := z + 1 } r e t u r n z x = (z + 1)2 is a loop invariant Explore methods that can generate (strong) loop invariants (useful program properties) automatically for a large class of programs

slide-20
SLIDE 20

Two Approaches for Generating Loop Invariants Automatically

  • 1. Ideal-Theoretic Methods

◮ properties of programs specified by a conjunction of

polynomial equations.

slide-21
SLIDE 21

Two Approaches for Generating Loop Invariants Automatically

  • 1. Ideal-Theoretic Methods

◮ properties of programs specified by a conjunction of

polynomial equations.

◮ associated with every program location is an invariant

(radical) ideal.

slide-22
SLIDE 22

Two Approaches for Generating Loop Invariants Automatically

  • 1. Ideal-Theoretic Methods

◮ properties of programs specified by a conjunction of

polynomial equations.

◮ associated with every program location is an invariant

(radical) ideal.

◮ Semantics of program constructs as ideal theoretic (algebraic

varieties) operations – implemented using Gr¨

  • bner basis

computations.

slide-23
SLIDE 23

Two Approaches for Generating Loop Invariants Automatically

  • 1. Ideal-Theoretic Methods

◮ properties of programs specified by a conjunction of

polynomial equations.

◮ associated with every program location is an invariant

(radical) ideal.

◮ Semantics of program constructs as ideal theoretic (algebraic

varieties) operations – implemented using Gr¨

  • bner basis

computations.

◮ Existence of a finite basis ensured by Hilbert’s basis condition.

slide-24
SLIDE 24

Two Approaches for Generating Loop Invariants Automatically

  • 1. Ideal-Theoretic Methods

◮ properties of programs specified by a conjunction of

polynomial equations.

◮ associated with every program location is an invariant

(radical) ideal.

◮ Semantics of program constructs as ideal theoretic (algebraic

varieties) operations – implemented using Gr¨

  • bner basis

computations.

◮ Existence of a finite basis ensured by Hilbert’s basis condition. ◮ approximations and fixed point computation to generate such

ideals.

slide-25
SLIDE 25

Two Approaches for Generating Loop Invariants Automatically

  • 1. Ideal-Theoretic Methods

◮ properties of programs specified by a conjunction of

polynomial equations.

◮ associated with every program location is an invariant

(radical) ideal.

◮ Semantics of program constructs as ideal theoretic (algebraic

varieties) operations – implemented using Gr¨

  • bner basis

computations.

◮ Existence of a finite basis ensured by Hilbert’s basis condition. ◮ approximations and fixed point computation to generate such

ideals.

slide-26
SLIDE 26

Two Approaches for Generating Loop Invariants Automatically

  • 1. Ideal-Theoretic Methods

◮ properties of programs specified by a conjunction of

polynomial equations.

◮ associated with every program location is an invariant

(radical) ideal.

◮ Semantics of program constructs as ideal theoretic (algebraic

varieties) operations – implemented using Gr¨

  • bner basis

computations.

◮ Existence of a finite basis ensured by Hilbert’s basis condition. ◮ approximations and fixed point computation to generate such

ideals. Papers with Enric Rodr´ ıguez-Carbonell in ISSAC (2004), SAS (2004), ICTAC (2004), Science of Programming (2007), Journal of Symbolic Computation (2007)

slide-27
SLIDE 27
  • 2. Quantifier-Elimination of Program Variables from Parameterized

Formulas

slide-28
SLIDE 28
  • 2. Quantifier-Elimination of Program Variables from Parameterized

Formulas

Papers in ACA-2004, Journal of Systems Sciences and Complexity-2006

slide-29
SLIDE 29
  • 2. Quantifier-Elimination of Program Variables from Parameterized

Formulas

Papers in ACA-2004, Journal of Systems Sciences and Complexity-2006 Geometric and Local Heuristics for Quantifier Elimination for Automatically Generating Octagonal Invariants Papers in TAMC (2012), McCuneMemorial (2013).

slide-30
SLIDE 30
  • 2. Quantifier-Elimination of Program Variables from Parameterized

Formulas

Papers in ACA-2004, Journal of Systems Sciences and Complexity-2006 Geometric and Local Heuristics for Quantifier Elimination for Automatically Generating Octagonal Invariants Papers in TAMC (2012), McCuneMemorial (2013).

Interplay of Computational Logic and Algebra

slide-31
SLIDE 31

Generating Loop Invariant: Approach

◮ Guess/fix the shape of invariants of interest at various

program locations with some parameters which need to be determined.

slide-32
SLIDE 32

Generating Loop Invariant: Approach

◮ Guess/fix the shape of invariants of interest at various

program locations with some parameters which need to be determined.

◮ Here is an illustration of generation of nonlinear invariants.

I : A x2 + B y2 + C z2 + D xy + E xz + F yz + G x + H y + J z + K = 0.

slide-33
SLIDE 33

Generating Loop Invariant: Approach

◮ Guess/fix the shape of invariants of interest at various

program locations with some parameters which need to be determined.

◮ Here is an illustration of generation of nonlinear invariants.

I : A x2 + B y2 + C z2 + D xy + E xz + F yz + G x + H y + J z + K = 0.

◮ Generate verification conditions using the hypothesized

invariants from the code.

slide-34
SLIDE 34

Generating Loop Invariant: Approach

◮ Guess/fix the shape of invariants of interest at various

program locations with some parameters which need to be determined.

◮ Here is an illustration of generation of nonlinear invariants.

I : A x2 + B y2 + C z2 + D xy + E xz + F yz + G x + H y + J z + K = 0.

◮ Generate verification conditions using the hypothesized

invariants from the code.

◮ VC1: At first possible entry of the loop (from initialization):

A + B + D + G + H + K = 0.

slide-35
SLIDE 35

Generating Loop Invariant: Approach

◮ Guess/fix the shape of invariants of interest at various

program locations with some parameters which need to be determined.

◮ Here is an illustration of generation of nonlinear invariants.

I : A x2 + B y2 + C z2 + D xy + E xz + F yz + G x + H y + J z + K = 0.

◮ Generate verification conditions using the hypothesized

invariants from the code.

◮ VC1: At first possible entry of the loop (from initialization):

A + B + D + G + H + K = 0.

◮ VC2: For every iteration of the loop body:

(I(x, y, z) ∧ x ≤ N) = ⇒ I(x + y + 2, y + 2, z + 1).

slide-36
SLIDE 36

Generating Loop Invariant: Approach

◮ Guess/fix the shape of invariants of interest at various

program locations with some parameters which need to be determined.

◮ Here is an illustration of generation of nonlinear invariants.

I : A x2 + B y2 + C z2 + D xy + E xz + F yz + G x + H y + J z + K = 0.

◮ Generate verification conditions using the hypothesized

invariants from the code.

◮ VC1: At first possible entry of the loop (from initialization):

A + B + D + G + H + K = 0.

◮ VC2: For every iteration of the loop body:

(I(x, y, z) ∧ x ≤ N) = ⇒ I(x + y + 2, y + 2, z + 1).

◮ Using quantifier elimination, find constraints on parameters

A, B, C, D, E, F, G, H, J, K which ensure that the verification conditions are valid for all possible program variables.

slide-37
SLIDE 37

Quantifier Elimination from Verification Conditions

Considering VC2:

◮ ( A x2+B y 2+C z2+D xy +E xz +F yz +G x +H y +J z +K = 0) =

⇒ ( A (x +y +2)2+B (y +2)2+C (z +1)2+D (x +y +2)(y +2)+E (x +y + 2)(z +1)+F (y +2)(z +1)+G (x +y +2)+H (y +2)+J (z +1)+K = 0)

slide-38
SLIDE 38

Quantifier Elimination from Verification Conditions

Considering VC2:

◮ ( A x2+B y 2+C z2+D xy +E xz +F yz +G x +H y +J z +K = 0) =

⇒ ( A (x +y +2)2+B (y +2)2+C (z +1)2+D (x +y +2)(y +2)+E (x +y + 2)(z +1)+F (y +2)(z +1)+G (x +y +2)+H (y +2)+J (z +1)+K = 0)

◮ Expanding the conclusion gives:

Ax2 + (A + B + D)y 2 + cz2 + (D + 2A)xy + Exz + (E + F)yz + (G + 4A + 2D + E)x + (H + 4A + 4B + 4D + E + F + G)y + (J + 2C + 2E + 2F)z + (4A + 4B + C + 4D + 2E + 2F + 2G + 2H + J + K) = 0

slide-39
SLIDE 39

Quantifier Elimination from Verification Conditions

Considering VC2:

◮ ( A x2+B y 2+C z2+D xy +E xz +F yz +G x +H y +J z +K = 0) =

⇒ ( A (x +y +2)2+B (y +2)2+C (z +1)2+D (x +y +2)(y +2)+E (x +y + 2)(z +1)+F (y +2)(z +1)+G (x +y +2)+H (y +2)+J (z +1)+K = 0)

◮ Expanding the conclusion gives:

Ax2 + (A + B + D)y 2 + cz2 + (D + 2A)xy + Exz + (E + F)yz + (G + 4A + 2D + E)x + (H + 4A + 4B + 4D + E + F + G)y + (J + 2C + 2E + 2F)z + (4A + 4B + C + 4D + 2E + 2F + 2G + 2H + J + K) = 0

◮ Simplifying using the hypothesis gives:

(A + D)y 2 + 2Axy + Eyz + (4A + 2D + E)x + (4A + 4B + 4D + E + F + G)y +(2C +2E +2F)z +(4A+4B +C +4D +2E +2F +2G +2H +J) = 0

slide-40
SLIDE 40

Quantifier Elimination from Verification Conditions

Considering VC2:

◮ ( A x2+B y 2+C z2+D xy +E xz +F yz +G x +H y +J z +K = 0) =

⇒ ( A (x +y +2)2+B (y +2)2+C (z +1)2+D (x +y +2)(y +2)+E (x +y + 2)(z +1)+F (y +2)(z +1)+G (x +y +2)+H (y +2)+J (z +1)+K = 0)

◮ Expanding the conclusion gives:

Ax2 + (A + B + D)y 2 + cz2 + (D + 2A)xy + Exz + (E + F)yz + (G + 4A + 2D + E)x + (H + 4A + 4B + 4D + E + F + G)y + (J + 2C + 2E + 2F)z + (4A + 4B + C + 4D + 2E + 2F + 2G + 2H + J + K) = 0

◮ Simplifying using the hypothesis gives:

(A + D)y 2 + 2Axy + Eyz + (4A + 2D + E)x + (4A + 4B + 4D + E + F + G)y +(2C +2E +2F)z +(4A+4B +C +4D +2E +2F +2G +2H +J) = 0

◮ Since this should be 0 for all values of x, y, z: we have:

A + D = 0; A = 0; E = 0 which implies D = 0; using these gives: 2C + 2F = 0 which implies C = −F; using all these: G = −4B − F, H = −G − K − B and J = −2B − F + 2K.

slide-41
SLIDE 41

Generating the Strongest Invariant

◮ Constraints on parameters are:

C = −F, J = −2B − F + 2K, G = −4B − F, H = 3B + F − K.

slide-42
SLIDE 42

Generating the Strongest Invariant

◮ Constraints on parameters are:

C = −F, J = −2B − F + 2K, G = −4B − F, H = 3B + F − K.

◮ Every value of parameters satisfying the above constraints

leads to an invariant (including the trivial invariant true when all parameter values are 0).

slide-43
SLIDE 43

Generating the Strongest Invariant

◮ Constraints on parameters are:

C = −F, J = −2B − F + 2K, G = −4B − F, H = 3B + F − K.

◮ Every value of parameters satisfying the above constraints

leads to an invariant (including the trivial invariant true when all parameter values are 0).

◮ 7 parameters and 4 equations, so 3 independent parameters,

say B, F, K. Making every independent parameter 1 separately with other independent parameters being 0, derive values of dependent parameters.

slide-44
SLIDE 44

Generating the Strongest Invariant

◮ Constraints on parameters are:

C = −F, J = −2B − F + 2K, G = −4B − F, H = 3B + F − K.

◮ Every value of parameters satisfying the above constraints

leads to an invariant (including the trivial invariant true when all parameter values are 0).

◮ 7 parameters and 4 equations, so 3 independent parameters,

say B, F, K. Making every independent parameter 1 separately with other independent parameters being 0, derive values of dependent parameters.

◮ K = 1, H = −1, J = 2 gives −y + 2z + 1 = 0.

slide-45
SLIDE 45

Generating the Strongest Invariant

◮ Constraints on parameters are:

C = −F, J = −2B − F + 2K, G = −4B − F, H = 3B + F − K.

◮ Every value of parameters satisfying the above constraints

leads to an invariant (including the trivial invariant true when all parameter values are 0).

◮ 7 parameters and 4 equations, so 3 independent parameters,

say B, F, K. Making every independent parameter 1 separately with other independent parameters being 0, derive values of dependent parameters.

◮ K = 1, H = −1, J = 2 gives −y + 2z + 1 = 0. ◮ F = 1, C = −1, J = −1, G = −1, H = 1 gives

−z2 + yz − x + y − z − 0.

slide-46
SLIDE 46

Generating the Strongest Invariant

◮ Constraints on parameters are:

C = −F, J = −2B − F + 2K, G = −4B − F, H = 3B + F − K.

◮ Every value of parameters satisfying the above constraints

leads to an invariant (including the trivial invariant true when all parameter values are 0).

◮ 7 parameters and 4 equations, so 3 independent parameters,

say B, F, K. Making every independent parameter 1 separately with other independent parameters being 0, derive values of dependent parameters.

◮ K = 1, H = −1, J = 2 gives −y + 2z + 1 = 0. ◮ F = 1, C = −1, J = −1, G = −1, H = 1 gives

−z2 + yz − x + y − z − 0.

◮ B = 1, J = −2, G = −4, H = 3 gives y 2 − 4x + 3y − 2z = 0.

slide-47
SLIDE 47

Generating the Strongest Invariant

◮ Constraints on parameters are:

C = −F, J = −2B − F + 2K, G = −4B − F, H = 3B + F − K.

◮ Every value of parameters satisfying the above constraints

leads to an invariant (including the trivial invariant true when all parameter values are 0).

◮ 7 parameters and 4 equations, so 3 independent parameters,

say B, F, K. Making every independent parameter 1 separately with other independent parameters being 0, derive values of dependent parameters.

◮ K = 1, H = −1, J = 2 gives −y + 2z + 1 = 0. ◮ F = 1, C = −1, J = −1, G = −1, H = 1 gives

−z2 + yz − x + y − z − 0.

◮ B = 1, J = −2, G = −4, H = 3 gives y 2 − 4x + 3y − 2z = 0. ◮ The most general invariant describing all invariants of the

above form is a conjunction of: y = 2z + 1; z2 − yz + z + x − y = 0 y2 − 2z − 4x + 3y = 0, from which x = (z + 1)2 follows.

slide-48
SLIDE 48

Method for Automatically Generating Invariants by Quantifier Elimination

◮ Hypothesize assertions, which are parametrized formulas, at

various points in a program.

slide-49
SLIDE 49

Method for Automatically Generating Invariants by Quantifier Elimination

◮ Hypothesize assertions, which are parametrized formulas, at

various points in a program.

◮ Typically entry of every loop and entry and exit of every

procedure suffice.

slide-50
SLIDE 50

Method for Automatically Generating Invariants by Quantifier Elimination

◮ Hypothesize assertions, which are parametrized formulas, at

various points in a program.

◮ Typically entry of every loop and entry and exit of every

procedure suffice.

◮ Nested loops and procedure/function calls can be handled.

slide-51
SLIDE 51

Method for Automatically Generating Invariants by Quantifier Elimination

◮ Hypothesize assertions, which are parametrized formulas, at

various points in a program.

◮ Typically entry of every loop and entry and exit of every

procedure suffice.

◮ Nested loops and procedure/function calls can be handled.

◮ Generate verification conditions for every path in the program

(a path from an assertion to another assertion including itself).

slide-52
SLIDE 52

Method for Automatically Generating Invariants by Quantifier Elimination

◮ Hypothesize assertions, which are parametrized formulas, at

various points in a program.

◮ Typically entry of every loop and entry and exit of every

procedure suffice.

◮ Nested loops and procedure/function calls can be handled.

◮ Generate verification conditions for every path in the program

(a path from an assertion to another assertion including itself).

◮ Depending upon the logical language chosen to write

invariants, approximations of assignments and test conditions may be necessary.

slide-53
SLIDE 53

Method for Automatically Generating Invariants by Quantifier Elimination

◮ Hypothesize assertions, which are parametrized formulas, at

various points in a program.

◮ Typically entry of every loop and entry and exit of every

procedure suffice.

◮ Nested loops and procedure/function calls can be handled.

◮ Generate verification conditions for every path in the program

(a path from an assertion to another assertion including itself).

◮ Depending upon the logical language chosen to write

invariants, approximations of assignments and test conditions may be necessary.

◮ Find a formula expressed in terms of parameters eliminating

all program variables (using quantifier elimination).

slide-54
SLIDE 54

Quality of Invariants

Soundness and Completeness

◮ Every assignment of parameter values which make the formula

true, gives an inductive invariant.

slide-55
SLIDE 55

Quality of Invariants

Soundness and Completeness

◮ Every assignment of parameter values which make the formula

true, gives an inductive invariant.

◮ If no parameter values can be found, then invariants of

hypothesized forms may not exist. Invariants can be guaranteed not to exist if no approximations are made, while generating verification conditions.

slide-56
SLIDE 56

Quality of Invariants

Soundness and Completeness

◮ Every assignment of parameter values which make the formula

true, gives an inductive invariant.

◮ If no parameter values can be found, then invariants of

hypothesized forms may not exist. Invariants can be guaranteed not to exist if no approximations are made, while generating verification conditions.

◮ If all assignments making the formula true can be finitely

described, invariants generated may be the strongest of the hypothesized form. Invariants generated are guaranteed to be the strongest if no approximations are made, while generating verification conditions.

slide-57
SLIDE 57

How to Scale this Approach

◮ Quantifier Elimination Methods typically do not scale up due

to high complexity even in this restricted case of ∃∀.

slide-58
SLIDE 58

How to Scale this Approach

◮ Quantifier Elimination Methods typically do not scale up due

to high complexity even in this restricted case of ∃∀.

◮ Even for Presburger arithmetic, complexity is doubly

exponential in the number of quantifier alternations and triply exponential in the number of quantified variables

slide-59
SLIDE 59

How to Scale this Approach

◮ Quantifier Elimination Methods typically do not scale up due

to high complexity even in this restricted case of ∃∀.

◮ Even for Presburger arithmetic, complexity is doubly

exponential in the number of quantifier alternations and triply exponential in the number of quantified variables

◮ Output is huge and difficult to decipher.

slide-60
SLIDE 60

How to Scale this Approach

◮ Quantifier Elimination Methods typically do not scale up due

to high complexity even in this restricted case of ∃∀.

◮ Even for Presburger arithmetic, complexity is doubly

exponential in the number of quantifier alternations and triply exponential in the number of quantified variables

◮ Output is huge and difficult to decipher. ◮ In practice, they often do not work (i.e., run out of memory or

hang).

slide-61
SLIDE 61

How to Scale this Approach

◮ Quantifier Elimination Methods typically do not scale up due

to high complexity even in this restricted case of ∃∀.

◮ Even for Presburger arithmetic, complexity is doubly

exponential in the number of quantifier alternations and triply exponential in the number of quantified variables

◮ Output is huge and difficult to decipher. ◮ In practice, they often do not work (i.e., run out of memory or

hang).

◮ Linear constraint solving on rationals and reals (polyhedral

domain), while of polynomial complexity, has been found in practice to be inefficient and slow, especially when used repeatedly as in abstract interpretation approach [Min´ e]

slide-62
SLIDE 62

Making QE based Method Practical

◮ Identify (atomic) formulas and program abstractions resulting

in verification conditions with good shape and structure.

slide-63
SLIDE 63

Making QE based Method Practical

◮ Identify (atomic) formulas and program abstractions resulting

in verification conditions with good shape and structure.

◮ Develop QE heuristics which exploit local structure of

formulas (e.g. two variables at a time) and geometry of state space defined by formulas.

slide-64
SLIDE 64

Making QE based Method Practical

◮ Identify (atomic) formulas and program abstractions resulting

in verification conditions with good shape and structure.

◮ Develop QE heuristics which exploit local structure of

formulas (e.g. two variables at a time) and geometry of state space defined by formulas.

◮ Among many possibilities in a result after QE, identify those

most likely to be useful.

slide-65
SLIDE 65

Making QE based Method Practical

◮ Identify (atomic) formulas and program abstractions resulting

in verification conditions with good shape and structure.

◮ Develop QE heuristics which exploit local structure of

formulas (e.g. two variables at a time) and geometry of state space defined by formulas.

◮ Among many possibilities in a result after QE, identify those

most likely to be useful.

◮ Octagonal formulas : l ≤ ±x ± y ≤ h, a highly restricted

subset of linear constraints (at most two variables with coefficients from {−1, 0, 1}).

slide-66
SLIDE 66

Making QE based Method Practical

◮ Identify (atomic) formulas and program abstractions resulting

in verification conditions with good shape and structure.

◮ Develop QE heuristics which exploit local structure of

formulas (e.g. two variables at a time) and geometry of state space defined by formulas.

◮ Among many possibilities in a result after QE, identify those

most likely to be useful.

◮ Octagonal formulas : l ≤ ±x ± y ≤ h, a highly restricted

subset of linear constraints (at most two variables with coefficients from {−1, 0, 1}).

◮ This fragment is the most expressive fragment of linear

arithmetic over the integers with a polynomial time decision procedure.

slide-67
SLIDE 67

Making QE based Method Practical

◮ Identify (atomic) formulas and program abstractions resulting

in verification conditions with good shape and structure.

◮ Develop QE heuristics which exploit local structure of

formulas (e.g. two variables at a time) and geometry of state space defined by formulas.

◮ Among many possibilities in a result after QE, identify those

most likely to be useful.

◮ Octagonal formulas : l ≤ ±x ± y ≤ h, a highly restricted

subset of linear constraints (at most two variables with coefficients from {−1, 0, 1}).

◮ This fragment is the most expressive fragment of linear

arithmetic over the integers with a polynomial time decision procedure.

◮ Max, Min formulas: max(±x − l, ±y − h), expressing

disjunction ((x − l ≥ y − h ∧ x − l ≥ 0) ∨ (y − h ≥ x − h ∧ y − h ≥ 0)).

slide-68
SLIDE 68

Making QE based Method Practical

◮ Identify (atomic) formulas and program abstractions resulting

in verification conditions with good shape and structure.

◮ Develop QE heuristics which exploit local structure of

formulas (e.g. two variables at a time) and geometry of state space defined by formulas.

◮ Among many possibilities in a result after QE, identify those

most likely to be useful.

◮ Octagonal formulas : l ≤ ±x ± y ≤ h, a highly restricted

subset of linear constraints (at most two variables with coefficients from {−1, 0, 1}).

◮ This fragment is the most expressive fragment of linear

arithmetic over the integers with a polynomial time decision procedure.

◮ Max, Min formulas: max(±x − l, ±y − h), expressing

disjunction ((x − l ≥ y − h ∧ x − l ≥ 0) ∨ (y − h ≥ x − h ∧ y − h ≥ 0)).

◮ Combination of Octagonal and Max formulas.

slide-69
SLIDE 69

Octagonal Formulas

◮ Octagonal formulas over two variables have a fixed shape. Its

parameterization can be given using 8 parameters.

slide-70
SLIDE 70

Octagonal Formulas

◮ Octagonal formulas over two variables have a fixed shape. Its

parameterization can be given using 8 parameters.

◮ Given n variables, the most general formula (after

simplification) is of the following form

  • i,j( Octai,j :

ai,j ≤ xi − xj ≤ bi,j, ci,j ≤ xi + xj ≤ di,j ei ≤ xi ≤ fi gj ≤ xj ≤ hj) for every pair of variables xi, xj, where ai,j, bi,j, ci,j, di,j, ei, fi, gj, hj are parameters.

slide-71
SLIDE 71

Octagonal Formulas

◮ Octagonal formulas over two variables have a fixed shape. Its

parameterization can be given using 8 parameters.

◮ Given n variables, the most general formula (after

simplification) is of the following form

  • i,j( Octai,j :

ai,j ≤ xi − xj ≤ bi,j, ci,j ≤ xi + xj ≤ di,j ei ≤ xi ≤ fi gj ≤ xj ≤ hj) for every pair of variables xi, xj, where ai,j, bi,j, ci,j, di,j, ei, fi, gj, hj are parameters.

◮ Class of programs that can be analyzed are very restricted.

Still using octagonal constraints (and other heuristics), ASTREE is able to successfully analyze hundreds of thousands

  • f lines of code of numerical software for array bound check,

memory faults, and related bugs.

slide-72
SLIDE 72

Octagonal Formulas

◮ Octagonal formulas over two variables have a fixed shape. Its

parameterization can be given using 8 parameters.

◮ Given n variables, the most general formula (after

simplification) is of the following form

  • i,j( Octai,j :

ai,j ≤ xi − xj ≤ bi,j, ci,j ≤ xi + xj ≤ di,j ei ≤ xi ≤ fi gj ≤ xj ≤ hj) for every pair of variables xi, xj, where ai,j, bi,j, ci,j, di,j, ei, fi, gj, hj are parameters.

◮ Class of programs that can be analyzed are very restricted.

Still using octagonal constraints (and other heuristics), ASTREE is able to successfully analyze hundreds of thousands

  • f lines of code of numerical software for array bound check,

memory faults, and related bugs.

◮ Algorithms used in ASTREE are of O(n3) complexity

(sometimes, O(n4)), where n is the number of variables (Min´ e, 2003).

slide-73
SLIDE 73

Octagonal Formulas

◮ Octagonal formulas over two variables have a fixed shape. Its

parameterization can be given using 8 parameters.

◮ Given n variables, the most general formula (after

simplification) is of the following form

  • i,j( Octai,j :

ai,j ≤ xi − xj ≤ bi,j, ci,j ≤ xi + xj ≤ di,j ei ≤ xi ≤ fi gj ≤ xj ≤ hj) for every pair of variables xi, xj, where ai,j, bi,j, ci,j, di,j, ei, fi, gj, hj are parameters.

◮ Class of programs that can be analyzed are very restricted.

Still using octagonal constraints (and other heuristics), ASTREE is able to successfully analyze hundreds of thousands

  • f lines of code of numerical software for array bound check,

memory faults, and related bugs.

◮ Algorithms used in ASTREE are of O(n3) complexity

(sometimes, O(n4)), where n is the number of variables (Min´ e, 2003).

◮ Goal: Performance of QE heuristic should be at least as good.

slide-74
SLIDE 74

A Simple Example

Example

x := 4; y := 6; while ( x + y >= 0) do i f ( y >= 6) then { x := −x ; y := y − 1 } e l s e { x := x − 1; y := −y } endwhile

slide-75
SLIDE 75

A Simple Example

Example

x := 4; y := 6; while ( x + y >= 0) do i f ( y >= 6) then { x := −x ; y := y − 1 } e l s e { x := x − 1; y := −y } endwhile VC0: I(4, 6) VC1: (I(x, y) ∧ (x + y) ≥ 0 ∧ y ≥ 6) = ⇒ I(−x, y − 1). VC2: (I(x, y) ∧ (x + y) ≥ 0 ∧ y < 6) = ⇒ I(x − 1, −y).

slide-76
SLIDE 76

Approach: Local QE Heuristics

◮ A program path is a sequence of assignment statements

interspersed with tests. Its behavior may have to be approximated to generate the post condition in which both the hypothesis and the conclusion are each conjunctions of atomic octagonal formulas.

slide-77
SLIDE 77

Approach: Local QE Heuristics

◮ A program path is a sequence of assignment statements

interspersed with tests. Its behavior may have to be approximated to generate the post condition in which both the hypothesis and the conclusion are each conjunctions of atomic octagonal formulas.

◮ A verification condition is expressed using atomic formulas

that are all octagonal constraints.

  • i,j
  • (Octai,j ∧ α(xi, xj)) ⇒ Octa′

i,j

  • ,

along with additional parameter-free constraints α(xi, xj), of the same form in which lower and upper bounds are constants.

slide-78
SLIDE 78

Approach: Local QE Heuristics

◮ A program path is a sequence of assignment statements

interspersed with tests. Its behavior may have to be approximated to generate the post condition in which both the hypothesis and the conclusion are each conjunctions of atomic octagonal formulas.

◮ A verification condition is expressed using atomic formulas

that are all octagonal constraints.

  • i,j
  • (Octai,j ∧ α(xi, xj)) ⇒ Octa′

i,j

  • ,

along with additional parameter-free constraints α(xi, xj), of the same form in which lower and upper bounds are constants.

◮ Analysis of a big conjunctive constraint on every possible pair

  • f variables can be considered individually by considering the

subformula on each distinct pair.

slide-79
SLIDE 79

Geometric QE Heuristic

◮ Analyze how a general octagon gets transformed due to

  • assignments. For each assignment case, a table is built

showing the effect on the parameter values.

slide-80
SLIDE 80

Geometric QE Heuristic

◮ Analyze how a general octagon gets transformed due to

  • assignments. For each assignment case, a table is built

showing the effect on the parameter values.

◮ Identify conditions under which the transformed octagon

includes the portion of the original octagon satisfying tests along a program path. This is guided again locally for every side of the octagon,

slide-81
SLIDE 81

Geometric QE Heuristic

◮ Analyze how a general octagon gets transformed due to

  • assignments. For each assignment case, a table is built

showing the effect on the parameter values.

◮ Identify conditions under which the transformed octagon

includes the portion of the original octagon satisfying tests along a program path. This is guided again locally for every side of the octagon,

◮ In the case of many possibilities, the one likely to generate the

most useful invariant is identified.

slide-82
SLIDE 82

Geometric QE Heuristic

◮ Analyze how a general octagon gets transformed due to

  • assignments. For each assignment case, a table is built

showing the effect on the parameter values.

◮ Identify conditions under which the transformed octagon

includes the portion of the original octagon satisfying tests along a program path. This is guided again locally for every side of the octagon,

◮ In the case of many possibilities, the one likely to generate the

most useful invariant is identified.

◮ Quantifier elimination heuristics to generate constraints on

lower and upper bounds by table look ups in O(n2) steps, where n is the number of program variables.

slide-83
SLIDE 83

Table 3: Sign of exactly one variable is changed

x := −x + A y := y + B ∆1 = A − B, ∆2 = A + B.

l2 ≤ x + y x + y ≤ u2 x − y ≤ a ∆2 − u2 ≤ x − y x − y ≤ ∆2 − l2

slide-84
SLIDE 84

Table 3: Sign of exactly one variable is changed

x := −x + A y := y + B ∆1 = A − B, ∆2 = A + B.

l2 ≤ x + y x + y ≤ u2 x − y ≤ a ∆2 − u2 ≤ x − y x − y ≤ ∆2 − l2 constraint present absent side condition x − y ≤ a a ≤ ∆2 − l2 u1 ≤ ∆2 − l2 – x − y ≥ b ∆2 − u2 ≤ b ∆2 − u2 ≤ l1 – x + y ≤ c c ≤ ∆1 − l1 u2 ≤ ∆1 − l1 – x + y ≥ d ∆1 − u1 ≤ d ∆1 − u1 ≤ l2 – x ≤ e e ≤ A − l3 u3 ≤ A − l3 – x ≥ f A − u3 ≤ f A − u3 ≤ l3 – y ≤ g u4 ≥ g + B u4 = +∞ B > 0 y ≥ h l4 ≤ h + B l4 = −∞ B < 0

slide-85
SLIDE 85

A Simple Example

Example

x := 4; y := 6; while ( x + y >= 0) do i f ( y >= 6) then { x := −x ; y := y − 1 } e l s e { x := x − 1; y := −y } endwhile

slide-86
SLIDE 86

A Simple Example

Example

x := 4; y := 6; while ( x + y >= 0) do i f ( y >= 6) then { x := −x ; y := y − 1 } e l s e { x := x − 1; y := −y } endwhile VC0: I(4, 6) VC1: (I(x, y) ∧ (x + y) ≥ 0 ∧ y ≥ 6) = ⇒ I(−x, y − 1). VC2: (I(x, y) ∧ (x + y) ≥ 0 ∧ y < 6) = ⇒ I(x − 1, −y).

slide-87
SLIDE 87

Generating Constraints on Parameters

◮ VC0:

l1 ≤ −2 ≤ u1 ∧ l2 ≤ 10 ≤ u2 ∧ l3 ≤ 4 ≤ u3 ∧ l4 ≤ 6 ≤ u4.

slide-88
SLIDE 88

Generating Constraints on Parameters

◮ VC0:

l1 ≤ −2 ≤ u1 ∧ l2 ≤ 10 ≤ u2 ∧ l3 ≤ 4 ≤ u3 ∧ l4 ≤ 6 ≤ u4.

◮ VC1: x − y: −u2 − 1 ≤ l1 ∧ u1 ≤ −l2 − 1.

x + y: −u1 + 1 ≤ 0 ∧ u2 ≤ −l1 + 1. x: l3 + u3 = 0. y: l4 ≤ 5.

slide-89
SLIDE 89

Generating Constraints on Parameters

◮ VC0:

l1 ≤ −2 ≤ u1 ∧ l2 ≤ 10 ≤ u2 ∧ l3 ≤ 4 ≤ u3 ∧ l4 ≤ 6 ≤ u4.

◮ VC1: x − y: −u2 − 1 ≤ l1 ∧ u1 ≤ −l2 − 1.

x + y: −u1 + 1 ≤ 0 ∧ u2 ≤ −l1 + 1. x: l3 + u3 = 0. y: l4 ≤ 5.

◮ VC2: x − y: −u2 − 1 ≤ −u1 ∧ 10 ≤ −l2 − 1.

x + y: l1 + 1 ≤ 0 ∧ u2 ≤ u1 + 1. x: l3 ≤ −6. y: −u4 ≤ l4 ∧ 5 ≤ −l4.

slide-90
SLIDE 90

Generating Constraints on Parameters

◮ VC0:

l1 ≤ −2 ≤ u1 ∧ l2 ≤ 10 ≤ u2 ∧ l3 ≤ 4 ≤ u3 ∧ l4 ≤ 6 ≤ u4.

◮ VC1: x − y: −u2 − 1 ≤ l1 ∧ u1 ≤ −l2 − 1.

x + y: −u1 + 1 ≤ 0 ∧ u2 ≤ −l1 + 1. x: l3 + u3 = 0. y: l4 ≤ 5.

◮ VC2: x − y: −u2 − 1 ≤ −u1 ∧ 10 ≤ −l2 − 1.

x + y: l1 + 1 ≤ 0 ∧ u2 ≤ u1 + 1. x: l3 ≤ −6. y: −u4 ≤ l4 ∧ 5 ≤ −l4.

◮ Make li’s as large as possible and ui’s as small as possible:

l1 = −10, u1 = 9, l2 = −11, u2 = 10, l3 = −6, u3 = 6, l4 = −5, u4 = 6.

slide-91
SLIDE 91

Generating Constraints on Parameters

◮ VC0:

l1 ≤ −2 ≤ u1 ∧ l2 ≤ 10 ≤ u2 ∧ l3 ≤ 4 ≤ u3 ∧ l4 ≤ 6 ≤ u4.

◮ VC1: x − y: −u2 − 1 ≤ l1 ∧ u1 ≤ −l2 − 1.

x + y: −u1 + 1 ≤ 0 ∧ u2 ≤ −l1 + 1. x: l3 + u3 = 0. y: l4 ≤ 5.

◮ VC2: x − y: −u2 − 1 ≤ −u1 ∧ 10 ≤ −l2 − 1.

x + y: l1 + 1 ≤ 0 ∧ u2 ≤ u1 + 1. x: l3 ≤ −6. y: −u4 ≤ l4 ∧ 5 ≤ −l4.

◮ Make li’s as large as possible and ui’s as small as possible:

l1 = −10, u1 = 9, l2 = −11, u2 = 10, l3 = −6, u3 = 6, l4 = −5, u4 = 6.

◮ The corresponding invariant is:

−10 ≤ x − y ≤ 9 ∧ −11 ≤ x + y ≤ 10 ∧ −6 ≤ x ≤ 6 ∧ −5 ≤ y ≤ 6.

slide-92
SLIDE 92

Generating Invariants using Table Look-ups

◮ Parameter constraints corresponding to a specific program

path are read from the corresponding entries in tables.

slide-93
SLIDE 93

Generating Invariants using Table Look-ups

◮ Parameter constraints corresponding to a specific program

path are read from the corresponding entries in tables.

◮ Accumulate all such constraints on parameter values. They

are also octagonal.

slide-94
SLIDE 94

Generating Invariants using Table Look-ups

◮ Parameter constraints corresponding to a specific program

path are read from the corresponding entries in tables.

◮ Accumulate all such constraints on parameter values. They

are also octagonal.

◮ Every parameter value that satisfies the parameter constraints

leads to an invariant.

slide-95
SLIDE 95

Generating Invariants using Table Look-ups

◮ Parameter constraints corresponding to a specific program

path are read from the corresponding entries in tables.

◮ Accumulate all such constraints on parameter values. They

are also octagonal.

◮ Every parameter value that satisfies the parameter constraints

leads to an invariant.

◮ Maximum values of lower bounds and minimal values of upper

bounds satisfying the parameter constraints gives the strongest invariants. Maximum and minimum values can be computed using Floyd-Warshall’s algorithm.

slide-96
SLIDE 96

Complexity and Parallelization

◮ Overall Complexity: O(k ∗ n2):

slide-97
SLIDE 97

Complexity and Parallelization

◮ Overall Complexity: O(k ∗ n2):

◮ For every pair of program variables, parametric constraint

generation is constant time: 8 constraints, so 8 entries.

slide-98
SLIDE 98

Complexity and Parallelization

◮ Overall Complexity: O(k ∗ n2):

◮ For every pair of program variables, parametric constraint

generation is constant time: 8 constraints, so 8 entries.

◮ Parametric constraints are decomposed based on parameters

appearing in them: there are O(n2) such constraints on disjoint blocks of parameters of size ≤ 4.

slide-99
SLIDE 99

Complexity and Parallelization

◮ Overall Complexity: O(k ∗ n2):

◮ For every pair of program variables, parametric constraint

generation is constant time: 8 constraints, so 8 entries.

◮ Parametric constraints are decomposed based on parameters

appearing in them: there are O(n2) such constraints on disjoint blocks of parameters of size ≤ 4.

◮ Program paths can be analyzed in parallel. Parametric

constraints can be processed in parallel.

slide-100
SLIDE 100

Max Formulas

Pictorial representation of all possible cases of max(±x + l, ±y + h). Observe that every defined region is nonconvex.

max(x − l5, y − l6) ≥ 0 (bottom left corner) max(x − l8, −y + u8) ≥ 0 (top left corner) max(−x + u7, y − l7) ≥ 0 (bottom right corner) max(−x + u5, −y + u6) ≥ 0 (top right corner)

slide-101
SLIDE 101

Max Formulas

A typical template: octagonal formulas and max formulas. l1 ≤ x − y ≤ u1 l2 ≤ x + y ≤ u2 l3 ≤ x ≤ u3 l4 ≤ y ≤ u4 max( x − l5, y − l6) ≥ 0 max( x − l8, −y + u8) ≥ 0 max(−x + u7, y − l7) ≥ 0 max(−x + u5, −y + u6) ≥ 0

slide-102
SLIDE 102

Max Formulas – some nonconvex regions

An octagon with two corners cut out. A square that turns into 2 disconnected components.

slide-103
SLIDE 103

Table 6: Parametric Constraints for assignments with sign

  • f one variable reversed

Assignments: x := −x + A, y := y + B Bottom left and bottom right corners: max(x − l5, y − l6) ≥ 0 and max(−x + u7, y − l7) ≥ 0

y ≥ h absent y ≥ h present x ≥ f absent (l5 + u7 ≥ A ∧ l7 − l6 ≤ B) l7 ≤ h + B ∨ l5 + u7 ≤ A ∨ l7 − l4 ≤ B ∨ l2 − l7 + u7 ≥ A − B x ≥ f present u7 ≥ −f + A u7 ≥ −f + A ∨ l6 ≤ h + B

The constraints for two absent tests can also be used as disjuncts in the other cases.

y ≥ h absent y ≥ h present x ≤ e absent (l5 + u7 ≤ A ∧ l6 − l7 ≤ B) l6 ≤ h + B ∨ l5 + u3 ≤ A ∨ l6 − l4 ≤ B ∨ l5 + l6 − u1 ≥ A + B x ≤ e present l5 ≤ −e + A l5 ≤ −e + A ∨ l6 ≤ h + B

The constraints for two absent tests can also be used as disjuncts in the other cases.

slide-104
SLIDE 104

Table 6 Contd: Parametric Constraints for assignments with sign of one variable reversed

Assignments: x := −x + A, y := y + B Top left and top right corners: max(x − l8, −y + u8) ≥ 0 and max(−x + u5, −y + u6) ≥ 0

y ≤ g absent y ≤ g present x ≥ f absent (l8 + u5 ≥ A ∧ u6 − u8 ≥ B) u6 ≥ g + B ∨ l3 + u5 ≥ A ∨ u6 − u4 ≥ B ∨ l1 + u5 + u6 ≥ A + B x ≥ f present u5 ≥ −f + A u5 ≤ −f + A ∨ u6 ≥ g + B

The constraints for two absent tests can also be used as disjuncts in the other cases.

y ≤ g absent y ≤ g present x ≤ e absent (l8 + u5 ≤ A ∧ u8 − u6 ≥ B) u8 ≥ g + B ∨ l8 + u3 ≤ A ∨ u8 − u4 ≥ B ∨ l8 + u2 − u8 ≤ A − B x ≤ e present l8 ≤ −e + A l8 ≤ −e + A ∨ u8 ≥ g + B

The constraints for two absent tests can also be used as disjuncts in the other cases.

slide-105
SLIDE 105

Example: Stairs Program

x := 1 ; y := 4; w h i l e ( y>1) { i f ( x<2) x++; e l s e i f ( y>3) y−−; e l s e i f ( x<3) x++; e l s e i f ( y>2) y−−; e l s e i f ( x<4) x++; e l s e y−−; }

1 2 3 4 5 1 2 3 4 5

slide-106
SLIDE 106

Example: Stairs Program

Parametric Constraints due to the initialization x := 1; y := 4: l1 ≤ −3 ≤ u1 l5 ≤ 1 ∨ l6 ≤ 4 l2 ≤ 5 ≤ u2 u5 ≥ 1 ∨ u6 ≥ 4 l3 ≤ 1 ≤ u3 l7 ≤ 1 ∨ u7 ≥ 4 l4 ≤ 4 ≤ u4 l8 ≥ 1 ∨ u8 ≥ 4

slide-107
SLIDE 107

Example: Stairs Program

Parametric Constraints from Table look up for

◮ Program paths in which x is increasing:

u1 = +∞ u5 ≥ 2 u2 = +∞ u5 ≥ 3 ∨ u6 ≥ 3 u3 ≥ 2 u5 ≥ 4 ∨ u6 ≥ 2 u3 ≥ 3 u3 ≥ 4

◮ Program Paths in which y is decreasing:

u1 = +∞ l5 ≥ 2 ∨ l6 ≥ 5 l2 = −∞ l5 ≥ 3 ∨ l6 ≥ 4 l4 ≤ 3 l5 ≥ 4 ∨ l6 ≥ 3 l4 ≤ 2 l4 ≤ 1

slide-108
SLIDE 108

Example: Stairs Program

Putting all parametric constraints together and deriving the strongest max invariant (contrasted with the strongest octagonal invariant)

x := 1 ; y := 4; w h i l e ( y>1) { i f ( x<2) x++; e l s e i f ( y>3) y−−; e l s e i f ( x<3) x++; e l s e i f ( y>2) y−−; e l s e i f ( x<4) x++; e l s e y−−; }

1 2 3 4 5 1 2 3 4 5

slide-109
SLIDE 109

Example: Stairs Program

Putting all parametric constraints together and deriving the strongest max invariant (contrasted with the strongest octagonal invariant)

x := 1 ; y := 4; w h i l e ( y>1) { i f ( x<2) x++; e l s e i f ( y>3) y−−; e l s e i f ( x<3) x++; e l s e i f ( y>2) y−−; e l s e i f ( x<4) x++; e l s e y−−; }

1 2 3 4 5 1 2 3 4 5

slide-110
SLIDE 110

Invariants of a Program with a nested loop

x := 1 ; y := 4; w h i l e ( t r u e ) { i f ( x<2) x++; e l s e i f ( y>3) y−−; e l s e i f ( x<3) x++; e l s e i f ( y>2) y−−; e l s e i f ( x<4) x++; e l s e i f ( y>1) y−−; e l s e w h i l e ( x>1) { x−−; y++; } }

1 2 3 4 5 1 2 3 4 5

slide-111
SLIDE 111

Invariants of a Program with a nested loop

x := 1 ; y := 4; w h i l e ( t r u e ) { i f ( x<2) x++; e l s e i f ( y>3) y−−; e l s e i f ( x<3) x++; e l s e i f ( y>2) y−−; e l s e i f ( x<4) x++; e l s e i f ( y>1) y−−; e l s e w h i l e ( x>1) { x−−; y++; } }

1 2 3 4 5 1 2 3 4 5

  • uter invariant
slide-112
SLIDE 112

Invariants of a Program with a nested loop

x := 1 ; y := 4; w h i l e ( t r u e ) { i f ( x<2) x++; e l s e i f ( y>3) y−−; e l s e i f ( x<3) x++; e l s e i f ( y>2) y−−; e l s e i f ( x<4) x++; e l s e i f ( y>1) y−−; e l s e w h i l e ( x>1) { x−−; y++; } }

1 2 3 4 5 1 2 3 4 5

  • uter invariant

inner invariant

slide-113
SLIDE 113

Max Invariants vs Octagonal Invariants

◮ 16 instead of 8 parameters per variable pair:

l1, u1, . . . , l4, u4, l5, u5, . . . , l8, u8

slide-114
SLIDE 114

Max Invariants vs Octagonal Invariants

◮ 16 instead of 8 parameters per variable pair:

l1, u1, . . . , l4, u4, l5, u5, . . . , l8, u8

◮ Octagon: Unique optimal values for parameters.

Max: Multiple noncomparable values for parameter tuples. (recall the step function invariant before) max(x − l5, y − l6) ≥ 0 max(−x + u5, −y + u6) ≥ 0 max(x − 2, y − 4) ≥ 0 max(−x + 2, −y + 3) ≥ 0 max(x − 3, y − 3) ≥ 0 max(−x + 3, −y + 2) ≥ 0 max(x − 4, y − 2) ≥ 0

slide-115
SLIDE 115

Max Invariants vs Octagonal Invariants

◮ 16 instead of 8 parameters per variable pair:

l1, u1, . . . , l4, u4, l5, u5, . . . , l8, u8

◮ Octagon: Unique optimal values for parameters.

Max: Multiple noncomparable values for parameter tuples. (recall the step function invariant before) max(x − l5, y − l6) ≥ 0 max(−x + u5, −y + u6) ≥ 0 max(x − 2, y − 4) ≥ 0 max(−x + 2, −y + 3) ≥ 0 max(x − 3, y − 3) ≥ 0 max(−x + 3, −y + 2) ≥ 0 max(x − 4, y − 2) ≥ 0

◮ Many disjunctions in Tables.

slide-116
SLIDE 116

Max Invariants vs Octagonal Invariants

◮ 16 instead of 8 parameters per variable pair:

l1, u1, . . . , l4, u4, l5, u5, . . . , l8, u8

◮ Octagon: Unique optimal values for parameters.

Max: Multiple noncomparable values for parameter tuples. (recall the step function invariant before) max(x − l5, y − l6) ≥ 0 max(−x + u5, −y + u6) ≥ 0 max(x − 2, y − 4) ≥ 0 max(−x + 2, −y + 3) ≥ 0 max(x − 3, y − 3) ≥ 0 max(−x + 3, −y + 2) ≥ 0 max(x − 4, y − 2) ≥ 0

◮ Many disjunctions in Tables.

◮ Experimentation and heuristics for determining possibilities in

disjunctions that are more useful.

slide-117
SLIDE 117

Max Invariants vs Octagonal Invariants

◮ 16 instead of 8 parameters per variable pair:

l1, u1, . . . , l4, u4, l5, u5, . . . , l8, u8

◮ Octagon: Unique optimal values for parameters.

Max: Multiple noncomparable values for parameter tuples. (recall the step function invariant before) max(x − l5, y − l6) ≥ 0 max(−x + u5, −y + u6) ≥ 0 max(x − 2, y − 4) ≥ 0 max(−x + 2, −y + 3) ≥ 0 max(x − 3, y − 3) ≥ 0 max(−x + 3, −y + 2) ≥ 0 max(x − 4, y − 2) ≥ 0

◮ Many disjunctions in Tables.

◮ Experimentation and heuristics for determining possibilities in

disjunctions that are more useful.

◮ Sacrificing efficiency to generate stronger invariants.

slide-118
SLIDE 118

Max Invariants vs Octagonal Invariants

◮ 16 instead of 8 parameters per variable pair:

l1, u1, . . . , l4, u4, l5, u5, . . . , l8, u8

◮ Octagon: Unique optimal values for parameters.

Max: Multiple noncomparable values for parameter tuples. (recall the step function invariant before) max(x − l5, y − l6) ≥ 0 max(−x + u5, −y + u6) ≥ 0 max(x − 2, y − 4) ≥ 0 max(−x + 2, −y + 3) ≥ 0 max(x − 3, y − 3) ≥ 0 max(−x + 3, −y + 2) ≥ 0 max(x − 4, y − 2) ≥ 0

◮ Many disjunctions in Tables.

◮ Experimentation and heuristics for determining possibilities in

disjunctions that are more useful.

◮ Sacrificing efficiency to generate stronger invariants.

◮ Same asymptotic complexity if a single parametric constraint

in every table entry is selected.

slide-119
SLIDE 119

Termination Analysis based on Quantifier Elimination

Ranking functions can be synthesized by hypothesizing poiynomials in program variables and unary predicates on program variable in a loop body.

Example

while (n>1) { i f n mod 2 = 0 then n := n/2 e l s e n := n+1 }

slide-120
SLIDE 120

Termination Analysis based on Quantifier Elimination

Ranking functions can be synthesized by hypothesizing poiynomials in program variables and unary predicates on program variable in a loop body.

Example

while (n>1) { i f n mod 2 = 0 then n := n/2 e l s e n := n+1 } Theorem There does not exist any polynomial in n that can serve as a ranking function.

slide-121
SLIDE 121

Termination Analysis based on Quantifier Elimination

The synthesis of a polynomial ranking function of arbitrary degree can be hypothesized: much like verification conditions, leading to two constraints:

slide-122
SLIDE 122

Termination Analysis based on Quantifier Elimination

The synthesis of a polynomial ranking function of arbitrary degree can be hypothesized: much like verification conditions, leading to two constraints:

  • 1. n mod 2 = 0: easy.
  • 2. otherwise: n′ = n + 1, so tricky.
slide-123
SLIDE 123

Termination Analysis based on Quantifier Elimination

The synthesis of a polynomial ranking function of arbitrary degree can be hypothesized: much like verification conditions, leading to two constraints:

  • 1. n mod 2 = 0: easy.
  • 2. otherwise: n′ = n + 1, so tricky.

Must use the function n mod 2. Consider n + 2(n mod 2) as a possible ranking function (which can be generated from An + B(n mod 2) + C).

  • 1. n mod 2 = 0: tricky but with the loop condition n > 1, easy.
  • 2. otherwise: n′ = n + 1: easy.
slide-124
SLIDE 124

Interpolant Generation using Quantifier Elimination

Craig: Given α = ⇒ β, an intermediate formula γ in common symbols of α and β exists and can be constructed such that α = ⇒ γ ∧ γ = ⇒ β

slide-125
SLIDE 125

Interpolant Generation using Quantifier Elimination

Craig: Given α = ⇒ β, an intermediate formula γ in common symbols of α and β exists and can be constructed such that α = ⇒ γ ∧ γ = ⇒ β The existence and construction typically relies on a proof.

slide-126
SLIDE 126

Interpolant Generation using Quantifier Elimination

Craig: Given α = ⇒ β, an intermediate formula γ in common symbols of α and β exists and can be constructed such that α = ⇒ γ ∧ γ = ⇒ β The existence and construction typically relies on a proof. In Kapur et al (FSE06) we showed an obvious connection between interpolation and quantifier elimination.

slide-127
SLIDE 127

Interpolant Generation using Quantifier Elimination

◮ Eliminate uncommon symbols from α: interpolant.

slide-128
SLIDE 128

Interpolant Generation using Quantifier Elimination

◮ Eliminate uncommon symbols from α: interpolant. ◮ Similarly for β.

slide-129
SLIDE 129

Interpolant Generation using Quantifier Elimination

◮ Eliminate uncommon symbols from α: interpolant. ◮ Similarly for β. ◮ All interpolants between α and β form a lattice using

implication with the interpolant generated from α as the top element of the lattice and the one from β being the bottom element.

slide-130
SLIDE 130

Interpolant Generation using Quantifier Elimination

◮ Eliminate uncommon symbols from α: interpolant. ◮ Similarly for β. ◮ All interpolants between α and β form a lattice using

implication with the interpolant generated from α as the top element of the lattice and the one from β being the bottom element.

◮ The above assertions assume complete quantifier elimination.

slide-131
SLIDE 131

Interpolant Generation using Quantifier Elimination

◮ Eliminate uncommon symbols from α: interpolant. ◮ Similarly for β. ◮ All interpolants between α and β form a lattice using

implication with the interpolant generated from α as the top element of the lattice and the one from β being the bottom element.

◮ The above assertions assume complete quantifier elimination. ◮ This interpolant generated from α can serve as an interpolant

all β’s whose uncommon symbols with α are precisely remain

  • invariant. Other properties of such interpolants can also be

established.

slide-132
SLIDE 132

Interpolants over Equality with Uninterpreted Symbols

α, a finite conjunction of equality and disequalities over constants and function symbols, with their subset UC being uncommon symbols with β’s (UC may or may not include nonconstant function symbols).

◮ Run Kapur’s congruence closure algorithm (RTA 1997) on

equations with two differences.

slide-133
SLIDE 133

Interpolants over Equality with Uninterpreted Symbols

α, a finite conjunction of equality and disequalities over constants and function symbols, with their subset UC being uncommon symbols with β’s (UC may or may not include nonconstant function symbols).

◮ Run Kapur’s congruence closure algorithm (RTA 1997) on

equations with two differences.

◮ Flatten terms by introducing new constant symbols. If a

nonconstant subterm being replaced by a new constant has an

  • utermost uncommon symbol, then the new constant is also

viewed as uncommon. Otherwise, it is viewed as a common symbol.

slide-134
SLIDE 134

Interpolants over Equality with Uninterpreted Symbols

α, a finite conjunction of equality and disequalities over constants and function symbols, with their subset UC being uncommon symbols with β’s (UC may or may not include nonconstant function symbols).

◮ Run Kapur’s congruence closure algorithm (RTA 1997) on

equations with two differences.

◮ Flatten terms by introducing new constant symbols. If a

nonconstant subterm being replaced by a new constant has an

  • utermost uncommon symbol, then the new constant is also

viewed as uncommon. Otherwise, it is viewed as a common symbol.

◮ Define a total ordering in which all uncommon nonconstant

symbols are bigger than all uncommon constant symbols, followed by all common nonconstant symbols which are made bigger than all common constant symbols, run congruence closure which is ground completion.

slide-135
SLIDE 135

Interpolants over Equality with Uninterpreted Symbols

α, a finite conjunction of equality and disequalities over constants and function symbols, with their subset UC being uncommon symbols with β’s (UC may or may not include nonconstant function symbols).

◮ Run Kapur’s congruence closure algorithm (RTA 1997) on

equations with two differences.

◮ Flatten terms by introducing new constant symbols. If a

nonconstant subterm being replaced by a new constant has an

  • utermost uncommon symbol, then the new constant is also

viewed as uncommon. Otherwise, it is viewed as a common symbol.

◮ Define a total ordering in which all uncommon nonconstant

symbols are bigger than all uncommon constant symbols, followed by all common nonconstant symbols which are made bigger than all common constant symbols, run congruence closure which is ground completion.

◮ This is in contrast to Kapur’s algorithm in which all

nonconstant symbols are bigger than constant symbols.

slide-136
SLIDE 136

Interpolants over Equality with Uninterpreted Symbols

◮ The result is a finite set of rewrite rules of the form

f (c, d) → e (f , c, d are common ) = ⇒ eis common c → e; (c is common) implies (e is common)

slide-137
SLIDE 137

Interpolants over Equality with Uninterpreted Symbols

◮ The result is a finite set of rewrite rules of the form

f (c, d) → e (f , c, d are common ) = ⇒ eis common c → e; (c is common) implies (e is common)

◮ Horn clause introduction From

f (a, b) → e, f (c, d) → g, (a = c ∧ b = d) = ⇒ e = g where f is uncommon or least one of a, b, c, d is uncommon.

slide-138
SLIDE 138

Interpolants over Equality with Uninterpreted Symbols

◮ The result is a finite set of rewrite rules of the form

f (c, d) → e (f , c, d are common ) = ⇒ eis common c → e; (c is common) implies (e is common)

◮ Horn clause introduction From

f (a, b) → e, f (c, d) → g, (a = c ∧ b = d) = ⇒ e = g where f is uncommon or least one of a, b, c, d is uncommon.

◮ Normalize Horn clauses Run congruence closure on the

antecedent and normalize the consequent. If a Horn clause becomes trivially true, it is discarded. This is done every time a new Horn clause is generated.

slide-139
SLIDE 139

Interpolants over Equality with Uninterpreted Symbols

◮ Conditional Rewriting The consequent of a Horn clause may

have a uncommon symbol on its left side, which may also appear in an antecedent. That can be replaced in all such antecedents by carrying the conditions of this antecedent, (c1 = d1 ∧ · · · ∧ ck = dk) = ⇒ c = d (a1 = b1 ∧ · · · ∧ al = bl) = ⇒ a = b If a is some ci or di, then (a1 = b1∧· · ·∧al = bl)∧(c1 = d1∧b = di∧· · · ck = dk) = ⇒ c = d DIsequalities do not play since at best they can do is to delete a Horn clause or identify unsatisfiability. But if α is assumed to be satisfiable in the input, then the result of this includes an interpolant which is all the equations and Horn clauses which only have common symbols.

slide-140
SLIDE 140

An Example of Interpolant Generation on EUF

Mutually contradictory α = {x1 = z1, z2 = x2, z3 = f (x1), f (x2) = z4, x3 = z5, z6 = x4, z7 = f (x3), f (x4) = z8} and β = {z1 = z2, z5 = f (z3), f (z4) = z6, y1 = z7, z8 = y2, y1 = y2} Commons symbols are {f , z1, z2, z3, z4, z5, z6, z7, z8}.

slide-141
SLIDE 141

An Example of Interpolant Generation on EUF

Mutually contradictory α = {x1 = z1, z2 = x2, z3 = f (x1), f (x2) = z4, x3 = z5, z6 = x4, z7 = f (x3), f (x4) = z8} and β = {z1 = z2, z5 = f (z3), f (z4) = z6, y1 = z7, z8 = y2, y1 = y2} Commons symbols are {f , z1, z2, z3, z4, z5, z6, z7, z8}. Our algorithm gives: {x1 → z1, x2 → z2, f (z1) → z3, f (z2) → z4, x3 → z5, x4 → z6, f (z5) → z7, f (z6) → z8}.

slide-142
SLIDE 142

An Example of Interpolant Generation on EUF

Mutually contradictory α = {x1 = z1, z2 = x2, z3 = f (x1), f (x2) = z4, x3 = z5, z6 = x4, z7 = f (x3), f (x4) = z8} and β = {z1 = z2, z5 = f (z3), f (z4) = z6, y1 = z7, z8 = y2, y1 = y2} Commons symbols are {f , z1, z2, z3, z4, z5, z6, z7, z8}. Our algorithm gives: {x1 → z1, x2 → z2, f (z1) → z3, f (z2) → z4, x3 → z5, x4 → z6, f (z5) → z7, f (z6) → z8}. The interpolant Iα: {f (z1) = z3, f (z2) = z4, f (z5) = z7, f (z6) = z8}. No need to generate any Horn clauses.

slide-143
SLIDE 143

An Example of Interpolant Generation on EUF

Mutually contradictory α = {x1 = z1, z2 = x2, z3 = f (x1), f (x2) = z4, x3 = z5, z6 = x4, z7 = f (x3), f (x4) = z8} and β = {z1 = z2, z5 = f (z3), f (z4) = z6, y1 = z7, z8 = y2, y1 = y2} Commons symbols are {f , z1, z2, z3, z4, z5, z6, z7, z8}. Our algorithm gives: {x1 → z1, x2 → z2, f (z1) → z3, f (z2) → z4, x3 → z5, x4 → z6, f (z5) → z7, f (z6) → z8}. The interpolant Iα: {f (z1) = z3, f (z2) = z4, f (z5) = z7, f (z6) = z8}. No need to generate any Horn clauses. The interpolant reported by McMillan’s algorithm is: (z1 = z2 ∧ (z3 = z4 = ⇒ z5 = z6)) = ⇒ (z3 = z4 ∧ z7 = z8)

slide-144
SLIDE 144

An Example of Interpolant Generation on EUF

Mutually contradictory α = {x1 = z1, z2 = x2, z3 = f (x1), f (x2) = z4, x3 = z5, z6 = x4, z7 = f (x3), f (x4) = z8} and β = {z1 = z2, z5 = f (z3), f (z4) = z6, y1 = z7, z8 = y2, y1 = y2} Commons symbols are {f , z1, z2, z3, z4, z5, z6, z7, z8}. Our algorithm gives: {x1 → z1, x2 → z2, f (z1) → z3, f (z2) → z4, x3 → z5, x4 → z6, f (z5) → z7, f (z6) → z8}. The interpolant Iα: {f (z1) = z3, f (z2) = z4, f (z5) = z7, f (z6) = z8}. No need to generate any Horn clauses. The interpolant reported by McMillan’s algorithm is: (z1 = z2 ∧ (z3 = z4 = ⇒ z5 = z6)) = ⇒ (z3 = z4 ∧ z7 = z8) Tinelli et al’s algorithm, it is: (z1 = z2 = ⇒ z3 = z4) ∧ (z5 = z6 = ⇒ z7 = z8).

slide-145
SLIDE 145

Interpolant Generation over Octagonal formulas

Let α to be a conjunction of ±xi ≤ ci and ±xi ± xj ≤ ci,j, where xi and xj are distinct.

  • 1. For each uncommon symbol xi in α, consider two octagon

formulas in which the sign of xi is positive in one and negative in the other. xi is eliminated by adding the two formulas. This must be done for every pair of such formulas. The result of all uncommon symbols is an interpolant generated from α. This is illustrated below.

slide-146
SLIDE 146

Interpolant Generation over Octagonal formulas

Let α to be a conjunction of ±xi ≤ ci and ±xi ± xj ≤ ci,j, where xi and xj are distinct.

  • 1. For each uncommon symbol xi in α, consider two octagon

formulas in which the sign of xi is positive in one and negative in the other. xi is eliminated by adding the two formulas. This must be done for every pair of such formulas.

  • 2. In case a formula of the form 2xj ≤ a or −2xJ ≤ a, it is

normalized in the case octagonal formulas are over the integers. The result of all uncommon symbols is an interpolant generated from α. This is illustrated below.

slide-147
SLIDE 147

Interpolant Generation over Octagonal formulas

Let α to be a conjunction of ±xi ≤ ci and ±xi ± xj ≤ ci,j, where xi and xj are distinct.

  • 1. For each uncommon symbol xi in α, consider two octagon

formulas in which the sign of xi is positive in one and negative in the other. xi is eliminated by adding the two formulas. This must be done for every pair of such formulas.

  • 2. In case a formula of the form 2xj ≤ a or −2xJ ≤ a, it is

normalized in the case octagonal formulas are over the integers.

  • 3. If some uncommon symbol only appears positively or

negatively, all octagonal formulas containing it can be eliminated as they do not occur in the interpolant. The result of all uncommon symbols is an interpolant generated from α. This is illustrated below.

slide-148
SLIDE 148

Griggio’s example of Octagonal Formulas

Mutually contradictory α = {x1 − x2 ≥ −4, − x2 − x3 ≥ 5, x2 + x6 ≥ 4, x2 + x5 ≥ −3}, β = { −x1 + x3 ≥ −2, − x4 − x6 ≥ 0, − x5 + x4 ≥ 0} Uncommon symbols: {x2}.

slide-149
SLIDE 149

Griggio’s example of Octagonal Formulas

Mutually contradictory α = {x1 − x2 ≥ −4, − x2 − x3 ≥ 5, x2 + x6 ≥ 4, x2 + x5 ≥ −3}, β = { −x1 + x3 ≥ −2, − x4 − x6 ≥ 0, − x5 + x4 ≥ 0} Uncommon symbols: {x2}.

  • 1. Eliminate x2:

{−x3 + x5 ≥ 2, x1 + x6 ≥ 0, x1 + x5 ≥ −7, − x3 + x6 ≥ 9}.

slide-150
SLIDE 150

Griggio’s example of Octagonal Formulas

Mutually contradictory α = {x1 − x2 ≥ −4, − x2 − x3 ≥ 5, x2 + x6 ≥ 4, x2 + x5 ≥ −3}, β = { −x1 + x3 ≥ −2, − x4 − x6 ≥ 0, − x5 + x4 ≥ 0} Uncommon symbols: {x2}.

  • 1. Eliminate x2:

{−x3 + x5 ≥ 2, x1 + x6 ≥ 0, x1 + x5 ≥ −7, − x3 + x6 ≥ 9}.

  • 2. No literal from α is included.
slide-151
SLIDE 151

Griggio’s example of Octagonal Formulas

Mutually contradictory α = {x1 − x2 ≥ −4, − x2 − x3 ≥ 5, x2 + x6 ≥ 4, x2 + x5 ≥ −3}, β = { −x1 + x3 ≥ −2, − x4 − x6 ≥ 0, − x5 + x4 ≥ 0} Uncommon symbols: {x2}.

  • 1. Eliminate x2:

{−x3 + x5 ≥ 2, x1 + x6 ≥ 0, x1 + x5 ≥ −7, − x3 + x6 ≥ 9}.

  • 2. No literal from α is included.
  • 3. Interpolant:

Iα = {−x3 + x5 ≥ 2, x1 + x6 ≥ 0, x1 + x5 ≥ −7, −x3 + x6 ≥ 9}.

slide-152
SLIDE 152

Griggio’s example of Octagonal Formulas

Mutually contradictory α = {x1 − x2 ≥ −4, − x2 − x3 ≥ 5, x2 + x6 ≥ 4, x2 + x5 ≥ −3}, β = { −x1 + x3 ≥ −2, − x4 − x6 ≥ 0, − x5 + x4 ≥ 0} Uncommon symbols: {x2}.

  • 1. Eliminate x2:

{−x3 + x5 ≥ 2, x1 + x6 ≥ 0, x1 + x5 ≥ −7, − x3 + x6 ≥ 9}.

  • 2. No literal from α is included.
  • 3. Interpolant:

Iα = {−x3 + x5 ≥ 2, x1 + x6 ≥ 0, x1 + x5 ≥ −7, −x3 + x6 ≥ 9}.

slide-153
SLIDE 153

Griggio’s example of Octagonal Formulas

Mutually contradictory α = {x1 − x2 ≥ −4, − x2 − x3 ≥ 5, x2 + x6 ≥ 4, x2 + x5 ≥ −3}, β = { −x1 + x3 ≥ −2, − x4 − x6 ≥ 0, − x5 + x4 ≥ 0} Uncommon symbols: {x2}.

  • 1. Eliminate x2:

{−x3 + x5 ≥ 2, x1 + x6 ≥ 0, x1 + x5 ≥ −7, − x3 + x6 ≥ 9}.

  • 2. No literal from α is included.
  • 3. Interpolant:

Iα = {−x3 + x5 ≥ 2, x1 + x6 ≥ 0, x1 + x5 ≥ −7, −x3 + x6 ≥ 9}. Griggio’s algorithm gives the conditional interpolant (−x6 − x5 ≥ 0) = ⇒ (x1 − x + 3 ≥ 3)

slide-154
SLIDE 154

Griggio’s example of Octagonal Formulas

Mutually contradictory α = {x1 − x2 ≥ −4, − x2 − x3 ≥ 5, x2 + x6 ≥ 4, x2 + x5 ≥ −3}, β = { −x1 + x3 ≥ −2, − x4 − x6 ≥ 0, − x5 + x4 ≥ 0} Uncommon symbols: {x2}.

  • 1. Eliminate x2:

{−x3 + x5 ≥ 2, x1 + x6 ≥ 0, x1 + x5 ≥ −7, − x3 + x6 ≥ 9}.

  • 2. No literal from α is included.
  • 3. Interpolant:

Iα = {−x3 + x5 ≥ 2, x1 + x6 ≥ 0, x1 + x5 ≥ −7, −x3 + x6 ≥ 9}. Griggio’s algorithm gives the conditional interpolant (−x6 − x5 ≥ 0) = ⇒ (x1 − x + 3 ≥ 3) The strongest interpolant is an octagonal formula and is generated by our algorithm.

slide-155
SLIDE 155

Saturation based Invariant Strengthening and Abductor Generation

◮ Given a formula claimed to be an invariant I (or a post

condition a la IC3)

slide-156
SLIDE 156

Saturation based Invariant Strengthening and Abductor Generation

◮ Given a formula claimed to be an invariant I (or a post

condition a la IC3)

◮ attempt to prove it inductive incrementally for every path:

(I ∧ cond) = ⇒ I ′.

slide-157
SLIDE 157

Saturation based Invariant Strengthening and Abductor Generation

◮ Given a formula claimed to be an invariant I (or a post

condition a la IC3)

◮ attempt to prove it inductive incrementally for every path:

(I ∧ cond) = ⇒ I ′.

◮ lucky and success: great.

slide-158
SLIDE 158

Saturation based Invariant Strengthening and Abductor Generation

◮ Given a formula claimed to be an invariant I (or a post

condition a la IC3)

◮ attempt to prove it inductive incrementally for every path:

(I ∧ cond) = ⇒ I ′.

◮ lucky and success: great. ◮ unsuccessful: attempt to strengthen I using ψ such that

(I ∧ cond ∧ ψ) = ⇒ (I ′ ∧ ψ′)

slide-159
SLIDE 159

Saturation based Invariant Strengthening and Abductor Generation

◮ Given a formula claimed to be an invariant I (or a post

condition a la IC3)

◮ attempt to prove it inductive incrementally for every path:

(I ∧ cond) = ⇒ I ′.

◮ lucky and success: great. ◮ unsuccessful: attempt to strengthen I using ψ such that

(I ∧ cond ∧ ψ) = ⇒ (I ′ ∧ ψ′)

◮ Repeat this process until a counter-example is found or

success.

slide-160
SLIDE 160

Saturation based Invariant Strengthening and Abductor Generation

◮ Given a formula claimed to be an invariant I (or a post

condition a la IC3)

◮ attempt to prove it inductive incrementally for every path:

(I ∧ cond) = ⇒ I ′.

◮ lucky and success: great. ◮ unsuccessful: attempt to strengthen I using ψ such that

(I ∧ cond ∧ ψ) = ⇒ (I ′ ∧ ψ′)

◮ Repeat this process until a counter-example is found or

success.

◮ How to obtain ψ?

slide-161
SLIDE 161

Saturation based Invariant Strengthening and Abductor Generation

◮ Given a formula claimed to be an invariant I (or a post

condition a la IC3)

◮ attempt to prove it inductive incrementally for every path:

(I ∧ cond) = ⇒ I ′.

◮ lucky and success: great. ◮ unsuccessful: attempt to strengthen I using ψ such that

(I ∧ cond ∧ ψ) = ⇒ (I ′ ∧ ψ′)

◮ Repeat this process until a counter-example is found or

success.

◮ How to obtain ψ? ◮ Approximate ψ to be (I ∧ cond ∧ ψ) =

⇒ I ′

slide-162
SLIDE 162

Saturation based Invariant Strengthening and Abductor Generation

◮ Given a formula claimed to be an invariant I (or a post

condition a la IC3)

◮ attempt to prove it inductive incrementally for every path:

(I ∧ cond) = ⇒ I ′.

◮ lucky and success: great. ◮ unsuccessful: attempt to strengthen I using ψ such that

(I ∧ cond ∧ ψ) = ⇒ (I ′ ∧ ψ′)

◮ Repeat this process until a counter-example is found or

success.

◮ How to obtain ψ? ◮ Approximate ψ to be (I ∧ cond ∧ ψ) =

⇒ I ′

◮ ψ is an abductor for (I ∧ cond, I ′).

slide-163
SLIDE 163

Saturation based Invariant Strengthening and Abductor Generation

Example

var x, y, z: integer end var x := 0, y := 0, z := 9; while x ≤ N do x := x + 1; y := y + 1; z := z + x − y; end while Goal: z ≤ 0 is a loop invariant.

slide-164
SLIDE 164

Saturation based Invariant Strengthening and Abductor Generation

Example

var x, y, z: integer end var x := 0, y := 0, z := 9; while x ≤ N do x := x + 1; y := y + 1; z := z + x − y; end while Goal: z ≤ 0 is a loop invariant. z ≤ 0 = ⇒ z + x − y ≤ 0.

slide-165
SLIDE 165

Saturation based Invariant Strengthening and Abductor Generation

Example

var x, y, z: integer end var x := 0, y := 0, z := 9; while x ≤ N do x := x + 1; y := y + 1; z := z + x − y; end while Goal: z ≤ 0 is a loop invariant. z ≤ 0 = ⇒ z + x − y ≤ 0. (z ≤ 0 ∧ z + x − y ≤ 0) = ⇒ (z + x − y ≤ 0 ∧ z + 2x − 2y ≤ 0).

slide-166
SLIDE 166

Saturation based Invariant Strengthening and Abductor Generation

Example

var x, y, z: integer end var x := 0, y := 0, z := 9; while x ≤ N do x := x + 1; y := y + 1; z := z + x − y; end while Goal: z ≤ 0 is a loop invariant. z ≤ 0 = ⇒ z + x − y ≤ 0. (z ≤ 0 ∧ z + x − y ≤ 0) = ⇒ (z + x − y ≤ 0 ∧ z + 2x − 2y ≤ 0). Strengthen it to z ≤ 0 ∧ x − y ≤ 0

slide-167
SLIDE 167

Saturation based Invariant Strengthening and Abductor Generation

Example

var x, y, z: integer end var x := 0, y := 0, z := 9; while x ≤ N do x := x + 1; y := y + 1; z := z + x − y; end while Goal: z ≤ 0 is a loop invariant. z ≤ 0 = ⇒ z + x − y ≤ 0. (z ≤ 0 ∧ z + x − y ≤ 0) = ⇒ (z + x − y ≤ 0 ∧ z + 2x − 2y ≤ 0). Strengthen it to z ≤ 0 ∧ x − y ≤ 0 Quantifier elimination comes to the rescue

slide-168
SLIDE 168

Salient Points

◮ Quantifier-elimination is ubiquitous.

slide-169
SLIDE 169

Salient Points

◮ Quantifier-elimination is ubiquitous. ◮ Since general (complete) QE methods are very expensive and

their outputs are hard to decipher, it is better to consider special cases, sacrificing completeness as well as generality.

slide-170
SLIDE 170

Salient Points

◮ Quantifier-elimination is ubiquitous. ◮ Since general (complete) QE methods are very expensive and

their outputs are hard to decipher, it is better to consider special cases, sacrificing completeness as well as generality.

◮ There is a real trade-off between resources/efficiency and

precision/incompleteness.

slide-171
SLIDE 171

Salient Points

◮ Quantifier-elimination is ubiquitous. ◮ Since general (complete) QE methods are very expensive and

their outputs are hard to decipher, it is better to consider special cases, sacrificing completeness as well as generality.

◮ There is a real trade-off between resources/efficiency and

precision/incompleteness.

◮ Let us call a spade a spade.

slide-172
SLIDE 172

Challenges

◮ Can we develop specialized quantifier elimination

algorithms/heuristics for various fragments of real and complex arithmetic?

slide-173
SLIDE 173

Challenges

◮ Can we develop specialized quantifier elimination

algorithms/heuristics for various fragments of real and complex arithmetic?

◮ Outputs generated by them need not be complete but must

be useful for SMT solvers and theorem provers/verification systems.

slide-174
SLIDE 174

Challenges

◮ Can we develop specialized quantifier elimination

algorithms/heuristics for various fragments of real and complex arithmetic?

◮ Outputs generated by them need not be complete but must

be useful for SMT solvers and theorem provers/verification systems.

◮ How can propositional reasoning, first-order and equational

reasoning, redundancy checks, and preprocessing be exploited in general quantifier elimination methods to make them more effective?

slide-175
SLIDE 175

Challenges

◮ Can we develop specialized quantifier elimination

algorithms/heuristics for various fragments of real and complex arithmetic?

◮ Outputs generated by them need not be complete but must

be useful for SMT solvers and theorem provers/verification systems.

◮ How can propositional reasoning, first-order and equational

reasoning, redundancy checks, and preprocessing be exploited in general quantifier elimination methods to make them more effective?

◮ Can we have better, effective interfaces between a computer

algebra system and a theorem prover?

slide-176
SLIDE 176

Challenges

◮ Can we develop specialized quantifier elimination

algorithms/heuristics for various fragments of real and complex arithmetic?

◮ Outputs generated by them need not be complete but must

be useful for SMT solvers and theorem provers/verification systems.

◮ How can propositional reasoning, first-order and equational

reasoning, redundancy checks, and preprocessing be exploited in general quantifier elimination methods to make them more effective?

◮ Can we have better, effective interfaces between a computer

algebra system and a theorem prover?

◮ Can certificates be generated for outputs computed by a

symbolic computation algorithm so that a theorem prover/SMT solver can trust it?

slide-177
SLIDE 177

Parametric Gr¨

  • bner Computations in Quantifier

Elimination over the reals

◮ Gr¨

  • bner basis computations are being widely used in many

application domains, especially for equational solving

slide-178
SLIDE 178

Parametric Gr¨

  • bner Computations in Quantifier

Elimination over the reals

◮ Gr¨

  • bner basis computations are being widely used in many

application domains, especially for equational solving

◮ Given the success of Gr¨

  • bner basis computations for handling

many problems in algebraic geometry, polynomial equation solving and program analysis, as well our good experience in computing comprehensive Gr¨

  • bner systems, we are encouraged

to build a practical incomplete heuristic for the theory of real closed field:

slide-179
SLIDE 179

Parametric Gr¨

  • bner Computations in Quantifier

Elimination over the reals

◮ Gr¨

  • bner basis computations are being widely used in many

application domains, especially for equational solving

◮ Given the success of Gr¨

  • bner basis computations for handling

many problems in algebraic geometry, polynomial equation solving and program analysis, as well our good experience in computing comprehensive Gr¨

  • bner systems, we are encouraged

to build a practical incomplete heuristic for the theory of real closed field:

  • 1. draw upon extensive experience from SAT/SMT solvers,

first-order reasoning to handle “nonalgebraic” reasoning.

slide-180
SLIDE 180

Parametric Gr¨

  • bner Computations in Quantifier

Elimination over the reals

◮ Gr¨

  • bner basis computations are being widely used in many

application domains, especially for equational solving

◮ Given the success of Gr¨

  • bner basis computations for handling

many problems in algebraic geometry, polynomial equation solving and program analysis, as well our good experience in computing comprehensive Gr¨

  • bner systems, we are encouraged

to build a practical incomplete heuristic for the theory of real closed field:

  • 1. draw upon extensive experience from SAT/SMT solvers,

first-order reasoning to handle “nonalgebraic” reasoning.

  • 2. use sum of squares heuristics (using completing square

strategy): Σk

u=1p2 u = 0 =

⇒ pi = 0.

slide-181
SLIDE 181

Parametric Gr¨

  • bner Computations in Quantifier

Elimination over the reals

◮ Gr¨

  • bner basis computations are being widely used in many

application domains, especially for equational solving

◮ Given the success of Gr¨

  • bner basis computations for handling

many problems in algebraic geometry, polynomial equation solving and program analysis, as well our good experience in computing comprehensive Gr¨

  • bner systems, we are encouraged

to build a practical incomplete heuristic for the theory of real closed field:

  • 1. draw upon extensive experience from SAT/SMT solvers,

first-order reasoning to handle “nonalgebraic” reasoning.

  • 2. use sum of squares heuristics (using completing square

strategy): Σk

u=1p2 u = 0 =

⇒ pi = 0.

  • 3. perhaps positive NullstellensatzNullstellensatzNullstellensatz

(some aspects)

slide-182
SLIDE 182

Parametric Gr¨

  • bner Computations in Quantifier

Elimination over the reals

◮ Gr¨

  • bner basis computations are being widely used in many

application domains, especially for equational solving

◮ Given the success of Gr¨

  • bner basis computations for handling

many problems in algebraic geometry, polynomial equation solving and program analysis, as well our good experience in computing comprehensive Gr¨

  • bner systems, we are encouraged

to build a practical incomplete heuristic for the theory of real closed field:

  • 1. draw upon extensive experience from SAT/SMT solvers,

first-order reasoning to handle “nonalgebraic” reasoning.

  • 2. use sum of squares heuristics (using completing square

strategy): Σk

u=1p2 u = 0 =

⇒ pi = 0.

  • 3. perhaps positive NullstellensatzNullstellensatzNullstellensatz

(some aspects)

  • 4. semi-definite Programming
slide-183
SLIDE 183

Parametric Gr¨

  • bner Computations in Quantifier

Elimination over the reals

◮ Gr¨

  • bner basis computations are being widely used in many

application domains, especially for equational solving

◮ Given the success of Gr¨

  • bner basis computations for handling

many problems in algebraic geometry, polynomial equation solving and program analysis, as well our good experience in computing comprehensive Gr¨

  • bner systems, we are encouraged

to build a practical incomplete heuristic for the theory of real closed field:

  • 1. draw upon extensive experience from SAT/SMT solvers,

first-order reasoning to handle “nonalgebraic” reasoning.

  • 2. use sum of squares heuristics (using completing square

strategy): Σk

u=1p2 u = 0 =

⇒ pi = 0.

  • 3. perhaps positive NullstellensatzNullstellensatzNullstellensatz

(some aspects)

  • 4. semi-definite Programming
  • 5. a small step: interpolant generation for concave quadratic

polynomial inequalities (over EUF).