A New Formalization of Power Series in Coq Catherine Lelay Toccata, - - PowerPoint PPT Presentation

a new formalization of power series in coq
SMART_READER_LITE
LIVE PREVIEW

A New Formalization of Power Series in Coq Catherine Lelay Toccata, - - PowerPoint PPT Presentation

Introduction Power Series Conclusion A New Formalization of Power Series in Coq Catherine Lelay Toccata, Inria Saclay le-de-France LRI, Universit Paris-Sud 5th Coq Workshop Rennes, July 22nd 1 / 21 Introduction Power Series


slide-1
SLIDE 1

Introduction Power Series Conclusion

A New Formalization of Power Series in Coq

Catherine Lelay

Toccata, Inria Saclay – Île-de-France LRI, Université Paris-Sud

5th Coq Workshop Rennes, July 22nd

1 / 21

slide-2
SLIDE 2

Introduction Power Series Conclusion

The Coquelicot project

Goal :

build a user-friendly library of real analysis in Coq.

2 / 21

slide-3
SLIDE 3

Introduction Power Series Conclusion

The Coquelicot project

Goal :

build a user-friendly library of real analysis in Coq.

Previous work [CPP’ 2012] :

total functions to easily write limits, derivatives and integrals, tactic to automatize proofs of differentiability.

2 / 21

slide-4
SLIDE 4

Introduction Power Series Conclusion

A few words about limits of sequences

Definition of limit in the style of the standard library:

Definition Lim_seq (un)n∈N (pr : {l : R | Un_cv(un)n∈Nl}) := projT1 pr.lim (un) + lim (un)

2 ∈ R total function with dependent type

3 / 21

slide-5
SLIDE 5

Introduction Power Series Conclusion

A few words about limits of sequences

Definition of limit in the style of the standard library:

Definition Lim_seq (un)n∈N :=

lim (un) + lim (un) 2 ∈ R total function without dependent type

3 / 21

slide-6
SLIDE 6

Introduction Power Series Conclusion

A few words about limits of sequences

Definition of limit in the style of the standard library:

Definition Lim_seq (un)n∈N :=

lim (un) + lim (un) 2 ∈ R total function without dependent type Some other user-friendly definitions:

Lim

t→x f (t) := Lim_seq (f (xn))n∈N ∈ R when lim (xn)n∈N = x

Derive f (x : R) := Lim

h→0

f (x + h) − f (x) h

  • ∈ R

RInt f (a b : R) := Lim_seq

  • b − a

n

n

  • k=0

f (xk)

  • n∈N

∈ R

3 / 21

slide-7
SLIDE 7

Introduction Power Series Conclusion

Some applications

D’Alembert Formula [CPP’ 2012] u(x, t) = 1

2 [u0(x + ct) + u0(x − ct)] + 1 2c

x+ct

x−ct u1(ξ) dξ

+ 1

2c

t x+c(t−τ)

x−c(t−τ) f (ξ, τ) dξ dτ ∂2u ∂t2 (x, t) − c ∂2u ∂x2 (x, t) = f (x, t)

Convergence of a sequence based on algebraic-geometric means [Bertot 2013] a0 = 1, b0 = 1

x , an+1 = an+bn 2

, bn+1 = √anbn and f (x) = lim an = lim bn ⇒ π = 2 √ 2 f

  • 1

√ 2

  • f ′

1 √ 2

  • Baccalaureate of Mathematics 2013 [BAC 2013]

1

1 e

2 + 2 ln x x dx = 1

4 / 21

slide-8
SLIDE 8

Introduction Power Series Conclusion

Motivations to build power series

Some of the many uses of power series: basic functions (ex, sin, cos, . . . ), solutions for differential equations, equivalent functions, generating functions, . . . ⇒ must be formalized in a library of real analysis.

5 / 21

slide-9
SLIDE 9

Introduction Power Series Conclusion

Coq standard library

about sequences

two different definitions for limits toward finite limit and +∞ limits of sums, opposites, products, and multiplicative inverses

  • f sequences in the finite case

about power series

series of real numbers provide convergence criteria sequences of functions provide continuity and differentiability

6 / 21

slide-10
SLIDE 10

Introduction Power Series Conclusion

Coq standard library

about sequences

two different definitions for limits toward finite limit and +∞ limits of sums, opposites, products, and multiplicative inverses

  • f sequences in the finite case

about power series

series of real numbers provide convergence criteria sequences of functions provide continuity and differentiability

not in the standard library:

single definition for both finite and infinite limits (±∞) limits of sums, opposites, products, and multiplicative inverses

  • f sequences in the infinite case

