Directed Hamiltonian cycle
AbbreviationInstances of HAMILTONIAN CYCLE (DIRECTED)#✓fully proved
An instance of HAMILTONIAN CYCLE (DIRECTED) is a pair \((n, E)\) of a natural number \(n\), the number of vertices, and a finite list \(E\) of ordered pairs of natural numbers, the arcs.
abbrev HamiltonianCycleDirectedInstance := ℕ × List (ℕ × ℕ)
DefinitionDirected adjacency for HAMILTONIAN CYCLE (DIRECTED)#✓fully proved
For a finite list \(E\) of ordered pairs of natural numbers and natural numbers \(u\) and \(v\), the directed adjacency of \(u\) to \(v\) in \(E\) is the boolean value that is true exactly when the pair \((u, v)\) occurs in \(E\).
Used by 1
DefinitionWell-formed instances of HAMILTONIAN CYCLE (DIRECTED)#✓fully proved
An instance \((n, E)\) of HAMILTONIAN CYCLE (DIRECTED), with \(n\) a natural number and \(E\) a finite list of ordered pairs of natural numbers, 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\).
def WellFormed (i : HamiltonianCycleDirectedInstance) : Prop :=
0 < i.1 ∧ i.2.Nodup ∧ ∀ e ∈ i.2, e.1 < i.1 ∧ e.2 < i.1 ∧ e.1 ≠ e.2
abbrev HamiltonianCycleDirectedInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/HamiltonianCycleDirectedWanted.lean:47
Uses 1 · Used by 1
DefinitionDirected Hamiltonian cycles of an instance#✓fully proved
An instance \((n, E)\) of HAMILTONIAN CYCLE (DIRECTED), with \(n\) a natural number and \(E\) a finite list of ordered pairs of natural numbers, has a directed Hamiltonian cycle when there is a list \((v_0, \dots, v_{n-1})\) of \(n\) distinct natural numbers containing every natural number below \(n\) such that the pair \((v_j, v_{(j+1) \bmod n})\) occurs in \(E\) for every \(j < n\).
def HamiltonianCycleDirectedFeasible
(i : HamiltonianCycleDirectedInstance) : Prop :=
∃ cycle : List ℕ, cycle.Nodup ∧ cycle.length = i.1 ∧ (∀ v < i.1, v ∈ cycle) ∧
∀ j < i.1, DAdj i.2 (cycle.getD j 0) (cycle.getD ((j + 1) % i.1) 0)
abbrev HamiltonianCycleDirectedInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/HamiltonianCycleDirectedWanted.lean:47
def DAdj (edges : List (ℕ × ℕ)) (u v : ℕ) : Bool :=
edges.contains (u, v)
WantedExt/Complexity/NPComplete/HamiltonianCycleDirectedWanted.lean:51
Uses 2 · Used by 1
DefinitionThe directed Hamiltonian cycle decision problem#✓fully proved
The decision problem HAMILTONIAN CYCLE (DIRECTED) accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding, to an instance \((n, E)\), consisting of a natural number \(n\) and a finite list \(E\) of ordered pairs of natural numbers, such that \((n, E)\) is well formed (\(n > 0\), \(E\) has no repeated entries, and every pair \((u, v)\) in \(E\) satisfies \(u < n\), \(v < n\) and \(u \ne v\)) and has a directed Hamiltonian cycle (a list \((v_0, \dots, v_{n-1})\) of \(n\) distinct natural numbers containing every natural number below \(n\) such that \((v_j, v_{(j+1) \bmod n})\) occurs in \(E\) for every \(j < n\)). It rejects every bitstring that does not decode to an instance.
noncomputable def hamiltonianCycleDirectedDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := HamiltonianCycleDirectedInstance) x with
| some i => decide (WellFormed i ∧ HamiltonianCycleDirectedFeasible 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 HamiltonianCycleDirectedInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/HamiltonianCycleDirectedWanted.lean:47
def WellFormed (i : HamiltonianCycleDirectedInstance) : Prop :=
0 < i.1 ∧ i.2.Nodup ∧ ∀ e ∈ i.2, e.1 < i.1 ∧ e.2 < i.1 ∧ e.1 ≠ e.2
WantedExt/Complexity/NPComplete/HamiltonianCycleDirectedWanted.lean:56
def HamiltonianCycleDirectedFeasible
(i : HamiltonianCycleDirectedInstance) : Prop :=
∃ cycle : List ℕ, cycle.Nodup ∧ cycle.length = i.1 ∧ (∀ v < i.1, v ∈ cycle) ∧
∀ j < i.1, DAdj i.2 (cycle.getD j 0) (cycle.getD ((j + 1) % i.1) 0)
WantedExt/Complexity/NPComplete/HamiltonianCycleDirectedWanted.lean:60
Uses 12 · Used by 1
TheoremHAMILTONIAN CYCLE (DIRECTED) is NP-complete#●ready to prove
The decision problem HAMILTONIAN CYCLE (DIRECTED) belongs to NP, and every decision problem \(L\) in NP has a polynomial-time many-one reduction to it.
public theorem_wanted hamiltonianCycleDirected_npComplete :
hamiltonianCycleDirectedDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L hamiltonianCycleDirectedDec
noncomputable def hamiltonianCycleDirectedDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := HamiltonianCycleDirectedInstance) x with
| some i => decide (WellFormed i ∧ HamiltonianCycleDirectedFeasible i)
| none => false
WantedExt/Complexity/NPComplete/HamiltonianCycleDirectedWanted.lean:67
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 CIRCUIT (directed); R. M. Karp, "Reducibility among combinatorial problems" (1972).
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.