Documentation

CslibFrontier.Algorithms.Lean.TSP.Shortcut

Shortcutting closed walks #

Under the triangle inequality, skipping vertices of a closed walk does not increase its cost ([WS11], Section 2.4, proof of Theorem 2.12). In particular, the distinct vertices of an Euler circuit of a multigraph H, visited in order, form a closed walk costing at most the total weight of H. This is the last step of the double-tree algorithm and of Christofides' algorithm.

Model #

Closed walks are lists of vertices with cost Cslib.Algorithms.Lean.TSP.cycleCost; walks along consecutive pairs and Euler circuits are those of Cslib.Algorithms.Lean.Euler. Shortcutting is modelled by List.Sublist: any subsequence of a closed walk is a shortcut of it. Mathlib's List.dedup keeps the last occurrence of each vertex, whereas [WS11] keeps the first; both are subsequences, and the cost bound only uses that.

Main results #

References #

theorem Cslib.Algorithms.Lean.TSP.cycleCost_cons_eq_sum_consecutivePairs {α : Type u_1} (δ : α → α → ℕ) (a : α) (L : List α) :
cycleCost δ (a :: L) = (List.map (fun (e : α × α) => δ e.1 e.2) (a :: L ++ [a]).consecutivePairs).sum

The cost of a closed walk from a is the cost of the walk a :: L ++ [a] along consecutive pairs.

theorem Cslib.Algorithms.Lean.TSP.cycleCost_le_of_sublist {α : Type u_1} (δ : α → α → ℕ) (htri : ∀ (x y z : α), δ x z ≤ δ x y + δ y z) {l₁ l₂ : List α} (h : l₁.Sublist l₂) :
cycleCost δ l₁ ≤ cycleCost δ l₂

Shortcutting ([WS11], Section 2.4): under the triangle inequality, skipping vertices of a closed walk does not increase its cost.

theorem Cslib.Algorithms.Lean.TSP.cycleCost_dedup_le_of_isEulerCircuit {α : Type u_1} [DecidableEq α] {δ : α → α → ℕ} (htri : ∀ (x y z : α), δ x z ≤ δ x y + δ y z) (hsymm : ∀ (x y : α), δ x y = δ y x) {H : List (α × α)} {u : α} {w : List α} (hw : Euler.IsEulerCircuit H u w) (hH : H ≠ []) :
cycleCost δ w.dedup ≤ (List.map (fun (e : α × α) => δ e.1 e.2) H).sum

Shortcutting an Euler circuit: under symmetry and the triangle inequality, the closed walk visiting the distinct vertices of an Euler circuit of a nonempty multigraph H (in order of last occurrence) costs at most the total weight of H.