29
Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay – ˆ Ile-de-France LIX ´ Ecole Polytechnique INRIA Microsoft Research Joint Centre [email protected] 18 octobre 2010 This work has been partially funded by the FORMATH project, nr. 243847, of the FET program within the 7th Framework program of the European Commission. Cyril Cohen Formalized foundations of polynomial real analysis

Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Formalized foundations of polynomial real analysis

Cyril Cohen

INRIA Saclay – Ile-de-FranceLIX Ecole Polytechnique

INRIA Microsoft Research Joint [email protected]

18 octobre 2010

This work has been partially funded by the FORMATH project, nr. 243847, ofthe FET program within the 7th Framework program of the European

Commission.

Cyril Cohen Formalized foundations of polynomial real analysis

Page 2: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Purpose of this formalization

Formalize real polynomial analysis in the SSReflect extension ofthe Coq proof assistant.SSReflect provides a lot of tools and uses a lot of specificprogramming techniques in the domain of finite groups andcombinatorics.Reuse theses techniques to handle more � continuous � theories.

Cyril Cohen Formalized foundations of polynomial real analysis

Page 3: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Real Closed Fields

Algebraic structure of reals : Real Closed Fields (RCF)Field + Ordered + Intermediate value theorem for polynomials

x

y

a

f (a)

b

f (b)

c

f (c) = 0

Cyril Cohen Formalized foundations of polynomial real analysis

Page 4: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Decidable Equality

In SSReflect, structures have decidable equality.We can define this (implicit) coercion in Coq

Coercion is_true (b : bool) : Prop := (b = true).

SSReflect

uses intensively this coercion

has facilities to go from one point of view to the other(bool-Prop reflection).

We then see boolean equality as propositional equality, for free.

Cyril Cohen Formalized foundations of polynomial real analysis

Page 5: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

What do we need ?

⇒ Make case analysis on x ≤ y

⇒ Combine statements (using transitivity with both ≤ <,compatibility with operations, etc ..)

⇒ Speak about signs and absolute value

⇒ Use max and min

Cyril Cohen Formalized foundations of polynomial real analysis

Page 6: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Taking advantage of the boolean predicate

Making le a boolean predicate.

Like before, consider this boolean predicate as propositionthrough the coercion is_true

⇒ Use equalities to rewrite expressions with order

(x+z <= y+z)= (x <= y)

(sign x == 1)= (0 < x)

. . .

⇒ Use if x <= y then ... else ... in programs

Cyril Cohen Formalized foundations of polynomial real analysis

Page 7: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Taking advantage of the boolean predicate

Making le a boolean predicate.

Like before, consider this boolean predicate as propositionthrough the coercion is_true

⇒ Use equalities to rewrite expressions with order

(x+z <= y+z)= (x <= y)

(sign x == 1)= (0 < x)

. . .

⇒ Use if x <= y then ... else ... in programs

Cyril Cohen Formalized foundations of polynomial real analysis

Page 8: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Tools

Multiple lemmas about transitivity and compatibility betweenle, lt and field operations

⇒ Need for good naming conventions.

Cyril Cohen Formalized foundations of polynomial real analysis

Page 9: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Strict comparison

We’ll define the strict order lt from the large one le by :

Definition lt x y := ~~ (le y x).

and prove its properties.

Cyril Cohen Formalized foundations of polynomial real analysis

Page 10: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Ordered ring mixin

Record mixin_of (R : ringType) := Mixin {

le : rel R;

_ : antisymmetric le;

_ : transitive le;

_ : total le;

_ : forall z x y, le x y -> le (x + z) (y + z);

_ : forall x y, le 0 x -> le 0 y -> le 0 (x * y)

}.

Cyril Cohen Formalized foundations of polynomial real analysis

Page 11: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Integration in existing SSReflect algebraic hierarchy

Field

IntegralDomain

ComUnitRing

ComRingUnitRing

Ring

Cyril Cohen Formalized foundations of polynomial real analysis

Page 12: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Integration in existing SSReflect algebraic hierarchy

Field

IntegralDomain

ComUnitRing

ComRingUnitRing

Ring

OrderedHierarchy

Cyril Cohen Formalized foundations of polynomial real analysis

Page 13: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Integration in existing SSReflect algebraic hierarchy

Field

IntegralDomain

ComUnitRing

ComRingUnitRing

Ring

OrderedIntegralDomain

OrderedField

Cyril Cohen Formalized foundations of polynomial real analysis

Page 14: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Rolle Theorem for polynomials

A first hint that RCF is a good abstraction of reals :We are able to prove :

Lemma rolle : forall (a b : R) (p : {poly R}),

a < b -> p.[a] = 0 -> p.[b] = 0 ->

exists c, a < c < b /\ p^‘().[c] == 0.

