Documentation

CslibFrontier.Algorithms.Lean.KCenter.HochbaumShmoys

Hochbaum–Shmoys threshold 2-approximation for metric k-center #

This module formalizes the parametric threshold 2-approximation algorithm for metric k-center following the bottleneck threshold method of [HS85] (see also the chapter notes of [WS11], Chapter 2).

Algorithm and source mapping #

For a candidate threshold r, the threshold graph thresholdGraph d r connects distinct vertices at distance at most r in both directions. Under symmetry and d v v ≤ r, a set of centers has radius at most r exactly when it dominates thresholdGraph d r (radius_le_coe_iff_isDominatingSet).

Given a list P of points, thresholdPacking d r P scans P and greedily adds a vertex whenever it lies strictly farther than 2 * r from all previously selected centers; thresholdCenters d P r is its underlying Finset. Thus thresholdCenters d P r is a maximal independent set of thresholdGraph d (2 * r) (both independent and dominating under symmetry) and an independent set of the square of thresholdGraph d r by the triangle inequality (not_common_neighbor_thresholdCenters). The original presentation of [HS85] computes a maximal independent set of the graph square (thresholdGraph d r)² directly; the greedy 2r-packing variant formalized here satisfies the same two guarantees:

  1. Covering (radius_thresholdCenters_le): every vertex is within 2 * r of thresholdCenters d P r (whenever ∀ v, d v v ≤ 2 * r).
  2. Packing lower bound (card_thresholdCenters_le_of_radius_le, lt_optRadius_of_lt_card_thresholdCenters): if any set of at most k centers achieves radius at most r, then (thresholdCenters d P r).card ≤ k, via length_le_card_of_pairwise_lt.

Finally, hochbaumShmoys d P k evaluates thresholdCenters d P r across all pairwise distances d u v (u, v ∈ P) and returns the centers for the smallest feasible threshold r with (thresholdCenters d P r).card ≤ k (or ∅ if none is feasible). Because the finite optimum optRadius d k is attained at some pairwise distance d v c, the chosen threshold is at most the optimum, yielding a 2-approximation (hochbaumShmoys_approx) using only symmetry and the triangle inequality.

Limitations #

