Documentation

CslibFrontier.Algorithms.WordRAM.HeldKarp

Word-RAM Bellman–Held–Karp dynamic programming for TSP #

Checked standard-basis Word-RAM implementation and O(n² · 2ⁿ) running-time bound for the Bellman–Held–Karp optimal traveling-salesman tour cost [Bel62] [HK62] (Cslib.Algorithms.Lean.TSP.heldKarp).

An instance I : Instance specifies n non-origin cities (n + 1 total cities Fin (n + 1)) and a pairwise distance function I.dist : Fin (n + 1) → Fin (n + 1) → ℕ, encoded in input memory as I.n followed by the (n + 1)² row-major distance entries (Instance.encode). Without using the multiplier instruction (Basis.standard), the fixed program program maintains row and bitmask strides additively, fills the 2ⁿ × (n + 1) subset-by-target table in increasing bitmask order, and halts with heldKarp I.dist in at most 80 (n² · 2ⁿ + 1) instructions at every fitting word width w (Instance.FitsWidth). Every address calculation, bitmask test, memory read/write, comparison, addition, loop branch/jump, and halt is charged.

Main definitions #

Main results #

References #

Problem instances and word-width admissibility #

An (n + 1)-city traveling-salesman distance matrix over ℕ.

  • n : ℕ

    Number of non-origin cities (n + 1 total cities Fin (n + 1)).

  • dist : Fin (self.n + 1) → Fin (self.n + 1) → ℕ

    Pairwise distances between cities in Fin (n + 1).

Flat input word encoding [n, d(0,0), …, d(0,n), …, d(n,0), …, d(n,n)].

Address bound covering the input header, (n + 1)² distance entries, and the 2ⁿ × (n + 1) dynamic-programming table.

Largest single-edge distance in I.dist.

Word width w fits all table addresses/strides and all (n + 1)-step tour costs.

Subset bitmasks and walk-cost bounds #

Structured Word-RAM program #

Uniform standard-basis Word-RAM program computing heldKarp I.dist.

Symbolic execution and loop invariants #

Public running-time theorems #

program computes heldKarp I.dist in at most 80 (n² · 2ⁿ + 1) standard-basis instructions at every fitting word width.

Word-RAM Bellman–Held–Karp execution bound [Bel62] [HK62]. At every fitting word width w, program halts on State.init I.encode with heldKarp I.dist within 80 (n² · 2ⁿ + 1) standard-basis instructions.

Uniform standard-basis Word-RAM computability of Bellman–Held–Karp optimal tour cost in 80 (n² · 2ⁿ + 1) instructions.

Uniform O(n² · 2ⁿ) standard-basis Word-RAM running time for Bellman–Held–Karp optimal tour cost in the number I.n of non-origin cities.