Facility location
AbbreviationFacility location instances#✓fully proved
A facility location instance is a triple \((o, D, B)\) made of a finite list \(o\) of natural numbers (the opening costs of the facilities), a finite list \(D\) of finite lists of natural numbers (the \(c\)-th list holds the costs of assigning client \(c\) to each facility), and a natural number \(B\) (the budget).
DefinitionWell-formed facility location instances#✓fully proved
A facility location instance \((o, D, B)\), with opening costs \(o\) and assignment-cost rows \(D\), is well-formed when every row of \(D\) has the same length as \(o\).
def WellFormed (i : FacilityLocationInstance) : Prop :=
∀ row ∈ i.2.1, row.length = i.1.length
abbrev FacilityLocationInstance := List ℕ × List (List ℕ) × ℕ
WantedExt/Complexity/NPComplete/FacilityLocationWanted.lean:50
Uses 1 · Used by 1
DefinitionFeasible facility location instances#✓fully proved
Let \((o, D, B)\) be a facility location instance with opening costs \(o = (o_0, \dots, o_{n-1})\), assignment-cost rows \(D = (D_0, \dots, D_{m-1})\) and budget \(B\), and write \(D_{c,j}\) for the \(j\)-th entry of the row \(D_c\), read as \(0\) when \(D_c\) has no \(j\)-th entry. The instance is feasible when there is a map \(\sigma\) from the clients \(\{0, \dots, m-1\}\) to the facilities \(\{0, \dots, n-1\}\) such that the opening costs of the facilities in the image of \(\sigma\) plus the assignment costs stay within the budget: \(\sum_{j \in \sigma(\{0, \dots, m-1\})} o_j + \sum_{c=0}^{m-1} D_{c,\sigma(c)} \le B\).
def FacilityLocationFeasible
(i : FacilityLocationInstance) : Prop :=
∃ assign : List ℕ, assign.length = i.2.1.length ∧
(∀ c < i.2.1.length, assign.getD c 0 < i.1.length) ∧
∃ used : List ℕ, used.Nodup ∧
(∀ f ∈ used, ∃ c < i.2.1.length, assign.getD c 0 = f) ∧
(∀ c < i.2.1.length, assign.getD c 0 ∈ used) ∧
(used.map (fun f => i.1.getD f 0)).sum +
(Finset.range i.2.1.length).sum
(fun c => (i.2.1.getD c []).getD (assign.getD c 0) 0) ≤ i.2.2
abbrev FacilityLocationInstance := List ℕ × List (List ℕ) × ℕ
WantedExt/Complexity/NPComplete/FacilityLocationWanted.lean:50
Uses 1 · Used by 1
DefinitionThe FACILITY LOCATION decision problem#✓fully proved
FACILITY LOCATION is the decision problem that accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding, to a facility location instance that is well-formed and feasible; bitstrings that do not decode to an instance are rejected.
noncomputable def facilityLocationDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := FacilityLocationInstance) x with
| some i => decide (WellFormed i ∧ FacilityLocationFeasible 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 FacilityLocationInstance := List ℕ × List (List ℕ) × ℕ
WantedExt/Complexity/NPComplete/FacilityLocationWanted.lean:50
def WellFormed (i : FacilityLocationInstance) : Prop :=
∀ row ∈ i.2.1, row.length = i.1.length
WantedExt/Complexity/NPComplete/FacilityLocationWanted.lean:53
def FacilityLocationFeasible
(i : FacilityLocationInstance) : Prop :=
∃ assign : List ℕ, assign.length = i.2.1.length ∧
(∀ c < i.2.1.length, assign.getD c 0 < i.1.length) ∧
∃ used : List ℕ, used.Nodup ∧
(∀ f ∈ used, ∃ c < i.2.1.length, assign.getD c 0 = f) ∧
(∀ c < i.2.1.length, assign.getD c 0 ∈ used) ∧
(used.map (fun f => i.1.getD f 0)).sum +
(Finset.range i.2.1.length).sum
(fun c => (i.2.1.getD c []).getD (assign.getD c 0) 0) ≤ i.2.2
WantedExt/Complexity/NPComplete/FacilityLocationWanted.lean:57
Uses 12 · Used by 1
TheoremFACILITY LOCATION is NP-complete#●ready to prove
FACILITY LOCATION belongs to NP, and every decision problem \(L\) in NP reduces to FACILITY LOCATION by a polynomial-time many-one reduction: there is a polynomial-time computable map \(f\) on bitstrings such that, for every bitstring \(x\), \(L\) accepts \(x\) exactly when FACILITY LOCATION accepts \(f(x)\).
public theorem_wanted facilityLocation_npComplete :
facilityLocationDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L facilityLocationDec
noncomputable def facilityLocationDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := FacilityLocationInstance) x with
| some i => decide (WellFormed i ∧ FacilityLocationFeasible i)
| none => false
WantedExt/Complexity/NPComplete/FacilityLocationWanted.lean:70
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
- G. Cornuéjols, G. L. Nemhauser, and L. A. Wolsey, "The uncapacitated facility location problem", in P. B. Mirchandani and R. L. Francis, eds., Discrete Location Theory, Wiley, 1990, 119-171.
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.