arithmetic operations on power series integrability of power series

6 / 21

slide-11
SLIDE 11

Introduction Power Series Conclusion

Coq standard library

about sequences

two different definitions for limits toward finite limit and +∞ limits of sums, opposites, products, and multiplicative inverses

  • f sequences in the finite case

about power series

series of real numbers provide convergence criteria sequences of functions provide continuity and differentiability

in the Coquelicot library:

single definition for both finite and infinite limits (±∞) limits of sums, opposites, products, and multiplicative inverses

  • f sequences in the infinite case

arithmetic operations on power series integrability of power series

6 / 21

slide-12
SLIDE 12

Introduction Power Series Conclusion

Coquelicot library – CPP version

standard library - Reals sup (un)n∈N lim (un)n∈N lim

t→x f (t)

f ′(x)

  • n∈N

an

  • n∈N

anxn b

a

f (t) dt ∈ R = R ∪ {±∞} ∈ R ∈ R = R ∪ {±∞}

7 / 21

slide-13
SLIDE 13

Introduction Power Series Conclusion

Coquelicot library – present version

standard library - Reals sup (un)n∈N lim (un)n∈N lim

t→x f (t)

f ′(x)

  • n∈N

an

  • n∈N

anxn b

a

f (t) dt ∈ R = R ∪ {±∞} ∈ R ∈ R = R ∪ {±∞}

  • n∈N

an

  • n∈N

anxn

7 / 21

slide-14
SLIDE 14

Introduction Power Series Conclusion

Definition

Series:

Series (an)n∈N = Lim_seq

n

  • k=0

ak

  • n∈N

Power series:

PSeries (an)n∈N = Series

  • akxk

n∈N

8 / 21

slide-15
SLIDE 15

Introduction Power Series Conclusion

Definition

Series:

Series (an)n∈N = Lim_seq

n

  • k=0

ak

  • n∈N

Power series:

PSeries (an)n∈N = Series

  • akxk

n∈N

inherit all the good properties of Lim_seq easy to write some rewritings without hypothesis

8 / 21

slide-16
SLIDE 16

Introduction Power Series Conclusion

Use-case: Bessel Functions

Jn = x 2 n +∞

  • p=0

(−1)p p!(n + p)! x 2 2p

9 / 21

slide-17
SLIDE 17

Introduction Power Series Conclusion

Use-case: Bessel Functions

Jn = x 2 n +∞

  • p=0

(−1)p p!(n + p)! x 2 2p J′′

n(x) + x · J′ n(x) + (x2 − n2) · Jn(x) = 0

Jn+1(x) = n · Jn(x) x − J′

n(x)

Jn+1(x) − Jn−1(x) = 2n x Jn(x) Jn+1(x) − Jn−1(x) = −2 · J′

n(x)

9 / 21

slide-18
SLIDE 18

Introduction Power Series Conclusion

Use-case: Bessel Functions

Jn = x 2 n +∞

  • p=0

(−1)p p!(n + p)! x 2 2p J′′

n(x) + x · J′ n(x) + (x2 − n2) · Jn(x) = 0

Jn+1(x) = n · Jn(x) x − J′

n(x)

Jn+1(x) − Jn−1(x) = 2n x Jn(x) Jn+1(x) − Jn−1(x) = −2 · J′

n(x)

9 / 21

slide-19
SLIDE 19

Introduction Power Series Conclusion

Example: differential equation

with a(n)

p

= (−1)p p!(n + p)! and X = x 2 2 : J′′

n(x) + x · J′ n(x) + (x2 − n2)Jn(x) = 0

Needed operations on power series:

10 / 21

slide-20
SLIDE 20

Introduction Power Series Conclusion

Example: differential equation

with a(n)

p

= (−1)p p!(n + p)! and X = x 2 2 :

x 2 n +∞

  • p=0

a(n)

p X p

′′ + x · x 2 n +∞

  • p=0

a(n)

p X p

′ +

  • x2 − n2 x

2 n +∞

  • p=0

a(n)

p X p = 0

Needed operations on power series: function to write power series

10 / 21

slide-21
SLIDE 21

Introduction Power Series Conclusion

Example: differential equation

with a(n)

p

= (−1)p p!(n + p)! and X = x 2 2 : X  

+∞

  • p=0

a(n)

p X p

 

′′

+ (n + 1)  

+∞

  • p=0

a(n)

p X p

 

+

+∞

  • p=0

a(n)

p X p = 0

Needed operations on power series: function to write power series

10 / 21

slide-22
SLIDE 22

