TorchLean API

FloatLib.Numerics.Exact.RadixText.PrecisionProof

Laws of significant-digit rounding in any radix #

The caller supplies integer rounding. These laws establish the grid, coefficient bounds and value-preserving carry independently of decimal or binary descriptors.

theorem FloatLib.Numerics.RadixText.carry_value (radix : ) (hradix : 0 < radix) (digits : ℕ+) (coefficient : ) (quantum : ) :
(carry radix digits coefficient quantum).1 * radix ^ (carry radix digits coefficient quantum).2 = coefficient * radix ^ quantum

Carry changes the written scale without changing the numerical value.

theorem FloatLib.Numerics.RadixText.significant_value (radix : ) (hradix : 0 < radix) (roundMagnitude : Bool) (negative : Bool) (coefficient : ) (quantum : ) (digits : ℕ+) :
(significant radix roundMagnitude negative coefficient quantum digits).1 * radix ^ (significant radix roundMagnitude negative coefficient quantum digits).2 = (roundCoefficient radix roundMagnitude negative coefficient quantum (significantQuantum radix coefficient quantum digits)) * radix ^ significantQuantum radix coefficient quantum digits

The written result denotes precisely the caller's integer rounding on the selected grid.

theorem FloatLib.Numerics.RadixText.scaled_lt (radix : ) (hradix : 1 < radix) (coefficient : ) (quantum : ) (digits : ℕ+) :
coefficient * radix ^ quantum / radix ^ significantQuantum radix coefficient quantum digits < radix ^ digits

The coefficient before rounding is strictly smaller than the radix to the requested precision.

theorem FloatLib.Numerics.RadixText.scaled_lower (radix : ) (hradix : 1 < radix) (coefficient : ) (quantum : ) (digits : ℕ+) (hc : coefficient 0) :
radix ^ (digits - 1) coefficient * radix ^ quantum / radix ^ significantQuantum radix coefficient quantum digits

A nonzero coefficient scaled to its requested grid has the expected leading digit.

theorem FloatLib.Numerics.RadixText.significant_coefficient_bounds (radix : ) (hradix : 1 < radix) (roundMagnitude : Bool) (hlower : ∀ (sign : Bool) (x : ), x⌋₊ roundMagnitude sign x) (hupper : ∀ (sign : Bool) (x : ) (n : ), 0 xx nroundMagnitude sign x n) (negative : Bool) (coefficient : ) (quantum : ) (digits : ℕ+) (hc : coefficient 0) :
radix ^ (digits - 1) (significant radix roundMagnitude negative coefficient quantum digits).1 (significant radix roundMagnitude negative coefficient quantum digits).1 < radix ^ digits

For a nonzero input, a rounder between floor and ceiling emits the requested digit count.

theorem FloatLib.Numerics.RadixText.significant_exact (radix : ) (hradix : 1 < radix) (roundMagnitude : Bool) (hexact : ∀ (sign : Bool) (n : ), roundMagnitude sign n = n) (negative : Bool) (coefficient : ) (quantum : ) (digits : ℕ+) (hc : coefficient < radix ^ digits) :
(significant radix roundMagnitude negative coefficient quantum digits).1 * radix ^ (significant radix roundMagnitude negative coefficient quantum digits).2 = coefficient * radix ^ quantum

Enough requested digits preserve value whenever integer inputs are fixed by the rounder.

theorem FloatLib.Numerics.RadixText.significant_error (radix : ) (hradix : 0 < radix) (roundMagnitude : Bool) (error : ) (herror : ∀ (sign : Bool) (x : ), 0 x|(roundMagnitude sign x) - x| error) (negative : Bool) (coefficient : ) (quantum : ) (digits : ℕ+) :
|(significant radix roundMagnitude negative coefficient quantum digits).1 * radix ^ (significant radix roundMagnitude negative coefficient quantum digits).2 - coefficient * radix ^ quantum| error * radix ^ significantQuantum radix coefficient quantum digits

An integer rounding error bound scales by the requested external grid unit.