IEEE32 Executable Instances #
This file gives IEEE32Exec the standard Lean numeric interfaces needed by tensor specs and
examples. The instances route arithmetic through the executable binary32 operations defined in the
Exec32 hierarchy.
Pretty-print using Lean's Float printer (via toFloat).
Coerce a natural number by rounding that exact integer directly to binary32.
Numeral literals for IEEE32Exec.
This allows writing:
(1 : IEEE32Exec)(42 : IEEE32Exec)
The conversion uses the exact dyadic n · 2⁰ and rounds once to nearest-even binary32. Avoiding an
intermediate binary64 value prevents double rounding for large numerals.
0.0 as an executable binary32 value (chosen as +0.0).
1.0 as an executable binary32 value.
Unary negation (IEEE-754 sign flip, with NaN payload rules).
IEEE-754 addition (with NaN/Inf rules).
IEEE-754 subtraction (with NaN/Inf rules).
IEEE-754 multiplication (with NaN/Inf rules).
IEEE-754 division (with NaN/Inf rules).
Exponentiation instance.
This is a deterministic executable choice, not a claim about correctly-rounded pow.
The value-level special cases follow the conventions used by common tensor runtimes:
x^(±0) = 1, including a NaN base;1^y = 1for finite, infinite, and quiet-NaN exponents (a signaling NaN still propagates);- an infinite exponent is classified from
|x|relative to1; (-∞)^yhas magnitude+∞for positive finiteyand+0for negative finitey, with the usual signed result retained whenyis an integer.
Finite negative bases accept integer exponents. For a general non-integer exponent on a positive
base, the implementation falls back to exp (b * log a).
Instances For
Boolean equality with IEEE-754 NaN/zero conventions.
- If either side is NaN, we return
false. - If both are zeros (either sign), we return
true. - Otherwise we compare raw bits.
Strict order instance, defined via IEEE32Exec.lt.
Non-strict order instance, defined via IEEE32Exec.le.
Decidable < inherited from the compare-based definition.
Decidable ≤ inherited from the compare-based definition.
min operator, implemented by IEEE-754 minimum.
max operator, implemented by IEEE-754 maximum.
Provide the MathFunctions interface using the deterministic implementations in this file.
Numeric constants used by the spec library, instantiated at binary32.