Exact rational reflection for algebraic certificates #
These lemmas connect executable rational tensor arithmetic to the existing real-valued tensor semantics. No floating-point rounding or transcendental approximation is involved.
@[instance_reducible]
Rational certificate arithmetic is exact, including affine reassociation.
Instances For
@[instance_reducible]
The rational arithmetic dictionary satisfies the real enclosure laws.
Instances For
noncomputable def
NN.Verification.Cert.RationalReflection.realTensor
{s : Spec.Shape}
(t : TorchLean.Tensor ℚ s)
:
Interpret each rational tensor entry as a real number.
Instances For
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realTensor_get
{n : ℕ}
{s : Spec.Shape}
(t : TorchLean.Tensor ℚ (Spec.Shape.dim n s))
(i : Fin n)
:
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realTensor_getScalar
{n : ℕ}
(t : TorchLean.Tensor ℚ [n])
(i : Fin n)
:
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realTensor_get2
{m n : ℕ}
(t : TorchLean.Tensor ℚ [m, n])
(i : Fin m)
(j : Fin n)
:
@[simp]
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realTensor_add
{s : Spec.Shape}
(a b : TorchLean.Tensor ℚ s)
:
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realTensor_matVecMul
{m n : ℕ}
(a : TorchLean.Tensor ℚ [m, n])
(b : TorchLean.Tensor ℚ [n])
:
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realTensor_matMul
{m n p : ℕ}
(a : TorchLean.Tensor ℚ [m, n])
(b : TorchLean.Tensor ℚ [n, p])
:
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realTensor_matPos
{m n : ℕ}
(w : TorchLean.Tensor ℚ [m, n])
:
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realTensor_matNeg
{m n : ℕ}
(w : TorchLean.Tensor ℚ [m, n])
:
noncomputable def
NN.Verification.Cert.RationalReflection.realBox
{s : Spec.Shape}
(b : MLTheory.CROWN.Box ℚ s)
:
Interpret both endpoints of a rational box over the reals.
Instances For
noncomputable def
NN.Verification.Cert.RationalReflection.realFlatBox
(b : MLTheory.CROWN.FlatBox ℚ)
:
Interpret a dimension-carrying rational box over the reals.
Instances For
noncomputable def
NN.Verification.Cert.RationalReflection.realAffine
{n m : ℕ}
(a : MLTheory.CROWN.AffineVec ℚ n m)
:
Interpret the coefficients of an exact affine form.
Instances For
noncomputable def
NN.Verification.Cert.RationalReflection.realAffineBounds
(b : MLTheory.CROWN.Graph.FlatAffineBounds ℚ)
:
Interpret a pair of exact affine bounds.
Instances For
@[simp]
theorem
NN.Verification.Cert.RationalReflection.castAffineOut_self
{α : Type}
[Context α]
{n m : ℕ}
(a : MLTheory.CROWN.AffineVec α n m)
(h : m = m)
:
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realAffineBounds_linear
{n m : ℕ}
(w : TorchLean.Tensor ℚ [m, n])
(bias : TorchLean.Tensor ℚ [m])
(b : MLTheory.CROWN.Graph.FlatAffineBounds ℚ)
(h : b.outDim = n)
:
realAffineBounds (MLTheory.CROWN.Cert.linearBoundsFromAffine w bias b h ⋯) = MLTheory.CROWN.Cert.linearBoundsFromAffine (realTensor w) (realTensor bias) (realAffineBounds b) h ⋯
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realAffineBounds_const
(n m : ℕ)
(lo hi : TorchLean.Tensor ℚ [m])
:
realAffineBounds (MLTheory.CROWN.Cert.boundsConst n m lo hi) = MLTheory.CROWN.Cert.boundsConst n m (realTensor lo) (realTensor hi)
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realTensor_relu
{s : Spec.Shape}
(t : TorchLean.Tensor ℚ s)
:
noncomputable def
NN.Verification.Cert.RationalReflection.realRelax
(r : MLTheory.CROWN.Runtime.Ops.ReLURelax ℚ)
:
Interpret the slope and offset of a ReLU relaxation exactly.
Instances For
@[simp]
@[simp]
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realRelax_upperVec
{n : ℕ}
(lo hi : TorchLean.Tensor ℚ [n])
:
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realRelax_lowerVec
{n : ℕ}
(lo hi alpha : TorchLean.Tensor ℚ [n])
:
TorchLean.Tensor.map realRelax (MLTheory.CROWN.Cert.alphaRelaxLowerVec lo hi alpha) = MLTheory.CROWN.Cert.alphaRelaxLowerVec (realTensor lo) (realTensor hi) (realTensor alpha)
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realAffine_propagate
{n m : ℕ}
(r : TorchLean.Tensor (MLTheory.CROWN.Runtime.Ops.ReLURelax ℚ) [m])
(a : MLTheory.CROWN.AffineVec ℚ n m)
:
@[simp]
theorem
NN.Verification.Cert.RationalReflection.realBox_linear
{m n : ℕ}
(w : TorchLean.Tensor ℚ [m, n])
(x : MLTheory.CROWN.Box ℚ [n])
(bias : MLTheory.CROWN.Box ℚ [m])
:
realBox (MLTheory.CROWN.IBP.linear w x bias) = MLTheory.CROWN.IBP.linear (realTensor w) (realBox x) (realBox bias)