Documentation

LeanMlir.Proofs.Float.FloatSubnormalBridge

ℝ → Float32 bridge: the subnormal floor, closed as a lemma (not a caveat) #

FloatBridge.lean's FloatModel carries the unconditional relative-error axiom |rnd x − x| ≤ u·|x|, true for IEEE-754 binary32 round-to-nearest only on the normal range (its docstring flags the subnormal absolute-error term as future work; planning/archive/floatbridge_certificate_gaps.md §2). Near 0 the real bound is |rnd x − x| ≤ u·|x| + η, a gradual-underflow floor η ≈ 2⁻¹⁵⁰ (½ ULP at the smallest subnormal). Deep activations can underflow, so the clean relative model is, strictly, a TRUSTED simplification.

This file closes that gap the way the plan recommends — not by polluting every downstream budget with an η term, but by proving activations stay normal so the clean relative model genuinely applies, and by showing the residual floor (for the genuinely-near-zero coordinates the invariant does not cover) is globally negligible.

The arc:

3-axiom clean (no sorry, no project axioms) — like the rest of the bridge.

noncomputable def Proofs.minNormalF32 :

Smallest positive normal binary32 magnitude, 2⁻¹²⁶. Below this the relative model degrades into gradual underflow.

Equations
Instances For
    noncomputable def Proofs.subFloorF32 :

    The round-to-nearest subnormal absolute-error floor, ½·2⁻¹⁴⁹ = 2⁻¹⁵⁰: the largest |rnd x − x| can be in/under the subnormal range.

    Equations
    Instances For

      The honest rounding model. A real IEEE round-to-nearest operator: the clean relative bound holds on the normal range (err_rel), and the honest gradual-underflow absolute floor η holds everywhere (err_abs), with rnd 0 = 0 exact. The idealized FloatModel is its η = 0 face.

      Instances For

        The exact rounder (rnd = id, u = η = 0) inhabits the interface — every bound collapses to 0, like FloatBridge's exactModel.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          FloatModel is the no-underflow face. With the floor η = 0 the honest model's err_abs becomes the unconditional relative bound — i.e. it is a FloatModel. This is the exact sense in which FloatModel is "binary32 on the normal range": the stays-normal / η→0 limit of the honest model, so every bridge bound proved against FloatModel is the normal-range truth.

          Equations
          Instances For

            Normal-domain recovery. On a normal argument (x = 0, which rounds exactly, or minNormal ≤ |x|) the honest bound collapses to the clean FloatModel.err |rnd x − x| ≤ u·|x| — no η. So provided activations stay normal, the whole bridge's relative-error model applies verbatim.

            theorem Proofs.bnDenom_normal (F : FaithfulFloatModel) {ε var : } ( : F.minNormal ε) (hvar : 0 var) :
            F.minNormal |var + ε|

            Stays-normal — the BN/LN denominator. var + ε (var ≥ 0, ε ≥ minNormal) is minNormal: the normalization denominator is in the normal range, so rounding it sits in the clean relative regime.

            theorem Proofs.bnSqrt_normal (F : FaithfulFloatModel) {ε var : } ( : F.minNormal ε) (hvar : 0 var) :
            F.minNormal |(var + ε)|

            Stays-normal — the standard deviation √(var+ε). Also minNormal (using minNormal ≤ 1, so minNormal² ≤ minNormal ≤ var+ε). The argument the rsqrt keystone consumes is normal.

            theorem Proofs.istd_ge_minNormal (F : FaithfulFloatModel) {ε var : } (hpos : 0 < var + ε) (hub : (var + ε) F.minNormal⁻¹) :
            F.minNormal 1 / (var + ε)

            Stays-normal — the inverse standard deviation istd = 1/√(var+ε). With a mild a-priori upper bound on the denominator's root (√(var+ε) ≤ minNormal⁻¹, i.e. var+ε ≤ 2²⁵² — always true for O(1) activations), istd ≥ minNormal. The lower bound is the subnormal-relevant one (the upper side is overflow, a separate maxNormal concern). So the BN istd the bridge rounds never underflows.

            theorem Proofs.subFloor_total_negligible (n : ) (hn : n 2 ^ 64) :
            n * subFloorF32 (2 ^ 86)⁻¹

            The subnormal floor cannot move any bound. Even if every one of n rounded quantities underflowed into the subnormal range, the total extra error is n · subFloorF32. For n ≤ 2⁶⁴ (vastly more ops than any net in the suite), this is ≤ 2⁻⁸⁶ — below every nonzero closeness budget that appears. So the genuinely-near-zero coordinates the stays-normal invariant does not cover (post-ReLU tiny values, softmax tails) are harmless.