x

y

a

f (a) = 0

b

f (b) = 0

c

f ′(c) = 0

Cyril Cohen Formalized foundations of polynomial real analysis

Page 15: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Sketch of the constructive proof

Lemma rolle_weak : forall (a b : R) (p : {poly R}),

a < b -> p.[a] = 0 -> p.[b] = 0 ->

exists c , a < c < b

/\ (p^‘().[c] = 0 \/ p.[c] = 0).

And conclude rolle from it by iterating rolle_weak. Itterminates because P has less than deg(P) roots.

Cyril Cohen Formalized foundations of polynomial real analysis

Page 16: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

What else can we do with IVT ?

Particularly useful examples

Rolle Theorem

Mean Value Theorem

Write a function that computes the real roots of anypolynomial

Prove that given a polynomial P, and a root x of P, one canfind a neighborhood of x on which P has no root except x .

. . .

Cyril Cohen Formalized foundations of polynomial real analysis

Page 17: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Isolation of roots

x

y

Cyril Cohen Formalized foundations of polynomial real analysis

Page 18: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Towards quantifier elimination

First step of Quantifier Elimination in RCF.Which entails decidability of the theory of RCF.

Let’s pick one concept from it : Cauchy Index (proof almost done).

Cyril Cohen Formalized foundations of polynomial real analysis

Page 19: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Definition of the Cauchy Index

CInd(P

Q, ]a, b[) =

number of positive jumps− number of negative jumps

-30

-20

-10

0

10

20

30

-4 -2 0 2 4

p(x)/q(x)

−1

0

+1

Cyril Cohen Formalized foundations of polynomial real analysis

Page 20: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Useful property of Cauchy Index

PropertyIf P(a),P(b),Q(a),Q(b) 6= 0 then,

CInd

(P

Q, ]a, b[

)+ CInd

(Q

P, ]a, b[

)=

{sign (PQ(b)) if PQ(a)PQ(b) < 0

0 else

Cyril Cohen Formalized foundations of polynomial real analysis

Page 21: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Idea of the proof : combinatorics

-30

-20

-10

0

10

20

30

-4 -2 0 2 4

p(x)/q(x)q(x)/p(x)

−1 0+1

Cyril Cohen Formalized foundations of polynomial real analysis

Page 22: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Idea of the proof : combinatorics

-30

-20

-10

0

10

20

30

-4 -2 0 2 4

p(x)/q(x)q(x)/p(x)

+1−1 0

+1−1

+1

Cyril Cohen Formalized foundations of polynomial real analysis

Page 23: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Idea of the proof : combinatorics

-30

-20

-10

0

10

20

30

-4 -2 0 2 4

p(x)/q(x)q(x)/p(x)

+1−1 0

+1−1

+1

Cyril Cohen Formalized foundations of polynomial real analysis

Page 24: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Idea of the proof : combinatorics

-30

-20

-10

0

10

20

30

-4 -2 0 2 4

p(x)/q(x)q(x)/p(x)

+1−1 0

+1−1

+1

Jumps in the list of signs of PQ. [-1;1;-1;-1;1;-1;1]

Cyril Cohen Formalized foundations of polynomial real analysis

Page 25: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Trick of the proof

The sum of jumps of a list l = x0, . . . , xn ∈ {−1, 1}∗ verifies auseful property : it’s the jump between x0 and xn.i.e. {

sign(xn) if x0xn < 0

0 else

Cyril Cohen Formalized foundations of polynomial real analysis

Page 26: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Idea of the proof : combinatorics

-30

-20

-10

0

10

20

30

-4 -2 0 2 4

p(x)/q(x)q(x)/p(x)

+1−1 0

+1−1

+1

Jumps in the list of signs of PQ. [-1;1;-1;-1;1;-1;1]Jump between the first sign -1 and the last one 1, i.e.{

sign (PQ(b)) if PQ(a)PQ(b) < 0

0 else

Cyril Cohen Formalized foundations of polynomial real analysis

Page 27: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

Conclusion

A library which provides usable tools.It is used in works in progress on

Quantifier elimination in RCF

Formalisation of Bernstein Polynomials

Cyril Cohen Formalized foundations of polynomial real analysis

Page 28: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

What next ?

Instantiate the Real Closed Fields Structure

Prove some reflexive tactics using it

... to provide a little more automation

Generalize notion of continuity in this context

Extend to further real analysis

Cyril Cohen Formalized foundations of polynomial real analysis

Page 29: Formalized foundations of polynomial real analysisperso.crans.org/~cohen/papers/slides_types2010.pdf · Formalized foundations of polynomial real analysis Cyril Cohen INRIA Saclay

The End

Thank you for your attention. Any questions ?

Cyril Cohen Formalized foundations of polynomial real analysis