Undirected Hamiltonian path
AbbreviationInstances of undirected Hamiltonian path#✓fully proved
An instance of undirected Hamiltonian path is a pair \((n, E)\) of a natural number \(n\), the number of vertices, and a finite list \(E\) of pairs of natural numbers, the edge list.
abbrev HamiltonianPathUndirectedInstance := ℕ × List (ℕ × ℕ)
DefinitionGraph of an undirected Hamiltonian path instance#✓fully proved
For an instance \((n, E)\) of undirected Hamiltonian path, its graph is the simple graph on the vertex set \(\{0, \dots, n-1\}\) in which distinct vertices \(i\) and \(j\) are adjacent when \((i, j)\) or \((j, i)\) belongs to \(E\).
def Graph (i : HamiltonianPathUndirectedInstance) : SimpleGraph (Fin i.1) :=
Cslib.Complexity.Karp.edgeGraph i.1 i.2
abbrev HamiltonianPathUndirectedInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/HamiltonianPathUndirectedWanted.lean:46
def edgeGraph (n : ℕ) (es : List (ℕ × ℕ)) : SimpleGraph (Fin n) :=
SimpleGraph.fromRel fun i j => ((i : ℕ), (j : ℕ)) ∈ es
CSLibExt/Computability/Complexity/Karp/Color.lean:51
Uses 2 · Used by 1
DefinitionWell-formed undirected Hamiltonian path instances#✓fully proved
An instance \((n, E)\) of undirected Hamiltonian path is well formed when \(n > 0\), the list \(E\) has no repeated entries, and every pair \((u, v)\) in \(E\) satisfies \(u < n\), \(v < n\) and \(u \ne v\), and the reversed pair \((v, u)\) does not belong to \(E\).
def WellFormed (i : HamiltonianPathUndirectedInstance) : Prop :=
0 < i.1 ∧ i.2.Nodup ∧ ∀ e ∈ i.2, e.1 < i.1 ∧ e.2 < i.1 ∧ e.1 ≠ e.2 ∧ (e.2, e.1) ∉ i.2
abbrev HamiltonianPathUndirectedInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/HamiltonianPathUndirectedWanted.lean:46
Uses 1 · Used by 1
DefinitionFeasible undirected Hamiltonian path instances#✓fully proved
An instance \((n, E)\) of undirected Hamiltonian path is feasible when its graph has a Hamiltonian path: a list of length \(n\) of vertices of the graph, with no repeated entries and containing every vertex, in which any two consecutive entries are adjacent.
def HamiltonianPathUndirectedFeasible
(i : HamiltonianPathUndirectedInstance) : Prop :=
∃ path : List (Fin i.1), path.Nodup ∧ path.length = i.1 ∧ (∀ v, v ∈ path) ∧
∀ j (h : j + 1 < path.length),
(Graph i).Adj (path[j]'(by omega)) (path[j + 1]'h)
abbrev HamiltonianPathUndirectedInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/HamiltonianPathUndirectedWanted.lean:46
def Graph (i : HamiltonianPathUndirectedInstance) : SimpleGraph (Fin i.1) :=
Cslib.Complexity.Karp.edgeGraph i.1 i.2
WantedExt/Complexity/NPComplete/HamiltonianPathUndirectedWanted.lean:49
Uses 2 · Used by 1
DefinitionHAMILTONIAN PATH (UNDIRECTED) as a decision problem#✓fully proved
The decision problem HAMILTONIAN PATH (UNDIRECTED) accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding, to an instance \((n, E)\) of undirected Hamiltonian path that is well formed and feasible; bitstrings that do not decode to an instance are rejected.
noncomputable def hamiltonianPathUndirectedDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := HamiltonianPathUndirectedInstance) x with
| some i => decide (WellFormed i ∧ HamiltonianPathUndirectedFeasible 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 HamiltonianPathUndirectedInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/HamiltonianPathUndirectedWanted.lean:46
def WellFormed (i : HamiltonianPathUndirectedInstance) : Prop :=
0 < i.1 ∧ i.2.Nodup ∧ ∀ e ∈ i.2, e.1 < i.1 ∧ e.2 < i.1 ∧ e.1 ≠ e.2 ∧ (e.2, e.1) ∉ i.2
WantedExt/Complexity/NPComplete/HamiltonianPathUndirectedWanted.lean:54
def HamiltonianPathUndirectedFeasible
(i : HamiltonianPathUndirectedInstance) : Prop :=
∃ path : List (Fin i.1), path.Nodup ∧ path.length = i.1 ∧ (∀ v, v ∈ path) ∧
∀ j (h : j + 1 < path.length),
(Graph i).Adj (path[j]'(by omega)) (path[j + 1]'h)
WantedExt/Complexity/NPComplete/HamiltonianPathUndirectedWanted.lean:58
Uses 12 · Used by 1
TheoremHAMILTONIAN PATH (UNDIRECTED) is NP-complete#●ready to prove
The decision problem HAMILTONIAN PATH (UNDIRECTED) belongs to NP, and every decision problem in NP reduces to it by a polynomial-time many-one reduction.
public theorem_wanted hamiltonianPathUndirected_npComplete :
hamiltonianPathUndirectedDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L hamiltonianPathUndirectedDec
noncomputable def hamiltonianPathUndirectedDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := HamiltonianPathUndirectedInstance) x with
| some i => decide (WellFormed i ∧ HamiltonianPathUndirectedFeasible i)
| none => false
WantedExt/Complexity/NPComplete/HamiltonianPathUndirectedWanted.lean:66
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), HAMILTONIAN PATH.
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.