Numerical Computations and Formal Methods Guillaume Melquiond - - PowerPoint PPT Presentation

numerical computations and formal methods
SMART_READER_LITE
LIVE PREVIEW

Numerical Computations and Formal Methods Guillaume Melquiond - - PowerPoint PPT Presentation

Program verification Formal arithmetic Decision procedures Numerical Computations and Formal Methods Guillaume Melquiond Proval, Laboratoire de Recherche en Informatique INRIA SaclayIdF, Universit e Paris Sud, CNRS October 28, 2009


slide-1
SLIDE 1

Program verification Formal arithmetic Decision procedures

Numerical Computations and Formal Methods

Guillaume Melquiond

Proval, Laboratoire de Recherche en Informatique INRIA Saclay–IdF, Universit´ e Paris Sud, CNRS

October 28, 2009

Guillaume Melquiond Numerical Computations and Formal Methods

slide-2
SLIDE 2

Program verification Formal arithmetic Decision procedures

Numerical Computations and Formal Methods

1

Deductive program verification

2

Computing in a formal system

3

Decision procedures for arithmetic theories

4

Conclusion

Guillaume Melquiond Numerical Computations and Formal Methods

slide-3
SLIDE 3

Program verification Formal arithmetic Decision procedures WP Why Gappa

Deductive Program Verification

1

Deductive program verification Floyd-Hoare logic and weakest preconditions A framework for program verification: Why Gappa

2

Computing in a formal system

3

Decision procedures for arithmetic theories

4

Conclusion

Guillaume Melquiond Numerical Computations and Formal Methods

slide-4
SLIDE 4

Program verification Formal arithmetic Decision procedures WP Why Gappa

Hoare Triple

Definition (Hoare triple)

{precondition} code {postcondition}. Meaning of correctness: If the precondition holds just before the code is executed, the postcondition holds just after it has been executed.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-5
SLIDE 5

Program verification Formal arithmetic Decision procedures WP Why Gappa

Hoare Triple

Definition (Hoare triple)

{precondition} code {postcondition}. Meaning of correctness: If the precondition holds just before the code is executed, the postcondition holds just after it has been executed. Note: the definition assumes the code terminates. If it does not, any postcondition holds, including False.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-6
SLIDE 6

Program verification Formal arithmetic Decision procedures WP Why Gappa

Hoare Triple

1 { x >= 0 } 2 y = floor(sqrt(x)) 3 { y >= 0 and y*y <= x < (y+1)*(y+1) } Guillaume Melquiond Numerical Computations and Formal Methods

slide-7
SLIDE 7

Program verification Formal arithmetic Decision procedures WP Why Gappa

Weakest Precondition

Definition (Weakest precondition)

R is the weakest precondition of a code C and a postcondition Q iff any correct triple {P} C {Q} satisfies P ⇒ R.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-8
SLIDE 8

Program verification Formal arithmetic Decision procedures WP Why Gappa

Weakest Precondition

Definition (Weakest precondition)

R is the weakest precondition of a code C and a postcondition Q iff any correct triple {P} C {Q} satisfies P ⇒ R. A function behaves correctly (modulo termination) if its specification can be expressed as a correct triple.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-9
SLIDE 9

Program verification Formal arithmetic Decision procedures WP Why Gappa

Weakest Precondition

Definition (Weakest precondition)

R is the weakest precondition of a code C and a postcondition Q iff any correct triple {P} C {Q} satisfies P ⇒ R. A function behaves correctly (modulo termination) if its specification can be expressed as a correct triple. How to verify it? Compute the weakest precondition (Dijkstra, 1975) from the function and its specified postcondition. Prove that the specified precondition implies the weakest one.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-10
SLIDE 10

Program verification Formal arithmetic Decision procedures WP Why Gappa

A Framework for Program Verification: Why

Why is a minimal system: small ML-like programming language, small specification language.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-11
SLIDE 11

Program verification Formal arithmetic Decision procedures WP Why Gappa

A Framework for Program Verification: Why

Why is a minimal system: small ML-like programming language, small specification language. Why is an intermediate environment: it computes weakest preconditions; it generates VCs for provers, interactive or not.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-12
SLIDE 12

Program verification Formal arithmetic Decision procedures WP Why Gappa

