Documentation

LeanMlir.Proofs.Certificates.LipschitzCertFloat

The robustness certificate composed with the float bridge #

REDUCED CERTIFICATE MODEL — this file's concrete net is the 4×4-pooled 49-dim MNIST family (width-8 hidden, /128–/256 rational weights), NOT the canonical 784→512→512→10 mlpVerified; chosen so every margin/norm/SOS check is exact rational arithmetic in-kernel. Canonical surface: Proofs/MlpCanonical.lean.

The 2026-07-02 audit's gap #1, closed: the scorecard's per-image Lipschitz- margin certificates (LipschitzCertScorecard.lean, exact-ℝ net) composed with the FloatBridge forward budgets, certifying the FLOAT-EVALUATED capped net.

For each image below: for every L2 perturbation ‖δ‖ < ε = 1/10 and every rounded input y within u32·(11/10) of img + δ coordinatewise (covering input quantization), the rounded two-layer forward M.mlp2F — for any rounding model M at binary32 accuracy or better (M.u ≤ u32) — keeps the true class the strict argmax.

The composition is pure margin arithmetic (certified_at_eps_close): the Tsuzuku gap at img + δ is at least m − √2·L·ε; the 2-layer float budget B ≤ ((14899 : ℝ)/2500000) (γ-form layerBudget chain at the capped net's exact magnitude bounds |W1s| ≤ ((475 : ℝ)/256), |W2s| ≤ ((129 : ℝ)/64), inputs ≤ 11/10) perturbs each logit by at most B, so any margin clearing (14143/10000)·L·ε + 2·B ≈ 2.8066 (vs the ℝ-only threshold ≈ 2.7947) keeps the float argmax: 33/34 of the ℝ-certified images survive the float widening (dropped: [41]).

Theorem vs. measurement — read this before quoting a number. Soundness lives in the ENGINE below (certified_at_eps_close + certifiedFloat_of_margin, proved once) — kernel-checking the 57th image buys nothing the 56th didn't. The 33/34 above is an exact-rational MEASUREMENT; the first 8 surviving images (test-set order — an unbiased, reproducible rule) each carry a certifiedC<i>_float THEOREM. Each such block re-checks all 49 coordinates by fin_cases, which is what this file costs on every proof push.

What this does NOT close (unchanged trust boundary, Binary32Instance.lean): the kernel↔model gap — FMA contraction, reduction reassociation, "the GPU rounds like rndP" — and rndP's overflow/subnormal idealization.

Generated by scripts/lipschitz_cert_float.py from the committed scorecard data; weights/images/margins are DATA here.

noncomputable def Proofs.FloatModel.mlp2F (M : FloatModel) {d₀ d₁ d₂ : } (W₀ : Mat d₀ d₁) (b₀ : Vec d₁) (W₁ : Mat d₁ d₂) (b₁ : Vec d₂) (x : Vec d₀) :
Vec d₂

The rounded 2-layer MLP forward: rounded dense, bare (exact) relu, rounded dense — the 2-layer face of mlpF.

Equations
Instances For
    theorem Proofs.FloatModel.mlp2_float_close_uniform (M : FloatModel) {d₀ d₁ d₂ : } {W₀ : Mat d₀ d₁} {b₀ : Vec d₁} {W₁ : Mat d₁ d₂} {b₁ : Vec d₂} {x y : Vec d₀} {w₀ β₀ w₁ β₁ a ein : } (hw₀ : 0 w₀) (hβ₀ : 0 β₀) (hw₁ : 0 w₁) (ha : 0 a) (hein : 0 ein) (hW₀ : ∀ (i : Fin d₀) (j : Fin d₁), |W₀ i j| w₀) (hb₀ : ∀ (j : Fin d₁), |b₀ j| β₀) (hW₁ : ∀ (i : Fin d₁) (j : Fin d₂), |W₁ i j| w₁) (hb₁ : ∀ (j : Fin d₂), |b₁ j| β₁) (hx : ∀ (i : Fin d₀), |x i| a) (hy : ∀ (i : Fin d₀), |y i - x i| ein) (k : Fin d₂) :
    |M.mlp2F W₀ b₀ W₁ b₁ y k - Proofs.dense W₁ b₁ (relu d₁ (Proofs.dense W₀ b₀ x)) k| layerBudget M.u d₁ w₁ β₁ (layerAct d₀ w₀ β₀ a) (layerBudget M.u d₀ w₀ β₀ a ein)

    2-layer MLP forward error, uniform budgets, quantized input. If the device input y is within ein of the real input x coordinatewise (input quantization), every rounded logit is within the closed-form 2-layer layerBudget chain of the exact-ℝ logit. The 2-layer face of mlp_float_close_uniform, with the fresh-input e = 0 generalized to e = ein.

    theorem Proofs.LipschitzCertDemo.certified_at_eps_close {n k : } {L m ε B : } {f : EuclideanSpace (Fin n)EuclideanSpace (Fin k)} (hf : LipschitzL2 L f) (hL : 0 < L) {x : EuclideanSpace (Fin n)} {i : Fin k} (hmargin : ∀ (j : Fin k), j im (f x).ofLp i - (f x).ofLp j) (hclear : 14143 / 10000 * L * ε + 2 * B < m) (hε0 : 0 ε) (_hB0 : 0 B) (δ : EuclideanSpace (Fin n)) ( : δ < ε) (z' : Fin k) (hz' : ∀ (j : Fin k), |z' j - (f (x + δ)).ofLp j| B) (j : Fin k) :
    j iz' j < z' i

    The certificate composed with a per-logit evaluation budget. If the ℝ logit map is L-Lipschitz with margin m at x, and the margin clears the float-widened threshold (14143/10000)·L·ε + 2·B, then ANY evaluation z' within B of the ℝ logits at x + δ keeps class i the strict argmax — for every ‖δ‖ < ε. Pure margin arithmetic; z' is the deployed (rounded) forward.

    noncomputable def Proofs.LipschitzCertDemo.W1sV :
    Mat 49 8

    Capped hidden weights in the Mat (input×output) convention.

    Equations
    Instances For
      noncomputable def Proofs.LipschitzCertDemo.zb8 :
      Vec 8
      Equations
      Instances For
        noncomputable def Proofs.LipschitzCertDemo.zb10 :
        Vec 10
        Equations
        Instances For
          theorem Proofs.LipschitzCertDemo.W1sV_abs_le (i : Fin 49) (j : Fin 8) :
          |W1sV i j| 475 / 256
          theorem Proofs.LipschitzCertDemo.W2sV_abs_le (i : Fin 8) (j : Fin 10) :
          |W2sV i j| 129 / 64
          theorem Proofs.LipschitzCertDemo.real_tie (y : EuclideanSpace (Fin 49)) (k : Fin 10) :
          dense W2sV zb10 (relu 8 (dense W1sV zb8 fun (c : Fin 49) => y.ofLp c)) k = (mlpS y).ofLp k

          The Vec-space real forward IS mlpS, coordinatewise (transposed convention, zero biases, relu = reluE).

          theorem Proofs.LipschitzCertDemo.capped_E0_nonneg (M : FloatModel) :
          0 FloatModel.layerBudget M.u 49 (475 / 256) 0 (11 / 10) (u32 * (11 / 10))
          theorem Proofs.LipschitzCertDemo.capped_E0_le (M : FloatModel) (hMu : M.u u32) :
          FloatModel.layerBudget M.u 49 (475 / 256) 0 (11 / 10) (u32 * (11 / 10)) 38747 / 125000000

          Layer-0 budget at the capped-net magnitudes, with the input-quantization error u32·(11/10) inherited.

          theorem Proofs.LipschitzCertDemo.capped_B_le (M : FloatModel) (hMu : M.u u32) :
          FloatModel.layerBudget M.u 8 (129 / 64) 0 (FloatModel.layerAct 49 (475 / 256) 0 (11 / 10)) (FloatModel.layerBudget M.u 49 (475 / 256) 0 (11 / 10) (u32 * (11 / 10))) 14899 / 2500000

          The whole 2-layer budget: every rounded logit within ((14899 : ℝ)/2500000).

          theorem Proofs.LipschitzCertDemo.certifiedFloat_of_margin (M : FloatModel) (hMu : M.u u32) (x : EuclideanSpace (Fin 49)) (hx1 : ∀ (c : Fin 49), |x.ofLp c| 1) {i : Fin 10} {m : } (hmargin : ∀ (j : Fin 10), j im (mlpS x).ofLp i - (mlpS x).ofLp j) (hclear : 14143 / 10000 * (19760433 / 1000000) * (1 / 10) + 2 * (14899 / 2500000) < m) (δ : EuclideanSpace (Fin 49)) ( : δ < 1 / 10) (y : Vec 49) (hy : ∀ (c : Fin 49), |y c - (x + δ).ofLp c| u32 * (11 / 10)) (j : Fin 10) :
          j iM.mlp2F W1sV zb8 W2sV zb10 y j < M.mlp2F W1sV zb8 W2sV zb10 y i

          The composed per-image engine: margin clears the float-widened threshold ⇒ the rounded forward of any quantized perturbed input keeps the class.

          theorem Proofs.LipschitzCertDemo.certifiedC0_float (M : FloatModel) (hMu : M.u u32) (δ : EuclideanSpace (Fin 49)) ( : δ < 1 / 10) (y : Vec 49) (hy : ∀ (c : Fin 49), |y c - (img0 + δ).ofLp c| u32 * (11 / 10)) (j : Fin 10) :
          j 7M.mlp2F W1sV zb8 W2sV zb10 y j < M.mlp2F W1sV zb8 W2sV zb10 y 7

          Float-certified at ε = 1/10 (image #0): every binary32-accuracy rounded forward of every quantized input within the L2 ball keeps class 7 the strict argmax.

          theorem Proofs.LipschitzCertDemo.certifiedC3_float (M : FloatModel) (hMu : M.u u32) (δ : EuclideanSpace (Fin 49)) ( : δ < 1 / 10) (y : Vec 49) (hy : ∀ (c : Fin 49), |y c - (img3 + δ).ofLp c| u32 * (11 / 10)) (j : Fin 10) :
          j 0M.mlp2F W1sV zb8 W2sV zb10 y j < M.mlp2F W1sV zb8 W2sV zb10 y 0

          Float-certified at ε = 1/10 (image #3): every binary32-accuracy rounded forward of every quantized input within the L2 ball keeps class 0 the strict argmax.

          theorem Proofs.LipschitzCertDemo.certifiedC5_float (M : FloatModel) (hMu : M.u u32) (δ : EuclideanSpace (Fin 49)) ( : δ < 1 / 10) (y : Vec 49) (hy : ∀ (c : Fin 49), |y c - (img5 + δ).ofLp c| u32 * (11 / 10)) (j : Fin 10) :
          j 1M.mlp2F W1sV zb8 W2sV zb10 y j < M.mlp2F W1sV zb8 W2sV zb10 y 1

          Float-certified at ε = 1/10 (image #5): every binary32-accuracy rounded forward of every quantized input within the L2 ball keeps class 1 the strict argmax.

          theorem Proofs.LipschitzCertDemo.certifiedC10_float (M : FloatModel) (hMu : M.u u32) (δ : EuclideanSpace (Fin 49)) ( : δ < 1 / 10) (y : Vec 49) (hy : ∀ (c : Fin 49), |y c - (img10 + δ).ofLp c| u32 * (11 / 10)) (j : Fin 10) :
          j 0M.mlp2F W1sV zb8 W2sV zb10 y j < M.mlp2F W1sV zb8 W2sV zb10 y 0

          Float-certified at ε = 1/10 (image #10): every binary32-accuracy rounded forward of every quantized input within the L2 ball keeps class 0 the strict argmax.

          theorem Proofs.LipschitzCertDemo.certifiedC13_float (M : FloatModel) (hMu : M.u u32) (δ : EuclideanSpace (Fin 49)) ( : δ < 1 / 10) (y : Vec 49) (hy : ∀ (c : Fin 49), |y c - (img13 + δ).ofLp c| u32 * (11 / 10)) (j : Fin 10) :
          j 0M.mlp2F W1sV zb8 W2sV zb10 y j < M.mlp2F W1sV zb8 W2sV zb10 y 0

          Float-certified at ε = 1/10 (image #13): every binary32-accuracy rounded forward of every quantized input within the L2 ball keeps class 0 the strict argmax.

          theorem Proofs.LipschitzCertDemo.certifiedC14_float (M : FloatModel) (hMu : M.u u32) (δ : EuclideanSpace (Fin 49)) ( : δ < 1 / 10) (y : Vec 49) (hy : ∀ (c : Fin 49), |y c - (img14 + δ).ofLp c| u32 * (11 / 10)) (j : Fin 10) :
          j 1M.mlp2F W1sV zb8 W2sV zb10 y j < M.mlp2F W1sV zb8 W2sV zb10 y 1

          Float-certified at ε = 1/10 (image #14): every binary32-accuracy rounded forward of every quantized input within the L2 ball keeps class 1 the strict argmax.

          theorem Proofs.LipschitzCertDemo.certifiedC17_float (M : FloatModel) (hMu : M.u u32) (δ : EuclideanSpace (Fin 49)) ( : δ < 1 / 10) (y : Vec 49) (hy : ∀ (c : Fin 49), |y c - (img17 + δ).ofLp c| u32 * (11 / 10)) (j : Fin 10) :
          j 7M.mlp2F W1sV zb8 W2sV zb10 y j < M.mlp2F W1sV zb8 W2sV zb10 y 7

          Float-certified at ε = 1/10 (image #17): every binary32-accuracy rounded forward of every quantized input within the L2 ball keeps class 7 the strict argmax.

          theorem Proofs.LipschitzCertDemo.certifiedC25_float (M : FloatModel) (hMu : M.u u32) (δ : EuclideanSpace (Fin 49)) ( : δ < 1 / 10) (y : Vec 49) (hy : ∀ (c : Fin 49), |y c - (img25 + δ).ofLp c| u32 * (11 / 10)) (j : Fin 10) :
          j 0M.mlp2F W1sV zb8 W2sV zb10 y j < M.mlp2F W1sV zb8 W2sV zb10 y 0

          Float-certified at ε = 1/10 (image #25): every binary32-accuracy rounded forward of every quantized input within the L2 ball keeps class 0 the strict argmax.