Introduction Power Series Conclusion

Example: differential equation

with a(n)

p

= (−1)p p!(n + p)! and X = x 2 2 :

X

+∞

  • p=0
  • (p + 1)(p + 2)a(n)

p+2X p

+ (n + 1)

+∞

  • p=0
  • (p + 1)a(n)

p+1X p

+

+∞

  • p=0

a(n)

p X p = 0

Needed operations on power series: function to write power series differentiability

10 / 21

slide-23
SLIDE 23

Introduction Power Series Conclusion

Example: differential equation

with a(n)

p

= (−1)p p!(n + p)! and X = x 2 2 :

+∞

  • p=0
  • p(p + 1)a(n)

p+1X p

+ (n + 1)

+∞

  • p=0
  • (p + 1)a(n)

p+1X p

+

+∞

  • p=0

a(n)

p X p = 0

Needed operations on power series: function to write power series differentiability variable multiplication

10 / 21

slide-24
SLIDE 24

Introduction Power Series Conclusion

Example: differential equation

with a(n)

p

= (−1)p p!(n + p)! and X = x 2 2 :

+∞

  • p=0
  • p(p + 1)a(n)

p+1 + (n + 1)(p + 1)a(n) p+1 + a(n) p

  • X p = 0

Needed operations on power series: function to write power series differentiability variable multiplication arithmetic operations

10 / 21

slide-25
SLIDE 25

Introduction Power Series Conclusion

Example: differential equation

with a(n)

p

= (−1)p p!(n + p)! and X = x 2 2 : ∀p ∈ N, p(p + 1)a(n)

p+1 + (n + 1)(p + 1)a(n) p+1 + a(n) p

= 0 Needed operations on power series: function to write power series differentiability variable multiplication arithmetic operations extensionality

10 / 21

slide-26
SLIDE 26

Introduction Power Series Conclusion

Example: differential equation

with a(n)

p

= (−1)p p!(n + p)! and X = x 2 2 : ∀p ∈ N, a(n)

p+1 =

−a(n)

p

(p + 1)(n + p + 1) Needed operations on power series: function to write power series differentiability variable multiplication arithmetic operations extensionality

10 / 21

slide-27
SLIDE 27

Introduction Power Series Conclusion

Unicity

X  

+∞

  • p=0

a(n)

p X p

 

′′

+ (n + 1)  

+∞

  • p=0

a(n)

p X p

 

+

+∞

  • p=0

a(n)

p X p = 0

∀p ∈ N, a(n)

p+1 =

−a(n)

p

(p + 1)(n + p + 1)

11 / 21

slide-28
SLIDE 28

Introduction Power Series Conclusion

Unicity

X  

+∞

  • p=0

a(n)

p X p

 

′′

+ (n + 1)  

+∞

  • p=0

a(n)

p X p

 

+

+∞

  • p=0

a(n)

p X p = 0

∀p ∈ N, a(n)

p+1 =

−a(n)

p

(p + 1)(n + p + 1)

11 / 21

slide-29
SLIDE 29

Introduction Power Series Conclusion

Operations on Series

scalar multiplication: c ·

  • n∈N

an =

  • n∈N

(c · an), without hypothesis. index shift: ∀k ∈ N∗,

k−1

  • n=0

an +

  • n∈N

an+k =

  • n∈N

an, if an are convergent or ∀n < k, an = 0.

12 / 21

slide-30
SLIDE 30

Introduction Power Series Conclusion

Operations on Series

scalar multiplication: c ·

  • n∈N

an =

  • n∈N

(c · an), without hypothesis. index shift: ∀k ∈ N∗,

k−1

  • n=0

an +

  • n∈N

an+k =

  • n∈N

an, if an are convergent or ∀n < k, an = 0. addition:

  • n∈N

an +

  • n∈N

bn =

  • n∈N

(an + bn), if an and bn are convergent.

12 / 21

slide-31
SLIDE 31

Introduction Power Series Conclusion

Operations on Series

scalar multiplication: c ·

  • n∈N

an =

  • n∈N

(c · an), without hypothesis. index shift: ∀k ∈ N∗,

k−1

  • n=0

an +

  • n∈N

an+k =

  • n∈N

an, if an are convergent or ∀n < k, an = 0. addition:

  • n∈N

an +

  • n∈N

bn =

  • n∈N

(an + bn), if an and bn are convergent. multiplication:

  • n∈N

an ·

  • n∈N

bn =

  • n∈N

n

  • k=0

ak · bn−k

  • ,

if |an| and |bn| are convergent.

12 / 21

