TorchLean API

NN.Floats.IEEEExec.BridgeFP32Total

BridgeFP32Total #

“Total” bridge theorems combining:

The key end-user view is toReal?:

In most of TorchLean, the finite path is treated as real arithmetic + float32 rounding while special-value behavior is kept explicit. This file packages that split in one place.

The per-op lemmas are phrased in the style:

toReal? (op …) = if isFinite (op …) then some (fp32Round …) else none.

That makes the trust boundary readable at the call site: the if is exactly where NaN/Inf (or overflow-to-Inf) can occur.

Background references (for float32 rounding/special values):

Basic facts: isFinitetoDyadic?/toReal? #

On finite values, toReal? x is just some (toReal x).

Helpers: NaN/Inf/zero interactions #

If dyadic decoding fails and the value is not NaN, then it must be infinite.

Per-op “finite branch” wrappers (hide dyadic witnesses) #

Addition refinement packaged for total reasoning.

Subtraction refinement packaged for total reasoning (hide dyadic witnesses).

This is the “finite-path” wrapper around BridgeFP32.toReal_sub_eq_fp32Round, replacing explicit toDyadic? witnesses with the more user-facing finiteness hypotheses.

Multiplication refinement packaged for total reasoning.

Fused multiply-add refinement packaged for total reasoning.

Square-root refinement packaged for total reasoning.

Division refinement packaged for total reasoning.

On finite values, IEEE-754 minimum agrees with real min.

On finite values, IEEE-754 maximum agrees with real max.

On finite values, compare x y = some .lt iff toReal x < toReal y.

On finite values, compare x y = some .eq iff toReal x = toReal y.

On finite values, compare x y = some .gt iff toReal y < toReal x.

“Both” view: toReal? semantics as an ite #

toReal? (add x y) as an ite over finiteness.

toReal? (mul x y) as an ite over finiteness.

toReal? (fma x y z) as an ite over finiteness.

toReal? (div x y) as an ite over finiteness.

minimum of two finite values is finite.

On finite inputs, toReal? (minimum x y) returns some (min (toReal x) (toReal y)).

maximum of two finite values is finite.

On finite inputs, toReal? (maximum x y) returns some (max (toReal x) (toReal y)).

Total packaging for minimum/maximum (covers ±Inf) #

Total characterization of toReal? (minimum x y) via toReal? x and toReal? y.

This lemma covers the cases where one side is +∞ (which acts as a neutral element for min) and the cases where toReal? is none because of NaN.

Total characterization of toReal? (maximum x y) via toReal? x and toReal? y.

This lemma covers the cases where one side is -∞ (which acts as a neutral element for max) and the cases where toReal? is none because of NaN.