Partition into paths of length 2
AbbreviationInstances of PARTITION INTO PATHS OF LENGTH 2#✓fully proved
An instance of PARTITION INTO PATHS OF LENGTH 2 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 PartitionIntoP3sInstance := ℕ × List (ℕ × ℕ)
DefinitionGraph of a PARTITION INTO PATHS OF LENGTH 2 instance#✓fully proved
For an instance \((n, E)\), the graph of the instance is the simple graph on the vertex set \(\{0, \dots, n - 1\}\) in which distinct vertices \(u\) and \(v\) are adjacent exactly when \((u, v)\) or \((v, u)\) belongs to \(E\). Pairs in \(E\) with an entry at least \(n\), and pairs \((u, u)\), contribute no edge.
def Graph (i : PartitionIntoP3sInstance) : SimpleGraph (Fin i.1) :=
Cslib.Complexity.Karp.edgeGraph i.1 i.2
abbrev PartitionIntoP3sInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/PartitionIntoP3sWanted.lean:48
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 PARTITION INTO PATHS OF LENGTH 2 instances#✓fully proved
An instance \((n, E)\) is well formed when 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 : PartitionIntoP3sInstance) : Prop :=
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 PartitionIntoP3sInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/PartitionIntoP3sWanted.lean:48
Uses 1 · Used by 1
DefinitionPartitions into paths of length 2#✓fully proved
An instance \((n, E)\) admits a partition into paths of length 2 when there is a list of triples, each a list of three distinct vertices from \(\{0, \dots, n - 1\}\), such that every vertex occurs exactly once among all the triples taken together, and every triple contains pairwise distinct vertices \(x\), \(y\), \(z\) such that \(x\) is adjacent to \(y\) and \(y\) is adjacent to \(z\) in the graph of the instance.
The path need not be induced: a triple spanning a triangle qualifies.
def PartitionIntoP3sFeasible
(i : PartitionIntoP3sInstance) : Prop :=
∃ triples : List (List (Fin i.1)), triples.flatten.Perm (List.finRange i.1) ∧
(∀ t ∈ triples, t.length = 3 ∧ t.Nodup) ∧
∀ t ∈ triples, ∃ x ∈ t, ∃ y ∈ t, ∃ z ∈ t,
x ≠ y ∧ y ≠ z ∧ x ≠ z ∧ (Graph i).Adj x y ∧ (Graph i).Adj y z
abbrev PartitionIntoP3sInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/PartitionIntoP3sWanted.lean:48
def Graph (i : PartitionIntoP3sInstance) : SimpleGraph (Fin i.1) :=
Cslib.Complexity.Karp.edgeGraph i.1 i.2
WantedExt/Complexity/NPComplete/PartitionIntoP3sWanted.lean:51
Uses 2 · Used by 1
DefinitionPARTITION INTO PATHS OF LENGTH 2#✓fully proved
The decision problem PARTITION INTO PATHS OF LENGTH 2 accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding of instances, to an instance \((n, E)\) that is well formed and admits a partition into paths of length 2. Bitstrings that do not decode to an instance are rejected.
noncomputable def partitionIntoP3sDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := PartitionIntoP3sInstance) x with
| some i => decide (WellFormed i ∧ PartitionIntoP3sFeasible 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 PartitionIntoP3sInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/PartitionIntoP3sWanted.lean:48
def WellFormed (i : PartitionIntoP3sInstance) : Prop :=
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/PartitionIntoP3sWanted.lean:56
def PartitionIntoP3sFeasible
(i : PartitionIntoP3sInstance) : Prop :=
∃ triples : List (List (Fin i.1)), triples.flatten.Perm (List.finRange i.1) ∧
(∀ t ∈ triples, t.length = 3 ∧ t.Nodup) ∧
∀ t ∈ triples, ∃ x ∈ t, ∃ y ∈ t, ∃ z ∈ t,
x ≠ y ∧ y ≠ z ∧ x ≠ z ∧ (Graph i).Adj x y ∧ (Graph i).Adj y z
WantedExt/Complexity/NPComplete/PartitionIntoP3sWanted.lean:60
Uses 12 · Used by 1
TheoremPARTITION INTO PATHS OF LENGTH 2 is NP-complete#●ready to prove
The decision problem PARTITION INTO PATHS OF LENGTH 2 belongs to NP, and every decision problem in NP has a polynomial-time many-one reduction to it.
public theorem_wanted partitionIntoP3s_npComplete :
partitionIntoP3sDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L partitionIntoP3sDec
noncomputable def partitionIntoP3sDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := PartitionIntoP3sInstance) x with
| some i => decide (WellFormed i ∧ PartitionIntoP3sFeasible i)
| none => false
WantedExt/Complexity/NPComplete/PartitionIntoP3sWanted.lean:69
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), PARTITION INTO PATHS; M. E. Dyer and A. M. Frieze, "On the complexity of partitioning graphs into connected subgraphs", Discrete Applied Mathematics 10 (1985), 139-153.
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.