ML.Kernel

Roll-up: the abstract RKHS interface, the kernel-ridge representer theorem, effective dimension, and the RKHS-ball Rademacher-complexity bound.

Effective­Dimension 3 core · 6 supporting The effective dimension at regularization level λ > 0 of a positive operator with (summable, nonnegative) eigenvalue family μ : ι → ℝ is N(λ) = ∑ᵢ μᵢ / (μᵢ + λ) = tr(T (T + λ)⁻¹). ★ effectiveDimension★ effectiveDimension_le_trace_div★ effectiveDimension_antitone

Effective dimension of a trace-class operator

The effective dimension at regularization level λ > 0 of a positive operator with (summable, nonnegative) eigenvalue family μ : ι → ℝ is

N(λ) = ∑ᵢ μᵢ / (μᵢ + λ) = tr(T (T + λ)⁻¹).

It is the quantity that governs the variance term of kernel ridge regression: the Caponnetto–De Vito optimal-rate analysis expresses the minimax L²(ρ) rate of kernel ridge through N(λ) and the eigenvalue-decay/source-condition exponents. This file provides the definition and its basic structural properties for the trace-class (summable-eigenvalue) regime — the infinite-dimensional RKHS setting.

* effectiveDimension_nonneg — 0 ≤ N(λ); * summable_effectiveDimension_term — the summand family is summable (so N(λ) is a genuine real number, not the fallback value of a non-summable tsum); * effectiveDimension_le_trace_div — N(λ) ≤ (tr T)/λ (the crude dimension-free bound); * effectiveDimension_le_card — over finitely many eigenvalues, N(λ) ≤ #ι; * effectiveDimension_antitone — N is antitone in λ (more regularization ⇒ smaller effective dimension).

The downstream rate theorem (N(λ)/eigenvalue-decay ⇒ the n^{-2rb/(2rb+1)} kernel-ridge L² rate) additionally requires Hilbert-space operator-concentration machinery (an operator Bernstein inequality for (T+λ)^{-1/2}(T − T̂ₙ)(T+λ)^{-1/2}) that is a separate substrate; this file is the definitional foundation it would build on.

def effectiveDimension reviewed
Causalean.ML

Effective dimension measures the spectral degrees of freedom retained by regularization through the regularized eigenvalue-ratio sum. It uses a real eigenvalue family over an arbitrary index set at a real regularization level. Without positivity, summability, and nonzero denominators, zero-denominator terms and nonsummable totals follow the ambient real-series convention and evaluate to zero.

Definition (Lean source)
ι :
Type u_1
shared
μ :
ι → ℝ
lam :
ℝ
effectiveDimension μ lam :
ℝ
∑' i, μ i / (μ i + lam)
Causalean.ML.effectiveDimension · Causalean/ML/Kernel/EffectiveDimension.lean:48
lemma effectiveDimension_le_trace_div reviewed
Causalean.ML

Trace bound. Effective dimension is at most total spectral mass divided by the regularization level for a nonnegative, summable eigenvalue family over the index set at a positive regularization level. This gives only inverse-linear dependence on regularization; sharper decay-dependent rates require a separate argument.

