Partition into triangles
AbbreviationInstances of PARTITION INTO TRIANGLES#✓fully proved
An instance of PARTITION INTO TRIANGLES is a pair consisting of a natural number \(n\), the number of vertices, and a list of pairs of natural numbers, the edges.
abbrev PartitionIntoTrianglesInstance := ℕ × List (ℕ × ℕ)
DefinitionGraph of a PARTITION INTO TRIANGLES instance#✓fully proved
For an instance consisting of a natural number \(n\) and a list \(E\) of pairs of natural numbers, its graph is the graph of the edge list \(E\) on \(n\) vertices: the simple graph on \(\{0, \dots, n - 1\}\) in which distinct vertices \(i\) and \(j\) are adjacent when \((i, j)\) or \((j, i)\) belongs to \(E\). Pairs with an endpoint at least \(n\) contribute no edge.
def Graph (i : PartitionIntoTrianglesInstance) : SimpleGraph (Fin i.1) :=
Cslib.Complexity.Karp.edgeGraph i.1 i.2
abbrev PartitionIntoTrianglesInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/PartitionIntoTrianglesWanted.lean:47
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 TRIANGLES instances#✓fully proved
An instance consisting of a natural number \(n\) and a list \(E\) of pairs of natural numbers is well formed when \(E\) has no repeated entries and every pair \((u, v)\) in \(E\) satisfies \(u < n\), \(v < n\), \(u \ne v\) and \((v, u) \notin E\).
def WellFormed (i : PartitionIntoTrianglesInstance) : 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 PartitionIntoTrianglesInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/PartitionIntoTrianglesWanted.lean:47
Uses 1 · Used by 1
DefinitionPartition into triangles#✓fully proved
An instance consisting of a natural number \(n\) and a list \(E\) of pairs of natural numbers admits a partition into triangles when the vertex set \(\{0, \dots, n - 1\}\) can be partitioned into sets of three vertices, any two of which are adjacent in the graph of \(E\) on \(n\) vertices.
def PartitionIntoTrianglesFeasible
(i : PartitionIntoTrianglesInstance) : Prop :=
∃ triples : List (List (Fin i.1)), triples.flatten.Perm (List.finRange i.1) ∧
(∀ t ∈ triples, t.length = 3 ∧ t.Nodup) ∧
∀ t ∈ triples, ∀ a ∈ t, ∀ b ∈ t, a ≠ b → (Graph i).Adj a b
abbrev PartitionIntoTrianglesInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/PartitionIntoTrianglesWanted.lean:47
def Graph (i : PartitionIntoTrianglesInstance) : SimpleGraph (Fin i.1) :=
Cslib.Complexity.Karp.edgeGraph i.1 i.2
WantedExt/Complexity/NPComplete/PartitionIntoTrianglesWanted.lean:50
Uses 2 · Used by 1
DefinitionPARTITION INTO TRIANGLES as a decision problem#✓fully proved
The decision problem PARTITION INTO TRIANGLES accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding, to an instance consisting of a natural number \(n\) and a list \(E\) of pairs of natural numbers such that \(E\) has no repeated entries, every pair \((u, v)\) in \(E\) satisfies \(u < n\), \(v < n\), \(u \ne v\) and \((v, u) \notin E\), and the vertex set \(\{0, \dots, n - 1\}\) can be partitioned into sets of three vertices, any two of which are adjacent in the graph of \(E\) on \(n\) vertices. Bitstrings that do not decode to an instance are rejected.
noncomputable def partitionIntoTrianglesDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := PartitionIntoTrianglesInstance) x with
| some i => decide (WellFormed i ∧ PartitionIntoTrianglesFeasible 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 PartitionIntoTrianglesInstance := ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/PartitionIntoTrianglesWanted.lean:47
def WellFormed (i : PartitionIntoTrianglesInstance) : 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/PartitionIntoTrianglesWanted.lean:55
def PartitionIntoTrianglesFeasible
(i : PartitionIntoTrianglesInstance) : Prop :=
∃ triples : List (List (Fin i.1)), triples.flatten.Perm (List.finRange i.1) ∧
(∀ t ∈ triples, t.length = 3 ∧ t.Nodup) ∧
∀ t ∈ triples, ∀ a ∈ t, ∀ b ∈ t, a ≠ b → (Graph i).Adj a b
WantedExt/Complexity/NPComplete/PartitionIntoTrianglesWanted.lean:59
Uses 12 · Used by 1
TheoremPARTITION INTO TRIANGLES is NP-complete#●ready to prove
The decision problem PARTITION INTO TRIANGLES lies in NP, and every decision problem in NP has a polynomial-time many-one reduction to PARTITION INTO TRIANGLES.
public theorem_wanted partitionIntoTriangles_npComplete :
partitionIntoTrianglesDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L partitionIntoTrianglesDec
noncomputable def partitionIntoTrianglesDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := PartitionIntoTrianglesInstance) x with
| some i => decide (WellFormed i ∧ PartitionIntoTrianglesFeasible i)
| none => false
WantedExt/Complexity/NPComplete/PartitionIntoTrianglesWanted.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), PARTITION INTO TRIANGLES; D. G. Kirkpatrick and P. Hell, "On the complexity of general graph factor problems", SIAM Journal on Computing 12 (1983), 601-609.
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.