Documentation

CslibFrontier.Algorithms.Lean.SteinerTree.Metric

The MST 2-approximation for metric Steiner tree #

In the Steiner tree problem we must connect a set R of terminals as cheaply as possible, and may route through other points (Steiner points). This module proves that a minimum spanning tree on the terminals alone costs at most twice the optimum when the cost is symmetric and satisfies the triangle inequality ([WS11], Exercise 2.5(a)). Williamson and Shmoys attribute the factor 2 to Moore, as described in [GP68] ([WS11], Chapter 12 notes). We prove the sharper form |R| · MST ≤ 2 (|R| - 1) · OPT.

Model #

Points have an arbitrary type α and a cost δ : α → α → ℕ. An edge set is a list of ordered pairs T : List (α × α) with additive cost edgeCost δ T. Connects T R says that the equivalence relation generated by the edges of T relates every two terminals. The edges may use any points of α, so T may pass through Steiner points. steinerOpt δ R is the least cost of a list that connects R. Costs are in ℕ, hence nonnegative, so this is also the least cost of a tree that connects R: dropping edges that close cycles keeps connectivity and does not increase the cost.

The algorithm steinerMST δ R takes a duplicate-free list of terminals R. It runs Kruskal's algorithm (Cslib.Algorithms.Lean.Kruskal.kruskalEdges) on the complete graph on the indices Fin R.length with costs terminalCost δ R i j = δ R[i] R[j], and maps the resulting tree back to the terminals. This is the minimum spanning tree of the subgraph G[R] induced by the terminals in the source. The bounds need R.Nodup because δ x x may be positive. With δ x x = 5, the heuristic pays 5 to join the two copies in R = [1, 1], while steinerOpt δ [1, 1] = 0 (see CslibFrontierTests.SteinerTree). When the diagonal cost is zero (∀ x, δ x x = 0), repeated terminals do not increase the cycle cost, and the bounds hold for arbitrary terminal lists (length_mul_edgeCost_steinerMST_le_of_diag).

Source mapping #

Proof #

Restrict a connecting list T to the component that contains the terminals, then double each edge. Every vertex now has even degree, so Hierholzer's algorithm (Cslib.Algorithms.Lean.Euler.eulerCircuit) gives an Euler circuit of cost 2 · cost(T). Shortcutting it to the terminals (Cslib.Algorithms.Lean.TSP.cycleCost_le_of_sublist) gives a Hamiltonian cycle on R of cost at most 2 · cost(T). Deleting its most expensive edge leaves a Hamiltonian path that costs at most (1 - 1/|R|) of the cycle, and the path weighs at least the minimum spanning tree (mul_totalWeight_kruskalEdges_le).

Main definitions #

Main results #

Limitations #

The statements are about the output and the optimum, not about running time. No time bound for steinerMST is stated here.

References #

The problem #

def Cslib.Algorithms.Lean.SteinerTree.Connects {α : Type u_1} (T : List (α × α)) (R : List α) :

The edges of T connect every two terminals in R.

def Cslib.Algorithms.Lean.SteinerTree.edgeCost {α : Type u_1} (δ : α → α → ℕ) (T : List (α × α)) :

The cost of an edge list.

noncomputable def Cslib.Algorithms.Lean.SteinerTree.steinerOpt {α : Type u_1} (δ : α → α → ℕ) (R : List α) :

The optimum Steiner cost: the least cost of an edge list that connects R. The set is never empty, since steinerMST δ R connects R (exists_connects_edgeCost_eq_steinerOpt).

theorem Cslib.Algorithms.Lean.SteinerTree.steinerOpt_le {α : Type u_1} {δ : α → α → ℕ} {R : List α} {T : List (α × α)} (hT : Connects T R) :

The algorithm #

def Cslib.Algorithms.Lean.SteinerTree.terminalCost {α : Type u_1} (δ : α → α → ℕ) (R : List α) (i j : Fin R.length) :

The cost on the indices of the terminal list R.

def Cslib.Algorithms.Lean.SteinerTree.steinerMST {α : Type u_1} (δ : α → α → ℕ) (R : List α) :
List (α × α)

The MST heuristic: Kruskal's minimum spanning tree of the complete graph on the terminals, as a list of pairs of terminals.

