TorchLean API

FloatLib.Floats.Formats.IEEE754.Native.Representation

Native values through the shared representation bridge #

Lean has named NaN and infinity constants alongside its logical floating-point models, and we're glad it is making more of this model available for proofs. Here we connect those constants and the ofFloat / toFloat adapters to the same packed-model proofs used for arithmetic and integer conversion.

Every native value round-trips. In the other direction, a FloatLib word may carry a NaN payload that Lean's model does not retain, and Model.canonicalizeModel describes that change. Finite values, infinities, and both signed zeros keep their bits.

Binary32 #

@[simp]

Importing a native value reads the word in its logical binary32 model.

Exporting binary32 uses the shared packed-model conversion, including NaN normalization.

An imported native binary32 value already satisfies Lean's canonical-NaN invariant.

@[simp]

Importing and then exporting a native binary32 value gives it back.

Binary64 #

@[simp]

Importing a native value reads the word in its logical binary64 model.

Exporting binary64 uses the shared packed-model conversion, including NaN normalization.

An imported native binary64 value already satisfies Lean's canonical-NaN invariant.

@[simp]

Importing and then exporting a native binary64 value gives it back.