TorchLean API

NN.MLTheory.CROWN.Proofs.GraphCertSoundness.IntervalLemmas

Interval Soundness Lemmas #

Scalar interval arithmetic, box-cast lemmas, and point-box facts used by the graph IBP soundness induction.

Op-level soundness lemmas (enclosure for each supported step) #

These lemmas are the building blocks for the final “certificate ⇒ semantics enclosure” theorem.

This proof reuses the following existing components:

Monotonicity of real ReLU, used by interval enclosure proofs.

theorem NN.MLTheory.CROWN.Graph.CertSoundness.add_mono_real {a b c d : } :
a bc da + c b + d

Addition is monotone in both operands.

theorem NN.MLTheory.CROWN.Graph.CertSoundness.sub_mono_real {a b c d : } :
a bd ca - c b - d

Subtraction is monotone in the minuend and antitone in the subtrahend.

The runtime if a < b then a else b is min.

The runtime if a > b then a else b is max.

The implementations branch on a comparison rather than calling min/max, so these two lemmas are what let the interval proofs use the Mathlib lattice lemmas at all.

theorem NN.MLTheory.CROWN.Graph.CertSoundness.mul_const_bounds {a ly uy y : } (hy : ly y) (hy' : y uy) :
min (a * ly) (a * uy) a * y a * y max (a * ly) (a * uy)

Multiplying an interval by a constant: the product lies between the two endpoint products.

Stated with min/max instead of a case split on the sign of a, so the caller never has to know which endpoint is which.

theorem NN.MLTheory.CROWN.Graph.CertSoundness.mul_var_bounds {lx ux x y : } (hx : lx x) (hx' : x ux) :
min (lx * y) (ux * y) x * y x * y max (lx * y) (ux * y)

The same, with the interval on the left and the constant on the right.

theorem NN.MLTheory.CROWN.Graph.CertSoundness.interval_mul_bounds {lx ux ly uy x y : } (hx : lx x) (hx' : x ux) (hy : ly y) (hy' : y uy) :
min (min (lx * ly) (lx * uy)) (min (ux * ly) (ux * uy)) x * y x * y max (max (lx * ly) (lx * uy)) (max (ux * ly) (ux * uy))

Interval multiplication: the product of two bounded values lies between the min and the max of the four endpoint products.

This is the classical four-corner rule. All four products are needed because signs can differ, and taking min and max of the corners is exactly tight for real multiplication.

Helpers: our bound propagation uses BoundOps.min2/max2, which are defined via decide (a > b). For these coincide with min/max.

The bound-arithmetic max2 is max over .

theorem NN.MLTheory.CROWN.Graph.CertSoundness.box_mulElem_sound_real (n : ) (lo1 hi1 lo2 hi2 x y : TorchLean.Tensor [n]) (hx : encloses { dim := n, lo := lo1, hi := hi1 } x) (hy : encloses { dim := n, lo := lo2, hi := hi2 } y) {B : FlatBox } :
boxMulElem { dim := n, lo := lo1, hi := hi1 } { dim := n, lo := lo2, hi := hi2 } = some BEnclosesBox B { n := n, v := x.mulSpec y }

Elementwise interval multiplication of two boxes is sound.

Coordinatewise this is interval_mul_bounds; the box wrapper adds the dimension check, which is why the conclusion is about whatever box boxMulElem actually returned.

Casting lemmas (avoid cases on B.dim = v.n) #

FlatBox and FlatTensor carry their dimensions in dependent types, so it is tempting to cases equalities like h : B.dim = v.n to “align” types. In Lean this can easily trigger dependent elimination failures when the equality mentions fields of dependent records.

Instead, we keep such equalities as data and move tensors/boxes across them using castDimScalar / castBoxDim. The following small lemmas are proved once (by cases on fresh Nat equalities) and then used throughout the main proof without ever cases-ing on B.dim = v.n directly.

theorem NN.MLTheory.CROWN.Graph.CertSoundness.castDimScalar_trans {n n' n'' : } (h₁ : n = n') (h₂ : n' = n'') (t : TorchLean.Tensor [n]) :

Dimension casts commute with elementwise maps.

Dimension casts commute with addition.

Dimension casts commute with subtraction.

Dimension casts commute with elementwise multiplication.

Casting a box and a point along the same equality does not change containment.

theorem NN.MLTheory.CROWN.Graph.CertSoundness.encloses_castDim {B : FlatBox } {n' : } (h : B.dim = n') (x : TorchLean.Tensor [B.dim]) :
encloses B xencloses { dim := n', lo := castDimScalar h B.lo, hi := castDimScalar h B.hi } (castDimScalar h x)

Enclosure survives a dimension cast, which is how a box proved for one layer width is reused at the next one without ever eliminating the equality itself.

Box.contains implies encloses on the flattened box; the two are definitionally the same, and the lemma exists so proofs can change vocabulary without unfolding.

The converse direction, for the same reason.

Point Boxes Always Enclose Their Point #

This is used in the .const case, where a constant node certifies a point box [v,v] and the semantics returns exactly the same v.