theorem Cslib.Algorithms.Lean.SteinerTree.connects_steinerMST {α : Type u_1} (δ : α → α → ℕ) (R : List α) :

The heuristic connects the terminals.

theorem Cslib.Algorithms.Lean.SteinerTree.exists_connects_edgeCost_eq_steinerOpt {α : Type u_1} (δ : α → α → ℕ) (R : List α) :
∃ (T : List (α × α)), Connects T R ∧ edgeCost δ T = steinerOpt δ R

The optimum is attained.

Minimum spanning trees of complete graphs #

theorem Cslib.Algorithms.Lean.SteinerTree.totalWeight_kruskalEdges_le_sum_consecutivePairs {k : ℕ} (δ : Fin k → Fin k → ℕ) {q : List (Fin k)} (hq : q.Nodup) (hcov : ∀ (x : Fin k), x ∈ q) :

Kruskal's tree on the complete graph weighs at most any Hamiltonian path.

theorem Cslib.Algorithms.Lean.SteinerTree.mul_totalWeight_kruskalEdges_le {k : ℕ} (δ : Fin k → Fin k → ℕ) {q : List (Fin k)} (hq : q.Nodup) (hcov : ∀ (x : Fin k), x ∈ q) :

Minimum spanning tree versus Hamiltonian cycle, sharpened: for every Hamiltonian cycle q of the complete graph on k vertices, k · MST ≤ (k - 1) · cost(q). Deleting the most expensive of the k edges of q leaves a Hamiltonian path costing at most (1 - 1/k) · cost(q). This sharpens [WS11], Lemma 2.10 (totalWeight_kruskalEdges_le_cycleCost).

The approximation guarantee #

theorem Cslib.Algorithms.Lean.SteinerTree.eqvGen_filter_of_invariant {α : Type u_1} {T : List (α × α)} {P : α → Bool} (hinv : ∀ e ∈ T, P e.1 = P e.2) {a b : α} (hab : Relation.EqvGen (fun (x y : α) => (x, y) ∈ T) a b) (ha : P a = true) :
Relation.EqvGen (fun (x y : α) => (x, y) ∈ List.filter (fun (e : α × α) => P e.1) T) a b

Filtering an edge list T by a vertex predicate P that is invariant along edges of T preserves connectivity (Relation.EqvGen) among vertices satisfying P.

theorem Cslib.Algorithms.Lean.SteinerTree.eqvGen_filter_component {α : Type u_1} {T : List (α × α)} {u a b : α} [DecidablePred fun (x : α) => Relation.EqvGen (fun (p q : α) => (p, q) ∈ T) x u] (hab : Relation.EqvGen (fun (x y : α) => (x, y) ∈ T) a b) (ha : Relation.EqvGen (fun (x y : α) => (x, y) ∈ T) a u) :
Relation.EqvGen (fun (x y : α) => (x, y) ∈ List.filter (fun (e : α × α) => decide (Relation.EqvGen (fun (p q : α) => (p, q) ∈ T) e.1 u)) T) a b

Filtering T to edges in u's connected component preserves connectivity within that component.

theorem Cslib.Algorithms.Lean.SteinerTree.length_mul_edgeCost_steinerMST_le {α : Type u_1} {δ : α → α → ℕ} (hsymm : ∀ (x y : α), δ x y = δ y x) (htri : ∀ (x y z : α), δ x z ≤ δ x y + δ y z) {R : List α} (hR : R.Nodup) {T : List (α × α)} (hT : Connects T R) :
R.length * edgeCost δ (steinerMST δ R) ≤ 2 * (R.length - 1) * edgeCost δ T

The MST heuristic for metric Steiner tree, sharp form: for a symmetric cost with the triangle inequality and duplicate-free terminals R, |R| · cost(steinerMST δ R) ≤ 2 (|R| - 1) · cost(T) for every edge list T connecting R. This is the factor 2 (1 - 1/|R|), a restricted form of [KMB81]'s 2 (1 - 1/ℓ) with ℓ the number of leaves of an optimal tree.