A Framework for Program Verification: Why

Why is a minimal system: small ML-like programming language, small specification language. Why is an intermediate environment: it computes weakest preconditions; it generates VCs for provers, interactive or not. Various tools translate programing languages (C, Java) to the ML language.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-13
SLIDE 13

Program verification Formal arithmetic Decision procedures WP Why Gappa

Environment

Coq PVS Isabelle Mizar HOL4

HOL light

Alt-Ergo (Yices, Z3, CVC3) SMT-lib Simplify Harvey Zenon Gappa Why Frama-C Jessie annotated C program annotated Java/JML prog. Interactive provers Automated provers Krakatoa Caduceus ML program

Guillaume Melquiond Numerical Computations and Formal Methods

slide-14
SLIDE 14

Program verification Formal arithmetic Decision procedures WP Why Gappa

Toy Example: Cosine Around Zero

1 /*@ requires \abs(x) <= 0x1p -5 ; 2

@ ensures \abs(\ result - \cos(x)) <= 0x1p -23; */

3 float

toy_cos(float x) {

4

// @assert \abs (1.0-x*x*0.5 - \cos(x)) <= 0x1p -24;

5

return 1.0f - x * x * 0.5f;

6 }

“\result” is the value returned by the function, that is: 1 − 0.5 · x2 with all the operations rounded to nearest binary32. Safety: none of the operations overflow nor are invalid. Correctness: the result is almost the mathematical cosine.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-15
SLIDE 15

Program verification Formal arithmetic Decision procedures WP Why Gappa

Frama-C/Jessie/Why + Gappa

Guillaume Melquiond Numerical Computations and Formal Methods

slide-16
SLIDE 16

Program verification Formal arithmetic Decision procedures WP Why Gappa

Verifying Arithmetic Properties

Kind of properties: Precondition validity:

no overflow: ∀ x, f ( x) ∈ D;

Guillaume Melquiond Numerical Computations and Formal Methods

slide-17
SLIDE 17

Program verification Formal arithmetic Decision procedures WP Why Gappa

Verifying Arithmetic Properties

Kind of properties: Precondition validity:

no overflow: ∀ x, f ( x) ∈ D; no domain error: ∀ x, d(f ( x), g( x), · · · ) ∈ D.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-18
SLIDE 18

Program verification Formal arithmetic Decision procedures WP Why Gappa

Verifying Arithmetic Properties

Kind of properties: Precondition validity:

no overflow: ∀ x, f ( x) ∈ D; no domain error: ∀ x, d(f ( x), g( x), · · · ) ∈ D.

Accuracy of results:

absolute error: ∀ x, f ( x) − g( x) ∈ E;

Guillaume Melquiond Numerical Computations and Formal Methods

slide-19
SLIDE 19

Program verification Formal arithmetic Decision procedures WP Why Gappa

Verifying Arithmetic Properties

Kind of properties: Precondition validity:

no overflow: ∀ x, f ( x) ∈ D; no domain error: ∀ x, d(f ( x), g( x), · · · ) ∈ D.

Accuracy of results:

absolute error: ∀ x, f ( x) − g( x) ∈ E; relative error: ∀ x, ∃ε, f ( x) = g( x) × (1 + ε).

Guillaume Melquiond Numerical Computations and Formal Methods

slide-20
SLIDE 20

Program verification Formal arithmetic Decision procedures WP Why Gappa

Verifying Arithmetic Properties

Kind of properties: Precondition validity:

no overflow: ∀ x, f ( x) ∈ D; no domain error: ∀ x, d(f ( x), g( x), · · · ) ∈ D.

Accuracy of results:

absolute error: ∀ x, f ( x) − g( x) ∈ E; relative error: ∀ x, ∃ε, f ( x) = g( x) × (1 + ε).

Language of formulas: intervals with nonsymbolic bounds, expressions with mathematical operators (e.g., ×, tan) and rounding operators (e.g., ⌊·⌋).

Guillaume Melquiond Numerical Computations and Formal Methods

slide-21
SLIDE 21

Program verification Formal arithmetic Decision procedures WP Why Gappa

Gappa

Input: logical formula about expressions on real numbers. Output: “Yes” and a formal proof, or ”I don’t know”.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-22
SLIDE 22

