Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 3 — every insertion method gives INSERT ≤ (⌈lg n⌉ + 1)·OPTIMAL

Proved
TSPHeuristics.Insertion.insert_le_clog_add_one_mul_optimal

by mikedeng1 · Sep 27, 2026 · Mathlib 0df444a (Lean v4.33.1)

approximation-ratioinsertionp2o-batch-p100ap2o-gran-per-chapterp2o-plan-paperp2o-v1traveling-salesman

Let (N,d)(N,d)(N,d) be a traveling salesman graph with n≥1n\ge1n≥1 nodes (symmetric, nonnegative distances satisfying the triangle inequality). Let T1,…,TnT_1,\dots,T_nT1​,…,Tn​ be the subtours of any insertion method: T1T_1T1​ is a single node a0a_0a0​, and each Ti+1T_{i+1}Ti+1​ is obtained from TiT_iTi​ by inserting some node ai∉Tia_i\notin T_iai​∈/Ti​ at a position that minimizes the increase in length. Let INSERT be the length of the final tour TnT_nTn​ and OPTIMAL the length of a shortest tour. Then

INSERT ≤ (⌈lg⁡n⌉+1) OPTIMAL.(3.6)\mathrm{INSERT}\ \le\ \bigl(\lceil\lg n\rceil+1\bigr)\,\mathrm{OPTIMAL}.\tag{3.6}INSERT ≤ (⌈lgn⌉+1)OPTIMAL.(3.6)

The bound holds regardless of how the nodes aia_iai​ are selected and how ties between insertion positions are broken. It places every insertion heuristic (nearest, cheapest, farthest, random, arbitrary insertion) within a logarithmic factor of optimal.

Formalization Note Subtours are lists of nodes; the closed length of a list [x0,…,xm−1][x_0,\dots,x_{m-1}][x0​,…,xm−1​] is d(x0,x1)+⋯+d(xm−2,xm−1)+d(xm−1,x0)d(x_0,x_1)+\dots+d(x_{m-2},x_{m-1})+d(x_{m-1},x_0)d(x0​,x1​)+⋯+d(xm−2​,xm−1​)+d(xm−1​,x0​). The paper's 1-based subtour index is kept: T1=[a0]T_1=[a_0]T1​=[a0​], and TnT_nTn​ is the final tour. Every choice of the inserted nodes and every minimizing insertion position is allowed. d(i,i)=0d(i,i)=0d(i,i)=0 is assumed as a normalization (not in the paper; it never enters a length). The paper's ratio INSERT/OPTIMAL≤⌈lg⁡n⌉+1\mathrm{INSERT}/\mathrm{OPTIMAL}\le\lceil\lg n\rceil+1INSERT/OPTIMAL≤⌈lgn⌉+1 is stated multiplied out, so the case OPTIMAL =0=0=0 (which the paper excludes by (1.1)) needs no separate hypothesis. ⌈lg⁡n⌉\lceil\lg n\rceil⌈lgn⌉ is Nat.clog 2 n.

Preamble
import Mathlib
import Definitions.Def_TSPHeuristics_Shared_TSPModel
import Definitions.Def_TSPHeuristics_Insertion_InsertionMethod
Formal statement
namespace TSPHeuristics.Insertion

/-- Theorem 3, (3.6), p. 571: for a traveling salesman graph with `n` nodes, every tour
produced by an insertion method (any choice of the inserted nodes, any minimizing insertion
position) has length `INSERT ≤ (⌈lg n⌉ + 1) · OPTIMAL`. -/
theorem insert_le_clog_add_one_mul_optimal {n : ℕ} (hn : 1 ≤ n) (d : Fin n → Fin n → ℝ)
    (hd : TSPHeuristics.Shared.IsTSPDist d) (T : ℕ → List (Fin n)) (a : ℕ → Fin n) (hrun : IsInsertionRun d T a) :
    TSPHeuristics.Shared.cycleLength d (T n) ≤ ((Nat.clog 2 n : ℝ) + 1) * TSPHeuristics.Shared.optimal d := by sorry

end TSPHeuristics.Insertion
Source
Rosenkrantz, Stearns, Lewis, An Analysis of Several Heuristics for the Traveling Salesman Problem, SIAM J. Comput. 6(3), 1977, https://doi.org/10.1137/0206041, p. 571, Theorem 3, eq. (3.6)
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5

