Arb-backed transcendentals for IEEE32Exec.Interval32 #
NN/Floats/Interval/IEEEExec32.lean provides an executable endpoint-interval type
IEEE32Exec.Interval32 with outward-rounded endpoint arithmetic for add/sub/mul:
- endpoints live on the IEEE-754 binary32 grid (
IEEE32Exec), addDown/addUp/mulDown/mulUpare implemented via exact-dyadic arithmetic + directed rounding.
For transcendentals (exp/log/tanh/sqrt/...) the situation is different:
- IEEE-754 does not specify correctly-rounded transcendentals (libm is out of scope),
NN/Floats/IEEEExec/Exec32.leancontains deterministic transcendental approximations, but they are not proved outward-rounded w.r.t. real semantics.
This file implements a pragmatic “sound route” for interval endpoints of transcendentals:
- Call the Arb oracle (
NN/Floats/Arb) to obtain a rigorous real enclosure[L,U] ⊇ f([a,b]). - Convert
L,U : ℚto float32 endpoints by rounding outward to theIEEE32Execgrid:- lower endpoint: round toward
-∞(usingroundDyadicDown), - upper endpoint: round toward
+∞(usingroundDyadicUp).
- lower endpoint: round toward
Trust boundary:
- The enclosure
[L,U]is an oracle claim from Arb/python-flint; this module does not prove the Arb computation inside Lean. - The rounding-to-float32 step is in-Lean and (for dyadic rounding) proved sound in
NN/Floats/IEEEExec/DirectedRoundingSoundness.lean.
The result is useful when you want executable float32 endpoints and a clearly delineated source of transcendental soundness (Arb).
Render a rational in a format that Arb's parser accepts (e.g. -3/2, 5).
Instances For
Exact rational view of float32 values #
Convert an exact dyadic (-1)^sign * mant * 2^exp into an exact rational (ℚ).
Instances For
Exact rational value of a finite IEEE32Exec float.
Returns none for NaN/Inf.
Instances For
Outward rounding from ℚ to IEEE32Exec #
A rational view of 2^k.
This is a small helper used to implement ratToDyadicDown/ratToDyadicUp.
Instances For
Approximate a rational q from below by a dyadic with denominator 2^k:
d = floor(q * 2^k) * 2^{-k}.
Instances For
Approximate a rational q from above by a dyadic with denominator 2^k:
d = ceil(q * 2^k) * 2^{-k}.
Instances For
Outward rounding down of a rational to the float32 grid (via a dyadic approximation).
Instances For
Outward rounding up of a rational to the float32 grid (via a dyadic approximation).
Instances For
Arb-backed interval endpoints for transcendentals #
Decode a float endpoint as an exact rational, failing if the value is NaN/Inf.
This is used to feed exact endpoint strings into the Arb oracle.
Instances For
Call Arb on the real interval [X.lo, X.hi] (interpreted exactly as rationals) and return the
oracle-provided rational enclosure bounds (L,U).
This is the only step that crosses the trust boundary.
Instances For
Compute an IEEE32Exec.Interval32 enclosure for a transcendental unary func by:
- getting a real enclosure
[L,U]from Arb, - rounding endpoints outward to the binary32 grid.
dyadicBits controls the internal dyadic approximation used when rounding rationals to float32;
it can be increased if you want the outward rounding to be closer to the Arb bounds.
Instances For
Arb-backed tanh enclosure for Interval32 (oracle + outward rounding to float32 endpoints).
Instances For
Arb-backed exp enclosure for Interval32 (oracle + outward rounding to float32 endpoints).
Instances For
Arb-backed log enclosure for Interval32 (oracle + outward rounding to float32 endpoints).
Instances For
Arb-backed sqrt enclosure for Interval32 (oracle + outward rounding to float32 endpoints).