TorchLean API

NN.MLTheory.Proofs.Verification.Robustness.LipschitzCertified

Lipschitz-based robustness lemmas #

This file connects Lipschitz continuity assumptions to the robustness specifications from NN.MLTheory.Robustness.Spec.

Main results (over ):

Lipschitz continuity implies adversarial robustness #

theorem NN.MLTheory.Proofs.Verification.Robustness.is_adversarially_robust_of_lipschitz {s₁ s₂ : Spec.Shape} {f : Spec.Tensor s₁Spec.Tensor s₂} {norm₁ norm₂ : {s : Spec.Shape} → Spec.Tensor s} {L : } (hL : 0 L) (hLip : Robustness.Spec.isLipschitzContinuous f (fun {s : Spec.Shape} => norm₁) (fun {s : Spec.Shape} => norm₂) L) (x₀ : Spec.Tensor s₁) (ε : ) :
Robustness.Spec.isAdversariallyRobust f (fun {s : Spec.Shape} => norm₁) (fun {s : Spec.Shape} => norm₂) x₀ ε (L * ε)

If f is L-Lipschitz and L ≥ 0, then f is adversarially robust at x₀: every input within distance ε of x₀ maps within distance L*ε of f x₀.

Bridging L2 and L∞ Lipschitz predicates #

L2-Lipschitz implies L∞-Lipschitz into logits, with the same constant.

This is the standard norm comparison ‖v‖∞ ≤ ‖v‖₂ (proved as Proofs.tensor_linf_norm_le_tensor_l2_norm).

Argmax stability from a positive logit margin #

The argmax classifier on logits vectors, breaking ties by the earliest index.

When n = 0, this returns 0 by convention.

Instances For

    HasLogitMargin y c m means class c beats every competitor by at least m in logit value.

    Instances For

      If y₀ has a positive logit margin m for class c, then any y within L∞ distance δ with 2*δ < m has the same argmax class.

      If y₀ has margin m > 0 for class c, then c is the argmaxClassifier of y₀.

      Certified robustness from a Lipschitz bound and a logit margin #

      theorem NN.MLTheory.Proofs.Verification.Robustness.is_certified_robust_of_lipschitz_of_logitMargin {s₁ : Spec.Shape} {n : } {f : Spec.Tensor s₁Spec.Tensor (Spec.Shape.dim n Spec.Shape.scalar)} {normIn : {s : Spec.Shape} → Spec.Tensor s} {L : } (hL : 0 L) (hLip : Robustness.Spec.isLipschitzContinuous f (fun {s : Spec.Shape} => normIn) (fun {s : Spec.Shape} => Robustness.Spec.tensorLinfNorm) L) {x₀ : Spec.Tensor s₁} {ε m : } {c : Fin n} (hm : 0 < m) (hmargin : HasLogitMargin (f x₀) c m) ( : 2 * (L * ε) < m) :
      Robustness.Spec.isCertifiedRobust (fun (x : Spec.Tensor s₁) => argmaxClassifier (f x)) (fun {s : Spec.Shape} => normIn) x₀ ε

      If f is L-Lipschitz into L∞ logits and the reference logits f x₀ have margin m for class c, then any input perturbation of radius ε with 2*(L*ε) < m preserves the predicted class.

      This is a standard “margin over Lipschitz constant” certified robustness lemma.

      theorem NN.MLTheory.Proofs.Verification.Robustness.is_certified_robust_of_l2_lipschitz_of_logitMargin {s₁ : Spec.Shape} {n : } {f : Spec.Tensor s₁Spec.Tensor (Spec.Shape.dim n Spec.Shape.scalar)} {normIn : {s : Spec.Shape} → Spec.Tensor s} {L : } (hL : 0 L) (hLip2 : Robustness.Spec.isLipschitzContinuous f (fun {s : Spec.Shape} => normIn) (fun {s : Spec.Shape} => Proofs.tensorL2Norm) L) {x₀ : Spec.Tensor s₁} {ε m : } {c : Fin n} (hm : 0 < m) (hmargin : HasLogitMargin (f x₀) c m) ( : 2 * (L * ε) < m) :
      Robustness.Spec.isCertifiedRobust (fun (x : Spec.Tensor s₁) => argmaxClassifier (f x)) (fun {s : Spec.Shape} => normIn) x₀ ε

      Certified robustness, but starting from an output-L2 Lipschitz assumption.

      This avoids requiring the user to manually insert the norm-equivalence step ‖·‖∞ ≤ ‖·‖₂.