Extreme Value Theorem

lean4-proofcalculusvisualization
fC(K),K compact    x,xK:  f(x)=minf=f(x)maxff\in C(K),\,K\text{ compact}\implies\exists\,x_*,x^*\in K:\;f(x_*)=\min f=f(x^*)\leq\max f

Statement

Let KK be a compact topological space (e.g., a closed bounded interval [a,b]R[a, b] \subset \mathbb{R}) and f:KRf : K \to \mathbb{R} a continuous function. Then ff is bounded and attains both its maximum and minimum:

xK:f(x)=minxKf(x)andxK:f(x)=maxxKf(x)\exists\, x_* \in K : f(x_*) = \min_{x \in K} f(x) \quad \text{and} \quad \exists\, x^* \in K : f(x^*) = \max_{x \in K} f(x)

Compactness is essential. On an open or unbounded domain, continuous functions need not attain their extrema.

Visualization

Counterexample without compactness: f(x)=xsin(1/x)f(x) = x \sin(1/x) on the open interval (0,1)(0, 1).

  f(x) = x sin(1/x) on (0,1)

  1 |   /\/\/\/\/\/\___   ← oscillates, |f(x)| ≤ x
    |  /
  0 |--+--+--+--+--+--
    |   \
 -1 |    \/\/\/\/\/\/\   ← oscillates below
    +-+--+--+--+--+--+-
      0                1

The supremum is approached but never attained on (0,1)(0,1) — compactness fails.

Valid case: f(x)=x2xf(x) = x^2 - x on [0,1][0, 1] (compact).

xxf(x)=x2xf(x) = x^2 - x
0.00.00
0.250.1875-0.1875
0.50.25-0.25 ← minimum ✓
0.750.1875-0.1875
1.00.00

Maximum value: 00 (attained at both endpoints x=0x = 0 and x=1x = 1). Minimum: 1/4-1/4 at x=1/2x = 1/2.

Proof Sketch

  1. Boundedness: The continuous image f(K)f(K) of a compact set is compact (general topology). A compact subset of R\mathbb{R} is bounded.
  2. Supremum exists: Since f(K)f(K) is bounded above, M=supf(K)M = \sup f(K) exists in R\mathbb{R}.
  3. Supremum is attained: By compactness of f(K)f(K) (closed and bounded in R\mathbb{R}), Mf(K)M \in f(K). So M=f(x)M = f(x^*) for some xKx^* \in K.
  4. Minimum: Apply the same argument to f-f (or directly to inff(K)\inf f(K)).

Connections

  • Intermediate Value TheoremIntermediate Value Theoremf(a)yf(b)c[a,b]:  f(c)=yf(a) \le y \le f(b) \Rightarrow \exists\, c \in [a,b]:\; f(c) = yA continuous function on a closed interval hits every value between its endpointsRead more → — the IVT shows continuous functions on [a,b][a,b] attain all intermediate values; the EVT shows they attain the extreme values
  • Heine-Borel Theorem — the Heine-Borel theorem characterises compactness in Rn\mathbb{R}^n as closed and bounded, which is what makes [a,b][a,b] the canonical domain for the EVT
  • Bolzano-Weierstrass Theorem — alternatively, the EVT follows from Bolzano-Weierstrass: take a sequence xnx_n with f(xn)supff(x_n) \to \sup f; by BWT it has a convergent subsequence

Lean4 Proof

import Mathlib.Topology.Order.Compact

/-- Extreme Value Theorem (maximum): a continuous function on a compact nonempty set
    attains its maximum. Wraps `IsCompact.exists_isMaxOn`. -/
theorem evt_max {α : Type*} [TopologicalSpace α] {f : α  }
    {s : Set α} (hs : IsCompact s) (hne : s.Nonempty)
    (hf : ContinuousOn f s) :
     x  s, IsMaxOn f s x :=
  hs.exists_isMaxOn hne hf

/-- Extreme Value Theorem (minimum): a continuous function on a compact nonempty set
    attains its minimum. Wraps `IsCompact.exists_isMinOn`. -/
theorem evt_min {α : Type*} [TopologicalSpace α] {f : α  }
    {s : Set α} (hs : IsCompact s) (hne : s.Nonempty)
    (hf : ContinuousOn f s) :
     x  s, IsMinOn f s x :=
  hs.exists_isMinOn hne hf