TorchLean API

NN.MLTheory.CROWN.Proofs.Distillation

Distillation / Equivalence certificates (TwoLayerMLP) #

This module adds a distillation-style certificate:

prove that a Student network matches a Teacher network up to ε on an input box, i.e. |T(x) - S(x)| ≤ ε componentwise for all inputs x in the domain.

The implementation is kept simple and reuses TorchLean's existing, proved IBP soundness theorem for 2-layer MLPs (NN.MLTheory.CROWN.Theorems.bound_ibp_sound).

Small vector helpers #

Interval arithmetic on output boxes #

Interval subtraction: boxSub T S encloses every pointwise difference $x-y$ with $x\in T$ and $y\in S$.

Instances For

    Predicate asserting all coordinates of B lie in [-eps, eps].

    Instances For

      If x ∈ T and y ∈ S, then x - y ∈ boxSub T S.

      Project a Box.contains hypothesis to scalar inequalities at a single coordinate.

      Distillation certificate for 2-layer MLPs #

      noncomputable def NN.MLTheory.CROWN.Distillation.checkEquivalenceTwoLayerMlp {inDim hidDim outDim : } (teacher student : TwoLayerMLP inDim hidDim outDim) (xB : Box (Spec.Shape.dim inDim Spec.Shape.scalar)) (eps : ) :

      Computable checker: returns true if IBP proves the student matches the teacher up to eps (componentwise) on the given input box.

      Instances For
        theorem NN.MLTheory.CROWN.Distillation.checkEquivalence_twoLayerMlp_sound {inDim hidDim outDim : } (teacher student : TwoLayerMLP inDim hidDim outDim) (xB : Box (Spec.Shape.dim inDim Spec.Shape.scalar)) (eps : ) (hcheck : checkEquivalenceTwoLayerMlp teacher student xB eps = true) (x : Spec.Tensor (Spec.Shape.dim inDim Spec.Shape.scalar)) :
        xB.contains x∀ (i : Fin outDim), |((forward teacher x).subSpec (forward student x)).vecGet i| eps

        Soundness: if checkEquivalenceTwoLayerMlp returns true, then for all inputs x in xB, the outputs are eps-close componentwise: |T(x)_i - S(x)_i| ≤ eps.