Subset product
AbbreviationSUBSET PRODUCT instances#✓fully proved
An instance of SUBSET PRODUCT is a pair \((a, T)\) of a finite list \(a\) of natural numbers and a target natural number \(T\).
abbrev SubsetProductInstance := List ℕ × ℕ
DefinitionWell-formed SUBSET PRODUCT instances#✓fully proved
An instance \((a, T)\) of SUBSET PRODUCT, with \(a\) a finite list of natural numbers and \(T\) a natural number, is well formed when every entry of \(a\) is positive.
def WellFormed (i : SubsetProductInstance) : Prop :=
∀ a ∈ i.1, 0 < a
abbrev SubsetProductInstance := List ℕ × ℕ
WantedExt/Complexity/NPComplete/SubsetProductWanted.lean:44
Uses 1 · Used by 1
DefinitionFeasible SUBSET PRODUCT instances#✓fully proved
An instance \((a, T)\) of SUBSET PRODUCT, with \(a\) a finite list of natural numbers and \(T\) a natural number, is feasible when some sublist of \(a\) (a list obtained from \(a\) by deleting entries and keeping the order of the rest) has product exactly \(T\).
def SubsetProductFeasible
(i : SubsetProductInstance) : Prop :=
∃ s : List ℕ, s.Sublist i.1 ∧ s.prod = i.2
abbrev SubsetProductInstance := List ℕ × ℕ
WantedExt/Complexity/NPComplete/SubsetProductWanted.lean:44
Uses 1 · Used by 1
DefinitionSUBSET PRODUCT as a decision problem#✓fully proved
The decision problem SUBSET PRODUCT accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding of pairs of a finite list of natural numbers and a natural number, to an instance \((a, T)\) that is well formed (every entry of \(a\) is positive) and feasible (some sublist of \(a\) has product exactly \(T\)). It rejects every bitstring that does not decode to an instance.
noncomputable def subsetProductDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := SubsetProductInstance) x with
| some i => decide (WellFormed i ∧ SubsetProductFeasible 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 SubsetProductInstance := List ℕ × ℕ
WantedExt/Complexity/NPComplete/SubsetProductWanted.lean:44
def WellFormed (i : SubsetProductInstance) : Prop :=
∀ a ∈ i.1, 0 < a
WantedExt/Complexity/NPComplete/SubsetProductWanted.lean:47
def SubsetProductFeasible
(i : SubsetProductInstance) : Prop :=
∃ s : List ℕ, s.Sublist i.1 ∧ s.prod = i.2
WantedExt/Complexity/NPComplete/SubsetProductWanted.lean:51
Uses 12 · Used by 1
TheoremSUBSET PRODUCT is NP-complete#●ready to prove
The decision problem SUBSET PRODUCT lies in NP, and every decision problem in NP has a polynomial-time many-one reduction to SUBSET PRODUCT.
public theorem_wanted subsetProduct_npComplete :
subsetProductDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L subsetProductDec
noncomputable def subsetProductDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := SubsetProductInstance) x with
| some i => decide (WellFormed i ∧ SubsetProductFeasible i)
| none => false
WantedExt/Complexity/NPComplete/SubsetProductWanted.lean:57
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), SUBSET PRODUCT.
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.