Program verification Formal arithmetic Decision procedures WP Why Gappa

Gappa

Input: logical formula about expressions on real numbers. Output: “Yes” and a formal proof, or ”I don’t know”. Method: saturation over a set of theorems. Naive interval arithmetic: u ∈ [u, u] ∧ v ∈ [v, v] ⇒ u + v ∈ [u + v, u + v].

Guillaume Melquiond Numerical Computations and Formal Methods

slide-23
SLIDE 23

Program verification Formal arithmetic Decision procedures WP Why Gappa

Gappa

Input: logical formula about expressions on real numbers. Output: “Yes” and a formal proof, or ”I don’t know”. Method: saturation over a set of theorems. Naive interval arithmetic: u ∈ [u, u] ∧ v ∈ [v, v] ⇒ u + v ∈ [u + v, u + v]. Floating-/fixed-point arithmetic properties: u ∈ 2−1074 · Z ⇒ ∃ε ∈ [−2−53, 2−53], ◦(u) = u × (1 + ε).

Guillaume Melquiond Numerical Computations and Formal Methods

slide-24
SLIDE 24

Program verification Formal arithmetic Decision procedures WP Why Gappa

Gappa

Input: logical formula about expressions on real numbers. Output: “Yes” and a formal proof, or ”I don’t know”. Method: saturation over a set of theorems. Naive interval arithmetic: u ∈ [u, u] ∧ v ∈ [v, v] ⇒ u + v ∈ [u + v, u + v]. Floating-/fixed-point arithmetic properties: u ∈ 2−1074 · Z ⇒ ∃ε ∈ [−2−53, 2−53], ◦(u) = u × (1 + ε). Forward error analysis: ˜ u × ˜ v − u × v = (˜ u − u) × v + u × (˜ v − v) + (˜ u − u) × (˜ v − v). . . .

Guillaume Melquiond Numerical Computations and Formal Methods

slide-25
SLIDE 25

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Computing in a Formal System

1

Deductive program verification

2

Computing in a formal system Type theory and proofs by reflection Some formalizations of arithmetic in Coq

3

Decision procedures for arithmetic theories

4

Conclusion

Guillaume Melquiond Numerical Computations and Formal Methods

slide-26
SLIDE 26

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Example: Peano’s Arithmetic

Inductive definition of natural numbers:

type nat = O | S of nat (∗ 5 = SSSSSO ∗)

Axioms for addition: addO: ∀b, O + b = b addS: ∀a b, (S a) + b = a + (S b)

Guillaume Melquiond Numerical Computations and Formal Methods

slide-27
SLIDE 27

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Example: Peano’s Arithmetic

Deductive proof of 4 + (2 + 3) = 9: (9 steps) 9 = 9 reflexivity 0 + 9 = 9 addO . . . . addS × 4 4 + 5 = 9 4 + (0 + 5) = 9 addO 4 + (1 + 4) = 9 addS 4 + (2 + 3) = 9 addS

Guillaume Melquiond Numerical Computations and Formal Methods

slide-28
SLIDE 28

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Introducing Computations into Proofs

Recursive definition of addition:

let rec plus x y = match x with | O -> y | S x’ -> plus x’ (S y)

Lemma plus xlate: ∀a b, a + b = plus a b

Guillaume Melquiond Numerical Computations and Formal Methods

slide-29
SLIDE 29

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Introducing Computations into Proofs

Recursive definition of addition:

let rec plus x y = match x with | O -> y | S x’ -> plus x’ (S y)

Lemma plus xlate: ∀a b, a + b = plus a b Proof of 4 + (2 + 3) = 9: (4 steps) 9 = 9 reflexivity plus 4 (plus 2 3) = 9 ??? 4 + (plus 2 3) = 9 plus xlate 4 + (2 + 3) = 9 plus xlate

Guillaume Melquiond Numerical Computations and Formal Methods

slide-30
SLIDE 30

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Type Theory and Conversion

Curry-Howard correspondence and type theory:

1 Proposition A holds if the type A is inhabited. 2 Convertible types have the same inhabitants.

p : A p : B A ≡β B

Guillaume Melquiond Numerical Computations and Formal Methods

slide-31
SLIDE 31

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Type Theory and Conversion

Curry-Howard correspondence and type theory:

