Documentation

LeanMlir.Proofs.Certificates.LipschitzCert.Instance

A concrete instantiation of the Lipschitz-margin certified radius #

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.

Fixed-weight networks whose Lipschitz constant is proved in Lean (no power iteration, no hypothesis), whose margin at a concrete input is computed in-kernel, and whose certified radius is provably positive.

Three instances:

Fixed 2×2 weight matrix: logits (3x₀, 4x₁). Frobenius norm exactly 5.

Equations
Instances For

    The concrete input x = e₀.

    Equations
    Instances For

      Margin computed in-kernel: logits at xlin are (3, 0), so class 0 leads by 3.

      The certified radius is strictly positive — the certificate is non-vacuous. Numerically 3/(√2·5) ≈ 0.424.

      theorem Proofs.LipschitzCertDemo.linear_demo_certified (δ : EuclideanSpace ℝ (Fin 2)) (hδ : ‖δ‖ < 3 / (√2 * 5)) (j : Fin 2) :
      j ≠ 0 → (denseE Wlin (xlin + δ)).ofLp j < (denseE Wlin (xlin + δ)).ofLp 0

      The instantiated Tsuzuku certificate (linear). Every L2 perturbation of norm < 3/(√2·5) of the concrete input leaves class 0 the strict argmax of the concrete network x ↦ (3x₀, 4x₁).

      Hidden layer: identity mixing (Frobenius √2 ≤ 2).

      Equations
      Instances For

        Output layer: (2h₀, h₁) (Frobenius √5 ≤ 3).

        Equations
        Instances For

          The per-layer product certificate L = 3·(1·2) = 6, assembled by LipschitzL2.comp from proved Frobenius bounds — the certified analogue of the ∏ᵢ‖Wᵢ‖₂ product the PGD demos compute numerically.

          theorem Proofs.LipschitzCertDemo.mlp_margin (j : Fin 2) :
          j ≠ 0 → 2 ≤ (mlp xlin).ofLp 0 - (mlp xlin).ofLp j

          Margin computed in-kernel through the whole MLP: forward of e₀ is (1,0) ↦ relu (1,0) = (1,0) ↦ (2,0), so class 0 leads by 2.

          theorem Proofs.LipschitzCertDemo.mlp_demo_certified (δ : EuclideanSpace ℝ (Fin 2)) (hδ : ‖δ‖ < 2 / (√2 * 6)) (j : Fin 2) :
          j ≠ 0 → (mlp (xlin + δ)).ofLp j < (mlp (xlin + δ)).ofLp 0

          The instantiated Tsuzuku certificate (MLP). Every L2 perturbation of norm < 2/(√2·6) ≈ 0.236 leaves class 0 the strict argmax of the concrete dense→ReLU→dense network — kink and all: the certificate is architecture-agnostic, no smoothness hypotheses needed.

          Trained hidden-layer weights (8×49), entries k/128.

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

            Trained output-layer weights (10×8), entries k/128.

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

              MNIST test image #1895 (digit 2), 4×4-average-pooled: exact pixel sums over 4080 (= 255·16).

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                noncomputable def Proofs.LipschitzCertDemo.hpreVals :
                Fin 8 → ℝ

                Exact hidden pre-activations of xt (denominator 128·4080).

                Equations
                Instances For

                  Frobenius² of W1t is ≤ C₁² for C₁ = 2911/200 ≈ ‖W1t‖_F.

                  Product certificate for the trained net: L = C₂·(1·C₁) = 2651921/12500.

                  theorem Proofs.LipschitzCertDemo.xt_margin (j : Fin 10) :
                  j ≠ 2 → 6953 / 500 ≤ (mlpT xt).ofLp 2 - (mlpT xt).ofLp j

                  In-kernel margin: class 2 leads every other class at xt by ≥ 6953/500.

                  theorem Proofs.LipschitzCertDemo.trained_radius_pos :
                  0 < 6953 / 500 / (√2 * (2651921 / 12500))
                  theorem Proofs.LipschitzCertDemo.trained_demo_certified (δ : EuclideanSpace ℝ (Fin 49)) (hδ : ‖δ‖ < 6953 / 500 / (√2 * (2651921 / 12500))) (j : Fin 10) :
                  j ≠ 2 → (mlpT (xt + δ)).ofLp j < (mlpT (xt + δ)).ofLp 2

                  The Tsuzuku certificate at TRAINED weights. Every L2 perturbation of the pooled MNIST digit-2 with ‖δ‖ < 13.906/(√2·212.154) ≈ 0.0463 leaves class 2 the strict argmax of the trained, rationalized network.

                  Exact Gram matrix G1t = W1t·W1tᵀ (8×8, denominators 128² = 16384).

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

                    Exact Gram matrix G2t = W2t·W2tᵀ (10×10).

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      theorem Proofs.LipschitzCertDemo.G1t_eq (a b : Fin 8) :
                      G1t a b = ∑ j : Fin 49, W1t a j * W1t b j
                      theorem Proofs.LipschitzCertDemo.G2t_eq (a b : Fin 10) :
                      G2t a b = ∑ j : Fin 8, W2t a j * W2t b j

                      Schatten-4 Lipschitz bound for the hidden layer: B₁ = 46/5 ≈ (Σσ⁴)^(1/4).

                      The tightened product certificate: L = B₂·(1·B₁) = 222203/2500.

                      theorem Proofs.LipschitzCertDemo.trained_radius_gram_pos :
                      0 < 6953 / 500 / (√2 * (222203 / 2500))
                      theorem Proofs.LipschitzCertDemo.trained_demo_certified_gram (δ : EuclideanSpace ℝ (Fin 49)) (hδ : ‖δ‖ < 6953 / 500 / (√2 * (222203 / 2500))) (j : Fin 10) :
                      j ≠ 2 → (mlpT (xt + δ)).ofLp j < (mlpT (xt + δ)).ofLp 2

                      The tightened trained certificate. Same trained net, same margin, the Gram bound in place of Frobenius: every ‖δ‖ < 13.906/(√2·88.88) ≈ 0.1106 (2.4× the Frobenius radius) leaves the prediction fixed.

                      Rationalized power-iteration vector for W1t (top right-singular direction ×1000).

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

                        Rationalized power-iteration vector for W2t.

                        Equations
                        Instances For

                          Certified lower bound: ANY L with LipschitzL2 L (denseE W1t) is ≥ 1863/250. With W1t_lip_gram : LipschitzL2 9.2 …, the true ‖W1t‖₂ is sandwiched in [7.452, 9.2] — the Gram bound is provably ≤ 1.235× optimal.

                          H1t = G1t² (= G1tᵀ·G1t, 8×8, denominators 16384² = 268435456).

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              theorem Proofs.LipschitzCertDemo.H1t_eq (a b : Fin 8) :
                              H1t a b = ∑ c : Fin 8, G1t c a * G1t c b
                              theorem Proofs.LipschitzCertDemo.H2t_eq (a b : Fin 10) :
                              H2t a b = ∑ c : Fin 10, G2t c a * G2t c b

                              Schatten-8 bound: B₁' = 7769/1000 ≈ (Σσ⁸)^(1/8) (true σ₁ ≈ 7.4525).

                              Schatten-8 product certificate: L = B₂'·(1·B₁') = 63791259/1000000 ≈ 63.79 — vs the certified lower bounds ℓ₁·ℓ₂ = 57.38, provably within 11.2% of the per-layer-optimal product.

                              theorem Proofs.LipschitzCertDemo.trained_radius_gram2_pos :
                              0 < 6953 / 500 / (√2 * (63791259 / 1000000))
                              theorem Proofs.LipschitzCertDemo.trained_demo_certified_gram2 (δ : EuclideanSpace ℝ (Fin 49)) (hδ : ‖δ‖ < 6953 / 500 / (√2 * (63791259 / 1000000))) (j : Fin 10) :
                              j ≠ 2 → (mlpT (xt + δ)).ofLp j < (mlpT (xt + δ)).ofLp 2

                              Schatten-8 trained certificate: radius ≈ 0.1541 (3.3× Frobenius, 1.4× Schatten-4; the true-σ ceiling for the product method is 0.171).

                              Each logit of the trained pooled-MNIST MLP is continuous: the coordinate formula ∑ k, W2ⱼₖ·max(∑ l, W1ₖₗ·xₗ, 0) is definitional.