TorchLean API

NN.MLTheory.CROWN.Proofs.Distillation

Distillation / Equivalence certificates (MLP2) #

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 deliberately 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 all pointwise differences x - y with x ∈ T, y ∈ 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.checkEquivalenceMlp2 {inDim hidDim outDim : } (teacher student : MLP2 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_mlp2_sound {inDim hidDim outDim : } (teacher student : MLP2 inDim hidDim outDim) (xB : Box (Spec.Shape.dim inDim Spec.Shape.scalar)) (eps : ) (hcheck : checkEquivalenceMlp2 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 checkEquivalence_mlp2 returns true, then for all inputs x in xB, the outputs are eps-close componentwise: |T(x)_i - S(x)_i| ≤ eps.