1 Proposition A holds if the type A is inhabited. 2 Convertible types have the same inhabitants.

p : A p : B A ≡β B Proof of 4 + (2 + 3) = 9: (4 steps) p : 9 = 9 reflexivity p : plus 4 (plus 2 3) = 9 β-reduction 4 + (plus 2 3) = 9 plus xlate 4 + (2 + 3) = 9 plus xlate

Guillaume Melquiond Numerical Computations and Formal Methods

slide-32
SLIDE 32

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Encoding Expressions

Inductive definition of expressions on natural numbers:

type expr = Nat of nat | Add of expr * expr let rec interp_expr e = match e with | Nat n -> n | Add (x, y) -> (interp_expr x) "+" (interp_expr y)

Proof of 4 + (2 + 3) = 9: ??? interp expr (Add (Nat 4, Add (Nat 2, Nat 3))) = 9 4 + (2 + 3) = 9 β-reduction

Guillaume Melquiond Numerical Computations and Formal Methods

slide-33
SLIDE 33

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Evaluating Expressions

Evaluating expressions on natural numbers:

let rec eval_expr e = match e with | Nat n -> n | Add (x, y) -> plus (eval_expr x) (eval_expr y)

Lemma expr xlate: ∀e interp expr e = eval expr e

Guillaume Melquiond Numerical Computations and Formal Methods

slide-34
SLIDE 34

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Evaluating Expressions

Evaluating expressions on natural numbers:

let rec eval_expr e = match e with | Nat n -> n | Add (x, y) -> plus (eval_expr x) (eval_expr y)

Lemma expr xlate: ∀e interp expr e = eval expr e Proof of 4 + (2 + 3) = 9: 9 = 9 reflexivity eval expr (Add (Nat 4, . . .)) = 9 β-reduction interp expr (Add (Nat 4, . . .)) = 9 expr xlate 4 + (2 + 3) = 9 β-reduction

Guillaume Melquiond Numerical Computations and Formal Methods

slide-35
SLIDE 35

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Relational Operators

Equality is usually a native concept, while comparisons are not. Comparing natural numbers:

let rec le x y = match x, y with | O , _

  • > true

| S _ , O

  • > false

| S x’, S y’ -> le x’ y’

Lemma: ∀a∀b le a b = true ⇔ a ≤ b

Guillaume Melquiond Numerical Computations and Formal Methods

slide-36
SLIDE 36

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Encoding Comparisons

Inductive definition of relations on natural expressions:

type prop = Le of expr * expr let interp_prop p = match p with | Le (x, y) -> (interp_expr x) " <=" (interp_expr y) let eval_prop p = match p with | Le (x, y) -> le (eval_expr x) (eval_expr y)

Guillaume Melquiond Numerical Computations and Formal Methods

slide-37
SLIDE 37

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Encoding Comparisons

Inductive definition of relations on natural expressions:

type prop = Le of expr * expr let interp_prop p = match p with | Le (x, y) -> (interp_expr x) " <=" (interp_expr y) let eval_prop p = match p with | Le (x, y) -> le (eval_expr x) (eval_expr y)

Proof of 4 + (2 + 3) ≤ 5 + 6: true = true reflexivity eval prop (Le (Add . . . , Add . . .)) = true β-reduction interp prop (Le (Add . . . , Add . . .)) prop xlate 4 + (2 + 3) ≤ 5 + 6 β-reduction

Guillaume Melquiond Numerical Computations and Formal Methods

slide-38
SLIDE 38

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Some Formalizations of Arithmetic in Coq

Integers as lists of bits: polynomial equality, semi-decision of (Z, +, =, <).

Guillaume Melquiond Numerical Computations and Formal Methods

slide-39
SLIDE 39

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Some Formalizations of Arithmetic in Coq

Integers as lists of bits: polynomial equality, semi-decision of (Z, +, =, <). Rational numbers and Bernstein polynomials: global optimization for Hales’ inequalities.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-40
SLIDE 40

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Some Formalizations of Arithmetic in Coq

Integers as lists of bits: polynomial equality, semi-decision of (Z, +, =, <). Rational numbers and Bernstein polynomials: global optimization for Hales’ inequalities. Dyadic numbers and intervals: verification of Gappa certificates.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-41
SLIDE 41

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Some Formalizations of Arithmetic in Coq