The algorithm is a pure Lean function over a list of points; no machine-level Word-RAM running time is certified (tracked in #9248). As noted above, the threshold subroutine uses a greedy 2r-packing rather than constructing the explicit graph square (thresholdGraph d r)².

Main definitions #

Main results #

References #

Threshold graph #

def Cslib.Algorithms.Lean.KCenter.thresholdGraph {V : Type u_1} {α : Type u_2} [LinearOrder α] (d : V → V → α) (r : α) :

The threshold graph at radius r: distinct vertices u and v are adjacent when d u v ≤ r and d v u ≤ r. Under symmetry this reduces to u ≠ v ∧ d u v ≤ r (thresholdGraph_adj_iff).

@[instance_reducible]
theorem Cslib.Algorithms.Lean.KCenter.thresholdGraph_adj_iff {V : Type u_1} {α : Type u_2} [LinearOrder α] {d : V → V → α} {r : α} (hsymm : ∀ (x y : V), d x y = d y x) {u v : V} :
(thresholdGraph d r).Adj u v ↔ u ≠ v ∧ d u v ≤ r

Under a symmetric distance, adjacency in thresholdGraph d r is u ≠ v ∧ d u v ≤ r.

theorem Cslib.Algorithms.Lean.KCenter.radius_le_coe_iff_isDominatingSet {V : Type u_1} {α : Type u_2} [LinearOrder α] {d : V → V → α} {r : α} [Fintype V] [Nonempty V] (hsymm : ∀ (x y : V), d x y = d y x) (hself : ∀ (v : V), d v v ≤ r) {S : Finset V} :

On a finite nonempty space with symmetric distance satisfying d v v ≤ r, a set of centers has radius at most r exactly when it dominates thresholdGraph d r.

Greedy 2r-packing and threshold centers #

def Cslib.Algorithms.Lean.KCenter.thresholdPacking {V : Type u_1} {α : Type u_2} [LinearOrder α] [Semiring α] (d : V → V → α) (r : α) (P : List V) :

Greedy 2r-packing of P: scan P and select a vertex whenever it is strictly farther than 2 * r from all previously selected vertices.

def Cslib.Algorithms.Lean.KCenter.thresholdCenters {V : Type u_1} {α : Type u_2} [LinearOrder α] [Semiring α] [DecidableEq V] (d : V → V → α) (P : List V) (r : α) :

The set of centers chosen by the greedy 2r-packing at threshold r.

theorem Cslib.Algorithms.Lean.KCenter.thresholdPacking_subset {V : Type u_1} {α : Type u_2} [LinearOrder α] [Semiring α] (d : V → V → α) (r : α) (P : List V) (x : V) :
x ∈ thresholdPacking d r P → x ∈ P

Every vertex selected by thresholdPacking belongs to P.

theorem Cslib.Algorithms.Lean.KCenter.pairwise_thresholdPacking {V : Type u_1} {α : Type u_2} [LinearOrder α] [Semiring α] (d : V → V → α) (r : α) (P : List V) :
List.Pairwise (fun (a b : V) => 2 * r < d a b) (thresholdPacking d r P)

Consecutive and pairwise entries of thresholdPacking d r P are strictly farther than 2 * r apart.

theorem Cslib.Algorithms.Lean.KCenter.thresholdPacking_cover_or_mem {V : Type u_1} {α : Type u_2} [LinearOrder α] [Semiring α] (d : V → V → α) (r : α) (P : List V) {v : V} (hv : v ∈ P) :
v ∈ thresholdPacking d r P ∨ ∃ c ∈ thresholdPacking d r P, d v c ≤ 2 * r

Every point v ∈ P is either selected by thresholdPacking d r P or within 2 * r of a selected point.

theorem Cslib.Algorithms.Lean.KCenter.isIndepSet_thresholdCenters {V : Type u_1} {α : Type u_2} [LinearOrder α] [Semiring α] [DecidableEq V] {d : V → V → α} (hsymm : ∀ (x y : V), d x y = d y x) (P : List V) (r : α) :

Under a symmetric distance, thresholdCenters d P r is an independent set of thresholdGraph d (2 * r).

theorem Cslib.Algorithms.Lean.KCenter.isDominatingSet_thresholdCenters {V : Type u_1} {α : Type u_2} [LinearOrder α] [Semiring α] [DecidableEq V] {d : V → V → α} (hsymm : ∀ (x y : V), d x y = d y x) {P : List V} (hP : ∀ (v : V), v ∈ P) (r : α) :

Under a symmetric distance on a list covering all points, thresholdCenters d P r dominates thresholdGraph d (2 * r) (so it is a maximal independent set of thresholdGraph d (2 * r)).

theorem Cslib.Algorithms.Lean.KCenter.not_common_neighbor_thresholdCenters {V : Type u_1} {α : Type u_2} [LinearOrder α] [Semiring α] [DecidableEq V] [IsOrderedAddMonoid α] {d : V → V → α} (hsymm : ∀ (x y : V), d x y = d y x) (htri : ∀ (x y z : V), d x z ≤ d x y + d y z) {P : List V} {r : α} {u v : V} (hu : u ∈ thresholdCenters d P r) (hv : v ∈ thresholdCenters d P r) (hne : u ≠ v) :
¬∃ (w : V), (thresholdGraph d r).Adj u w ∧ (thresholdGraph d r).Adj w v

Independence in the square of thresholdGraph d r: under symmetry and the triangle inequality, two distinct centers in thresholdCenters d P r share no common neighbor in thresholdGraph d r.

theorem Cslib.Algorithms.Lean.KCenter.radius_thresholdCenters_le {V : Type u_1} {α : Type u_2} [LinearOrder α] [Semiring α] [DecidableEq V] [Fintype V] [Nonempty V] {d : V → V → α} {P : List V} {r : α} (hP : ∀ (v : V), v ∈ P) (hself : ∀ (v : V), d v v ≤ 2 * r) :
radius d (thresholdCenters d P r) ≤ ↑(2 * r)

Covering at threshold r: if P contains every vertex and d v v ≤ 2 * r, then thresholdCenters d P r has radius at most 2 * r.

theorem Cslib.Algorithms.Lean.KCenter.card_thresholdCenters_le_of_radius_le {V : Type u_1} {α : Type u_2} [LinearOrder α] [Semiring α] [DecidableEq V] [IsOrderedAddMonoid α] [Fintype V] [Nonempty V] {d : V → V → α} (hsymm : ∀ (x y : V), d x y = d y x) (htri : ∀ (x y z : V), d x z ≤ d x y + d y z) {P : List V} {S : Finset V} {k : ℕ} {r : α} (hS : S.card ≤ k) (hr : radius d S ≤ ↑r) :

Packing bound at threshold r ([HS85]): if any set S of at most k centers achieves radius at most r, then thresholdCenters d P r has at most k centers.

theorem Cslib.Algorithms.Lean.KCenter.lt_optRadius_of_lt_card_thresholdCenters {V : Type u_1} {α : Type u_2} [LinearOrder α] [Semiring α] [DecidableEq V] [IsOrderedAddMonoid α] [Fintype V] [Nonempty V] {d : V → V → α} (hsymm : ∀ (x y : V), d x y = d y x) (htri : ∀ (x y z : V), d x z ≤ d x y + d y z) {P : List V} {k : ℕ} {r : α} (hk : k < (thresholdCenters d P r).card) :
↑r < optRadius d k

Infeasibility certificate: if thresholdCenters d P r has more than k centers, then every set of at most k centers has radius strictly greater than r.

Parametric threshold 2-approximation #

def Cslib.Algorithms.Lean.KCenter.hochbaumShmoys {V : Type u_1} {α : Type u_2} [LinearOrder α] [Semiring α] [DecidableEq V] (d : V → V → α) (P : List V) (k : ℕ) :

Hochbaum–Shmoys parametric threshold algorithm ([HS85]): searches all pairwise distances d u v (u, v ∈ P) for the smallest threshold r whose greedy 2r-packing uses at most k centers, and returns thresholdCenters d P r (or ∅ if no threshold is feasible).

theorem Cslib.Algorithms.Lean.KCenter.card_hochbaumShmoys_le {V : Type u_1} {α : Type u_2} [LinearOrder α] [Semiring α] [DecidableEq V] (d : V → V → α) (P : List V) (k : ℕ) :

Feasibility: hochbaumShmoys d P k returns at most k centers.

theorem Cslib.Algorithms.Lean.KCenter.hochbaumShmoys_approx {V : Type u_1} {α : Type u_2} [LinearOrder α] [Semiring α] [DecidableEq V] [IsOrderedAddMonoid α] [Fintype V] [Nonempty V] {d : V → V → α} (hsymm : ∀ (x y : V), d x y = d y x) (htri : ∀ (x y z : V), d x z ≤ d x y + d y z) {P : List V} (hP : ∀ (v : V), v ∈ P) {k : ℕ} {r : α} (hr : optRadius d k ≤ ↑r) :
radius d (hochbaumShmoys d P k) ≤ ↑(2 * r)

Hochbaum–Shmoys threshold algorithm is a 2-approximation for k-center ([HS85]; [WS11], Section 2.2): on a finite space with a symmetric distance satisfying the triangle inequality, run on a list P of all the points, the chosen centers have radius at most 2 * r for every bound r on the optimal radius.