automating asymptotics in a theorem prover
play

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


  1. Example: Stieltjes constants � ln n k − ln n + 1 ( k + 1 ) − ln n + 1 k ∞ � ∑ γ n = n + 1 k k = 1 Why does this sum exist? Because the summand is ∼ ( k − 2 ln n k ) ∈ O ( k − 3 / 2 ) 12 / 31

  2. Example: Stieltjes constants � ln n k − ln n + 1 ( k + 1 ) − ln n + 1 k ∞ � ∑ γ n = n + 1 k k = 1 Why does this sum exist? Because the summand is ∼ ( k − 2 ln n k ) ∈ O ( k − 3 / 2 ) and ∑ k x is summable for any x < − 1! 12 / 31

  3. Example: Stieltjes constants � ln n k − ln n + 1 ( k + 1 ) − ln n + 1 k ∞ � ∑ γ n = n + 1 k k = 1 Why does this sum exist? Because the summand is ∼ ( k − 2 ln n k ) ∈ O ( k − 3 / 2 ) and ∑ k x is summable for any x < − 1! But proving those asymptotics by hand is a lot of work. 12 / 31

  4. Example: Lemma required for Akra–Bazzi   � � p 1 1  − 1 −  1 + lim b log 1 + ε x log ε / 2 � � x → ∞ bx + x log 1 + ε x � � 1 = 0 + 1 + log ε / 2 x 13 / 31

  5. Example: Lemma required for Akra–Bazzi   � � p 1 1  − 1 −  1 + lim b log 1 + ε x log ε / 2 � � x → ∞ bx + x log 1 + ε x � � 1 = 0 + 1 + log ε / 2 x Original author: ‘Trivial, just Taylor-expand it!’ 13 / 31

  6. In Isabelle: lemma akra_bazzi_aux: filterlim ( λ x . ( 1 − 1 / ( b ∗ ln x ˆ ( 1 + ε )) ˆ p ) ∗ ( 1 + ln ( b ∗ x + x / ln x ˆ ( 1 + ε )) ˆ ( − ε / 2 )) − ( 1 + ln x ˆ ( − ε / 2 ))) ( at_right 0 ) at_top 14 / 31

  7. In Isabelle: lemma akra_bazzi_aux: filterlim ( λ x . ( 1 − 1 / ( b ∗ ln x ˆ ( 1 + ε )) ˆ p ) ∗ ( 1 + ln ( b ∗ x + x / ln x ˆ ( 1 + ε )) ˆ ( − ε / 2 )) − ( 1 + ln x ˆ ( − ε / 2 ))) ( at_right 0 ) at_top Omitted: 700 lines of messy proofs 14 / 31

  8. In Isabelle: lemma akra_bazzi_aux: filterlim ( λ x . ( 1 − 1 / ( b ∗ ln x ˆ ( 1 + ε )) ˆ p ) ∗ ( 1 + ln ( b ∗ x + x / ln x ˆ ( 1 + ε )) ˆ ( − ε / 2 )) − ( 1 + ln x ˆ ( − ε / 2 ))) ( at_right 0 ) at_top Omitted: 700 lines of messy proofs Luckily, we now have automation for this: by real_asymp 14 / 31

  9. In Isabelle: lemma akra_bazzi_aux: filterlim ( λ x . ( 1 − 1 / ( b ∗ ln x ˆ ( 1 + ε )) ˆ p ) ∗ ( 1 + ln ( b ∗ x + x / ln x ˆ ( 1 + ε )) ˆ ( − ε / 2 )) − ( 1 + ln x ˆ ( − ε / 2 ))) ( at_right 0 ) at_top Omitted: 700 lines of messy proofs Luckily, we now have automation for this: by real_asymp How does it work? 14 / 31

  10. Multiseries Expansions 15 / 31

  11. Multiseries Expansions Disclaimer: None of this was invented by me. Related Work: ◮ Asymptotic Expansions of exp–log Functions by Richardson, Salvy, Shackell, van der Hoeven ◮ On Computing Limits in a Symbolic Manipulation System by Gruntz ◮ Verified Real Asymptotics in Isabelle/HOL by E. 15 / 31

  12. Multiseries Expansions Power series expansions are insufficient for many important functions: exp ( x ) , ln ( x ) , Γ ( x ) for x → ∞ 16 / 31

  13. Multiseries Expansions Power series expansions are insufficient for many important functions: exp ( x ) , ln ( x ) , Γ ( x ) for x → ∞ Example: ( x + ln ( x )) − 1 ∼ 2 x − 1 − 1 8 x − 3 ln ( x ) 2 + . . . 4 x − 2 ln ( x ) + 1 1 Solution: Multiseries ◮ Like an asymptotic power series, but may contain powers of several ‘basis functions’ b 1 ( x ) , . . . , b n ( x ) 16 / 31

  14. Multiseries Expansions Power series expansions are insufficient for many important functions: exp ( x ) , ln ( x ) , Γ ( x ) for x → ∞ Example: ( x + ln ( x )) − 1 ∼ 2 x − 1 − 1 8 x − 3 ln ( x ) 2 + . . . 4 x − 2 ln ( x ) + 1 1 Solution: Multiseries ◮ Like an asymptotic power series, but may contain powers of several ‘basis functions’ b 1 ( x ) , . . . , b n ( x ) ◮ Formally: R [ B 1 , . . . , B n ] or R [ B n ] . . . [ B 1 ] 16 / 31

  15. Multiseries Expansions Power series expansions are insufficient for many important functions: exp ( x ) , ln ( x ) , Γ ( x ) for x → ∞ Example: ( x + ln ( x )) − 1 ∼ 2 x − 1 − 1 8 x − 3 ln ( x ) 2 + . . . 4 x − 2 ln ( x ) + 1 1 Solution: Multiseries ◮ Like an asymptotic power series, but may contain powers of several ‘basis functions’ b 1 ( x ) , . . . , b n ( x ) ◮ Formally: R [ B 1 , . . . , B n ] or R [ B n ] . . . [ B 1 ] ◮ The basis must be ordered descendingly by ‘growth class’: ∀ i . ln b i + 1 ( x ) ∈ o ( ln b i ( x )) 16 / 31

  16. Multiseries Expansions Power series expansions are insufficient for many important functions: exp ( x ) , ln ( x ) , Γ ( x ) for x → ∞ Example: ( x + ln ( x )) − 1 ∼ 2 x − 1 − 1 8 x − 3 ln ( x ) 2 + . . . 4 x − 2 ln ( x ) + 1 1 Solution: Multiseries ◮ Like an asymptotic power series, but may contain powers of several ‘basis functions’ b 1 ( x ) , . . . , b n ( x ) ◮ Formally: R [ B 1 , . . . , B n ] or R [ B n ] . . . [ B 1 ] ◮ The basis must be ordered descendingly by ‘growth class’: ∀ i . ln b i + 1 ( x ) ∈ o ( ln b i ( x )) ◮ Typical basis: exp ( x 2 ) , exp ( x ) , x , ln x , ln ln x 16 / 31

  17. A coalgebraic view of Multiseries type Basis = ( R → R ) list 17 / 31

  18. A coalgebraic view of Multiseries type Basis = ( R → R ) list datatype MS : Basis → Type where Const : R → MS [] Series : LList ( MS bs × R ) → MS ( b :: bs ) 17 / 31

  19. A coalgebraic view of Multiseries 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

  20. A coalgebraic view of Multiseries 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

  21. A coalgebraic view of Multiseries 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 ) = Const ( − c ) 17 / 31

  22. A coalgebraic view of Multiseries 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 ) = Const ( − c ) negate ( Series ts ) = Series [( negate c , e ) | ( c , e ) ← ts ] 17 / 31

  23. More Complicated Operations ◮ Basic operations (defined corecursively): constants, identity, addition, multiplication 18 / 31

  24. More Complicated Operations ◮ Basic operations (defined corecursively): constants, identity, addition, multiplication ◮ Substitution into convergent power series: Gives us division; ln , exp , sin , etc. at non-singular points 18 / 31

  25. More Complicated Operations ◮ Basic operations (defined corecursively): constants, identity, addition, multiplication ◮ Substitution into convergent power series: Gives us division; ln , exp , sin , etc. at non-singular points ◮ exp and ln at singular points require specialised procedures and may add new basis elements 18 / 31

  26. More Complicated Operations ◮ Basic operations (defined corecursively): constants, identity, addition, multiplication ◮ Substitution into convergent power series: Gives us division; ln , exp , sin , etc. at non-singular points ◮ exp and ln at singular points require specialised procedures and may add new basis elements ◮ For operations like Γ , erf, li: factor out singularities and treat them separately 18 / 31

  27. Connecting Series and Functions For simple power series, f ∼ ts can be expressed coinductively: f ( x ) − c x e ∼ ts f ( x ) ∈ O ( x e ) f ( x ) ∼ ( c , e ) :: ts 19 / 31

  28. Connecting Series and Functions For simple power series, f ∼ ts can be expressed coinductively: f ( x ) − c x e ∼ ts f ( x ) ∈ O ( x e ) f ( x ) ∼ ( c , e ) :: ts Operations are defined corecursively; correctness is proven coinductively. Both are straightforward. The same works for multiseries quite similarly. 19 / 31

  29. Finding Expansions We can construct expansions for functions ‘bottom up’: 20 / 31

  30. Finding Expansions We can construct expansions for functions ‘bottom up’: Example Find an expansion for sin ( 1 / x ) + exp ( x ) for x → ∞ : 20 / 31

  31. Finding Expansions We can construct expansions for functions ‘bottom up’: Example Find an expansion for sin ( 1 / x ) + exp ( x ) for x → ∞ : ◮ 1 / x has the trivial expansion x − 1 w. r. t. the basis [ x ] 20 / 31

  32. Finding Expansions We can construct expansions for functions ‘bottom up’: Example Find an expansion for sin ( 1 / x ) + exp ( x ) for x → ∞ : ◮ 1 / x has the trivial expansion x − 1 w. r. t. the basis [ x ] ◮ substitute the series x − 1 into the Taylor expansion of sin 20 / 31

  33. Finding Expansions We can construct expansions for functions ‘bottom up’: Example Find an expansion for sin ( 1 / x ) + exp ( x ) for x → ∞ : ◮ 1 / x has the trivial expansion x − 1 w. r. t. the basis [ x ] ◮ substitute the series x − 1 into the Taylor expansion of sin ◮ exp ( x ) has to be added as a new basis element 20 / 31

  34. Finding Expansions We can construct expansions for functions ‘bottom up’: Example Find an expansion for sin ( 1 / x ) + exp ( x ) for x → ∞ : ◮ 1 / x has the trivial expansion x − 1 w. r. t. the basis [ x ] ◮ substitute the series x − 1 into the Taylor expansion of sin ◮ exp ( x ) has to be added as a new basis element ◮ exp ( x ) then has the trivial expansion exp ( x ) 20 / 31

  35. Finding Expansions We can construct expansions for functions ‘bottom up’: Example Find an expansion for sin ( 1 / x ) + exp ( x ) for x → ∞ : ◮ 1 / x has the trivial expansion x − 1 w. r. t. the basis [ x ] ◮ substitute the series x − 1 into the Taylor expansion of sin ◮ exp ( x ) has to be added as a new basis element ◮ exp ( x ) then has the trivial expansion exp ( x ) ◮ our expansion for sin ( 1 / x ) must be lifted to the new basis [ exp ( x ) , x ] 20 / 31

  36. Finding Expansions We can construct expansions for functions ‘bottom up’: Example Find an expansion for sin ( 1 / x ) + exp ( x ) for x → ∞ : ◮ 1 / x has the trivial expansion x − 1 w. r. t. the basis [ x ] ◮ substitute the series x − 1 into the Taylor expansion of sin ◮ exp ( x ) has to be added as a new basis element ◮ exp ( x ) then has the trivial expansion exp ( x ) ◮ our expansion for sin ( 1 / x ) must be lifted to the new basis [ exp ( x ) , x ] ◮ add expansions for sin ( 1 / x ) and exp ( x ) 20 / 31

  37. Finding Expansions End result: Theorem that sin ( 1 / x ) + exp ( x ) has the following expansion w. r. t. basis ( exp ( x ) , x ) : 21 / 31

  38. Finding Expansions 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

  39. Finding Expansions 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 6 x − 3 + 1 120 x − 5 − . . . 21 / 31

  40. Sign Determination Problem: ◮ Many operations involve comparisons of real numbers 22 / 31

  41. Sign Determination Problem: ◮ Many operations involve comparisons of real numbers ◮ ‘Trimming’ expansions involves zeroness tests of real functions 22 / 31

  42. Sign Determination Problem: ◮ Many operations involve comparisons of real numbers ◮ ‘Trimming’ expansions involves zeroness tests of real functions ◮ Both of these are difficult or even undecidable 22 / 31

  43. Sign Determination Solution: Heuristic approach using Isabelle’s automation 23 / 31

  44. Sign Determination Solution: Heuristic approach using Isabelle’s automation ◮ Use automation to determine signs – might fail 23 / 31

  45. Sign Determination Solution: Heuristic approach using Isabelle’s automation ◮ Use automation to determine signs – might fail ◮ Use automation to determine if function is identically zero – might cause non-termination 23 / 31

  46. Sign Determination Solution: Heuristic approach using Isabelle’s automation ◮ Use automation to determine signs – might fail ◮ Use automation to determine if function is identically zero – might cause non-termination ◮ Optionally: Use approximation by interval arithmetic 23 / 31

  47. Sign Determination Solution: Heuristic approach using Isabelle’s automation ◮ Use automation to determine signs – might fail ◮ Use automation to determine if function is identically zero – might cause non-termination ◮ Optionally: Use approximation by interval arithmetic ◮ User may have to supply additional facts 23 / 31

  48. Sign Determination Solution: Heuristic approach using Isabelle’s automation ◮ Use automation to determine signs – might fail ◮ Use automation to determine if function is identically zero – might cause non-termination ◮ Optionally: Use approximation by interval arithmetic ◮ User may have to supply additional facts This works surprisingly well 23 / 31

  49. Proof Method With some pre-processing, we can automatically prove statements of the form ◮ f ( x ) − → c ◮ f ( x ) ∼ g ( x ) ◮ f ( x ) < g ( x ) eventually ◮ f ( x ) ∈ L ( g ( x )) for any Landau symbol L as x → l for l ∈ R ∪ {± ∞ } 24 / 31

  50. Proof Method With some pre-processing, we can automatically prove statements of the form ◮ f ( x ) − → c ◮ f ( x ) ∼ g ( x ) ◮ f ( x ) < g ( x ) eventually ◮ f ( x ) ∈ L ( g ( x )) for any Landau symbol L as x → l for l ∈ R ∪ {± ∞ } √· f and g can be built from + − · / ln exp min max ˆ | · | n without restrictions 24 / 31

  51. Proof Method With some pre-processing, we can automatically prove statements of the form ◮ f ( x ) − → c ◮ f ( x ) ∼ g ( x ) ◮ f ( x ) < g ( x ) eventually ◮ f ( x ) ∈ L ( g ( x )) for any Landau symbol L 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

  52. Proof Method Problem: What about ‘oscillating’ functions like sin , ⌊·⌋ , mod? 25 / 31

  53. Proof Method Problem: What about ‘oscillating’ functions like sin , ⌊·⌋ , mod? ⌊ x ⌋ = √ x + o ( 1 ) � Example: 25 / 31

Recommend


More recommend