Asymmetric traveling salesperson problem
AbbreviationAsymmetric TSP instances#✓fully proved
An instance of the asymmetric traveling salesperson problem is a triple \((n, w, B)\) consisting of a natural number \(n\) (the number of cities), a weight matrix \(w\) given as a list of rows, each row a list of natural numbers, and a natural number \(B\) (the bound).
DefinitionLength of a tour in the asymmetric TSP#✓fully proved
Let \(w\) be a weight matrix, given as a list of rows of natural numbers, and let \(t = (t_0, \dots, t_{L-1})\) be a list of natural numbers. The length of the tour \(t\) under \(w\) is \(\sum_{j=0}^{L-1} w_{t_j, t_{(j+1) \bmod L}}\), the sum of the weights along the closed walk including the return edge from \(t_{L-1}\) to \(t_0\), where \(w_{a,b}\) denotes the entry in row \(a\) and column \(b\) of \(w\), taken to be \(0\) when that entry does not exist. In particular the empty tour has length \(0\).
def TourLength (w : List (List ℕ)) (tour : List ℕ) : ℕ :=
((List.range tour.length).map (fun j =>
(w.getD (tour.getD j 0) []).getD (tour.getD ((j + 1) % tour.length) 0) 0)).sum
Used by 1
DefinitionWell-formed asymmetric TSP instances#✓fully proved
An asymmetric TSP instance \((n, w, B)\), with \(n\) the number of cities, \(w\) the weight matrix and \(B\) the bound, is well formed when \(n > 0\), \(w\) has exactly \(n\) rows, every row of \(w\) has length \(n\), and the diagonal entry \(w_{a,a}\) in row \(a\) and column \(a\) is \(0\) for every \(a < n\).
def WellFormed (i : AsymmetricTspInstance) : Prop :=
0 < i.1 ∧ i.2.1.length = i.1 ∧ (∀ row ∈ i.2.1, row.length = i.1) ∧
∀ a < i.1, (i.2.1.getD a []).getD a 0 = 0
abbrev AsymmetricTspInstance := ℕ × List (List ℕ) × ℕ
WantedExt/Complexity/NPComplete/AsymmetricTspWanted.lean:48
Uses 1 · Used by 1
DefinitionFeasible asymmetric TSP instances#✓fully proved
An asymmetric TSP instance \((n, w, B)\) is feasible when there is a list \(t\) of natural numbers with no repeated entries, of length \(n\) and containing every \(v < n\) (so \(t\) lists the cities \(0, \dots, n - 1\) in some order), whose tour length under \(w\) is at most \(B\).
def AsymmetricTspFeasible
(i : AsymmetricTspInstance) : Prop :=
∃ tour : List ℕ, tour.Nodup ∧ tour.length = i.1 ∧ (∀ v < i.1, v ∈ tour) ∧
TourLength i.2.1 tour ≤ i.2.2
abbrev AsymmetricTspInstance := ℕ × List (List ℕ) × ℕ
WantedExt/Complexity/NPComplete/AsymmetricTspWanted.lean:48
def TourLength (w : List (List ℕ)) (tour : List ℕ) : ℕ :=
((List.range tour.length).map (fun j =>
(w.getD (tour.getD j 0) []).getD (tour.getD ((j + 1) % tour.length) 0) 0)).sum
WantedExt/Complexity/NPComplete/AsymmetricTspWanted.lean:52
Uses 2 · Used by 1
DefinitionThe asymmetric traveling salesperson decision problem#✓fully proved
The asymmetric TSP decision problem accepts a bitstring \(x\) when \(x\) decodes, under the canonical bitstring encoding of asymmetric TSP instances, to an instance \((n, w, B)\) that is well formed and feasible, and rejects \(x\) otherwise; in particular it rejects every bitstring that does not decode to an instance.
noncomputable def asymmetricTspDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := AsymmetricTspInstance) x with
| some i => decide (WellFormed i ∧ AsymmetricTspFeasible i)
| none => false
abbrev DecisionProblem := List Bool → Bool
MathlibExt/Computability/Complexity.lean:170
def bitDecode [BitstringEncoding α] (l : List Bool) : Option α := toEncoding.decode l
MathlibExt/Computability/Complexity.lean:58
abbrev AsymmetricTspInstance := ℕ × List (List ℕ) × ℕ
WantedExt/Complexity/NPComplete/AsymmetricTspWanted.lean:48
def WellFormed (i : AsymmetricTspInstance) : Prop :=
0 < i.1 ∧ i.2.1.length = i.1 ∧ (∀ row ∈ i.2.1, row.length = i.1) ∧
∀ a < i.1, (i.2.1.getD a []).getD a 0 = 0
WantedExt/Complexity/NPComplete/AsymmetricTspWanted.lean:58
def AsymmetricTspFeasible
(i : AsymmetricTspInstance) : Prop :=
∃ tour : List ℕ, tour.Nodup ∧ tour.length = i.1 ∧ (∀ v < i.1, v ∈ tour) ∧
TourLength i.2.1 tour ≤ i.2.2
WantedExt/Complexity/NPComplete/AsymmetricTspWanted.lean:63
Uses 12 · Used by 1
TheoremTRAVELING SALESPERSON (ASYMMETRIC) is NP-complete#●ready to prove
The asymmetric traveling salesperson decision problem belongs to NP, and every decision problem in NP reduces to it by a polynomial-time many-one reduction.
public theorem_wanted asymmetricTsp_npComplete :
asymmetricTspDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L asymmetricTspDec
noncomputable def asymmetricTspDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := AsymmetricTspInstance) x with
| some i => decide (WellFormed i ∧ AsymmetricTspFeasible i)
| none => false
WantedExt/Complexity/NPComplete/AsymmetricTspWanted.lean:70
def NP : DecisionComplexityClass :=
{ L | ∃ (p : Polynomial ℕ), ∃ R : (List Bool × List Bool) → Bool,
IsPolyTime R ∧
∀ x, L x ↔ ∃ w : List Bool, w.length ≤ p.eval x.length ∧ R (x, w) }
MathlibExt/Computability/Complexity.lean:200
abbrev DecisionProblem := List Bool → Bool
MathlibExt/Computability/Complexity.lean:170
def PolyManyOneRed (L₁ L₂ : MetaMathlibExt.ComplexityTheory.DecisionProblem) : Prop :=
∃ reduce : List Bool → List Bool,
MetaMathlibExt.ComplexityTheory.IsPolyTime reduce ∧ ∀ x, L₁ x = L₂ (reduce x)
CSLibExt/Computability/CookLevin.lean:396
Sources
- M. R. Garey and D. S. Johnson, Computers and Intractability (1979), TRAVELING SALESPERSON PROBLEM (asymmetric).
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.