TorchLean API

FloatLib.Floats.Formats.DecimalInterchange.Sqrt.Semantics

Public square-root semantics #

These results cover zero's sign and preferred quantum, invalid negative inputs, and the real numerical error of a finite nonnegative operand. The public error bound includes zero rather than assuming the input is strictly positive.

Square root preserves either zero sign and clamps the floored half-exponent to the format's quantum range.

A negative nonzero finite operand raises invalid and returns a quiet NaN.

theorem FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.sqrt_error_le_half (f : Format) (mode : RoundingMode) (hm : mode = RoundingMode.nearestEven mode = RoundingMode.nearestAway) (x : Datum) (a : ) (hx : x.toRat? = some a) (ha : 0 a) (hfinite : (sqrt f mode x).status.overflow = false) :
∃ (value : ), (sqrt f mode x).value.toRat? = some value |value - a| 10 ^ sqrtQuantum f a / 2

The returned square root has at most half a decimal grid unit of real error.