theorem Cslib.Algorithms.Lean.SteinerTree.length_mul_edgeCost_steinerMST_le_of_diag {α : Type u_1} {δ : α → α → ℕ} (hdiag : ∀ (x : α), δ x x = 0) (hsymm : ∀ (x y : α), δ x y = δ y x) (htri : ∀ (x y z : α), δ x z ≤ δ x y + δ y z) {R : List α} {T : List (α × α)} (hT : Connects T R) :
R.length * edgeCost δ (steinerMST δ R) ≤ 2 * (R.length - 1) * edgeCost δ T

The MST heuristic for metric Steiner tree with zero diagonal: when ∀ x, δ x x = 0, |R| · cost(steinerMST δ R) ≤ 2 (|R| - 1) · cost(T) for every edge list T connecting R, without assuming R.Nodup. Steps between duplicate visits inside a block cost zero.

theorem Cslib.Algorithms.Lean.SteinerTree.edgeCost_steinerMST_le_two_mul {α : Type u_1} {δ : α → α → ℕ} (hsymm : ∀ (x y : α), δ x y = δ y x) (htri : ∀ (x y z : α), δ x z ≤ δ x y + δ y z) {R : List α} (hR : R.Nodup) {T : List (α × α)} (hT : Connects T R) :
edgeCost δ (steinerMST δ R) ≤ 2 * edgeCost δ T

The MST heuristic for metric Steiner tree ([WS11], Exercise 2.5(a)): the heuristic costs at most twice any edge list connecting the terminals.

theorem Cslib.Algorithms.Lean.SteinerTree.edgeCost_steinerMST_le_two_mul_of_diag {α : Type u_1} {δ : α → α → ℕ} (hdiag : ∀ (x : α), δ x x = 0) (hsymm : ∀ (x y : α), δ x y = δ y x) (htri : ∀ (x y z : α), δ x z ≤ δ x y + δ y z) {R : List α} {T : List (α × α)} (hT : Connects T R) :
edgeCost δ (steinerMST δ R) ≤ 2 * edgeCost δ T

The 2-approximation for zero-diagonal costs and arbitrary terminal lists.

theorem Cslib.Algorithms.Lean.SteinerTree.edgeCost_steinerMST_le_two_mul_steinerOpt {α : Type u_1} {δ : α → α → ℕ} (hsymm : ∀ (x y : α), δ x y = δ y x) (htri : ∀ (x y z : α), δ x z ≤ δ x y + δ y z) {R : List α} (hR : R.Nodup) :

The MST 2-approximation for metric Steiner tree ([WS11], Exercise 2.5(a)): cost(steinerMST δ R) ≤ 2 · OPT.

theorem Cslib.Algorithms.Lean.SteinerTree.edgeCost_steinerMST_le_two_mul_steinerOpt_of_diag {α : Type u_1} {δ : α → α → ℕ} (hdiag : ∀ (x : α), δ x x = 0) (hsymm : ∀ (x y : α), δ x y = δ y x) (htri : ∀ (x y z : α), δ x z ≤ δ x y + δ y z) {R : List α} :

The 2-approximation against the optimum for zero-diagonal costs.

theorem Cslib.Algorithms.Lean.SteinerTree.length_mul_edgeCost_steinerMST_le_steinerOpt {α : Type u_1} {δ : α → α → ℕ} (hsymm : ∀ (x y : α), δ x y = δ y x) (htri : ∀ (x y z : α), δ x z ≤ δ x y + δ y z) {R : List α} (hR : R.Nodup) :
R.length * edgeCost δ (steinerMST δ R) ≤ 2 * (R.length - 1) * steinerOpt δ R

The sharp form against the optimum: |R| · cost(steinerMST δ R) ≤ 2 (|R| - 1) · OPT.

theorem Cslib.Algorithms.Lean.SteinerTree.length_mul_edgeCost_steinerMST_le_steinerOpt_of_diag {α : Type u_1} {δ : α → α → ℕ} (hdiag : ∀ (x : α), δ x x = 0) (hsymm : ∀ (x y : α), δ x y = δ y x) (htri : ∀ (x y z : α), δ x z ≤ δ x y + δ y z) {R : List α} :
R.length * edgeCost δ (steinerMST δ R) ≤ 2 * (R.length - 1) * steinerOpt δ R

The sharp form against the optimum for zero-diagonal costs.