Automating Asymptotics in a Theorem Prover
Manuel Eberl
Technical University of Munich Formal Methods in Mathematics 6 January 2020
1 / 31
Automating Asymptotics in a Theorem Prover Manuel Eberl Technical - - PowerPoint PPT Presentation
Automating Asymptotics in a Theorem Prover Manuel Eberl Technical University of Munich Formal Methods in Mathematics 6 January 2020 1 / 31 My Christmas Project I found some lovely 5-pages of lecture notes on Transcendental Number Theory by
Manuel Eberl
Technical University of Munich Formal Methods in Mathematics 6 January 2020
1 / 31
I found some lovely 5-pages of lecture notes on Transcendental Number Theory by Filaseta:
2 / 31
So I decided to formalise them:
3 / 31
Mathematical proofs in a proof assistant (compared to pen-and-paper)
4 / 31
Mathematical proofs in a proof assistant (compared to pen-and-paper)
4 / 31
Mathematical proofs in a proof assistant (compared to pen-and-paper)
4 / 31
Mathematical proofs in a proof assistant (compared to pen-and-paper)
4 / 31
Mathematical proofs in a proof assistant (compared to pen-and-paper)
There are many reasons for this.
4 / 31
Mathematical proofs in a proof assistant (compared to pen-and-paper)
There are many reasons for this. But I want to talk about one in particular.
4 / 31
5 / 31
In a proof assistant, you have to define everything completely rigorously.
5 / 31
In a proof assistant, you have to define everything completely rigorously.
5 / 31
In a proof assistant, you have to define everything completely rigorously.
A proof assistant will force you to prove every single side condition.
5 / 31
In a proof assistant, you have to define everything completely rigorously.
A proof assistant will force you to prove every single side condition.
5 / 31
In a proof assistant, you have to define everything completely rigorously.
A proof assistant will force you to prove every single side condition.
Most mathematical results have not been formalised
5 / 31
In a proof assistant, you have to define everything completely rigorously.
A proof assistant will force you to prove every single side condition.
Most mathematical results have not been formalised And even if: perhaps not in the system you use.
5 / 31
Solution: No idea. :(
6 / 31
Solution: No idea. :( Partial solutions:
6 / 31
Solution: No idea. :( Partial solutions: (in my opinion)
6 / 31
Solution: No idea. :( Partial solutions: (in my opinion)
6 / 31
Solution: No idea. :( Partial solutions: (in my opinion)
6 / 31
Solution: No idea. :( Partial solutions: (in my opinion)
When writing a formal proof, we can externalise work to the reader as well.
6 / 31
Solution: No idea. :( Partial solutions: (in my opinion)
When writing a formal proof, we can externalise work to the reader as well. The reader is the proof assistant.
6 / 31
Human mathematicians have a large repertoire of domain-specific automation procedures in their brain:
7 / 31
Human mathematicians have a large repertoire of domain-specific automation procedures in their brain:
7 / 31
Human mathematicians have a large repertoire of domain-specific automation procedures in their brain:
7 / 31
Human mathematicians have a large repertoire of domain-specific automation procedures in their brain:
This saves lots of time when writing mathematical papers.
7 / 31
Human mathematicians have a large repertoire of domain-specific automation procedures in their brain:
This saves lots of time when writing mathematical papers. For effective formalisation of mathematics, we need to teach proof assistants these skills.
7 / 31
8 / 31
8 / 31
8 / 31
16 = 4 etc.
8 / 31
16 = 4 etc.
8 / 31
16 = 4 etc.
8 / 31
16 = 4 etc.
8 / 31
9 / 31
10 / 31
10 / 31
10 / 31
Large collection of Isabelle proof developments
10 / 31
Let’s talk about asymptotics in a proof assistant.
11 / 31
Let’s talk about asymptotics in a proof assistant. Suppose you write a formal proof and sudenly have to prove lim
x→∞ x2 − x = ∞ .
11 / 31
Let’s talk about asymptotics in a proof assistant. Suppose you write a formal proof and sudenly have to prove lim
x→∞ x2 − x = ∞ .
Any ‘real’ mathematician would rightly dismiss this as trivial.
11 / 31
Let’s talk about asymptotics in a proof assistant. Suppose you write a formal proof and sudenly have to prove lim
x→∞ x2 − x = ∞ .
Any ‘real’ mathematician would rightly dismiss this as trivial. But in a theorem prover, even something this trivial requires some thinking and several lines of proofs
11 / 31
Let’s talk about asymptotics in a proof assistant. Suppose you write a formal proof and sudenly have to prove lim
x→∞ x2 − x = ∞ .
Any ‘real’ mathematician would rightly dismiss this as trivial. But in a theorem prover, even something this trivial requires some thinking and several lines of proofs If you have to do this every 5 minutes, it gets annoying.
11 / 31
γn =
∞
k=1
lnn k k
n + 1
γn =
∞
k=1
lnn k k
n + 1
12 / 31
γn =
∞
k=1
lnn k k
n + 1
Because the summand is ∼ (k−2 lnn k) ∈ O(k−3/2)
12 / 31
γn =
∞
k=1
lnn k k
n + 1
Because the summand is ∼ (k−2 lnn k) ∈ O(k−3/2) and ∑ kx is summable for any x < −1!
12 / 31
γn =
∞
k=1
lnn k k
n + 1
Because the summand is ∼ (k−2 lnn k) ∈ O(k−3/2) and ∑ kx is summable for any x < −1! But proving those asymptotics by hand is a lot of work.
12 / 31
lim
x→∞
1 b log1+ε x p 1 + 1 logε/2 bx +
x log1+ε x
−
1 logε/2 x
13 / 31
lim
x→∞
1 b log1+ε x p 1 + 1 logε/2 bx +
x log1+ε x
−
1 logε/2 x
Original author: ‘Trivial, just Taylor-expand it!’
13 / 31
In Isabelle: lemma akra_bazzi_aux: filterlim
14 / 31
In Isabelle: lemma akra_bazzi_aux: filterlim
Omitted: 700 lines of messy proofs
14 / 31
In Isabelle: lemma akra_bazzi_aux: filterlim
Omitted: 700 lines of messy proofs Luckily, we now have automation for this: by real_asymp
14 / 31
In Isabelle: lemma akra_bazzi_aux: filterlim
Omitted: 700 lines of messy proofs Luckily, we now have automation for this: by real_asymp How does it work?
14 / 31
15 / 31
Disclaimer: None of this was invented by me. Related Work:
by Richardson, Salvy, Shackell, van der Hoeven
by Gruntz
by E.
15 / 31
Power series expansions are insufficient for many important functions: exp(x), ln(x), Γ(x) for x → ∞
16 / 31
Power series expansions are insufficient for many important functions: exp(x), ln(x), Γ(x) for x → ∞ Example:
1 2x−1 − 1 4x−2 ln(x) + 1 8x−3 ln(x)2 + . . .
Solution: Multiseries
16 / 31
Power series expansions are insufficient for many important functions: exp(x), ln(x), Γ(x) for x → ∞ Example:
1 2x−1 − 1 4x−2 ln(x) + 1 8x−3 ln(x)2 + . . .
Solution: Multiseries
16 / 31
Power series expansions are insufficient for many important functions: exp(x), ln(x), Γ(x) for x → ∞ Example:
1 2x−1 − 1 4x−2 ln(x) + 1 8x−3 ln(x)2 + . . .
Solution: Multiseries
16 / 31
Power series expansions are insufficient for many important functions: exp(x), ln(x), Γ(x) for x → ∞ Example:
1 2x−1 − 1 4x−2 ln(x) + 1 8x−3 ln(x)2 + . . .
Solution: Multiseries
16 / 31
type Basis = (R → R) list
17 / 31
type Basis = (R → R) list datatype MS : Basis → Type where Const : R → MS [] Series : LList (MS bs × R) → MS (b :: bs)
17 / 31
type Basis = (R → R) list datatype MS : Basis → Type where Const : R → MS [] Series : LList (MS bs × R) → MS (b :: bs) Additionally: bases and series must be ‘sorted’.
17 / 31
type Basis = (R → R) list datatype MS : Basis → Type where Const : R → MS [] Series : LList (MS bs × R) → MS (b :: bs) Additionally: bases and series must be ‘sorted’. Example for a simple operation: negate : MS bs → MS bs
17 / 31
type Basis = (R → R) list datatype MS : Basis → Type where Const : R → MS [] Series : LList (MS bs × R) → MS (b :: bs) Additionally: bases and series must be ‘sorted’. Example for a simple operation: negate : MS bs → MS bs negate (Const c)
17 / 31
type Basis = (R → R) list datatype MS : Basis → Type where Const : R → MS [] Series : LList (MS bs × R) → MS (b :: bs) Additionally: bases and series must be ‘sorted’. Example for a simple operation: negate : MS bs → MS bs negate (Const c)
negate (Series ts) = Series [(negate c, e) | (c, e) ← ts]
17 / 31
constants, identity, addition, multiplication
18 / 31
constants, identity, addition, multiplication
Gives us division; ln, exp, sin, etc. at non-singular points
18 / 31
constants, identity, addition, multiplication
Gives us division; ln, exp, sin, etc. at non-singular points
procedures and may add new basis elements
18 / 31
constants, identity, addition, multiplication
Gives us division; ln, exp, sin, etc. at non-singular points
procedures and may add new basis elements
factor out singularities and treat them separately
18 / 31
For simple power series, f ∼ ts can be expressed coinductively: f (x) ∈ O(xe) f (x) − c xe ∼ ts f (x) ∼ (c, e) :: ts
19 / 31
For simple power series, f ∼ ts can be expressed coinductively: f (x) ∈ O(xe) f (x) − c xe ∼ ts f (x) ∼ (c, e) :: ts Operations are defined corecursively; correctness is proven
The same works for multiseries quite similarly.
19 / 31
We can construct expansions for functions ‘bottom up’:
20 / 31
We can construct expansions for functions ‘bottom up’:
Find an expansion for sin(1/x) + exp(x) for x → ∞:
20 / 31
We can construct expansions for functions ‘bottom up’:
Find an expansion for sin(1/x) + exp(x) for x → ∞:
20 / 31
We can construct expansions for functions ‘bottom up’:
Find an expansion for sin(1/x) + exp(x) for x → ∞:
20 / 31
We can construct expansions for functions ‘bottom up’:
Find an expansion for sin(1/x) + exp(x) for x → ∞:
20 / 31
We can construct expansions for functions ‘bottom up’:
Find an expansion for sin(1/x) + exp(x) for x → ∞:
20 / 31
We can construct expansions for functions ‘bottom up’:
Find an expansion for sin(1/x) + exp(x) for x → ∞:
basis [exp(x), x]
20 / 31
We can construct expansions for functions ‘bottom up’:
Find an expansion for sin(1/x) + exp(x) for x → ∞:
basis [exp(x), x]
20 / 31
End result: Theorem that sin(1/x) + exp(x) has the following expansion w. r. t. basis (exp(x), x):
21 / 31
End result: Theorem that sin(1/x) + exp(x) has the following expansion w. r. t. basis (exp(x), x): lift_expansion (sin_ms (Series [(1, −1)])) + Series [(Series [(1, 0)], 1)]
21 / 31
End result: Theorem that sin(1/x) + exp(x) has the following expansion w. r. t. basis (exp(x), x): lift_expansion (sin_ms (Series [(1, −1)])) + Series [(Series [(1, 0)], 1)] which evaluates to exp(x) + x−1 − 1 6x−3 + 1 120x−5 − . . .
21 / 31
Problem:
22 / 31
Problem:
functions
22 / 31
Problem:
functions
22 / 31
Solution: Heuristic approach using Isabelle’s automation
23 / 31
Solution: Heuristic approach using Isabelle’s automation
23 / 31
Solution: Heuristic approach using Isabelle’s automation
– might cause non-termination
23 / 31
Solution: Heuristic approach using Isabelle’s automation
– might cause non-termination
23 / 31
Solution: Heuristic approach using Isabelle’s automation
– might cause non-termination
23 / 31
Solution: Heuristic approach using Isabelle’s automation
– might cause non-termination
This works surprisingly well
23 / 31
With some pre-processing, we can automatically prove statements of the form
as x → l for l ∈ R ∪ {±∞}
24 / 31
With some pre-processing, we can automatically prove statements of the form
as x → l for l ∈ R ∪ {±∞} f and g can be built from + − · / ln exp min max ˆ | · |
n
without restrictions
24 / 31
With some pre-processing, we can automatically prove statements of the form
as x → l for l ∈ R ∪ {±∞} f and g can be built from + − · / ln exp min max ˆ | · |
n
without restrictions sin, cos, tan at finite points also possible.
24 / 31
Problem: What about ‘oscillating’ functions like sin, ⌊·⌋, mod?
25 / 31
Problem: What about ‘oscillating’ functions like sin, ⌊·⌋, mod? Example:
25 / 31
Problem: What about ‘oscillating’ functions like sin, ⌊·⌋, mod? Example:
Obvious solution: Asymptotic interval arithmetic:
25 / 31
Problem: What about ‘oscillating’ functions like sin, ⌊·⌋, mod? Example:
Obvious solution: Asymptotic interval arithmetic:
25 / 31
Problem: What about ‘oscillating’ functions like sin, ⌊·⌋, mod? Example:
Obvious solution: Asymptotic interval arithmetic:
25 / 31
Problem: What about ‘oscillating’ functions like sin, ⌊·⌋, mod? Example:
Obvious solution: Asymptotic interval arithmetic:
Result: Pair of asymptotic lower/upper bound with known multiseries expansion
25 / 31
Problem: What about ‘oscillating’ functions like sin, ⌊·⌋, mod? Example:
Obvious solution: Asymptotic interval arithmetic:
Result: Pair of asymptotic lower/upper bound with known multiseries expansion Works in many cases, but does not cope well with cancellations.
25 / 31
Problem: What about ‘oscillating’ functions like sin, ⌊·⌋, mod? Example:
Obvious solution: Asymptotic interval arithmetic:
Result: Pair of asymptotic lower/upper bound with known multiseries expansion Works in many cases, but does not cope well with
25 / 31
26 / 31
lemma (λn. (1 + 1/n) ˆ n) −
by real_asymp
27 / 31
lemma (λn. (1 + 1/n) ˆ n) −
by real_asymp
lemma (λn. (1 + a/n) ˆ n) −
by real_asymp
27 / 31
28 / 31
(most of them by me – but not all of them)
28 / 31
(most of them by me – but not all of them)
28 / 31
(most of them by me – but not all of them)
the method.
28 / 31
(most of them by me – but not all of them)
the method.
trivialities like x2 − x → ∞ should not be underestimated!
28 / 31
When formalising some paper and reaching a page full of limits, integrals, and uniform convergence, I used to feel like this:
29 / 31
When formalising some paper and reaching a page full of limits, integrals, and uniform convergence, I used to feel like this: Now I feel like this:
29 / 31
What could be improved?
30 / 31
What could be improved?
30 / 31
What could be improved?
30 / 31
What could be improved?
30 / 31
What could be improved?
30 / 31
31 / 31