TorchLean API

FloatLib.Floats.Formats.IEEE754.Native.Model.Representation

Canonical representations in Lean's floating-point model #

The bridge uses the conventional IEEE interpretation of the exponent and fraction widths. Packing an unpacked value need not preserve an arbitrary mantissa and exponent, but unpacking packed bits always gives a representable value. Repacking those values preserves every bit except the sign and payload of a noncanonical NaN.

A valid packed value is recovered exactly after unpacking and repacking.

Canonicalization fixes precisely the bit patterns admitted by Lean's packed model.

@[simp]

Canonical packed words round-trip exactly through the unpacked model.

@[simp]

A second canonicalization leaves the result unchanged.

@[simp]

Values packed from the unpacked model are already canonical.

@[simp]

Canonicalization preserves the entire unpacked value, including the sign of zero.

Equality after unpacking is exactly equality of canonical packed representations. Operation refinement proofs may therefore use either form of the representation relation.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.eq_of_toModel_eq {fmt : FloatFormat} {left right : Model fmt} (hleft : left.IsModelCanonical) (hright : right.IsModelCanonical) (h : left.toModel = right.toModel) :
left = right

The unpacked interpretation is injective on canonical packed representations.