Documentation

CslibFrontier.MachineLearning.PACLearning.DSDimension

Graph Dimension, Pseudo-Cubes, and the Daniely–Shalev-Shwartz Dimension #

For binary classification (β = Bool), the Vapnik–Chervonenkis dimension characterizes both uniform convergence and PAC learnability. For multiclass concept classes C : ConceptClass α β, three distinct combinatorial dimensions govern different regimes:

  1. Natarajan dimension (NatarajanShatters, natarajanDim in CslibFrontier/MachineLearning/PACLearning/NatarajanDimension.lean; [Nat89]): pairs of witness labelings f₀, f₁ : α → β realizing all 2 ^ |W| binary choices on W.
  2. Daniely–Shalev-Shwartz (DS) dimension (IsPseudoCube, DSShatters, dsDim; [DSS14]; [BCD+22]): the largest size of a finite set W on which the restriction of C contains a pseudo-cube — a nonempty finite set P of labelings of W in which every f ∈ P and coordinate i ∈ W admits an i-neighbor g ∈ P differing from f exclusively at i. Finite DS dimension characterizes multiclass PAC learnability over arbitrary label spaces [BCD+22].
  3. Graph dimension (GraphShatters, graphDim; [Nat89]; [BDCBHL95]): a single reference labeling f : α → β against which every subset B ⊆ W is realized by some c ∈ C agreeing with f on B and disagreeing with f on W \ B, equivalently the VC dimension of the binary concept-graph class conceptGraph C on α × β (graphDim_eq_evcDim_conceptGraph).

This module develops GraphShatters/graphDim and IsPseudoCube/DSShatters/dsDim, connects them to Sauer's lemma (GrowthFunction.lean) and Natarajan's lemma (NatarajanDimension.lean), proves the universal hierarchy natarajanDim C ≤ dsDim C ≤ graphDim C together with their quantitative O(d log |β|) equivalence over finite label spaces (graphDim_le_mul_natarajanDim), and establishes strict separations at both inequalities (hexagonClass for |β| = 3 and revealingSetClass for infinite label spaces).

Main definitions #

Main results #

References #

Graph shattering and the graph dimension #

def Cslib.MachineLearning.PACLearning.GraphShatters {α : Type u_1} {β : Type u_2} (C : ConceptClass α β) (W : Set α) :

A concept class C G-shatters (graph-shatters) a set W if there is a reference labeling f : α → β such that for every B ⊆ W some concept c ∈ C agrees with f on B and disagrees with f at every point of W \ B [Natarajan1989; BenDavidCesaBianchiHausslerLong1995].

noncomputable def Cslib.MachineLearning.PACLearning.graphDim {α : Type u_1} {β : Type u_2} (C : ConceptClass α β) :

The graph dimension of C is the supremum in ℕ∞ of the sizes of finite G-shattered sets.

The graph dimension is finite.