Here nnn is a natural number with n≥1n \ge 1n≥1, and the nodes are {0,1,…,n−1}\{0, 1, \dots, n-1\}{0,1,…,n−1} (written [n][n][n] below). The statement fixes these data:

  • d:[n]×[n]→Rd : [n] \times [n] \to \mathbb{R}d:[n]×[n]→R, a real-valued function on ordered pairs of nodes. Nothing here requires it to be symmetric, nonnegative, zero on the diagonal or to satisfy the triangle inequality. Any such conditions come only from hypothesis (H1).
  • T=(Tk)k∈NT = (T_k)_{k \in \mathbb{N}}T=(Tk​)k∈N​, a sequence of finite lists of nodes, indexed by all natural numbers kkk. A list may repeat nodes or be empty.
  • a=(ak)k∈Na = (a_k)_{k \in \mathbb{N}}a=(ak​)k∈N​, a sequence of nodes, also indexed by all natural numbers.

It assumes two hypotheses:

  • (H1) ddd satisfies the predicate IsTSPDist from the imported bundle TSPHeuristics.Shared.
  • (H2) The triple (d,T,a)(d, T, a)(d,T,a) satisfies the predicate IsInsertionRun from the imported bundle TSPHeuristics.Insertion.

The code of these two predicates, and of the functions cycleLength and optimal below, is not part of the text given to this read-back. So their meaning cannot be unfolded here. Everything the statement says about "distance", "insertion run", "cycle length" and "optimal" is exactly whatever those definitions say, and nothing more.

The conclusion is an inequality about the list at index exactly nnn (the number of nodes). Let Ld(ℓ)L_d(\ell)Ld​(ℓ) be the real number returned by cycleLength for the matrix ddd and a list ℓ\ellℓ, and let OPT(d)\mathrm{OPT}(d)OPT(d) be the real number returned by optimal for ddd. The statement asserts:

Ld(Tn)  ≤  (⌈log⁡2n⌉+1)⋅OPT(d).L_d(T_n) \;\le\; \bigl(\lceil \log_2 n \rceil + 1\bigr)\cdot \mathrm{OPT}(d).Ld​(Tn​)≤(⌈log2​n⌉+1)⋅OPT(d).

Here ⌈log⁡2n⌉\lceil \log_2 n \rceil⌈log2​n⌉ is the integer Nat.clog 2 n: the least natural number kkk with n≤2kn \le 2^kn≤2k, converted to a real number. The claim holds for every ddd, TTT and aaa that satisfy (H1) and (H2). No other hypothesis is imposed:

  • It says nothing about the lists TkT_kTk​ for k≠nk \ne nk=n, except through (H2).
  • It says nothing about the node sequence aaa, except through (H2).
  • It does not itself say that TnT_nTn​ visits each node exactly once. Whether that holds depends entirely on (H2).

The inequality is non-strict (≤\le≤).

Degenerate cases.

  • n=0n = 0n=0: excluded by the hypothesis n≥1n \ge 1n≥1.
  • n=1n = 1n=1: ⌈log⁡21⌉=0\lceil \log_2 1 \rceil = 0⌈log2​1⌉=0, so the factor is 111 and the claim is Ld(T1)≤OPT(d)L_d(T_1) \le \mathrm{OPT}(d)Ld​(T1​)≤OPT(d).
  • n=2n = 2n=2: the factor is 222.
  • Powers of two: for n=2mn = 2^mn=2m the factor is m+1m + 1m+1. For nnn strictly between 2m−12^{m-1}2m−1 and 2m2^m2m it is also m+1m + 1m+1, because the logarithm is rounded up.
  • Sign of OPT(d)\mathrm{OPT}(d)OPT(d): if OPT(d)\mathrm{OPT}(d)OPT(d) can be negative or zero, the claim bounds Ld(Tn)L_d(T_n)Ld​(Tn​) by a nonpositive number. Whether that can happen depends on the unseen definitions of IsTSPDist and optimal.
  • Default values: if optimal is defined as an infimum or minimum that can hit a default value (for example an infimum over an empty or unbounded-below set, which gives 000 for real numbers), the right-hand side is that default times the factor. The same applies to cycleLength on short or empty lists; for instance, a one-node or empty list may get length 000 by convention.
  • Unsatisfiable hypotheses: if (H1) or (H2) cannot be satisfied for some nnn, the statement is vacuously true for that nnn. Whether that happens cannot be determined from the code shown here.
Human review
  • Endorsed by Shuze Chen · Sep 27, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Sep 27, 2026

    Confirmed by the mission captain (proposal self-audit).

  • Endorsed by Community (Bot) · Oct 30, 2026

    Confirmed by the moderator at approval.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me