A Monadic Approach to Certified Exact Real Arithmetic Russell - - PowerPoint PPT Presentation

a monadic approach to certified exact real arithmetic
SMART_READER_LITE
LIVE PREVIEW

A Monadic Approach to Certified Exact Real Arithmetic Russell - - PowerPoint PPT Presentation

A Monadic Approach to Certified Exact Real Arithmetic Russell OConnor Radboud University Nijmegen TYPES / TFP 2006 April 19, 2006 Certified Real Arithmetic Arbitrary precision real number computation We have fast complex libraries


slide-1
SLIDE 1

A Monadic Approach to Certified Exact Real Arithmetic

Russell O’Connor Radboud University Nijmegen TYPES / TFP 2006 April 19, 2006

slide-2
SLIDE 2

Certified Real Arithmetic

  • Arbitrary precision real number computation
  • We have fast complex libraries

– MPFR

  • We have slow certified implementations

– C-CoRN

  • We want to find the sweet spot of easy to

certify fast enough real arithemetic.

slide-3
SLIDE 3

Certified Reals Arithmetic

  • Why certified?

– Toward certified computer algebra

  • Certified calculator

– Disproof of Merten’s conjecture

  • Requires approximating roots of zeta function

– Kepler conjecture

  • 99% certain it is correct
  • We are going to make that 100%.
slide-4
SLIDE 4

Completion

  • Let X be a “metric space”.
  • Define C(X) the metric space of regular

functions.

CX≝{ f :ℚ

+⇒ X ∣ ∀12 , B12 f 1, f 2}

slide-5
SLIDE 5

Completion

  • Let X be a “metric space”.
  • Define C(X) the metric space of regular

functions.

CX≝{ f :ℚ

+⇒ X ∣ ∀12 , B12 f 1, f 2}

  • C is a monad.

– X  C(X) – C(C(X)) → C(X) – (X → Y) ⇒ (C(X) → C(Y))

slide-6
SLIDE 6

Uniform Continuity

  • Suppose

– X is a nice metric space. – f : X → Y is uniformly continuous with modulus μ. – x : ℚ+ ⇒ X is a regular function.

slide-7
SLIDE 7

Uniform Continuity

  • Suppose

– X is a nice metric space. – f : X → Y is uniformly continuous with modulus μ. – x : ℚ+ ⇒ X is a regular function.

  • Then

– f ∘ x ∘ μ : ℚ+ ⇒ Y is a regular function.

slide-8
SLIDE 8

Uniform Continuity

  • Suppose

– X is a nice metric space. – f : X → Y is uniformly continuous with modulus μ. – x : ℚ+ ⇒ X is a regular function.

  • Then

– f ∘ x ∘ μ : ℚ+ ⇒ Y is a regular function.

  • This yields the map operation of type

(X → Y) ⇒ (C(X) → C(Y)).

slide-9
SLIDE 9

Uniformly Continuous Functions

  • ℚ is nice.
  • Uniformly continuous functions, ℚ → ℚ:

– λx. -x – λx. |x| – λx. c + x – λx. cx

  • λε. c-1ε is a modulus of continuity
  • All these lift to C(ℚ) → C(ℚ).
slide-10
SLIDE 10

Uniformly Continuous, Curried Functions

  • X → ℚ is a metric space.

– Using the ∞-norm.

  • More uniformly continuous functions,

ℚ → ([a, b] → ℚ):

– λx. λy. x + y – λx. λy. xy

  • All these lift to C(ℚ) → C([a, b] → ℚ).

– Isomorphic to C(ℚ) → C([a, b]) → C(ℚ).

slide-11
SLIDE 11

Reciprocal

  • Let x : C(ℚ) and x # 0.
  • Consider 0 < a < x where a : ℚ.
  • Consider the domain [a, ∞) ∩ ℚ.
slide-12
SLIDE 12

Reciprocal

  • Let x : C(ℚ) and x # 0.
  • Consider 0 < a < x where a : ℚ.
  • Consider the domain [a, ∞) ∩ ℚ.
  • λy. (max(a, y))-1 is uniformly continuous with

modulus λε. εa2.

  • Map x over this uniformly continuous

function.

slide-13
SLIDE 13

Calculus

  • Taylor series!
  • Alternating sums easily make regular

functions.

– cosℚ : ℚ → C(ℚ) – bind cosℚ : C(ℚ) → C(ℚ)

cosa=∑

i=0 ∞ −1 i a 2i

2i!

slide-14
SLIDE 14

Range Reduction - exp

expx= 1 exp−x

slide-15
SLIDE 15

Range Reduction - ln

lnx=−ln 1 x 

slide-16
SLIDE 16

Range Reduction - exp

expx=exp

2 x

2 

slide-17
SLIDE 17

Range Reduction - cos

cosx=1−2sin

2 x

2 

slide-18
SLIDE 18

Range Reduction - sin

sinx=3sin x 3 −4sin

3 x

3 

slide-19
SLIDE 19

Range Reduction - ln

lnx=ln x 2

nn ln2

slide-20
SLIDE 20

Range Reduction - ln

lnx=ln 3 4 xln 4 3 

slide-21
SLIDE 21

Range Reduction - arctan

arctanx=−arctan−x

slide-22
SLIDE 22

Range Reduction - arctan

0≤x⇒arctanx= 2 −arctan 1 x 

slide-23
SLIDE 23

Range Reduction - arctan

0≤x⇒arctanx= 4 arctan x−1 x1 

slide-24
SLIDE 24

π

=48arctan 1 38 80 arctan 1 57 28arctan 1 239 96arctan 1 268 

slide-25
SLIDE 25

Compression

  • [a − ε, a + ε] contains a unique smallest

rational.

  • Let approxε(a) be that rational.
  • Let x : C(ℚ).
  • λε. approxε/2(x(ε/2)) : C(ℚ)

is equivalent to x but “smaller”.

slide-26
SLIDE 26

Correctness

  • What does it mean to be correct?

– Could prove properties of these functions. – Could prove equivalence to a reference

standard.

  • C-CoRN

– Provides a reference implementation of real

numbers in Coq.

  • Formalize this theory in your favourite

system!

slide-27
SLIDE 27

Speed

  • Is this fast enough?
  • What is fast enough?
  • Hales’s proof of the Kepler conjecture

provides a “test suite”.

  • Haskell prototype: Few Digits

– Entered in the “Many Digits” competition

  • Did not finish last!
slide-28
SLIDE 28

Other Representations

CX≝ { f :ℚ

+⇒ X ∣ ∀12 , B12 f 1, f 2}

Gauge Base

{2

n∣ n:ℤ}

{a2

b ∣a ,b: ℤ}

n ∣n:ℤ}

ℤ[φ]

slide-29
SLIDE 29

Other Work

  • Use the type ℚ + C(ℚ)

– Run rational operations when it is known to be

rational

  • Sometimes rational operations are slower
  • Have functions return an interval

– Return a point the the result is known to be

precise

slide-30
SLIDE 30

More Information

  • Google “Few Digits”

– http://r6.ca/FewDigits/

  • Upcoming paper in Mathematical Structures

in Computer Science.