Exact cover by 3-sets
AbbreviationInstances of EXACT COVER BY 3-SETS#✓fully proved
An instance of EXACT COVER BY 3-SETS is a pair \((q, C)\) of a natural number \(q\) and a finite list \(C\) of finite lists of natural numbers. The intended universe is \(\{0, \dots, 3q - 1\}\) and the entries of \(C\) are the candidate three-element subsets; that each entry lists three distinct elements of the universe is required by well-formedness, not by the type of instances.
DefinitionWell-formed EXACT COVER BY 3-SETS instances#✓fully proved
An instance \((q, C)\) of EXACT COVER BY 3-SETS is well formed when every entry of \(C\) is a list of exactly three pairwise distinct natural numbers, each less than \(3q\).
def WellFormed (i : ExactCoverBy3SetsInstance) : Prop :=
∀ s ∈ i.2, s.length = 3 ∧ s.Nodup ∧ ∀ x ∈ s, x < 3 * i.1
abbrev ExactCoverBy3SetsInstance := ℕ × List (List ℕ)
WantedExt/Complexity/NPComplete/ExactCoverBy3SetsWanted.lean:45
Uses 1 · Used by 1
DefinitionFeasible EXACT COVER BY 3-SETS instances#✓fully proved
An instance \((q, C)\) of EXACT COVER BY 3-SETS is feasible when \(C\) has a sublist \(S\), obtained by deleting some entries of \(C\), such that for every natural number \(x < 3q\) there is exactly one list that occurs in \(S\) and contains \(x\).
def ExactCoverBy3SetsFeasible
(i : ExactCoverBy3SetsInstance) : Prop :=
∃ sub : List (List ℕ), sub.Sublist i.2 ∧
∀ x < 3 * i.1, ∃! s ∈ sub, x ∈ s
abbrev ExactCoverBy3SetsInstance := ℕ × List (List ℕ)
WantedExt/Complexity/NPComplete/ExactCoverBy3SetsWanted.lean:45
Uses 1 · Used by 1
DefinitionEXACT COVER BY 3-SETS as a decision problem#✓fully proved
The decision problem EXACT COVER BY 3-SETS accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding of pairs of a natural number and a list of lists of natural numbers, to an instance of EXACT COVER BY 3-SETS that is well formed and feasible; bitstrings that do not decode are rejected.
noncomputable def exactCoverBy3SetsDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := ExactCoverBy3SetsInstance) x with
| some i => decide (WellFormed i ∧ ExactCoverBy3SetsFeasible 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 ExactCoverBy3SetsInstance := ℕ × List (List ℕ)
WantedExt/Complexity/NPComplete/ExactCoverBy3SetsWanted.lean:45
def WellFormed (i : ExactCoverBy3SetsInstance) : Prop :=
∀ s ∈ i.2, s.length = 3 ∧ s.Nodup ∧ ∀ x ∈ s, x < 3 * i.1
WantedExt/Complexity/NPComplete/ExactCoverBy3SetsWanted.lean:48
def ExactCoverBy3SetsFeasible
(i : ExactCoverBy3SetsInstance) : Prop :=
∃ sub : List (List ℕ), sub.Sublist i.2 ∧
∀ x < 3 * i.1, ∃! s ∈ sub, x ∈ s
WantedExt/Complexity/NPComplete/ExactCoverBy3SetsWanted.lean:52
Uses 12 · Used by 1
TheoremEXACT COVER BY 3-SETS is NP-complete#●ready to prove
The decision problem EXACT COVER BY 3-SETS is in NP, and every decision problem in NP has a polynomial-time many-one reduction to it.
public theorem_wanted exactCoverBy3Sets_npComplete :
exactCoverBy3SetsDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L exactCoverBy3SetsDec
noncomputable def exactCoverBy3SetsDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := ExactCoverBy3SetsInstance) x with
| some i => decide (WellFormed i ∧ ExactCoverBy3SetsFeasible i)
| none => false
WantedExt/Complexity/NPComplete/ExactCoverBy3SetsWanted.lean:59
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), EXACT COVER BY 3-SETS.
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.