Integers as lists of bits: polynomial equality, semi-decision of (Z, +, =, <). Rational numbers and Bernstein polynomials: global optimization for Hales’ inequalities. Dyadic numbers and intervals: verification of Gappa certificates. Integers as binary trees of machine words: verification of Pocklington primality certificates.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-42
SLIDE 42

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Some Formalizations of Arithmetic in Coq

Integers as lists of bits: polynomial equality, semi-decision of (Z, +, =, <). Rational numbers and Bernstein polynomials: global optimization for Hales’ inequalities. Dyadic numbers and intervals: verification of Gappa certificates. Integers as binary trees of machine words: verification of Pocklington primality certificates. Floating-point numbers and intervals: enclosures for expressions of elementary functions.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-43
SLIDE 43

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Some Formalizations of Arithmetic in Coq

Integers as lists of bits: polynomial equality, semi-decision of (Z, +, =, <). Rational numbers and Bernstein polynomials: global optimization for Hales’ inequalities. Dyadic numbers and intervals: verification of Gappa certificates. Integers as binary trees of machine words: verification of Pocklington primality certificates. Floating-point numbers and intervals: enclosures for expressions of elementary functions. Real numbers as streams of integer words.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-44
SLIDE 44

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Enclosures for Expressions of Elementary Functions

Example: ∀x ∈ [2−20, 1],

  • x × (1 − 10473 · 2−16 · x2)

sin x − 1

  • ≤ 102 · 2−16.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-45
SLIDE 45

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Enclosures for Expressions of Elementary Functions

Example: ∀x ∈ [2−20, 1],

  • x × (1 − 10473 · 2−16 · x2)

sin x − 1

  • ≤ 102 · 2−16.

Method: order-1 Taylor interval computations and bisection.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-46
SLIDE 46

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Interval Approaches: Relative Error of a Rounded Sine

Relative error between sin x and the binary32 Horner evaluation

  • f a degree-3 polynomial for x ∈ [2−20, 1]:

1

Theorem rounded_sine :

2

forall x y,

3

y = rnd(x * rnd(1 - rnd(rnd(x*x) * (10473/65536) ))) ->

4

1/1048576 <= x <= 1 ->

5

Rabs(y - sin x) <= 103 / 65536 * Rabs(sin x).

6

Proof.

7

intros.

8

set (My := x * (1 - (x*x) * (10473/65536) )).

9

assert (Rabs(My - sin x) <= 102 / 65536 * Rabs(sin x)).

10

(∗ method e r r o r ∗)

11

apply

  • helper. admit.

12

unfold My.

13

abstract interval with

14

( i_bisect_diff x, i_depth 40, i_nocheck).

15

unfold My in H1.

16

  • gappa. (∗

g l o b a l e r r o r ∗)

17

Qed.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-47
SLIDE 47

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Interval Approaches: Square Root

Fully computational approach: f ([u, u]) = ▽√u, △ √ u

  • if 0 ≤ u,

  • therwise.

Correctness lemma: ∀x ∈ [u, u], √x ∈ f ([u, u]).

Guillaume Melquiond Numerical Computations and Formal Methods

slide-48
SLIDE 48

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Interval Approaches: Square Root

Fully computational approach: f ([u, u]) = ▽√u, △ √ u

  • if 0 ≤ u,

  • therwise.

Correctness lemma: ∀x ∈ [u, u], √x ∈ f ([u, u]). Oracle-based approach: f ([u, u], [v, v]) = 0 ≤ v ∧ u ≤ v2 ∧ 0 ≤ u if v ≤ 0 v2 ≤ u

  • therwise.

Correctness lemma: ∀x ∈ [u, u], f ([u, u], [v, v]) = true ⇒ √x ∈ [v, v].

Guillaume Melquiond Numerical Computations and Formal Methods

slide-49
SLIDE 49

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Computing with (Approximate) Reals: Issues

Decidability?

Guillaume Melquiond Numerical Computations and Formal Methods

slide-50
SLIDE 50

Program verification Formal arithmetic Decision procedures Reflection Formalizations

Computing with (Approximate) Reals: Issues

Decidability? Semi-decidability?

