Foundations to Frontier
Tests
B. Statistical Learning Theory › B2 Generalization theory

VC Dimension and Sauer's Lemma

Infinite hypothesis classes, such as all thresholds, all lines or all rectangles, can't be counted, yet they're learnable. The Vapnik–Chervonenkis dimension measures their effective size: the largest number of points the class can label in every possible way (shatter). This topic computes VC dimensions (thresholds 1, intervals 2, half-planes 3, rectangles 4, halfspaces d + 1), proves Sauer's lemma (a class of VC dimension d produces only O(m^d) labelings of m points, not 2^m), and states the fundamental theorem: a class is PAC learnable if and only if its VC dimension is finite. In the research exercise you verify Cover's exact count for half-planes and measure how the generalization gap of linear classifiers grows with dimension, compared with the VC bound.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Measuring flexibility by shattering

How flexible is “all straight lines” as a way to split points into two groups? Place 3 points in a triangle: whatever colouring you choose for them, some line separates the colours. That set is shattered. Now try 4 points at the corners of a square, coloured diagonally (top-left and bottom-right red, the other two blue). No straight line can split them. The biggest set a class can always shatter, here 3, is its VC dimension. It works like a parameter count, but it measures what the model can actually do.

Can this class shatter your points?
123
··· ✓
+·· ✓
·+· ✓
++· ✓
··+ ✓
+·+ ✓
·++ ✓
+++ ✓
3 points · 8 of 8 labelings realizable · shattered ✓ · VC dimension of this class: 3
Each chip is one labeling of points 1…n (+ positive, · negative); green means some line puts exactly the + points on one side. Three points not on a line are shattered by half-planes, but no 4 points are (try the square: the two diagonals can't be separated, the XOR pattern). Rectangles shatter the diamond of 4 but no set of 5: the extreme points in each direction always trap the fifth. Sauer's lemma then caps how many labelings any class of VC dimension d can produce: polynomially many, not 2ⁿ.
Why engineers care

VC dimension explains why a linear classifier on 10 features needs on the order of tens of examples, while a model that can shatter any dataset can’t generalize at all. It underlies classic results for support vector machines and perceptrons, and it is the first tool that handles infinite model classes rigorously.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A class shatters a set of points if…
  2. 2. The VC dimension of lines (half-planes) in the plane is…
  3. 3. Higher VC dimension means the class is…

Level 1: Beginner

★★☆☆☆ Basic⏱ 25 minSecondary-school mathematics: arithmetic and elementary algebra.

Definitions

  • The growth function ΠH(m)\Pi_H(m) is the maximum, over sets of m points, of the number of distinct labelings H produces.
  • H shatters a set S if it realizes all 2∣S∣2^{|S|} labelings of S.
  • The VC dimension dVC(H)d_{VC}(H) is the size of the largest shattered set (∞ if sets of every size can be shattered).

To show dVC=dd_{VC} = d, exhibit one shattered set of size d, and prove that no set of size d + 1 is shattered.

Examples

class VC dimension why d + 1 points fail
thresholds on ℝ 1 the labeling (+, −) on two points needs a decreasing rule
intervals on ℝ 2 (+, −, +) on three points
half-planes in ℝ² 3 four points: an XOR pattern, or one point inside the triangle of the others
axis-aligned rectangles 4 five points: the extreme points trap the fifth
halfspaces in ℝ^d d + 1 Radon’s theorem
📝 Quick check (Level 1)
0/3 answered
  1. 1. VC dimension of intervals on the line:
  2. 2. To prove d_VC = d you must show…
  3. 3. VC dimension of halfspaces in ℝ¹⁰:

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Sauer’s lemma

If dVC(H)=dd_{VC}(H) = d, then for every m,

ΠH(m)≤∑i=0d(mi)≤(emd)d(m≥d).\Pi_H(m)\le\sum_{i=0}^d\binom mi\le\Big(\frac{em}d\Big)^d\quad(m\ge d).

So the growth function is exponential (2m2^m) only up to m = d, then polynomial. Intervals meet the bound with equality: Π(m)=1+m+(m2)\Pi(m) = 1 + m + \binom m2. Half-planes on m points in general position realize exactly 2∑i≤2(m−1i)2\sum_{i\le2}\binom{m-1}i labelings (Cover, 1965): 14 of 16 for m = 4, and 58 of 256 for m = 8.

The VC generalization bound

Replacing |H| by ΠH(2m)\Pi_H(2m) in the union-bound argument (via a “ghost sample” symmetrization; Vapnik and Chervonenkis, 1971) gives, with probability ≥ 1 − δ, for all h ∈ H:

R(h)≤R^(h)+8m(dln⁡2emd+ln⁡4δ).R(h)\le\hat R(h) + \sqrt{\frac8m\Big(d\ln\frac{2em}d + \ln\frac4\delta\Big)}.

The fundamental theorem of statistical learning

For binary classification, these are equivalent: H has uniform convergence; H is agnostic PAC learnable; ERM learns H; dVC(H)<∞d_{VC}(H) < \infty. The sample complexity is Θ((d+ln⁡(1/δ))/ε2)\Theta\big((d + \ln(1/\delta))/\varepsilon^2\big) (agnostic), and the bound is tight up to constants (Blumer et al., 1989; Shalev-Shwartz and Ben-David, 2014).

🐍 Exercise 1: shattering and growth functions
Decide whether thresholds, intervals and axis-aligned rectangles can realize a given labeling. Brute-force shattering to confirm VC dimensions 1, 2 and 4, and check that intervals meet Sauer's bound exactly.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Sauer's lemma bounds the growth function by…
  2. 2. Half-planes realize how many labelings of 4 points in general position?
  3. 3. A class is PAC learnable iff its VC dimension is…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Lower-bound proofs

  • Intervals can’t shatter 3 points x1<x2<x3x_1 < x_2 < x_3: an interval containing x₁ and x₃ contains x₂, so (+, −, +) is impossible. ∎
  • Half-planes can’t shatter 4 points in ℝ². Either one point lies in the triangle of the other three (label it − and the others +: any half-plane containing the three contains their convex hull), or the four are in convex position, where the diagonal XOR labeling fails for the same reason. ∎

Sauer’s lemma (sketch)

Induct on m. Remove one point x. The labelings of the remaining m − 1 points split into those that extend in one way and those that extend both ways. The second family has VC dimension ≤ d − 1 (adding x to any set it shatters gives a set shattered by H). So Πd(m)≤Πd(m−1)+Πd−1(m−1)\Pi_d(m)\le\Pi_d(m - 1) + \Pi_{d-1}(m - 1), which is Pascal’s rule for ∑i≤d(mi)\sum_{i\le d}\binom mi. ∎

Why VC bounds are loose for real models

The bound is worst-case over distributions and ignores the data. For m = 200 and VC dimension 3 it is already 0.94, and above 1 (vacuous) for larger d. Data-dependent quantities (Rademacher complexity b2-4, margins, PAC-Bayes b2-8) are much tighter.

Exercise 3.1: polynomial vs exponential

For m = 100 and d = 3, Sauer gives ∑i≤3(100i)=166 751\sum_{i\le3}\binom{100}i = 166\,751 labelings (the cruder (em/d)3≈743 909(em/d)^3\approx743\,909), versus 2100≈1.3×10302^{100}\approx1.3\times10^{30} possible labelings.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Sauer's induction is Pascal's rule because…
  2. 2. Why can't intervals realize (+, −, +)?
  3. 3. Σ_{i≤3} C(100, i) =

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Counting labelings and measuring the gap

Exact counts. Sweeping 3600 normal directions finds every half-plane labeling of random points. The counts are 8, 14, 32 and 58 for m = 3, 4, 6 and 8, exactly Cover’s formula, and always below Sauer’s bound with VC dimension 3. Intervals give 2, 4, 7, 11, …, 37, meeting Sauer’s bound with equality.

Gap vs dimension. A least-squares linear classifier is trained on m = 200 noisy linear labels in ℝ^d. The average test − train error gap is:

d 2 5 10 20 40
gap 0.007 0.013 0.027 0.061 0.115
VC bound 0.94 1.19 1.48 1.87 2.36

The gap grows with dimension, here roughly in proportion to d/m (log–log slope 0.97). The worst-case √(d/m) rate isn’t reached at this low noise level, the same fast-rate effect as in b2-1. The VC bound predicts the trend but is 20–130× too large, and vacuous from d = 5.

🐍 Exercise 2 (research): Cover's count and the VC bound
Enumerate all half-plane labelings of random point sets by sweeping directions and compare with Cover's formula and Sauer's bound. Then measure the test − train gap of linear classifiers for growing dimension d and compare with the VC bound.

VC theory in AI, robotics and aerospace

  • Classic results: perceptron and SVM margin bounds (VC dimension of large-margin separators scales with (R/γ)², not with the dimension).
  • Sample planning: rough data requirements for linear and kernel models on sensor features.
  • Limits: for deep networks the VC dimension is huge (about parameters × depth), yet they generalize, which needs data-dependent and algorithm-dependent explanations (B4).
  • Cover’s theorem also motivates kernels: mapping into high dimensions makes more labelings linearly separable (B3).

References

  1. V. Vapnik, A. Chervonenkis (1971). “On the uniform convergence of relative frequencies of events to their probabilities.” Theory of Probability and Its Applications, 16.
  2. N. Sauer (1972). “On the density of families of sets.” Journal of Combinatorial Theory A, 13.
  3. T. Cover (1965). “Geometrical and statistical properties of systems of linear inequalities with applications in pattern recognition.” IEEE Trans. Electronic Computers, 14.
  4. A. Blumer, A. Ehrenfeucht, D. Haussler, M. Warmuth (1989). “Learnability and the Vapnik–Chervonenkis dimension.” Journal of the ACM, 36.
  5. P. Bartlett, N. Harvey, C. Liaw, A. Mehrabian (2019). “Nearly-tight VC-dimension and pseudodimension bounds for piecewise linear neural networks.” JMLR, 20.