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 #
Cslib.Algorithms.WordRAM.HeldKarp.Instance:(n + 1) × (n + 1)natural distance matrix, its flat word encodingInstance.encode, address boundInstance.spaceBound, maximum entryInstance.maxEntry, and width conditionInstance.FitsWidth.Cslib.Algorithms.WordRAM.HeldKarp.program: uniformProgram .standard 18computing optimal tour cost.
Main results #
Cslib.Algorithms.WordRAM.HeldKarp.Instance.FitsWidth.inputFits,Instance.inputAdmissible: word-width fit impliesInputFitsand every instance admits a fitting width.Cslib.Algorithms.WordRAM.HeldKarp.executes_program,computesInTime_program,uniformComputableInTime_heldKarp:programcomputesheldKarp I.distwithin80 (n² · 2ⁿ + 1)standard-basis instructions.Cslib.Algorithms.WordRAM.HeldKarp.uniformComputableInO_heldKarp: uniformO(n² · 2ⁿ)Word-RAM running time inI.n.
References #
Problem instances and word-width admissibility #
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.