slide-32
SLIDE 32

Introduction Power Series Conclusion

Operations on Power Series

scalar multiplication: c ·

  • n∈N

anxn =

  • n∈N

(c · an) xn multiplication by a variable: ∀k ∈ N, xk ·

  • n∈N

anxn =

  • n∈N

an−kxn                  No hypothesis addition:

  • n∈N

anxn +

  • n∈N

bnxn =

  • n∈N

(an + bn) xn, if anxn and bnxn are convergent. multiplication:

  • n∈N

anxn ·

  • n∈N

bnxn =

  • n∈N

n

  • k=0

ak · bn−k

  • xn,

if |anxn| and |bnxn| are convergent.

13 / 21

slide-33
SLIDE 33

Introduction Power Series Conclusion

Some features related to power series

Convergence circle Differentiability Sequences of functions

14 / 21

slide-34
SLIDE 34

Introduction Power Series Conclusion

Convergence circle

Ca = sup

  • r ∈ R
  • |anrn| is convergent
  • ∈ R

15 / 21

slide-35
SLIDE 35

Introduction Power Series Conclusion

Convergence circle

Ca = sup

  • r ∈ R
  • |anrn| is convergent
  • ∈ R

Formally proved: Equality with sup {r ∈ R | |anrn| is bounded} Compatibility with operations (e.g.: Ca+b ≥ min {Ca, Cb})

15 / 21

slide-36
SLIDE 36

Introduction Power Series Conclusion

Convergence circle

Ca = sup

  • r ∈ R
  • |anrn| is convergent
  • ∈ R

Formally proved: Equality with sup {r ∈ R | |anrn| is bounded} Compatibility with operations (e.g.: Ca+b ≥ min {Ca, Cb}) If |x| < Ca, then anxn is absolutely convergent If |x| > Ca, then anxn is strongly divergent

15 / 21

slide-37
SLIDE 37

Introduction Power Series Conclusion

Differentiability

To write If |x| < Ca, then

  • n∈N

anxn ′ =

  • n∈N

(n + 1)an+1xn: using the Coq standard library:

Lemma Derive_PSeries (a : nat -> R) (cv_a : R) : forall (PS : forall x : R, Rabs x < cv_a -> {l : R | Pser a x l}) (PS’ : forall x : R, Rabs x < cv_a -> {l : R | Pser (fun n : nat => INR (S n) * a (S n)) x l}) (pr : forall x : R, Rabs x < cv_a -> derivable_pt (fun y : R => match Rlt_dec (Rabs y) cv_a with | left Hy => projT1 (PS y Hy) | right _ => 0 end) x) (x : R) (Hx : Rabs x < cv_a), derive_pt (fun y : R => match Rlt_dec (Rabs y) cv_a with | left Hy => projT1 (PS y Hy) | right _ => 0 end) x (pr x Hx) = projT1 (PS’ x Hx) 16 / 21

slide-38
SLIDE 38

Introduction Power Series Conclusion

Differentiability

To write If |x| < Ca, then

  • n∈N

anxn ′ =

  • n∈N

(n + 1)an+1xn: using the Coquelicot library:

Lemma Derive_PSeries (a : nat -> R) : forall x : R, Rbar_lt (Rabs x) (CV_circle a) -> Derive (PSeries a) x = PSeries (fun n : nat => INR (S n) * a (S n)) x.

16 / 21

slide-39
SLIDE 39

Introduction Power Series Conclusion

Differentiability

To write If |x| < Ca, then

  • n∈N

anxn (k) =

  • n∈N

(n + k)! n! an+kxn: using the Coquelicot library:

Lemma Derive_n_PSeries (k : nat) (a : nat -> R) : forall x : R, Rbar_lt (Rabs x) (CV_circle a) -> Derive_n (PSeries a) n x = PSeries (fun n : nat => (INR (fact (n + k)) / INR (fact n)) * a (n + k)) x.

16 / 21

slide-40
SLIDE 40

Introduction Power Series Conclusion

Sequences of function

Useful for: Power series anxn Fourier series an cos(nx) + bn sin(nx) ...

17 / 21

slide-41
SLIDE 41

Introduction Power Series Conclusion

Sequences of function

Useful for: Power series anxn Fourier series an cos(nx) + bn sin(nx) ... Formally proved: limits: ∀ (fn)n∈N a sequence of functions, D an open subset of R, if (fn)n∈N is uniformly convergent and ∀x ∈ D, ∀n ∈ N, limt→x f (t) exists, then ∀x ∈ D, lim

t→x

  • lim

n→+∞ (fn(t))

  • =

