TorchLean API

FloatLib.Floats.Formats.DecimalInterchange.Scaling.Proof

Exponent-operation semantics #

The bounds on logB characterize its answer by consecutive radix powers. Scaling inherits the actual projection's value, range, rounding and cohort guarantees, including signed zero and decimal tininess before rounding.

theorem FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.scaleB_exact_magnitude (c : ) (q n : ) :
c * 10 ^ (q + n) = c * 10 ^ q * 10 ^ n

The intermediate magnitude is exactly the input magnitude times the radix power.

theorem FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.scaleB_exact_status (f : Format) (mode : RoundingMode) (s : Bool) (c : ) (q n : ) (hvalid : Datum.Valid f (Datum.finite s c (q + n))) :
(scaleB f mode (Datum.finite s c q) n).status = { }

An in-range exact shifted representation incurs no exceptions.

theorem FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.scaleB_quantum_closest (f : Format) (mode : RoundingMode) (s : Bool) (c : ) (q n : ) (hvalid : Datum.Valid f (Datum.finite s c (q + n))) (d : ) (r : ) (hout : (scaleB f mode (Datum.finite s c q) n).value = Datum.finite s d r) (e : ) (t : ) (he : Datum.Valid f (Datum.finite s e t)) (hvalue : c * 10 ^ (q + n) = e * 10 ^ t) :
|q + n - r| |q + n - t|

The selected quantum is closest to q + n among valid representations of the exact result.

Scaling zero changes only its quantum, clamped at the format boundaries.

theorem FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.scaleB_inexact_iff (f : Format) (mode : RoundingMode) (s : Bool) (c : ) (q n : ) (v : ) (hq : (roundedPair f mode s (c * 10 ^ (q + n))).2 f.maxQuantum) (hv : (scaleB f mode (Datum.finite s c q) n).value.toRat? = some v) :
(scaleB f mode (Datum.finite s c q) n).status.inexact = true v Datum.finiteValue s c q * 10 ^ n
theorem FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.scaleB_underflow_iff (f : Format) (mode : RoundingMode) (s : Bool) (c : ) (q n : ) (hq : (roundedPair f mode s (c * 10 ^ (q + n))).2 f.maxQuantum) :
(scaleB f mode (Datum.finite s c q) n).status.underflow = true c * 10 ^ (q + n) < f.minNormal (scaleB f mode (Datum.finite s c q) n).status.inexact = true

Scaling uses the exact, unrounded magnitude in the decimal tininess test.

theorem FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.logB_finite (f : Format) (s : Bool) (c : ) (q : ) (hc : c 0) :
logB f (Datum.finite s c q) = { value := q + (Nat.log 10 c) }
theorem FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.logB_bounds (f : Format) (s : Bool) (c : ) (q : ) (hc : c 0) :
10 ^ (logB f (Datum.finite s c q)).value c * 10 ^ q c * 10 ^ q < 10 ^ ((logB f (Datum.finite s c q)).value + 1)

The returned exponent is exactly the unique radix-power bracket for the magnitude.

The exceptional integer exceeds twice either absolute endpoint of the exponent range.

Every valid finite exponent has absolute value less than half the exceptional sentinel.

The integer exceptional result cannot collide with a valid finite nonzero exponent.