Formal statement
ι :
Type u_1
ι → ℝ
shared
lam :
ℝ
hμ :
∀ i, 0 ≤ μ i
hlam :
0 < lam
hsum :
effectiveDimension μ lam ≤ (∑' i, μ i) / lam
Proof (Lean source)
lemma effectiveDimension_le_trace_div {μ : ι → ℝ} {lam : ℝ} (hμ : ∀ i, 0 ≤ μ i) (hlam : 0 < lam) (hsum : Summable μ) : effectiveDimension μ lam ≤ (∑' i, μ i) / lam := by have hle : effectiveDimension μ lam ≤ ∑' i, μ i / lam := Summable.tsum_le_tsum (fun i => effectiveDimension_term_le_div hμ hlam i) (summable_effectiveDimension_term hμ hlam hsum) (hsum.div_const lam) rwa [tsum_div_const] at hle
Causalean.ML.effectiveDimension_le_trace_div · Causalean/ML/Kernel/EffectiveDimension.lean:90 · uses effectiveDimension
lemma effectiveDimension_antitone reviewed
Causalean.ML

If all eigenvalues are nonnegative, the first regularization level is positive, the first level is no larger than the second, and the eigenvalues are summable, then effective dimension is antitone in the regularization level.

Formal statement
ι :
Type u_1
ι → ℝ
shared
lam₁ lam₂ :
ℝ
hμ :
∀ i, 0 ≤ μ i
hlam₁ :
0 < lam₁
hle :
lam₁ ≤ lam₂
hsum :
effectiveDimension μ lam₂ ≤ effectiveDimension μ lam₁
Proof (Lean source)
lemma effectiveDimension_antitone {μ : ι → ℝ} {lam₁ lam₂ : ℝ} (hμ : ∀ i, 0 ≤ μ i) (hlam₁ : 0 < lam₁) (hle : lam₁ ≤ lam₂) (hsum : Summable μ) : effectiveDimension μ lam₂ ≤ effectiveDimension μ lam₁ := by have hlam₂ : 0 < lam₂ := lt_of_lt_of_le hlam₁ hle refine Summable.tsum_le_tsum (fun i => ?_) (summable_effectiveDimension_term hμ hlam₂ hsum) (summable_effectiveDimension_term hμ hlam₁ hsum) gcongr <;> linarith [hμ i, hlam₁, hle]
Causalean.ML.effectiveDimension_antitone · Causalean/ML/Kernel/EffectiveDimension.lean:113 · uses effectiveDimension
6 supporting declarations (lemmas, instances)
  • effectiveDimension_term_nonneg lemma — Each summand μᵢ/(μᵢ+λ) is nonnegative (for nonnegative eigenvalues and λ > 0).
    ι :
    Type u_1
    ι → ℝ
    shared
    lam :
    ℝ
    hμ :
    ∀ i, 0 ≤ μ i
    hlam :
    0 < lam
    i :
    ι
    0 ≤ μ i / (μ i + lam)
    Proof (Lean source)
    lemma effectiveDimension_term_nonneg {μ : ι → ℝ} {lam : ℝ} (hμ : ∀ i, 0 ≤ μ i) (hlam : 0 < lam) (i : ι) : 0 ≤ μ i / (μ i + lam) := div_nonneg (hμ i) (add_nonneg (hμ i) hlam.le)
    Causalean.ML.effectiveDimension_term_nonneg · Causalean/ML/Kernel/EffectiveDimension.lean:59
  • effectiveDimension_term_le_div lemma — Each summand is dominated by μᵢ/λ.
    ι :
    Type u_1
    ι → ℝ
    shared
    lam :
    ℝ
    hμ :
    ∀ i, 0 ≤ μ i
    hlam :
    0 < lam
    i :
    ι
    μ i / (μ i + lam) ≤ μ i / lam
    Proof (Lean source)
    lemma effectiveDimension_term_le_div {μ : ι → ℝ} {lam : ℝ} (hμ : ∀ i, 0 ≤ μ i) (hlam : 0 < lam) (i : ι) : μ i / (μ i + lam) ≤ μ i / lam := by gcongr <;> linarith [hμ i]
    Causalean.ML.effectiveDimension_term_le_div · Causalean/ML/Kernel/EffectiveDimension.lean:64
  • effectiveDimension_term_le_one lemma — Each summand is at most 1.
    ι :
    Type u_1
    ι → ℝ
    shared
    lam :
    ℝ
    hμ :
    ∀ i, 0 ≤ μ i
    hlam :
    0 < lam
    i :
    ι
    μ i / (μ i + lam) ≤ 1
    Proof (Lean source)
    lemma effectiveDimension_term_le_one {μ : ι → ℝ} {lam : ℝ} (hμ : ∀ i, 0 ≤ μ i) (hlam : 0 < lam) (i : ι) : μ i / (μ i + lam) ≤ 1 := by rw [div_le_one (add_pos_of_nonneg_of_pos (hμ i) hlam)] linarith [hμ i]
    Causalean.ML.effectiveDimension_term_le_one · Causalean/ML/Kernel/EffectiveDimension.lean:69
  • summable_effectiveDimension_term lemma — The effective-dimension summands form a summable family when the eigenvalues are nonnegative, the regularization level is positive, and the eigenvalue family is summable. Thus the indexed spectral sum is genuine rather than a nonsummable-series default.
    ι :
    Type u_1
    ι → ℝ
    shared
    lam :
    ℝ
    hμ :
    ∀ i, 0 ≤ μ i
    hlam :
    0 < lam
    hsum :
    Summable (fun i => μ i / (μ i + lam))
    Proof (Lean source)
    lemma summable_effectiveDimension_term {μ : ι → ℝ} {lam : ℝ} (hμ : ∀ i, 0 ≤ μ i) (hlam : 0 < lam) (hsum : Summable μ) : Summable (fun i => μ i / (μ i + lam)) := Summable.of_nonneg_of_le (fun i => effectiveDimension_term_nonneg hμ hlam i) (fun i => effectiveDimension_term_le_div hμ hlam i) (hsum.div_const lam)
    Causalean.ML.summable_effectiveDimension_term · Causalean/ML/Kernel/EffectiveDimension.lean:75
  • effectiveDimension_nonneg lemma — The effective dimension is nonnegative.
    ι :
    Type u_1
    ι → ℝ
    shared
    lam :
    ℝ
    hμ :
    ∀ i, 0 ≤ μ i
    hlam :
    0 < lam
    0 ≤ effectiveDimension μ lam
    Proof (Lean source)
    lemma effectiveDimension_nonneg {μ : ι → ℝ} {lam : ℝ} (hμ : ∀ i, 0 ≤ μ i) (hlam : 0 < lam) : 0 ≤ effectiveDimension μ lam := tsum_nonneg (fun i => effectiveDimension_term_nonneg hμ hlam i)
    Causalean.ML.effectiveDimension_nonneg · Causalean/ML/Kernel/EffectiveDimension.lean:85
  • effectiveDimension_le_card lemma — Over finitely many eigenvalues, N(λ) never exceeds the ambient dimension #ι.
    ι :
    Type u_1
    ι → ℝ
    shared
    lam :
    ℝ
    hμ :
    ∀ i, 0 ≤ μ i
    hlam :
    0 < lam
    effectiveDimension μ lam ≤ (Fintype.card ι : ℝ)
    Proof (Lean source)
    lemma effectiveDimension_le_card [Fintype ι] {μ : ι → ℝ} {lam : ℝ} (hμ : ∀ i, 0 ≤ μ i) (hlam : 0 < lam) : effectiveDimension μ lam ≤ (Fintype.card ι : ℝ) := by unfold effectiveDimension rw [tsum_fintype] calc ∑ i, μ i / (μ i + lam) ≤ ∑ _i : ι, (1 : ℝ) := Finset.sum_le_sum fun i _ => effectiveDimension_term_le_one hμ hlam i _ = (Fintype.card ι : ℝ) := by simp [Finset.card_univ]
    Causalean.ML.effectiveDimension_le_card · Causalean/ML/Kernel/EffectiveDimension.lean:103
Ridge 2 core · 0 supporting The file defines krrRisk on a real inner-product space with a supplied evaluation map and proves representer_theorem: under λ > 0, any global minimizer is a finite linear combination of the sample representers k(·, xᵢ) w ★ representer_theorem

Regularized least squares — the representer theorem

The file defines krrRisk on a real inner-product space with a supplied evaluation map and proves representer_theorem: under λ > 0, any global minimizer is a finite linear combination of the sample representers k(·, xᵢ) when evaluation satisfies the reproducing identity.

def krrRisk reviewed
Causalean.ML

Kernel-ridge empirical risk trades average squared error against a weighted squared function norm. It scores a candidate in a real inner-product space through its evaluation rule on covariates and responses from a sample of the specified size, with covariate space and regularization level.

Definition (Lean source)
feval :
H → X → ℝ
n :
ℕ
x :
Fin n → X
y :
Fin n → ℝ
lam :
ℝ
f :
H
krrRisk feval x y lam f :
ℝ
(n : ℝ)⁻¹ * ∑ i, (feval f (x i) - y i) ^ 2 + lam * ‖f‖ ^ 2
Causalean.ML.krrRisk · Causalean/ML/Kernel/Ridge.lean:26
theorem representer_theorem reviewed
Causalean.ML

A kernel-ridge minimizer lies in the sampled representer span, reducing an infinite-dimensional optimization problem to sample coefficients. The reduction applies to the sampled covariates and responses when evaluation has supplied Hilbert-space representers, the penalty is strictly positive, and the candidate globally minimizes.

Formal statement
X H :
Type*
H → X → ℝ
X → H
hrkhs :
HasReproducingRepresenters X H feval representer
n :
ℕ
x :
Fin n → X
y :
Fin n → ℝ
lam :
ℝ
hlam :
0 < lam
fhat :
H
hmin :
∀ g : H, krrRisk feval x y lam fhat ≤ krrRisk feval x y lam g
∃ α : Fin n → ℝ, fhat = ∑ i, α i • representer (x i)
Proof (Lean source)
theorem representer_theorem {X H : Type*} [NormedAddCommGroup H] [InnerProductSpace ℝ H] [CompleteSpace H] {feval : H → X → ℝ} {representer : X → H} (hrkhs : HasReproducingRepresenters X H feval representer) {n : ℕ} (x : Fin n → X) (y : Fin n → ℝ) {lam : ℝ} (hlam : 0 < lam) {fhat : H} (hmin : ∀ g : H, krrRisk feval x y lam fhat ≤ krrRisk feval x y lam g) : ∃ α : Fin n → ℝ, fhat = ∑ i, α i • representer (x i) := by classical let M : Submodule ℝ H := span ℝ (Set.range fun i : Fin n => representer (x i)) have : FiniteDimensional ℝ M := FiniteDimensional.span_of_finite ℝ (Set.finite_range _) have : CompleteSpace M := by infer_instance let p : H := M.starProjection fhat have hp_mem : p ∈ M := M.starProjection_apply_mem fhat have hrep_mem : ∀ i : Fin n, representer (x i) ∈ M := by intro i exact Submodule.subset_span ⟨i, rfl⟩ have heval_eq : ∀ i : Fin n, feval fhat (x i) = feval p (x i) := by intro i have horth : inner ℝ (fhat - p) (representer (x i)) = 0 := by exact Submodule.starProjection_inner_eq_zero (K := M) fhat (representer (x i)) (hrep_mem i) rw [hrkhs.reproducing fhat (x i), hrkhs.reproducing p (x i)] calc inner ℝ fhat (representer (x i)) = inner ℝ ((fhat - p) + p) (representer (x i)) := by rw [sub_add_cancel] _ = inner ℝ (fhat - p) (representer (x i)) + inner ℝ p (representer (x i)) := by rw [inner_add_left] _ = inner ℝ p (representer (x i)) := by rw [horth, zero_add] have hdata_eq : (∑ i, (feval fhat (x i) - y i) ^ 2) = ∑ i, (feval p (x i) - y i) ^ 2 := by refine Finset.sum_congr rfl ?_ intro i _ rw [heval_eq i] have hmin_p : krrRisk feval x y lam fhat ≤ krrRisk feval x y lam p := hmin p have hnorm_le : ‖fhat‖ ^ 2 ≤ ‖p‖ ^ 2 := by have hmul_le : lam * ‖fhat‖ ^ 2 ≤ lam * ‖p‖ ^ 2 := by unfold krrRisk at hmin_p rw [hdata_eq] at hmin_p linarith nlinarith have hnorm_decomp : ‖fhat‖ ^ 2 = ‖p‖ ^ 2 + ‖(Mᗮ).starProjection fhat‖ ^ 2 := Submodule.norm_sq_eq_add_norm_sq_starProjection fhat M have hperp_sq : ‖(Mᗮ).starProjection fhat‖ ^ 2 = 0 := by have hnonneg : 0 ≤ ‖(Mᗮ).starProjection fhat‖ ^ 2 := sq_nonneg _ nlinarith have hperp_zero : (Mᗮ).starProjection fhat = 0 := by apply norm_eq_zero.mp have hnonneg : 0 ≤ ‖(Mᗮ).starProjection fhat‖ := norm_nonneg _ nlinarith have hfhat_eq_p : fhat = p := by have hsplit := Submodule.starProjection_add_starProjection_orthogonal (K := M) fhat calc fhat = M.starProjection fhat + (Mᗮ).starProjection fhat := hsplit.symm _ = M.starProjection fhat + 0 := by rw [hperp_zero] _ = p := by rw [add_zero] have hfhat_mem : fhat ∈ M := by simpa [hfhat_eq_p] using hp_mem rcases (Submodule.mem_span_range_iff_exists_fun (R := ℝ) (v := fun i : Fin n => representer (x i)) (x := fhat)).mp hfhat_mem with ⟨α, hα⟩ exact ⟨α, hα.symm⟩
RKHSRademacher 1 core · 1 supporting This file proves the canonical RKHS-ball empirical Rademacher bound Rhat_n({‖f‖_H ≤ r}) ≤ κ * r / sqrt n, where κ² = sup_x K(x,x). ★ rkhs_ball_empiricalRademacher_le

RKHS-ball Rademacher complexity

This file proves the canonical RKHS-ball empirical Rademacher bound Rhat_n({‖f‖_H ≤ r}) ≤ κ * r / sqrt n, where κ² = sup_x K(x,x). The main Hilbert-space theorem is empiricalRademacherComplexity_innerBall_le; the RKHS specialization is rkhs_ball_empiricalRademacher_le, which uses the reproducing identity to turn function evaluation into an inner product. This is the standard worst-case O(1 / sqrt n) kernel learning rate associated with Bartlett--Mendelson style Rademacher complexity bounds.

theorem rkhs_ball_empiricalRademacher_le reviewed
Causalean.ML

If evaluation on H has supplied reproducing representers, κ is a nonnegative bound, r is a nonnegative radius, and every sampled representer representer (xs k) has norm at most κ, then the empirical Rademacher complexity, on the sample xs, of the closed ball of radius r in H is at most κ·r/√n.

Formal statement
X H :
Type*
H → X → ℝ
X → H
hK :
HasReproducingRepresenters X H feval representer
n :
ℕ
κ r :
ℝ
hκ :
0 ≤ κ
hr :
0 ≤ r
xs :
Fin n → X
hbound :
∀ k, ‖representer (xs k)‖ ≤ κ
empiricalRademacherComplexity n (fun (f : {f : H // ‖f‖ ≤ r}) (x : X) => feval (f : H) x) xs
≤ κ * r / sqrt n
Proof (Lean source)
theorem rkhs_ball_empiricalRademacher_le {X H : Type*} [NormedAddCommGroup H] [InnerProductSpace ℝ H] {feval : H → X → ℝ} {representer : X → H} (hK : HasReproducingRepresenters X H feval representer) {n : ℕ} {κ r : ℝ} (hκ : 0 ≤ κ) (hr : 0 ≤ r) (xs : Fin n → X) (hbound : ∀ k, ‖representer (xs k)‖ ≤ κ) : empiricalRademacherComplexity n (fun (f : {f : H // ‖f‖ ≤ r}) (x : X) => feval (f : H) x) xs ≤ κ * r / sqrt n := by classical let ball := {f : H // ‖f‖ ≤ r} let Y : Fin n → H := fun k => representer (xs k) let w : ball → H := fun f => (f : H) have hw : ∀ f : ball, ‖w f‖ ≤ r := by intro f exact f.2 have hlinear : empiricalRademacherComplexity n (fun (f : ball) (a : H) => inner ℝ (w f) a) Y ≤ κ * r / sqrt n := by exact empiricalRademacherComplexity_innerBall_le κ r hκ hr Y hbound w hw -- Rewrite evaluation into the inner product with the representer; the two -- complexity terms then agree by beta reduction, so close by `exact`. have heval : (fun (f : ball) (x : X) => feval (f : H) x) = fun (f : ball) (x : X) => inner ℝ (w f) (representer x) := by funext f x exact hK.reproducing (f : H) x rw [heval] exact hlinear
Causalean.ML.rkhs_ball_empiricalRademacher_le · Causalean/ML/Kernel/RKHSRademacher.lean:470 · uses HasReproducingRepresenters
1 supporting declaration (lemmas, instances)
  • empiricalRademacherComplexity_innerBall_le theorem — Hilbert-space linear complexity is radius product over square-root sample size. The bound uses nonnegative sample and weight radii, a vector sample bounded by its radius, and linear weights bounded by their radius.
    ι :
    Type*
    n :
    ℕ
    κ r :
    ℝ
    hκ :
    0 ≤ κ
    hr :
    0 ≤ r
    Y :
    Fin n → E
    hY :
    ∀ k, ‖Y k‖ ≤ κ
    w :
    ι → E
    hw :
    ∀ i, ‖w i‖ ≤ r
    empiricalRademacherComplexity n (fun i a => inner ℝ (w i) a) Y ≤ κ * r / sqrt n
    Proof (Lean source)
    theorem empiricalRademacherComplexity_innerBall_le {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {ι : Type*} {n : ℕ} (κ r : ℝ) (hκ : 0 ≤ κ) (hr : 0 ≤ r) (Y : Fin n → E) (hY : ∀ k, ‖Y k‖ ≤ κ) (w : ι → E) (hw : ∀ i, ‖w i‖ ≤ r) : empiricalRademacherComplexity n (fun i a => inner ℝ (w i) a) Y ≤ κ * r / sqrt n := by classical by_cases hι : Nonempty ι · let : Nonempty ι := hι exact empiricalRademacherComplexity_innerBall_le_nonempty κ r hκ hr Y hY w hw · have : IsEmpty ι := not_nonempty_iff.mp hι unfold empiricalRademacherComplexity simp only [Signs.card, Nat.cast_pow, Nat.cast_ofNat, Int.reduceNeg, abs_mul, abs_inv, Nat.abs_cast, iSup_of_isEmpty, Finset.sum_const_zero, mul_zero, ge_iff_le] exact div_nonneg (mul_nonneg hκ hr) (Real.sqrt_nonneg _)
    Causalean.ML.empiricalRademacherComplexity_innerBall_le · Causalean/ML/Kernel/RKHSRademacher.lean:446