TorchLean API

FloatLib.Floats.Formats.Flocq.Theory.Rounding.Affine

Executable affine quantization and real rounding #

The rational nearest-even kernel and the real nearest-even specification choose exactly the same integer, including negative inputs and half-way ties. Consequently, executable affine quantization agrees with real affine quantization before and after saturation, and exact reconstruction commutes with the rational-to-real embedding.

The rounding-independent API lives in Numerics.Quantization.Affine.Real. This module also specializes its order, round-trip, and error theorems to the existing Flocq rounding contracts.

Rational nearest-even execution agrees exactly with real nearest-even rounding.

A Flocq-valid integer rounder gives monotone affine quantization.

theorem FloatLib.Floats.Formats.Flocq.affine_quantize_dequantize (q : Numerics.Quantization.RealAffineQuantizer) (rnd : ) [ValidRnd rnd] {code : } (hlo : q.qmin code) (hhi : code q.qmax) :
q.quantize rnd (q.dequantize code) = code

Any Flocq-valid rounder preserves in-range stored codes under reconstruction and rounding.

Without saturation, every valid nearest rounder reconstructs within half a grid step.

Saturated rational execution and real nearest-even affine quantization return the same code.

Exact reconstruction agrees after the complete nearest-even quantization operation.