lim

n→+∞

  • lim

t→x fn(t)

  • 17 / 21
slide-42
SLIDE 42

Introduction Power Series Conclusion

Sequences of function

Useful for: Power series anxn Fourier series an cos(nx) + bn sin(nx) ... Formally proved: limits: ∀ (fn)n∈N a sequence of functions, D an open subset of R, if (fn)n∈N is uniformly convergent and ∀x ∈ D, ∀n ∈ N, limt→x f (t) exists, then ∀x ∈ D, lim

t→x

  • lim

n→+∞ (fn(t))

  • =

lim

n→+∞

  • lim

t→x fn(t)

  • continuity

differentiability

17 / 21

slide-43
SLIDE 43

Introduction Power Series Conclusion

Power series in other proof assistants

C-CoRN, HOL Light, Isabelle/HOL, PVS: two different notions of finite and infinite convergence circle series of real numbers provide

various convergence theorems

sequences of functions provide

differentiability integrability

18 / 21

slide-44
SLIDE 44

Introduction Power Series Conclusion

Power series in other proof assistants

C-CoRN, HOL Light, Isabelle/HOL, PVS: two different notions of finite and infinite convergence circle series of real numbers provide

various convergence theorems

sequences of functions provide

differentiability integrability

but results are not explicitly power series

18 / 21

slide-45
SLIDE 45

Introduction Power Series Conclusion

Conclusion

New power series for Coq: easy to use:    CJn = +∞ : 41 LoC Jn+1(x) + Jn−1(x) = 2n

x Jn(x)

: 35 LoC x2 · J′′

n(x) + x · J′ n(x) + (x2 − n2) · Jn(x) = 0 : 94 LoC

19 / 21

slide-46
SLIDE 46

Introduction Power Series Conclusion

Conclusion

New power series for Coq: easy to use:    CJn = +∞ : 41 LoC Jn+1(x) + Jn−1(x) = 2n

x Jn(x)

: 35 LoC x2 · J′′

n(x) + x · J′ n(x) + (x2 − n2) · Jn(x) = 0 : 94 LoC

with a proper notion of convergence circle

19 / 21

slide-47
SLIDE 47

Introduction Power Series Conclusion

Conclusion

New power series for Coq: easy to use:    CJn = +∞ : 41 LoC Jn+1(x) + Jn−1(x) = 2n

x Jn(x)

: 35 LoC x2 · J′′

n(x) + x · J′ n(x) + (x2 − n2) · Jn(x) = 0 : 94 LoC

with a proper notion of convergence circle

  • Nb. Definitions
  • Nb. Lemmas
  • Nb. Lines

Series 3 47 764 PSeries 13 70 1674 Available at : http://coquelicot.saclay.inria.fr/

19 / 21

slide-48
SLIDE 48

Introduction Power Series Conclusion

Perspectives

About Power Series:

Composition Quotient Automation

20 / 21

slide-49
SLIDE 49

Introduction Power Series Conclusion

Perspectives

About Power Series:

Composition Quotient Automation

About Real Analysis:

Left and right limits Equivalent functions Automation for limits, integrals and equivalents

20 / 21

slide-50
SLIDE 50

Introduction Power Series Conclusion

Perspectives

About Power Series:

Composition Quotient Automation

About Real Analysis:

Left and right limits Equivalent functions Automation for limits, integrals and equivalents

To go further: complex numbers

20 / 21

slide-51
SLIDE 51

Any questions?

Build a user-friendly library of real analysis in Coq. http://coquelicot.saclay.inria.fr/

slide-52
SLIDE 52

Bibliography

Sylvie Boldo and Catherine Lelay and Guillaume Melquiond Improving Real Analysis in Coq: a User-Friendly Approach to Integrals and Derivatives Proceedings of the Second International Conference on Certified Programs and Proofs, 289–304, 2012 Yves Bertot www-sop.inria.fr/members/Yves.Bertot/proofs.html Catherine Lelay www.lri.fr/∼lelay/

21 / 21

slide-53
SLIDE 53

Limits’ troubles

Definition Lim_seq (un)n∈N := lim (un) + lim (un)

2 ∈ R

Lim_seq (−1)n = 0 Lim_fct

x→0

x−1 = +∞ As on paper: can be written, but no meaning without proof of convergence

21 / 21

slide-54
SLIDE 54

Left and right limits

Actual alternative on left and right limits: lim

x→0+ x−1 = Lim_fct x→0

|x|−1 and lim

x→0+ x−1 = Lim_fct x→0

(− |x|)−1

21 / 21