Exact cover
AbbreviationInstances of EXACT COVER#✓fully proved
An instance of EXACT COVER is a pair \((n, C)\) of a natural number \(n\), the size of the universe \(\{0, \dots, n - 1\}\), and a finite list \(C\) of finite lists of natural numbers, the candidate subsets. That each entry of \(C\) lists distinct elements of the universe is required by well-formedness, not by the type of instances.
DefinitionWell-formed EXACT COVER instances#✓fully proved
An instance \((n, C)\) of EXACT COVER is well formed when every entry of \(C\) is a list of pairwise distinct natural numbers, each less than \(n\).
def WellFormed (i : ExactCoverInstance) : Prop :=
∀ s ∈ i.2, s.Nodup ∧ ∀ x ∈ s, x < i.1
abbrev ExactCoverInstance := ℕ × List (List ℕ)
WantedExt/Complexity/NPComplete/ExactCoverWanted.lean:45
Uses 1 · Used by 1
DefinitionFeasible EXACT COVER instances#✓fully proved
An instance \((n, C)\) of EXACT COVER is feasible when \(C\) has a sublist \(S\), obtained by deleting some entries of \(C\), such that for every natural number \(x < n\) there is exactly one list that occurs in \(S\) and contains \(x\).
def ExactCoverFeasible
(i : ExactCoverInstance) : Prop :=
∃ sub : List (List ℕ), sub.Sublist i.2 ∧
∀ x < i.1, ∃! s ∈ sub, x ∈ s
abbrev ExactCoverInstance := ℕ × List (List ℕ)
WantedExt/Complexity/NPComplete/ExactCoverWanted.lean:45
Uses 1 · Used by 1
DefinitionEXACT COVER as a decision problem#✓fully proved
The decision problem EXACT COVER 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 that is well formed and feasible; bitstrings that do not decode are rejected.
noncomputable def exactCoverDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := ExactCoverInstance) x with
| some i => decide (WellFormed i ∧ ExactCoverFeasible 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 ExactCoverInstance := ℕ × List (List ℕ)
WantedExt/Complexity/NPComplete/ExactCoverWanted.lean:45
def WellFormed (i : ExactCoverInstance) : Prop :=
∀ s ∈ i.2, s.Nodup ∧ ∀ x ∈ s, x < i.1
WantedExt/Complexity/NPComplete/ExactCoverWanted.lean:48
def ExactCoverFeasible
(i : ExactCoverInstance) : Prop :=
∃ sub : List (List ℕ), sub.Sublist i.2 ∧
∀ x < i.1, ∃! s ∈ sub, x ∈ s
WantedExt/Complexity/NPComplete/ExactCoverWanted.lean:52
Uses 12 · Used by 1
TheoremEXACT COVER is NP-complete#●ready to prove
The decision problem EXACT COVER is in NP, and every decision problem in NP has a polynomial-time many-one reduction to it.
public theorem_wanted exactCover_npComplete :
exactCoverDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L exactCoverDec
noncomputable def exactCoverDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := ExactCoverInstance) x with
| some i => decide (WellFormed i ∧ ExactCoverFeasible i)
| none => false
WantedExt/Complexity/NPComplete/ExactCoverWanted.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; R. M. Karp, "Reducibility among combinatorial problems" (1972).
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.