Guillaume Melquiond Numerical Computations and Formal Methods

slide-51
SLIDE 51

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Decision Procedures for Arithmetic Theories

1

Deductive program verification

2

Computing in a formal system

3

Decision procedures for arithmetic theories Quantifier elimination Theory (C, +, ×, =) Theory (Q, +, =, <) ∀-formulas, ideals, and cones

4

Conclusion

Guillaume Melquiond Numerical Computations and Formal Methods

slide-52
SLIDE 52

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Quantifier Elimination

Definition (Quantifier elimination)

A theory T in a first-order language L admits QE if, for any formula p ∈ L, there is a quantifier-free formula q ∈ L such that T | = p ⇔ q and q has no other free variables than p. Sufficient condition: any formula “∃x, α1 ∧ · · · ∧ αn” admits QE.

Property

A formula is decidable in a theory QE if it has no free variables.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-53
SLIDE 53

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Quantifier Elimination

Definition (Quantifier elimination)

A theory T in a first-order language L admits QE if, for any formula p ∈ L, there is a quantifier-free formula q ∈ L such that T | = p ⇔ q and q has no other free variables than p. Sufficient condition: any formula “∃x, α1 ∧ · · · ∧ αn” admits QE.

Property

A formula is decidable in a theory QE if it has no free variables. Example on N: ∀x, 1 ≤ x ⇒ ∃y, y < x. ¬(∃x, 1 ≤ x ∧ ¬(∃y, y < x)) ¬(∃x, 1 ≤ x ∧ ¬(0 < x)) ¬(1 ≤ 0)

Guillaume Melquiond Numerical Computations and Formal Methods

slide-54
SLIDE 54

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Arithmetic Theories and Quantifier Elimination

Decidable theories: (C, +, ×, =) Tarski

Guillaume Melquiond Numerical Computations and Formal Methods

slide-55
SLIDE 55

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Arithmetic Theories and Quantifier Elimination

Decidable theories: (C, +, ×, =) Tarski (R, +, ×, =, <) Collins, H¨

  • rmander

Guillaume Melquiond Numerical Computations and Formal Methods

slide-56
SLIDE 56

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Arithmetic Theories and Quantifier Elimination

Decidable theories: (C, +, ×, =) Tarski (R, +, ×, =, <) Collins, H¨

  • rmander

(Q, +, =, <) Fourier, Motzkin

Guillaume Melquiond Numerical Computations and Formal Methods

slide-57
SLIDE 57

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Arithmetic Theories and Quantifier Elimination

Decidable theories: (C, +, ×, =) Tarski (R, +, ×, =, <) Collins, H¨

  • rmander

(Q, +, =, <) Fourier, Motzkin (Z, +, =, <) Presburger, Cooper

Guillaume Melquiond Numerical Computations and Formal Methods

slide-58
SLIDE 58

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Arithmetic Theories and Quantifier Elimination

Decidable theories: (C, +, ×, =) Tarski (R, +, ×, =, <) Collins, H¨

  • rmander

(Q, +, =, <) Fourier, Motzkin (Z, +, =, <) Presburger, Cooper (Q, +, ⌊·⌋, =, <) Weispfenning

Guillaume Melquiond Numerical Computations and Formal Methods

slide-59
SLIDE 59

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Arithmetic Theories and Quantifier Elimination

Decidable theories: (C, +, ×, =) Tarski (R, +, ×, =, <) Collins, H¨

  • rmander

(Q, +, =, <) Fourier, Motzkin (Z, +, =, <) Presburger, Cooper (Q, +, ⌊·⌋, =, <) Weispfenning Undecidable theory: (Z, +, ×, =, <) Tarski, G¨

  • del

Guillaume Melquiond Numerical Computations and Formal Methods

slide-60
SLIDE 60

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Theory (C, +, ×, =)

Given ∃x, p1(x) = 0 ∧ · · · ∧ pm(x) = 0 ∧ q1(x) = 0 ∧ · · · ∧ qn(x) = 0.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-61
SLIDE 61

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Theory (C, +, ×, =)

Given ∃x, p1(x) = 0 ∧ · · · ∧ pm(x) = 0 ∧ q1(x) = 0 ∧ · · · ∧ qn(x) = 0.

1 Reducing to ∃x, P(x) = 0 ∧ Q(x) = 0:

q1(x) = 0 ∧ · · · ∧ qn(x) = 0 ⇔ q1(x) × · · · × qn(x) = 0.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-62
SLIDE 62

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Theory (C, +, ×, =)

Given ∃x, p1(x) = 0 ∧ · · · ∧ pm(x) = 0 ∧ q1(x) = 0 ∧ · · · ∧ qn(x) = 0.

1 Reducing to ∃x, P(x) = 0 ∧ Q(x) = 0:

q1(x) = 0 ∧ · · · ∧ qn(x) = 0 ⇔ q1(x) × · · · × qn(x) = 0. ck × pi(x) = pj(x) × q(x) + r(x), so pi(x) = 0 ∧ pj(x) = 0 ⇔ r(x) = 0 ∧ pj(x) = 0 if c = 0 pi(x) = 0 ∧ p∗

j (x) = 0

if c = 0

Guillaume Melquiond Numerical Computations and Formal Methods

slide-63
SLIDE 63

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Theory (C, +, ×, =)

Given ∃x, p1(x) = 0 ∧ · · · ∧ pm(x) = 0 ∧ q1(x) = 0 ∧ · · · ∧ qn(x) = 0.

1 Reducing to ∃x, P(x) = 0 ∧ Q(x) = 0:

q1(x) = 0 ∧ · · · ∧ qn(x) = 0 ⇔ q1(x) × · · · × qn(x) = 0. ck × pi(x) = pj(x) × q(x) + r(x), so pi(x) = 0 ∧ pj(x) = 0 ⇔ r(x) = 0 ∧ pj(x) = 0 if c = 0 pi(x) = 0 ∧ p∗

j (x) = 0

if c = 0

2 Cases:

(∃x, Q(x) = 0) ⇔ ¬(coefs of Q are zero). (∃x, P(x) = 0) ⇔ ¬(. . .)

Guillaume Melquiond Numerical Computations and Formal Methods

slide-64
SLIDE 64

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Theory (C, +, ×, =)

Given ∃x, p1(x) = 0 ∧ · · · ∧ pm(x) = 0 ∧ q1(x) = 0 ∧ · · · ∧ qn(x) = 0.

1 Reducing to ∃x, P(x) = 0 ∧ Q(x) = 0:

q1(x) = 0 ∧ · · · ∧ qn(x) = 0 ⇔ q1(x) × · · · × qn(x) = 0. ck × pi(x) = pj(x) × q(x) + r(x), so pi(x) = 0 ∧ pj(x) = 0 ⇔ r(x) = 0 ∧ pj(x) = 0 if c = 0 pi(x) = 0 ∧ p∗

j (x) = 0

if c = 0

2 Cases:

(∃x, Q(x) = 0) ⇔ ¬(coefs of Q are zero). (∃x, P(x) = 0) ⇔ ¬(. . .) (∃x, P(x) = 0 ⇒ Q(x) = 0) ⇔ ¬(P|xQn).

Guillaume Melquiond Numerical Computations and Formal Methods

slide-65
SLIDE 65

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Theory (Q, +, =, <)

Quantifier elimination of linear constraints: (∃x, x = a · y ∧ P[x, y]) ⇔ P[ a · y, y].

Guillaume Melquiond Numerical Computations and Formal Methods

slide-66
SLIDE 66

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Theory (Q, +, =, <)

Quantifier elimination of linear constraints: (∃x, x = a · y ∧ P[x, y]) ⇔ P[ a · y, y]. (∃x,

i x <

ai · y ∧

j x >

bj · y) ⇔

i,j 0 < (

ai − bj) · y.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-67
SLIDE 67

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

Theory (Q, +, =, <)

Quantifier elimination of linear constraints: (∃x, x = a · y ∧ P[x, y]) ⇔ P[ a · y, y]. (∃x,

i x <

ai · y ∧

j x >

bj · y) ⇔

i,j 0 < (

ai − bj) · y. Special case: closed ∃-formulas of conjunctions. Methods: simplex, interior point.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-68
SLIDE 68

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

∀-Formulas, Ideals, and Cones

On C: ∀ x,

i pi(

x) = 0 ∨

j qj(

x) = 0. (F)

Guillaume Melquiond Numerical Computations and Formal Methods

