A minimum-spanning-tree 2-approximation for metric TSP #
This module formalizes a 2-approximation for the metric traveling salesman problem built on a
minimum spanning tree ([WS11], Section 2.4). The algorithm computes a minimum
spanning tree of the complete graph with Kruskal's algorithm (kruskalEdges), then grows a tour
from vertex 0: while some tree edge has exactly one endpoint on the tour, the other endpoint is
inserted immediately after it.
Model #
Vertices are Fin n and δ : Fin n → Fin n → ℕ is an arbitrary cost function. The cost of a
closed walk visiting the entries of a list in order is cycleCost δ t
(CslibFrontier.Algorithms.Lean.TSP.Walk). The approximation bound
assumes only that δ is symmetric and satisfies the triangle inequality for all triples, including
i = k, so each diagonal entry is at most twice any cost from its vertex; diagonal entries need not
be zero. Costs are natural numbers, hence nonnegative.
Source mapping #
[WS11], Section 2.4, proves Lemma 2.10 (a minimum spanning tree costs at most an
optimal tour) by deleting an edge of the tour. Here totalWeight_kruskalEdges_le_cycleCost instead
compares Kruskal's tree with a spanning forest of the tour's edges, which needs no edge deletion.
Theorem 2.11 (nearest addition is a 2-approximation) charges each insertion of a city j after i
at most c_ij + c_ji = 2 c_ij, by the triangle inequality; summed over the edges of the spanning
tree built by Prim's algorithm, the tour costs at most twice the tree. The same charging argument
applies to any spanning tree whose edges guide the insertions, so mstTour uses the tree computed
by the library's Kruskal implementation (cycleCost_insertAfter_le,
cycleCost_mstTour_le_two_mul_totalWeight). Like the double-tree algorithm of Theorem 2.12, it
computes the tree first and then derives the tour from it.
Limitations #
The algorithm is a pure Lean function; no machine-level running time is certified. The bound is stated against every tour, in particular an optimal one.
Main definitions #
Cslib.Algorithms.Lean.TSP.insertAfter: insertion immediately after a given vertex.Cslib.Algorithms.Lean.TSP.growTour: grow a tour along the edges of a forest.Cslib.Algorithms.Lean.TSP.completeEdges: the complete graph weighted byδ.Cslib.Algorithms.Lean.TSP.mstTour: the tour grown along Kruskal's minimum spanning tree.
Main results #
cycleCost_insertAfter_le: an insertion costs at mostδ u v + δ v u(triangle inequality).mstTour_perm:mstTour δvisits every vertex exactly once.totalWeight_kruskalEdges_completeEdges_le: Kruskal's tree on the complete graph weighs at most any duplicate-free connected list of its edges.totalWeight_kruskalEdges_le_cycleCost: the minimum spanning tree costs at most any tour.cycleCost_mstTour_le_two_mul_totalWeight: forn ≥ 2, the tour costs at most twice the tree.cycleCost_mstTour_le_two_mul: for symmetricδwith the triangle inequality, the tour costs at most twice any tour.
References #
Closed walks and insertion #
The insertion step ([WS11], proof of Theorem 2.11): inserting v right
after u in a closed walk costs at most δ u v + δ v u, by the triangle inequality.
Insert v immediately after the first occurrence of u in t (at the end if u ∉ t).
Instances For
Inserting after a vertex of the walk adds exactly the inserted vertex.
The insertion bound ([WS11], proof of Theorem 2.11): inserting v after a
vertex u of a closed walk raises its cost by at most δ u v + δ v u.
Growing a tour along a forest #
Whether exactly one endpoint of e is on the tour t.
Instances For
Insert the endpoint of e that is off the tour immediately after the endpoint on it.
Instances For
Growing a tour along F: while some edge of F has exactly one endpoint on the tour,
insert its other endpoint right after it, the first such edge of F first; at most k
insertions.
Instances For
A crossing step inserts the endpoint b off the tour right after the endpoint a on it.
Coverage. If the edges of F connect all of Fin n and there is fuel for n vertices,
growing a nonempty tour without repetitions reaches every vertex.
The charging argument #
The algorithm #
Kruskal's tree on the complete graph connects all vertices.
Feasibility. The MST tour visits every vertex exactly once.
The upper bound ([WS11], proof of Theorem 2.11): for symmetric δ with
the triangle inequality and at least two vertices, the MST tour costs at most twice the tree.
The lower bound #
Kruskal's tree on the complete graph weighs at most any duplicate-free list of its edges that connects all vertices.
The lower bound ([WS11], Lemma 2.10): the minimum spanning tree of the complete graph costs at most any closed walk visiting every vertex exactly once. The tour's edges form a connected subgraph of the complete graph, so Kruskal's forest of them is a spanning forest, which weighs at least the minimum spanning tree and at most the tour.
The factor 2 #
The MST 2-approximation for metric TSP ([WS11], Section 2.4): for
symmetric δ with the triangle inequality, the MST tour costs at most twice any closed walk
visiting every vertex exactly once, in particular an optimal tour.