TorchLean API

NN.MLTheory.Proofs.ReLU.Approximation.CompactSet

ReLU approximation on compact sets (nD) #

Key theorems proved in this file:

Dependencies:

ApproxOn D f means: on the domain D, the scalar function f can be uniformly approximated by a single-hidden-layer ReLU MLP (mlp_eval_nd).

Instances For

    The zero function is uniformly approximable on any domain D.

    If f and g are uniformly approximable on D, then so is f + g.

    If f is uniformly approximable on D, then so is the scalar multiple c • f.

    ApproxOnC K f means: the continuous map f : C(K,ℝ) can be uniformly approximated (on K) by a single-hidden-layer ReLU MLP (mlp_eval_nd, evaluated on the underlying point x.1).

    Instances For

      Closure properties #

      The zero continuous function is uniformly approximable on K.

      If f and g are uniformly approximable on K, then so is f + g.

      If f is uniformly approximable on K, then so is the scalar multiple c • f.

      theorem NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.ApproxOnC.sum_finset {n : } {K : Set (ReLUMlpBridge.TensorVec n)} {ι : Type} (s : Finset ι) (f : ιC(K, )) (hf : is, ApproxOnC K (f i)) :
      ApproxOnC K (∑ is, f i)

      Finite sums preserve ApproxOnC (Finset-indexed).

      theorem NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.ApproxOnC.sum_fintype {n : } {K : Set (ReLUMlpBridge.TensorVec n)} {ι : Type} [Fintype ι] (f : ιC(K, )) (hf : ∀ (i : ι), ApproxOnC K (f i)) :
      ApproxOnC K (∑ i : ι, f i)

      Finite sums preserve ApproxOnC (Fintype-indexed).

      Identify the Stone–Weierstrass coordinate subalgebra with the range of multivariate-polynomial evaluation.

      This is a small algebraic normalization lemma used to connect coordinate polynomials to MvPolynomial syntax (aeval).

      Sign associated to a Boolean: true ↦ +1, false ↦ -1.

      Instances For

        Product of signs for an assignment ε : Fin d → Bool.

        Instances For
          noncomputable def NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.signedSum {d : } (ε : Fin dBool) (u : Fin d) :

          Signed linear form ∑ i, sgn (ε i) * u i.

          Instances For

            Closed form for ∑ b : Bool, (sgn b)^k.

            For even exponents, ∑ b : Bool, (sgn b)^k = 2.

            For odd exponents, ∑ b : Bool, (sgn b)^k = 0.

            noncomputable def NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.fiberCount {d : } (p : Fin dFin d) (j : Fin d) :

            The cardinality of the fiber { i | p i = j } as a natural number.

            Instances For
              theorem NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.prod_sgn_comp_eq_prod_pow_fiberCount {d : } (p : Fin dFin d) (ε : Fin dBool) :
              i : Fin d, sgn (ε (p i)) = j : Fin d, sgn (ε j) ^ fiberCount p j

              Rewrite ∏ i, sgn (ε (p i)) as a product over fibers of p, i.e. as powers of sgn (ε j).

              The “sign cancellation coefficient” associated to a map p : Fin d → Fin d.

              This is the coefficient that appears when expanding the polarization sum and swapping the order of summation: it measures how many sign assignments ε survive after cancellations.

              Instances For

                Product-of-sums form for signCoeff, expressed in terms of fiber cardinalities of p.

                Evaluate signCoeff: it is 2^d iff all fibers of p have odd cardinality, and 0 otherwise.

                For a function p : Fin d → Fin d, all fiber cardinalities are odd iff p is bijective.

                Since Fin d is finite of size d, odd fibers force every fiber to have size 1.

                Evaluate signCoeff: it is 2^d iff p is bijective, and 0 otherwise.

                Polarization identity #

                theorem NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.polarization_prod {d : } (u : Fin d) :
                ε : Fin dBool, signedProd ε * signedSum ε u ^ d = 2 ^ d * d.factorial * i : Fin d, u i

                Polarization identity for products (algebraic form).

                The signed sum of d-th powers isolates the full product ∏ i, u i, up to the constant 2^d * d!.

                Compact domains: boxes and linear forms #

                The box [-M,M]^n as a subset of TensorVec n.

                Instances For

                  A coordinate of x ∈ boxN n M lies in the interval [-M, M].

                  noncomputable def NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.wPlus {n : } (i j : Fin n) :
                  Fin n

                  The weight vector e_i + e_j (sum of two standard basis vectors).

                  Instances For
                    noncomputable def NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.wMinus {n : } (i j : Fin n) :
                    Fin n

                    The weight vector e_i - e_j (difference of two standard basis vectors).

                    Instances For

                      Linearity of dot in the weight argument: dot (w1+w2) = dot w1 + dot w2.

                      Negation compatibility for dot: dot (-w) = - dot w.

                      dot (e_i + e_j) x = x_i + x_j for TensorVec coordinates.

                      dot (e_i - e_j) x = x_i - x_j for TensorVec coordinates.

                      theorem NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.sum_mem_Icc {n : } {M : } (_hM : 0 M) {x : ReLUMlpBridge.TensorVec n} (hx : x boxN n M) (i j : Fin n) :
                      ReLUMlpBridge.dot (wPlus i j) x Set.Icc (-2 * M) (2 * M)

                      If x ∈ [-M,M]^n, then x_i + x_j ∈ [-2M, 2M].

                      theorem NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.diff_mem_Icc {n : } {M : } (_hM : 0 M) {x : ReLUMlpBridge.TensorVec n} (hx : x boxN n M) (i j : Fin n) :
                      ReLUMlpBridge.dot (wMinus i j) x Set.Icc (-2 * M) (2 * M)

                      If x ∈ [-M,M]^n, then x_i - x_j ∈ [-2M, 2M].

                      theorem NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.relu_mul_coord_universal_approximation_box {n : } {M : } (hM : 0 < M) (i j : Fin n) (ε : ) :
                      ε > 0∃ (hidDim : ) (l1 : Spec.LinearSpec n hidDim) (l2 : Spec.LinearSpec hidDim 1), xboxN n M, |ReLUMlpBridge.toVec x i * ReLUMlpBridge.toVec x j - ReLUMlpBridge.mlpEvalNd l1 l2 x| < ε

                      Coordinate multiplication is uniformly approximable on the box [-M,M]^n.

                      More precisely: for fixed indices i,j : Fin n, the function x ↦ x_i * x_j can be uniformly approximated on boxN n M by a single-hidden-layer ReLU MLP.

                      theorem NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.pow_lipschitz_Icc {R : } (hR : 0 R) (d : ) (x : ) :
                      x Set.Icc (-R) RySet.Icc (-R) R, |x ^ d - y ^ d| d * R ^ (d - 1) * |x - y|

                      Lipschitz bound for the power function on a bounded interval.

                      For x,y ∈ [-R,R], the map u ↦ u^d is Lipschitz with constant d * R^(d-1) (with the convention that the d=0 case is constant).

                      theorem NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.relu_universal_approximation_pow_Icc {R : } (hR : 0 < R) (d : ) (ε : ) :
                      ε > 0∃ (hidDim : ) (l1 : Spec.LinearSpec 1 hidDim) (l2 : Spec.LinearSpec hidDim 1), xSet.Icc (-R) R, |x ^ d - UniversalApproximation.mlpEval1d hidDim l1 l2 x| < ε

                      Uniform approximation of the power function on a bounded interval by a 1D ReLU MLP.

                      This packages the 1D Lipschitz ReLU approximation theorem for the specific function x ↦ x^d on [-R,R].

                      The linear form x ↦ w ⋅ x as a continuous map on the compact set K.

                      Instances For

                        Evaluate linFormC as the dot product w ⋅ x on the underlying tensor vector.

                        Uniform approximation of the continuous function x ↦ (w ⋅ x)^d on K by a 2-layer ReLU MLP.

                        noncomputable def NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.wSigned {n d : } (idx : Fin dFin n) (ε : Fin dBool) :
                        Fin n

                        Weight vector encoding a signed sum of selected coordinates ∑ i, sgn(ε i) * x_{idx i}.

                        Instances For

                          dot (wSigned idx ε) x computes the signed sum of the selected coordinates of x.

                          Uniform approximation of a coordinate-product monomial on a compact set.

                          For a fixed index map idx : Fin d → Fin n, the function x ↦ ∏ i, x_{idx i} (expressed as a product of coordinate maps on K) is uniformly approximable by a 2-layer ReLU MLP.

                          Uniform approximation of a coordinate-product over an arbitrary finite index type.

                          This is a reindexed form of approx_coordProd_fin, using an equivalence ι ≃ Fin d.

                          Re-express a fintype product over a multiset as the corresponding multiset product.

                          theorem NN.MLTheory.Proofs.ReLU.Approximation.CompactSet.finsupp_prod_pow_eq_prod_toMultiset {α β : Type} [DecidableEq α] [CommMonoid β] (d : α →₀ ) (g : αβ) :
                          (d.prod fun (a : α) (n : ) => g a ^ n) = x : (Finsupp.toMultiset d).ToType, g x.fst

                          Re-express a Finsupp exponent-vector product as a product over toMultiset.

                          This is a small bookkeeping lemma: d.prod (fun a n => (g a)^n) is the same as multiplying g a once for each occurrence of a in the multiset d.toMultiset.

                          Uniform approximation for an evaluated coordinate monomial aeval (monomial d r) on K.

                          Uniform approximation of a coordinate polynomial aeval coord p on a compact set K.

                          Bridge lemma: elements of the Stone–Weierstrass coordinate subalgebra are ApproxOnC-approximable.

                          This packages the facts that:

                          • coordSubalg is the range of MvPolynomial.aeval coord, and
                          • coordinate polynomials are approximable by ReLU MLPs (previous section).

                          ReLU universal approximation on compact sets (nD).

                          For compact K and any continuous f : C(K,ℝ), f is uniformly approximable on K by a single-hidden-layer ReLU MLP, in the ApproxOnC sense.

                          Two compatibility forms for two-dimensional multiplication #

                          Compatibility theorem for the standalone 2D multiplication construction from ReLUMulApprox.

                          The n-dimensional development below subsumes this result, but keeping this theorem name gives downstream files a stable import point for the classical two-coordinate multiplication statement.

                          The same 2D multiplication guarantee derived from the nD coordinate-product theorem.

                          This theorem is a cross-check between the specialized two-dimensional construction and the general coordinate-product approximation pipeline used by the compact-set theorem.