Documentation

CslibFrontier.Computability.Complexity.Problems.TSP.HeldKarp

Deciding TSP by the Bellman–Held–Karp algorithm #

This file connects the Bellman–Held–Karp dynamic program Cslib.Algorithms.Lean.TSP.heldKarp [Bel62] [HK62] to the decision problem Cslib.Complexity.TSP on instances x : TSPInstance and certifies its exponential running time on deterministic multi-tape Turing machines.

An instance x with x.dist.length = n + 1 has the cities 0, …, n at distances TSP.dist x.dist i j, and it belongs to TSP when some ordering of all cities has closed tour length at most x.bound. The tour length is the closed-walk cost cycleCost (dist x.dist) (TSP.tourLength_eq_cycleCost), which is invariant under rotation (cycleCost_append_comm), so such a tour can be taken to start at city 0, which is the normal form heldKarp optimizes over.

For the multi-tape Turing-machine realization, the DP table of 2 ^ n subset rows (each row holding n + 1 optional binary tour costs List (Option ℕ)) is processed in streaming passes via a cyclic bit-rotation butterfly (evens table ++ passOdds row i table): each pass pairs adjacent even/odd entries (i ∉ S vs. i ∈ S), relaxes S from S \ {i}, and moves bit i to the back of the table ordering so that n passes restore the original order and complete one Bellman–Held–Karp stage, repeated n times (O(2 ^ n · poly(|encTSP x|)) total steps, with zero quadratic 4 ^ n table-copying overhead). Composing with the polynomial-time reduction HamCycle.toTSP decides HamCycle within 2 ^ (n - 1) · poly(|encGraph G|) multi-tape steps.

Main definitions #

Main results #

References #

The length of a tour is the cost of the closed walk through its cities under dist D.

theorem Cslib.Complexity.TSP.mem_TSP_iff_heldKarp_le {x : TSPInstance} {n : ℕ} (hn : x.dist.length = n + 1) :
x ∈ TSP ↔ (Algorithms.Lean.TSP.heldKarp fun (i j : Fin (n + 1)) => dist x.dist ↑i ↑j) ≤ x.bound

TSP by the Bellman–Held–Karp algorithm. An instance with n + 1 cities belongs to TSP exactly when the optimal tour computed by heldKarp has length at most the budget.

Decide TSP by the Bellman–Held–Karp algorithm [HK62]: run heldKarp on the distance matrix and compare the optimal tour length with the budget. The empty matrix is a yes-instance, witnessed by the empty tour.

Multi-tape Turing-machine exponential-time realization #

Streaming list-pass combinator and DP correctness #

Full DP iteration and semantic equivalence #

TSP in exponential time 2 ^ (n - 1) · poly(|encTSP x|) on multi-tape Turing machines. heldKarpDecide is computable within time and space O(2 ^ (x.dist.length - 1) · (|encTSP x| + 1) ^ e) for some polynomial exponent e.

TSP is in DTIME(2 ^ (n - 1) · poly(|encTSP x|)) on multi-tape Turing machines, where n = x.dist.length is the number of cities (μ x = x.dist.length - 1, δ = 1).

Deciding HamCycle by reducing to TSP via HamCycle.toTSP and running TSP.heldKarpDecide.

HamCycle in exponential time 2 ^ (n - 1) · poly(|encGraph G|) on multi-tape Turing machines, where n = G.distinctVertices.length.

HamCycle is in DTIME(2 ^ (n - 1) · poly(|encGraph G|)) on multi-tape Turing machines, where n = G.distinctVertices.length (μ G = G.distinctVertices.length - 1, δ = 1).