Documentation

CslibFrontier.Algorithms.Lean.TSP.Christofides

Combinatorial 3/2-ratio step and exhaustive-matching Christofides prototype for metric TSP #

This module formalizes the combinatorial 3/2-approximation ratio step after Christofides' construction ([Chr76]; [WS11], Section 2.4, Theorem 2.13), together with an exponential-time prototype (christofidesExhaustive) that substitutes exhaustive search over all (2k - 1)!! perfect matchings (minPerfectMatching) for Edmonds' polynomial-time weighted matching algorithm. It does not formalize Christofides' polynomial-time algorithm ([Chr76]; [WS11], Theorem 2.13): formalizing Edmonds' weighted blossom algorithm ([Edm65]) and certifying polynomial running time remain open in #2869 and #3337.

Given a minimum spanning tree T and a minimum-weight perfect matching M on the odd-degree vertices of T, the construction builds a tour as follows:

  1. compute a minimum spanning tree T of the complete graph (Kruskal's algorithm, kruskalEdges);
  2. supply a minimum-weight perfect matching M on oddVertices T (instantiated in the prototype christofidesExhaustive by super-exponential exhaustive search minPerfectMatching);
  3. compute an Euler circuit of the multigraph T ⊎ M (Hierholzer's algorithm, eulerCircuit);
  4. shortcut it to a tour visiting every vertex once (List.dedup).

The resulting tour costs at most c(T) + c(M) ≤ OPT + OPT / 2.

Model #

Vertices are Fin n and δ : Fin n → Fin n → ℕ is an arbitrary cost function; the cost of a tour is cycleCost δ, as for the minimum-spanning-tree 2-approximation mstTour. The approximation bound assumes that δ is symmetric and satisfies the triangle inequality for all triples; diagonal entries need not be zero. The multigraph T ⊎ M is the edge list T.map WeightedEdge.endpoints ++ M, so an edge of T that M repeats appears twice.

Source mapping #

Combinatorial steps after [WS11], Section 2.4 (not the polynomial-time algorithm of Theorem 2.13; see #2869 and #3337):

The textbook shortcut keeps the first visit to each city; List.dedup keeps the last. Both are subsequences of the Euler circuit, which is all the bound uses.

Limitations #

The concrete tour christofidesExhaustive replaces Edmonds' polynomial-time weighted matching algorithm ([Edm65]) with exhaustive search (minPerfectMatching), which examines (2k - 1)!! matchings on 2k odd-degree vertices (super-exponential in n, e.g. on even-order star metrics where all n = 2k vertices have odd degree in the MST). Neither Edmonds' weighted blossom algorithm nor a machine-level polynomial-time certificate is formalized; both remain open in #2869 and #3337.

Main definitions #

Main results #

References #

Odd-degree vertices #

The vertices of odd degree in the multigraph of the edges of T, in increasing order.

The handshake lemma for T: it has an even number of odd-degree vertices.

The shortcut tour and exhaustive-matching prototype #

The shortcut Euler tour of T and M: Hierholzer's Euler circuit of the multigraph with the edges of T and of M, from vertex 0, keeping only the last visit to each vertex (List.dedup).

Exhaustive-matching prototype after Christofides' construction ([Chr76]; [WS11], Section 2.4): not the cited polynomial-time algorithm. It computes Kruskal's minimum spanning tree T of the complete graph weighted by δ, finds a minimum-weight perfect matching M on oddVertices T via super-exponential (2k - 1)!! exhaustive search (minPerfectMatching), and shortcuts an Euler circuit of T together with M. Replacing exhaustive search with Edmonds' polynomial-time weighted matching ([Edm65]) and certifying polynomial running time remain open in #2869 and #3337.

Feasibility and cost of the shortcut tour #

theorem Cslib.Algorithms.Lean.TSP.shortcutTour_perm {n : ℕ} {W : Type} {T : List (Kruskal.WeightedEdge n W)} (hT : ∀ (a b : Fin n), Relation.EqvGen (fun (x y : Fin n) => ∃ e ∈ T, x = e.u ∧ y = e.v) a b) {M : List (Fin n × Fin n)} (hM : (VertexCover.endpoints M).Perm (oddVertices T)) :

Feasibility. If the edges of T connect all vertices and M is a perfect matching on the odd-degree vertices of T, the shortcut Euler tour visits every vertex exactly once.

theorem Cslib.Algorithms.Lean.TSP.cycleCost_shortcutTour_le {n : ℕ} {δ : Fin n → Fin n → ℕ} (hsymm : ∀ (x y : Fin n), δ x y = δ y x) (htri : ∀ (x y z : Fin n), δ x z ≤ δ x y + δ y z) (hn : 2 ≤ n) {T : List (Kruskal.WeightedEdge n ℕ)} (hTw : ∀ e ∈ T, e.weight = δ e.u e.v) (hT : ∀ (a b : Fin n), Relation.EqvGen (fun (x y : Fin n) => ∃ e ∈ T, x = e.u ∧ y = e.v) a b) {M : List (Fin n × Fin n)} (hM : (VertexCover.endpoints M).Perm (oddVertices T)) :
cycleCost δ (shortcutTour T M) ≤ Kruskal.totalWeight T + (List.map (fun (e : Fin n × Fin n) => δ e.1 e.2) M).sum

Combinatorial shortcutting bound (a step after [WS11], proof of Theorem 2.13): for symmetric δ with the triangle inequality and at least two vertices, if the edges of T connect all vertices and are weighted by δ, and M is a perfect matching on the odd-degree vertices of T, the shortcut Euler tour costs at most T and M together.

Combinatorial 3/2-ratio step and exhaustive-matching bound #

The complete graph on at least one vertex is connected.

Intermediate feasibility step for the (2k - 1)!! exhaustive-matching prototype christofidesExhaustive (not the polynomial-time algorithm of [Chr76]; [WS11], Theorem 2.13; see #2869 and #3337): the prototype tour visits every vertex exactly once.

theorem Cslib.Algorithms.Lean.TSP.two_mul_cycleCost_shortcutTour_le_three_mul {n : ℕ} {δ : Fin n → Fin n → ℕ} (hsymm : ∀ (x y : Fin n), δ x y = δ y x) (htri : ∀ (x y z : Fin n), δ x z ≤ δ x y + δ y z) {T : List (Kruskal.WeightedEdge n ℕ)} (hT : Kruskal.IsMinSpanningTree (completeEdges δ) T) {M : List (Fin n × Fin n)} (hM : (VertexCover.endpoints M).Perm (oddVertices T)) (hmin : ∀ (M' : List (Fin n × Fin n)), (VertexCover.endpoints M').Perm (oddVertices T) → (List.map (fun (e : Fin n × Fin n) => δ e.1 e.2) M).sum ≤ (List.map (fun (e : Fin n × Fin n) => δ e.1 e.2) M').sum) {q : List (Fin n)} (hq : q.Nodup) (hcov : ∀ (x : Fin n), x ∈ q) :

Combinatorial 3/2-ratio step (after [Chr76]; [WS11], Theorem 2.13) for any supplied minimum spanning tree T and any supplied minimum-weight perfect matching M on oddVertices T; this is not the cited polynomial-time algorithm (Edmonds' polynomial-time weighted matching [Edm65] and machine-level polynomial-time certification remain open in #2869 and #3337). For symmetric δ with the triangle inequality, the shortcut Euler tour of T and M costs at most 3/2 times any closed walk visiting every vertex exactly once, in particular an optimal tour.

theorem Cslib.Algorithms.Lean.TSP.two_mul_cycleCost_christofidesExhaustive_le_three_mul {n : ℕ} {δ : Fin n → Fin n → ℕ} (hsymm : ∀ (x y : Fin n), δ x y = δ y x) (htri : ∀ (x y z : Fin n), δ x z ≤ δ x y + δ y z) {q : List (Fin n)} (hq : q.Nodup) (hcov : ∀ (x : Fin n), x ∈ q) :

Prototype combinatorial 3/2-ratio step instantiating two_mul_cycleCost_shortcutTour_le_three_mul with (2k - 1)!! exhaustive matching (minPerfectMatching); this is not the polynomial-time algorithm of [Chr76] / [WS11], Theorem 2.13 (Edmonds' polynomial-time weighted matching [Edm65] and a polynomial-time certificate remain open in #2869 and #3337). For symmetric δ with the triangle inequality, christofidesExhaustive δ costs at most 3/2 times any closed walk visiting every vertex exactly once, in particular an optimal tour.