theorem Cslib.MachineLearning.PACLearning.GraphShatters.subset {α : Type u_1} {β : Type u_2} {C : ConceptClass α β} {W V : Set α} (hW : GraphShatters C W) (hVW : V ⊆ W) :
theorem Cslib.MachineLearning.PACLearning.GraphShatters.superset {α : Type u_1} {β : Type u_2} {C C' : ConceptClass α β} {W : Set α} (hW : GraphShatters C W) (hCC' : C ⊆ C') :
theorem Cslib.MachineLearning.PACLearning.graphDim_le_iff {α : Type u_1} {β : Type u_2} {C : ConceptClass α β} {d : ℕ∞} :
graphDim C ≤ d ↔ ∀ (W : Finset α), GraphShatters C ↑W → ↑W.card ≤ d
theorem Cslib.MachineLearning.PACLearning.hasFiniteGraphDim_iff {α : Type u_1} {β : Type u_2} {C : ConceptClass α β} :
HasFiniteGraphDim C ↔ ∃ (n : ℕ), ∀ (W : Finset α), GraphShatters C ↑W → W.card ≤ n
theorem Cslib.MachineLearning.PACLearning.exists_graphShatters_card_eq {α : Type u_1} {β : Type u_2} {C : ConceptClass α β} {d : ℕ} (hd : graphDim C = ↑d) (hpos : 0 < d) :
∃ (W : Finset α), W.card = d ∧ GraphShatters C ↑W

Binary concept-graph class {(x, y) ↦ decide (c x = y) | c ∈ C} on α × β.

The graph dimension of C equals the extended VC dimension of conceptGraph C.

With Bool labels, graph shattering coincides with ordinary VC shattering.

With Bool labels, the graph and extended VC dimensions agree.

theorem Cslib.MachineLearning.PACLearning.ncard_restriction_le_sum_choose_graphDim {α : Type u_1} {β : Type u_2} [Fintype β] {C : ConceptClass α β} {d : ℕ} (hd : graphDim C ≤ ↑d) {n : ℕ} (x : Fin n → α) :
((fun (x_1 : α → β) => x_1 ∘ x) '' C).ncard ≤ ∑ i ∈ Finset.range (d + 1), (n * Fintype.card β).choose i

Sauer–Shelah growth bound for graph dimension [Natarajan1989; BenDavidCesaBianchiHausslerLong1995]: if graphDim C ≤ d and β is finite, C realizes at most ∑_{i ≤ d} C(n |β|, i) labelings on any n points x : Fin n → α.

Pseudo-cubes and the Daniely–Shalev-Shwartz (DS) dimension #

def Cslib.MachineLearning.PACLearning.IsPseudoCube {β : Type u_2} {ι : Type u_4} (P : Finset (ι → β)) :

A finite set P of labelings ι → β is a pseudo-cube on ι if it is nonempty and every f ∈ P and coordinate i : ι admits an i-neighbor g ∈ P differing from f exclusively at coordinate i [DanielyShalevShwartz2014; BrukhimCarmonDinurMoranYehudayoff2022].

theorem Cslib.MachineLearning.PACLearning.IsPseudoCube.image_precomp {β : Type u_2} {ι : Type u_4} {κ : Type u_5} [DecidableEq (κ → β)] {P : Finset (ι → β)} (hP : IsPseudoCube P) {e : κ → ι} (he : Function.Injective e) :
IsPseudoCube (Finset.image (fun (x : ι → β) => x ∘ e) P)

Precomposing along an injection projects a pseudo-cube onto a smaller coordinate set.

Every pseudo-cube on a finite coordinate set ι has at least 2 ^ |ι| elements.

Over a two-element label space, a finite family on ι is a pseudo-cube iff it is the entire hypercube Finset.univ.

def Cslib.MachineLearning.PACLearning.DSShatters {α : Type u_1} {β : Type u_2} (C : ConceptClass α β) (W : Set α) :

A concept class C DS-shatters a set W if the restriction of C to W contains a pseudo-cube on W [DanielyShalevShwartz2014; BrukhimCarmonDinurMoranYehudayoff2022].

noncomputable def Cslib.MachineLearning.PACLearning.dsDim {α : Type u_1} {β : Type u_2} (C : ConceptClass α β) :

The Daniely–Shalev-Shwartz (DS) dimension of C is the supremum in ℕ∞ of the sizes of finite DS-shattered sets [DanielyShalevShwartz2014; BrukhimCarmonDinurMoranYehudayoff2022].

The DS dimension is finite.

theorem Cslib.MachineLearning.PACLearning.DSShatters.finite {α : Type u_1} {β : Type u_2} {C : ConceptClass α β} {W : Set α} (hW : DSShatters C W) :

Only finite sets can be DS-shattered: each coordinate of W requires a distinct i-neighbor in the finite pseudo-cube P.

theorem Cslib.MachineLearning.PACLearning.DSShatters.subset {α : Type u_1} {β : Type u_2} {C : ConceptClass α β} {W V : Set α} (hW : DSShatters C W) (hVW : V ⊆ W) :
theorem Cslib.MachineLearning.PACLearning.DSShatters.superset {α : Type u_1} {β : Type u_2} {C C' : ConceptClass α β} {W : Set α} (hW : DSShatters C W) (hCC' : C ⊆ C') :
theorem Cslib.MachineLearning.PACLearning.DSShatters.nonempty {α : Type u_1} {β : Type u_2} {C : ConceptClass α β} {W : Set α} (hW : DSShatters C W) :
theorem Cslib.MachineLearning.PACLearning.DSShatters.of_restrict {α : Type u_1} {β : Type u_2} {γ : Type u_3} {C : ConceptClass α β} {e : γ → α} {W : Set γ} (hW : DSShatters ((fun (x : α → β) => x ∘ e) '' C) W) :

DS-shattering transfers along restrictions e : γ → α: if (· ∘ e) '' C DS-shatters W, then e is injective on W and C DS-shatters e '' W.

theorem Cslib.MachineLearning.PACLearning.DSShatters.card_le_dsDim {α : Type u_1} {β : Type u_2} {C : ConceptClass α β} {W : Finset α} (hW : DSShatters C ↑W) :
↑W.card ≤ dsDim C
theorem Cslib.MachineLearning.PACLearning.dsDim_le_iff {α : Type u_1} {β : Type u_2} {C : ConceptClass α β} {d : ℕ∞} :
dsDim C ≤ d ↔ ∀ (W : Finset α), DSShatters C ↑W → ↑W.card ≤ d
theorem Cslib.MachineLearning.PACLearning.hasFiniteDSDim_iff {α : Type u_1} {β : Type u_2} {C : ConceptClass α β} :
HasFiniteDSDim C ↔ ∃ (n : ℕ), ∀ (W : Finset α), DSShatters C ↑W → W.card ≤ n
theorem Cslib.MachineLearning.PACLearning.exists_dsShatters_card_eq {α : Type u_1} {β : Type u_2} {C : ConceptClass α β} {d : ℕ} (hd : dsDim C = ↑d) (hpos : 0 < d) :
∃ (W : Finset α), W.card = d ∧ DSShatters C ↑W

For a finite set W and Bool labels, DS-shattering coincides with ordinary VC shattering.

With Bool labels, the DS and extended VC dimensions agree.

The multiclass dimension hierarchy natarajanDim ≤ dsDim ≤ graphDim #

theorem Cslib.MachineLearning.PACLearning.NatarajanShatters.dsShatters {α : Type u_1} {β : Type u_2} {C : ConceptClass α β} {W : Finset α} (hW : NatarajanShatters C ↑W) :
DSShatters C ↑W

Every finite N-shattered set is DS-shattered via its embedded 2 ^ |W| Boolean hypercube.

theorem Cslib.MachineLearning.PACLearning.DSShatters.graphShatters {α : Type u_1} {β : Type u_2} {C : ConceptClass α β} {W : Finset α} (hW : DSShatters C ↑W) :

Every finite DS-shattered set is G-shattered: starting from any anchor f₀ ∈ P, walking along coordinate neighbors one element of W \ B at a time produces a labeling in P agreeing with f₀ on B and disagreeing with f₀ on W \ B.

Every N-shattered set is G-shattered.

The Natarajan dimension never exceeds the Daniely–Shalev-Shwartz dimension.

The Daniely–Shalev-Shwartz dimension never exceeds the graph dimension.

The Natarajan dimension never exceeds the graph dimension.

Quantitative equivalence over finite label spaces (O(d log |β|)) #

theorem Cslib.MachineLearning.PACLearning.GraphShatters.two_pow_card_le_natarajanSum {α : Type u_1} {β : Type u_2} [Fintype β] {C : ConceptClass α β} {W : Finset α} {d : ℕ} (hW : GraphShatters C ↑W) (hd : ∀ (V : Finset α), NatarajanShatters C ↑V → V.card ≤ d) :

If C G-shatters W and N-shatters no finite set of size exceeding d, then 2 ^ |W| ≤ natarajanSum |W| |β| d.

theorem Cslib.MachineLearning.PACLearning.card_le_of_graphShatters {α : Type u_1} {β : Type u_2} [Fintype β] {C : ConceptClass α β} {W : Finset α} {d : ℕ} (hW : GraphShatters C ↑W) (hd : ∀ (V : Finset α), NatarajanShatters C ↑V → V.card ≤ d) :
W.card ≤ 4 * d * (Nat.log 2 (Fintype.card β) + 2)

Ben-David–Cesa-Bianchi–Haussler–Long O(d log |β|) graph-dimension bound [BDCBHL95]: over a finite label space β, if every finite N-shattered set of C has size at most d, then every finite G-shattered set of C has size at most 4 * d * (⌊log₂ |β|⌋ + 2).

Over a finite label space, graphDim C ≤ 4 * natarajanDim C * (⌊log₂ |β|⌋ + 2).

Over a finite label space, dsDim C ≤ 4 * natarajanDim C * (⌊log₂ |β|⌋ + 2).

Over a finite label space, graphDim C is finite iff natarajanDim C is finite.

Over a finite label space, dsDim C is finite iff natarajanDim C is finite.

Separation 1: Finite-label (|β| = 3) separation natarajanDim < dsDim #

The 6-cycle ("hexagon") concept class {f : Fin 2 → Fin 3 | f 0 ≠ f 1} on two points and three labels [DanielyShalevShwartz2014; BrukhimCarmonDinurMoranYehudayoff2022].

hexagonClass has Natarajan dimension 1: no 2 × 2 Cartesian product fits inside the off-diagonal of Fin 3 × Fin 3.

hexagonClass DS-shatters {0, 1} as a 2-dimensional 6-cycle pseudo-cube, so dsDim hexagonClass = 2.

Separation 2: Infinite-label separation dsDim = 1 < ⊤ = graphDim #

Revealing-subset concept associated with B : Finset α: outputs none on B and reveals the entire active set some B outside B [BenDavidCesaBianchiHausslerLong1995; DanielyShalevShwartz2014].

The revealing-subset class {revealingConcept B | B : Finset α}: every finite subset is G-shattered against constant none, yet any non-none label uniquely identifies B, preventing any 2-dimensional pseudo-cube.

On any infinite domain, revealingSetClass α has infinite graph dimension (⊤).

No set of two or more points is DS-shattered by revealingSetClass α.

On any nonempty domain, revealingSetClass α has DS dimension 1.

On any nonempty domain, revealingSetClass α has Natarajan dimension 1.