TorchLean API

NN.Floats.IEEEExec.BridgeFP32.Ops

IEEE32Exec and FP32: Arithmetic Operation Refinement #

Op-level refinement theorems (finite/no-overflow) #

These are the results that the rest of TorchLean typically consumes: statements that each arithmetic operation in IEEE32Exec refines its FP32 real-rounded counterpart.

If you are coming from PyTorch: this is the “float32 math model” that underlies many informal numerical arguments (“the kernel computes the exact real result, then rounds to float32”), but made explicit and proved for our executable kernel.

Finite refinement for addition: IEEE32Exec.add = exact real add + float32 rounding.

Finite refinement for subtraction, reduced to addition + negation.

Finite refinement for multiplication: IEEE32Exec.mul = exact real mul + float32 rounding.

theorem TorchLean.Floats.IEEE754.IEEE32Exec.toReal_fma_eq_fp32Round (x y z : IEEE32Exec) {dx dy dz : Dyadic} (hx : x.toDyadic? = some dx) (hy : y.toDyadic? = some dy) (hz : z.toDyadic? = some dz) (hfin : (x.fma y z).isFinite = true) :

Finite refinement for fused multiply-add: fma x y z rounds x*y + z once at the end.

theorem TorchLean.Floats.IEEE754.IEEE32Exec.toReal_div_eq_fp32Round (x y : IEEE32Exec) {dx dy : Dyadic} (hx : x.toDyadic? = some dx) (hy : y.toDyadic? = some dy) (hy0 : dy.mant 0) (hfin : (x.div y).isFinite = true) :

Finite refinement for division.

At the executable level, division is implemented by forming an exact rational quotient num/den (after aligning dyadic exponents) and then rounding that rational to float32. This theorem states that the overall real meaning is FP32 rounding of real division.

Finite refinement for square root.

IEEE32Exec.sqrt computes an executable approximation and then rounds it to float32. This bridge theorem states that, on the finite path, the real meaning agrees with FP32 rounding of Real.sqrt.