slide-69
SLIDE 69

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

∀-Formulas, Ideals, and Cones

On C: ∀ x,

i pi(

x) = 0 ∨

j qj(

x) = 0. (F) F ⇔ ∀ x z, ¬

  • i pi(

x) = 0 ∧

j zj × qj(

x) − 1 = 0

  • Guillaume Melquiond

Numerical Computations and Formal Methods

slide-70
SLIDE 70

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

∀-Formulas, Ideals, and Cones

On C: ∀ x,

i pi(

x) = 0 ∨

j qj(

x) = 0. (F) F ⇔ ∀ x z, ¬

  • i pi(

x) = 0 ∧

j zj × qj(

x) − 1 = 0

  • ⇔ 1 ∈ Ideal(· · · , pi, · · · , zj × qj − 1, · · · ).

Guillaume Melquiond Numerical Computations and Formal Methods

slide-71
SLIDE 71

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

∀-Formulas, Ideals, and Cones

On C: ∀ x,

i pi(

x) = 0 ∨

j qj(

x) = 0. (F) F ⇔ ∀ x z, ¬

  • i pi(

x) = 0 ∧

j zj × qj(

x) − 1 = 0

  • ⇔ 1 ∈ Ideal(· · · , pi, · · · , zj × qj − 1, · · · ).

On R: ∀ x, ¬

  • i pi(

x) = 0 ∧

j qj(

x) ≥ 0

  • .

(F)

Guillaume Melquiond Numerical Computations and Formal Methods

slide-72
SLIDE 72

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

∀-Formulas, Ideals, and Cones

On C: ∀ x,

i pi(

x) = 0 ∨

j qj(

x) = 0. (F) F ⇔ ∀ x z, ¬

  • i pi(

x) = 0 ∧

j zj × qj(

x) − 1 = 0

  • ⇔ 1 ∈ Ideal(· · · , pi, · · · , zj × qj − 1, · · · ).

On R: ∀ x, ¬

  • i pi(

x) = 0 ∧

j qj(

x) ≥ 0

  • .

(F) F ⇔ −1 ∈ Ideal(p1, · · · , pm) + Cone(q1, · · · , qn).

Guillaume Melquiond Numerical Computations and Formal Methods

slide-73
SLIDE 73

Program verification Formal arithmetic Decision procedures Quantifier elimination C Q Ideals

∀-Formulas, Ideals, and Cones

On C: ∀ x,

i pi(

x) = 0 ∨

j qj(

x) = 0. (F) F ⇔ ∀ x z, ¬

  • i pi(

x) = 0 ∧

j zj × qj(

x) − 1 = 0

  • ⇔ 1 ∈ Ideal(· · · , pi, · · · , zj × qj − 1, · · · ).

On R: ∀ x, ¬

  • i pi(

x) = 0 ∧

j qj(

x) ≥ 0

  • .

(F) F ⇔ −1 ∈ Ideal(p1, · · · , pm) + Cone(q1, · · · , qn). Methods: Gr¨

  • bner bases, semi-definite programming, . . .

Suitable for oracles: verifying ideal membership (⇐) is just a single polynomial equality.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-74
SLIDE 74

Program verification Formal arithmetic Decision procedures

Conclusion

Deductive verification allows to certify arbitrary programs. But proof obligations lack structure, making it difficult for automated provers.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-75
SLIDE 75

Program verification Formal arithmetic Decision procedures

Conclusion

Deductive verification allows to certify arbitrary programs. But proof obligations lack structure, making it difficult for automated provers. Numerical computations are not incompatible with formal systems. They can be used to prove mathematical theorems.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-76
SLIDE 76

Program verification Formal arithmetic Decision procedures

Conclusion

Deductive verification allows to certify arbitrary programs. But proof obligations lack structure, making it difficult for automated provers. Numerical computations are not incompatible with formal systems. They can be used to prove mathematical theorems. There are powerful but slow methods for proving some large sets of proof obligations. Oracle-based approaches can dramatically increase performances on specific subsets.

Guillaume Melquiond Numerical Computations and Formal Methods

slide-77
SLIDE 77

Program verification Formal arithmetic Decision procedures

Questions?

Guillaume Melquiond Numerical Computations and Formal Methods