3-partition problem
Abbreviation3-partition instances#✓fully proved
An instance of 3-PARTITION is a pair \((a, B)\) of a finite list \(a\) of natural numbers and a natural number \(B\), the target sum.
abbrev ThreePartitionInstance := List ℕ × ℕ
DefinitionWell-formed 3-partition instances#✓fully proved
A 3-partition instance \((a, B)\) is well formed when the length of the list \(a\) is a multiple of \(3\).
def WellFormed (i : ThreePartitionInstance) : Prop :=
i.1.length % 3 = 0
abbrev ThreePartitionInstance := List ℕ × ℕ
WantedExt/Complexity/NPComplete/ThreePartitionWanted.lean:46
Uses 1 · Used by 1
DefinitionFeasible 3-partition instances#✓fully proved
Let \((a, B)\) be a 3-partition instance with \(a = (a_0, \dots, a_{N-1})\), and let \(m = \lfloor N/3 \rfloor\). The instance is feasible when there is a map \(g : \{0, \dots, N-1\} \to \{0, \dots, m-1\}\) such that for every \(t < m\) exactly three indices \(j\) satisfy \(g(j) = t\), and the sum of \(a_j\) over these indices equals \(B\).
def ThreePartitionFeasible
(i : ThreePartitionInstance) : Prop :=
∃ assign : List ℕ, assign.length = i.1.length ∧
(∀ j < i.1.length, assign.getD j 0 < i.1.length / 3) ∧
∀ t < i.1.length / 3,
((List.range i.1.length).filter (fun j => assign.getD j 0 == t)).length = 3 ∧
(Finset.range i.1.length).sum
(fun j => if assign.getD j 0 = t then i.1.getD j 0 else 0) = i.2
abbrev ThreePartitionInstance := List ℕ × ℕ
WantedExt/Complexity/NPComplete/ThreePartitionWanted.lean:46
Uses 1 · Used by 1
Definition3-PARTITION as a decision problem#✓fully proved
The decision problem 3-PARTITION accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding, to a 3-partition instance \((a, B)\) that is well formed (the length of the list \(a\) is a multiple of \(3\)) and feasible (the entries of \(a\) can be split into triples each summing to \(B\)). Bitstrings that do not decode to an instance are rejected.
noncomputable def threePartitionDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := ThreePartitionInstance) x with
| some i => decide (WellFormed i ∧ ThreePartitionFeasible 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 ThreePartitionInstance := List ℕ × ℕ
WantedExt/Complexity/NPComplete/ThreePartitionWanted.lean:46
def WellFormed (i : ThreePartitionInstance) : Prop :=
i.1.length % 3 = 0
WantedExt/Complexity/NPComplete/ThreePartitionWanted.lean:49
def ThreePartitionFeasible
(i : ThreePartitionInstance) : Prop :=
∃ assign : List ℕ, assign.length = i.1.length ∧
(∀ j < i.1.length, assign.getD j 0 < i.1.length / 3) ∧
∀ t < i.1.length / 3,
((List.range i.1.length).filter (fun j => assign.getD j 0 == t)).length = 3 ∧
(Finset.range i.1.length).sum
(fun j => if assign.getD j 0 = t then i.1.getD j 0 else 0) = i.2
WantedExt/Complexity/NPComplete/ThreePartitionWanted.lean:53
Uses 12 · Used by 1
Theorem3-PARTITION is NP-complete#●ready to prove
The decision problem 3-PARTITION on bitstrings is in NP, and every decision problem in NP reduces to it by a polynomial-time many-one reduction.
public theorem_wanted threePartition_npComplete :
threePartitionDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L threePartitionDec
noncomputable def threePartitionDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := ThreePartitionInstance) x with
| some i => decide (WellFormed i ∧ ThreePartitionFeasible i)
| none => false
WantedExt/Complexity/NPComplete/ThreePartitionWanted.lean:64
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), 3-PARTITION (strongly NP-complete).
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.