TorchLean API

NN.Floats.IEEEExec.Exec32.Instances

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.

@[implicit_reducible]

Pretty-print using Lean's Float printer (via toFloat).

@[implicit_reducible]

Coerce a natural number by rounding that exact integer directly to binary32.

@[implicit_reducible]

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.

@[implicit_reducible]

0.0 as an executable binary32 value (chosen as +0.0).

@[implicit_reducible]

1.0 as an executable binary32 value.

@[implicit_reducible]

Unary negation (IEEE-754 sign flip, with NaN payload rules).

@[implicit_reducible]

IEEE-754 addition (with NaN/Inf rules).

@[implicit_reducible]

IEEE-754 subtraction (with NaN/Inf rules).

@[implicit_reducible]

IEEE-754 multiplication (with NaN/Inf rules).

@[implicit_reducible]

IEEE-754 division (with NaN/Inf rules).

@[implicit_reducible]

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 = 1 for finite, infinite, and quiet-NaN exponents (a signaling NaN still propagates);
  • an infinite exponent is classified from |x| relative to 1;
  • (-∞)^y has magnitude +∞ for positive finite y and +0 for negative finite y, with the usual signed result retained when y is 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).

@[implicit_reducible]

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.
@[implicit_reducible]

Strict order instance, defined via IEEE32Exec.lt.

@[implicit_reducible]

Non-strict order instance, defined via IEEE32Exec.le.

@[implicit_reducible]

Decidable < inherited from the compare-based definition.

@[implicit_reducible]

Decidable inherited from the compare-based definition.

@[implicit_reducible]

min operator, implemented by IEEE-754 minimum.

@[implicit_reducible]

max operator, implemented by IEEE-754 maximum.

@[implicit_reducible]

Provide the MathFunctions interface using the deterministic implementations in this file.

@[implicit_reducible]

Numeric constants used by the spec library, instantiated at binary32.