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 naturals to binary32 by converting through Lean's Float and re-encoding.

@[implicit_reducible]

Numeral literals for IEEE32Exec.

This allows writing:

  • (1 : IEEE32Exec)
  • (42 : IEEE32Exec)

The interpretation is NatFloat (binary64) → IEEE32Exec via ofFloat, i.e. it rounds the exact integer to the nearest representable float32 (which is exact for small enough integers).

@[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: we implement a small set of IEEE-like special cases and handle integer exponents exactly enough to avoid the most common footguns (negative bases, 0^0, 1^∞, etc.). For general non-integer exponents we fall back to exp (b * log a) on positive bases.

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

@[implicit_reducible]

Context instance so the spec layer can execute with IEEE32Exec scalars.