Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Set cover: bundled instances, integral and fractional covers, dual packings, and the two certificate predicates

Definition
PrimalDualOnline_SetCover

by moutei · Sep 17, 2026 · Mathlib 0df444a (Lean v4.33.1)

approximation-algorithmscombinatoricsprimal-dualset-cover

The set-cover problem of Section 2.2. An instance has a finite type EEE of elements (the source's X={e1,…,en}X = \{e_1,\dots,e_n\}X={e1​,…,en​}), a finite type SSS indexing the available sets (the source's S={s1,…,sm}S = \{s_1,\dots,s_m\}S={s1​,…,sm​}), an assignment s↦As⊆Es \mapsto A_s \subseteq Es↦As​⊆E, and a cost c:S→Rc : S \to \mathbb{R}c:S→R. The coverage relation is membership: the set indexed by sss covers eee exactly when e∈Ase \in A_se∈As​. It is carried as a Finset-valued function rather than a separate S → E → Prop relation because every statement below sums over the elements of one set, which needs the Finset, and because Finset membership is decidable without a further hypothesis.

SetCoverInstance is the carrier of the problem's standing assumptions. An inhabitant bundles sets, cost, a proof that every cost is nonnegative (the source's "non negative cost csc_scs​", p. 10), and a proof that every element lies in some available set. Every source-facing theorem in the mission takes such an instance and reads those two facts off its fields; none of them takes either as a loose hypothesis. The two indicator lemmas are the only exceptions and are marked as generalized assisting results, since one has no cost function in scope at all and the other's hypothesis that a given CCC covers is strictly stronger than coverability of the family.

Nonnegativity is retained even where it is logically redundant. In any statement that also assumes a dual packing, 0≤y0 \le y0≤y together with ∑e∈Asye≤cs\sum_{e \in A_s} y_e \le c_s∑e∈As​​ye​≤cs​ already gives 0≤cs0 \le c_s0≤cs​; the field is kept because the source's model is of nonnegative costs and should not have to be reconstructed from an accident of which certificate a theorem happens to assume.

A cover is a finite C⊆SC \subseteq SC⊆S meeting every element, with cost ∑s∈Ccs\sum_{s \in C} c_s∑s∈C​cs​. A fractional cover is a nonnegative xxx with ∑s:e∈Asxs≥1\sum_{s : e \in A_s} x_s \ge 1∑s:e∈As​​xs​≥1 for every element, with cost ∑scsxs\sum_s c_s x_s∑s​cs​xs​; there is no upper bound on xsx_sxs​. A dual packing is a nonnegative yyy with ∑e∈Asye≤cs\sum_{e \in A_s} y_e \le c_s∑e∈As​​ye​≤cs​ for every set, of value ∑eye\sum_e y_e∑e​ye​. The frequency of an element counts the sets containing it and maxFrequency is the source's fff.

The empty ground type is retained on purpose: no Nonempty E hypothesis appears anywhere. With EEE empty, fff is a supremum over an empty index set and so is 000; the consequence for the certificate bounds is benign rather than false, because every AsA_sAs​ is then empty and the tightness clause forces cs=0c_s = 0cs​=0 for every chosen set, making both sides of the bound 000. Nonemptiness and cardinality hypotheses belong later, and only where an actual algorithm divides by a cost or takes a logarithm of ∣E∣|E|∣E∣.

The two certificate predicates carry the invariants the source's proofs actually use. IsGreedyCertificate at ratio ρ\rhoρ asserts that CCC covers, y≥0y \ge 0y≥0, the cover cost equals the dual value exactly, and every packing constraint holds after scaling by ρ\rhoρ. IsPrimalDualCertificate asserts that CCC covers, yyy is dual feasible without scaling, and every set in CCC has a tight dual constraint. They take sets and cost directly rather than an instance, because they are properties of a candidate solution rather than carriers of the problem's standing assumptions; the theorems apply them to the instance's fields.

Definition code
import Mathlib.Tactic
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
import Mathlib.NumberTheory.Harmonic.Bounds

namespace PrimalDualOnline.SetCover

/-!
The set-cover problem of Section 2.2.

An instance consists of a finite type `E` of elements (the source's `X = {e_1,…,e_n}`), a
finite type `S` indexing the available sets (the source's `S = {s_1,…,s_m}`), an assignment
`sets : S → Finset E` giving the elements of each available set, and a nonnegative cost
`cost : S → ℝ`.

The coverage relation of the problem is membership: the set indexed by `s` covers the element
`e` exactly when `e ∈ sets s`. It is carried as a `Finset`-valued function rather than as a
separate `S → E → Prop` relation because every statement below sums over the elements of a
single set, which needs the `Finset`, and because membership in a `Finset` is decidable
without a further hypothesis.

`Coverable` records the standing assumption that every element lies in at least one available
set. The source leaves this implicit; without it the instance has no cover at all and the
approximation statements are vacuous or false.

**Both standing assumptions live in `SetCoverInstance` and reach the theorems only through its
fields.** No source-facing theorem in this development takes nonnegativity of cost or
coverability as a loose hypothesis; each takes `I : SetCoverInstance E S` and reads
`I.cost_nonneg` and `I.coverable` off it. The two `indicator` lemmas are the only exceptions and
are explicitly marked as generalized assisting results rather than source-facing ones.
-/

variable {E S : Type*} [Fintype E] [Fintype S] [DecidableEq E]

/-- The sets containing a given element. -/
def containing [DecidableEq S] (sets : S → Finset E) (e : E) : Finset S :=
  Finset.univ.filter fun s => e ∈ sets s

/-- Every element belongs to at least one available set. Required for any cover to exist. -/
def Coverable (sets : S → Finset E) : Prop := ∀ e : E, ∃ s : S, e ∈ sets s

/-- Every available set has nonnegative cost. The source assumes this throughout ("Each set
`s` is associated with a non negative cost `c_s`", p. 10). It is stated as an explicit
predicate rather than left to be forced by packing feasibility, because the negative-cost
instances that feasibility would silently render vacuous are not instances of the problem the
source is discussing. Zero cost is permitted.

Note on logical redundancy: in any statement that also assumes a *dual packing*
(`IsDualPacking`), this predicate is implied, since `0 ≤ y` and `∑ e ∈ sets s, y e ≤ cost s`
together give `0 ≤ cost s`. It is nevertheless retained as part of the instance, because the
source's model is of nonnegative costs and that model should not be reconstructed from an
accident of which certificate a particular theorem happens to assume. -/
def NonnegCost (cost : S → ℝ) : Prop := ∀ s : S, 0 ≤ cost s

/-- A set-cover instance as the source poses it: a finite family of available sets over a
finite ground type, with nonnegative costs, in which every element is covered by at least one
available set.

This structure is the carrier of the problem's standing assumptions, and the source-facing
theorems consume it rather than re-assuming its fields. -/
structure SetCoverInstance (E S : Type*) [Fintype E] [Fintype S] where
  /-- The elements of each available set; `e ∈ sets s` is the coverage relation. -/
  sets : S → Finset E
  /-- The cost of each available set. -/
  cost : S → ℝ
  /-- Costs are nonnegative (source, p. 10). -/
  cost_nonneg : NonnegCost cost
  /-- Every element lies in some available set, so a cover exists. -/
  coverable : Coverable sets

/-- `C` is an integral cover: every element lies in some chosen set. -/
def IsCover (sets : S → Finset E) (C : Finset S) : Prop :=
  ∀ e : E, ∃ s ∈ C, e ∈ sets s

/-- The cost of an integral cover. -/
def coverCost (cost : S → ℝ) (C : Finset S) : ℝ := ∑ s ∈ C, cost s

/-- `x` is a fractional cover: nonnegative weights whose total on the sets containing each
element is at least one. This is the LP relaxation `(P)` of p. 10. -/
def IsFractionalCover [DecidableEq S] (sets : S → Finset E) (x : S → ℝ) : Prop :=
  (∀ s : S, 0 ≤ x s) ∧ ∀ e : E, 1 ≤ ∑ s ∈ containing sets e, x s

/-- The cost of a fractional cover. -/
def fractionalCost (cost : S → ℝ) (x : S → ℝ) : ℝ := ∑ s : S, cost s * x s

/-- `y` is feasible for the dual packing program `(D)` of p. 11: nonnegative element weights
whose total inside each available set does not exceed that set's cost. -/
def IsDualPacking (sets : S → Finset E) (cost : S → ℝ) (y : E → ℝ) : Prop :=
  (∀ e : E, 0 ≤ y e) ∧ ∀ s : S, ∑ e ∈ sets s, y e ≤ cost s

/-- The dual objective: the total element weight. -/
def packingValue (y : E → ℝ) : ℝ := ∑ e : E, y e

/-- The frequency of an element: how many available sets contain it. -/
def frequency [DecidableEq S] (sets : S → Finset E) (e : E) : ℕ :=
  (containing sets e).card

/-- The maximum frequency `f` of the instance (p. 14).

**The empty ground type is retained on purpose.** With `E` empty this is a supremum over an
empty index set, hence `0`; no `Nonempty E` hypothesis is imposed anywhere in this development.
The consequence for the certificate bounds is benign rather than false: when `E` is empty every
`sets s` is empty, so the tightness clause of `IsPrimalDualCertificate` forces `cost s = 0` for
every `s ∈ C` and hence `coverCost cost C = 0`, which is exactly what the bound
`coverCost cost C ≤ (maxFrequency sets : ℝ) * fractionalCost cost x` demands when its
coefficient is `0`. Nonemptiness or cardinality hypotheses belong later, and only where an
actual algorithm divides by a cost or takes a logarithm of `|E|`. -/
def maxFrequency [DecidableEq S] (sets : S → Finset E) : ℕ :=
  Finset.univ.sup (frequency sets)

/-- The least cost of an integral cover, as an attained value. -/
def IsOptIntegral (sets : S → Finset E) (cost : S → ℝ) (v : ℝ) : Prop :=
  IsLeast {w : ℝ | ∃ C : Finset S, IsCover sets C ∧ coverCost cost C = w} v

/-- The least cost of a fractional cover, as an attained value. -/
def IsOptFractional [DecidableEq S] (sets : S → Finset E) (cost : S → ℝ) (v : ℝ) : Prop :=
  IsLeast {w : ℝ | ∃ x : S → ℝ, IsFractionalCover sets x ∧ fractionalCost cost x = w} v

/-- The indicator fractional solution of an integral cover: weight one on chosen sets. Used to
witness that every integral cover is also a fractional cover. -/
def indicator [DecidableEq S] (C : Finset S) : S → ℝ := fun s => if s ∈ C then 1 else 0

/-!
## Certificates

The two deterministic analyses of Section 2.2 are stated about *certificates* rather than
about an executable algorithm. A certificate is a pair consisting of a cover and a dual
vector, together with the invariants the source's analysis actually uses. This separates the
algorithm-independent analysis — which is the mathematical content — from the separate
question of whether a particular algorithm produces such a pair.

The certificate predicates take `sets` and `cost` directly rather than a `SetCoverInstance`,
because they are properties of a candidate solution, not carriers of the problem's standing
assumptions; the theorems apply them to `I.sets` and `I.cost`.
-/

/-- A greedy (dual-fitting) certificate, packaging the three claims in the proof of
Theorem 2.4: the output covers, the primal cost equals the constructed dual value, and each
packing constraint is violated by at most a factor `ρ`. -/
def IsGreedyCertificate (sets : S → Finset E) (cost : S → ℝ)
    (C : Finset S) (y : E → ℝ) (ρ : ℝ) : Prop :=
  IsCover sets C ∧
    (∀ e : E, 0 ≤ y e) ∧
    coverCost cost C = packingValue y ∧
    ∀ s : S, ∑ e ∈ sets s, y e ≤ ρ * cost s

/-- A primal-dual certificate, packaging the invariants in the proof of Theorem 2.6: the
output covers, the dual is feasible, and every chosen set has a tight dual constraint. -/
def IsPrimalDualCertificate (sets : S → Finset E) (cost : S → ℝ)
    (C : Finset S) (y : E → ℝ) : Prop :=
  IsCover sets C ∧
    IsDualPacking sets cost y ∧
    ∀ s ∈ C, ∑ e ∈ sets s, y e = cost s

end PrimalDualOnline.SetCover
Source
Niv Buchbinder, Designing Competitive Online Algorithms via a Primal-Dual Approach, PhD thesis, Tel Aviv University, 2008, https://www.tau.ac.il/~nivb/download/phd-thsis.pdf, Section 2.2, pp. 10-14 (instance and nonnegative costs on p. 10; programs (P) and (D) on pp. 10-11; the maximum frequency f on p. 14; the invariants in the proofs of Theorems 2.4 and 2.6)
Read-back

What the Lean code literally says, in plain math · claude-opus-5

Read-back — set-cover declaration bundle (PrimalDualOnline.SetCover)

Ambient context shared by every declaration

Every declaration in this bundle is stated over two ambient types EEE and SSS, each in an arbitrary universe, introduced by section-level binders together with three instance assumptions: EEE is a finite type, SSS is a finite type, and equality on EEE is decidable. These are implicit arguments of each declaration that mentions the corresponding type. Six declarations additionally require decidable equality on SSS as a further instance argument: containing, IsFractionalCover, frequency, maxFrequency, IsOptFractional, and indicator; the other declarations do not require it.

Throughout I write AsA_sAs​ for the value at sss of the family named sets — a total function assigning to each index s:Ss : Ss:S a finite subset As⊆EA_s \subseteq EAs​⊆E — and csc_scs​ for the value at sss of cost, a total function S→RS \to \mathbb{R}S→R. Nothing in the ambient context constrains either function: AsA_sAs​ may be empty for some or all sss, the sets may coincide or overlap arbitrarily, and csc_scs​ may be zero, positive, or negative unless a particular declaration says otherwise. CCC always denotes a finite subset of SSS, x:S→Rx : S \to \mathbb{R}x:S→R a weight on indices, y:E→Ry : E \to \mathbb{R}y:E→R a weight on elements, and ρ\rhoρ a real number. Both EEE and SSS may be empty types; no declaration assumes either is nonempty, and no declaration relates their sizes.

All seventeen items in the file are definitions or one structure. There is no theorem and no lemma anywhere in the bundle: the file proves nothing and asserts nothing about any of the notions it introduces; it only introduces vocabulary. The file imports general tactic support, ordered-semiring big-operator lemmas over finite sets, and bounds on harmonic numbers, but no declaration mentions harmonic numbers, logarithms, set cardinalities ∣As∣|A_s|∣As​∣, or any numeric approximation factor; the only approximation-like quantity in the bundle is the free real parameter ρ\rhoρ of IsGreedyCertificate, which that definition leaves entirely unconstrained.


containing

Given decidable equality on SSS in addition to the ambient instances, a family s↦Ass \mapsto A_ss↦As​ of finite subsets of EEE, and an element e:Ee : Ee:E, this defines the finite subset of SSS

containing(A,e)  =  { s∈S  :  e∈As },\mathrm{containing}(A, e) \;=\; \{\, s \in S \;:\; e \in A_s \,\},containing(A,e)={s∈S:e∈As​},

obtained by filtering the universal finite set of all indices (available because SSS is assumed finite) by the predicate "eee belongs to AsA_sAs​"; decidability of that predicate comes from decidable equality on EEE. The filtering ranges over the whole of SSS, not over any candidate subcollection, so this is the collection of all indices whose set contains eee. It may be empty — exactly when eee lies in no AsA_sAs​, which includes the case SSS empty and the case where every AsA_sAs​ is empty. No cost function appears, so no constraint on the sign of any cost is imposed, and the definition does not require that every element lie in some set: it merely records which indices, possibly none, contain eee.

Coverable

Given a family s↦Ass \mapsto A_ss↦As​, this is the proposition

∀ e∈E, ∃ s∈S, e∈As,\forall\, e \in E,\ \exists\, s \in S,\ e \in A_s,∀e∈E, ∃s∈S, e∈As​,

that every element of the ambient element type belongs to at least one member of the family; the existential ranges over all of SSS. This is the one predicate whose entire content is "every element lies in some set". It is purely propositional, built from finite-set membership, and uses no decidability beyond the ambient instances; no cost function appears, so nothing about the sign of any cost is constrained. Degenerate cases: if EEE is empty the statement holds vacuously for any family, including the family sending every index to the empty set and including SSS empty; if EEE is nonempty and SSS is empty, or more generally if some element belongs to no AsA_sAs​, it is false. The existential is unweighted and says nothing about how many sets contain a given element.

NonnegCost

Given a cost function s↦css \mapsto c_ss↦cs​ into the reals, this is the proposition

∀ s∈S, 0≤cs,\forall\, s \in S,\ 0 \le c_s,∀s∈S, 0≤cs​,

that every index has nonnegative cost. The inequality is non-strict, so zero-cost indices are permitted, including a cost identically zero; the statement is vacuously true when SSS is empty. It concerns costs only: it says nothing about the family, nothing about coverage, and in particular does not require that every element lie in some set.

SetCoverInstance

This structure takes four parameters written out in its own signature: two explicit type arguments EEE and SSS, and two instance arguments, finiteness of EEE and finiteness of SSS. (It does not take decidable equality on EEE or on SSS.) An inhabitant of SetCoverInstance(E,S)\mathrm{SetCoverInstance}(E, S)SetCoverInstance(E,S) bundles exactly four components and nothing else:

  1. sets — a total function from SSS to finite subsets of EEE, i.e. the family s↦Ass \mapsto A_ss↦As​;
  2. cost — a total function S→RS \to \mathbb{R}S→R, i.e. s↦css \mapsto c_ss↦cs​;
  3. cost_nonneg — a proof of NonnegCost(cost)\mathrm{NonnegCost}(\mathrm{cost})NonnegCost(cost), unfolded: 0≤cs0 \le c_s0≤cs​ for every s∈Ss \in Ss∈S;
  4. coverable — a proof of Coverable(sets)\mathrm{Coverable}(\mathrm{sets})Coverable(sets), unfolded: every e∈Ee \in Ee∈E belongs to AsA_sAs​ for at least one s∈Ss \in Ss∈S.

So an inhabitant is a finite element type, a finite index type, a set family over them, a real cost per index, a nonnegativity guarantee for all costs, and a coverability guarantee for all elements. There is no requirement that the sets be nonempty or pairwise distinct, no cardinality or frequency bound, no strict positivity of costs (only nonnegativity), and no stored optimum. If EEE is empty the coverability field is vacuous, so inhabitants exist for any family with any nonnegative cost; if SSS is empty the cost field's condition is vacuous and an inhabitant exists precisely when EEE is also empty, the coverability field being otherwise unsatisfiable; a cost identically zero yields legitimate inhabitants.

Whether the structure is consumed in this file. Checking every other declaration one by one: containing takes a bare family and an element; Coverable a bare family; NonnegCost a bare cost; IsCover a bare family and CCC; coverCost a bare cost and CCC; IsFractionalCover a bare family and xxx; fractionalCost a bare cost and xxx; IsDualPacking a bare family, a bare cost and yyy; packingValue only yyy; frequency a bare family and an element; maxFrequency a bare family; IsOptIntegral a bare family, a bare cost and a real vvv; IsOptFractional a bare family, a bare cost and a real vvv; indicator only CCC; IsGreedyCertificate a bare family, a bare cost, CCC, yyy and ρ\rhoρ; IsPrimalDualCertificate a bare family, a bare cost, CCC and yyy. No declaration in this file takes a SetCoverInstance as an argument, and none projects any of its four fields. The dependency runs only inward: the structure's field types mention NonnegCost and Coverable, and those two predicates are themselves used nowhere else in the file. Within this file the structure is therefore inert — defined and never consumed. In particular the cost nonnegativity and the coverability it packages are not transported into any other definition here; every other definition either requires such a hypothesis separately or does not require it at all.

IsCover

Given a family s↦Ass \mapsto A_ss↦As​ and a finite subset C⊆SC \subseteq SC⊆S, this is the proposition

∀ e∈E, ∃ s∈C, e∈As,\forall\, e \in E,\ \exists\, s \in C,\ e \in A_s,∀e∈E, ∃s∈C, e∈As​,

that every element of EEE belongs to at least one set indexed by a member of CCC. The existential is restricted to CCC, unlike Coverable, where it ranges over all of SSS. This is the "every element lies in some set" condition localised to CCC. No cost function occurs, so no sign constraint on costs is imposed or implied. Degenerate cases: if EEE is empty the statement holds for every CCC, including C=∅C = \varnothingC=∅ and including SSS empty; if EEE is nonempty then C=∅C = \varnothingC=∅ makes it false, the inner existential over an empty collection being false, and likewise if SSS is empty. Multiplicity is irrelevant — an element covered by many members of CCC satisfies the condition exactly as one covered by a single member — and there is no minimality, irredundancy, or distinctness requirement on CCC.

coverCost

Given a cost function s↦css \mapsto c_ss↦cs​ and a finite subset C⊆SC \subseteq SC⊆S, this is the real number

coverCost(c,C)  =  ∑s∈Ccs,\mathrm{coverCost}(c, C) \;=\; \sum_{s \in C} c_s,coverCost(c,C)=s∈C∑​cs​,

a plain finite sum over the members of CCC, counting each member once regardless of how many elements it covers. It is defined for every finite subset CCC, whether or not CCC covers anything: no coverage condition appears, so it does not require that every element lie in some set. It imposes no sign condition on cost — with negative csc_scs​ the value may be negative, and enlarging CCC may decrease the total. If CCC is empty (in particular if SSS is empty, forcing CCC empty) the value is the empty sum 000; if the cost is identically zero the value is 000 for every CCC; zero-cost indices contribute nothing and may be added to or removed from CCC without changing the value.

IsFractionalCover

Given decidable equality on SSS, a family s↦Ass \mapsto A_ss↦As​, and a weight vector x:S→Rx : S \to \mathbb{R}x:S→R, this is the conjunction of two conditions:

(∀ s∈S, 0≤xs)and(∀ e∈E, 1≤∑s : e∈Asxs),\bigl(\forall\, s \in S,\ 0 \le x_s\bigr) \quad\text{and}\quad \Bigl(\forall\, e \in E,\ 1 \le \sum_{s \,:\, e \in A_s} x_s\Bigr),(∀s∈S, 0≤xs​)and(∀e∈E, 1≤s:e∈As​∑​xs​),

where the inner sum ranges over containing(A,e)\mathrm{containing}(A,e)containing(A,e) — that is, over all indices of the whole type SSS whose set contains eee, with containing unfolded. So the weights are nonnegative and, for each element, the total weight of the sets containing it is at least 111. The sign constraint here is on xxx, not on cost: no cost function is an argument, so the definition neither assumes nor implies anything about the sign of any cost. The second clause is the fractional analogue of "every element lies in some set" and does entail it: if some eee belonged to no AsA_sAs​, its sum would be the empty sum 000 and 1≤01 \le 01≤0 would fail. There is no upper bound of 111 on the weights — xsx_sxs​ may exceed 111, may be arbitrarily large, the per-element covering sums may far exceed 111, and ∑sxs\sum_s x_s∑s​xs​ is unbounded. Degenerate cases: if EEE is empty the second clause is vacuous and the condition reduces to nonnegativity of xxx alone, so x≡0x \equiv 0x≡0 qualifies; if SSS is empty, or more generally if some element lies in no set, the second clause is unsatisfiable whenever EEE is nonempty, so no xxx qualifies; the zero vector qualifies only when EEE is empty.

fractionalCost

Given a cost function s↦css \mapsto c_ss↦cs​ and a weight vector x:S→Rx : S \to \mathbb{R}x:S→R, this is the real number

fractionalCost(c,x)  =  ∑s∈Scs xs,\mathrm{fractionalCost}(c, x) \;=\; \sum_{s \in S} c_s\, x_s,fractionalCost(c,x)=s∈S∑​cs​xs​,

a sum over the entire index type SSS (legitimate because SSS is finite), not over a subcollection and not over the support of xxx. No hypothesis restricts xxx or ccc: the definition applies to arbitrary real vectors, so it does not assume nonnegative cost, does not assume nonnegative weights, imposes no coverage requirement, and its value may be negative. If SSS is empty the value is 000; if the cost is identically zero the value is 000 for every xxx; an index of zero cost contributes nothing however large its weight, and an index of zero weight contributes nothing however large its cost.

IsDualPacking

Given a family s↦Ass \mapsto A_ss↦As​, a cost function s↦css \mapsto c_ss↦cs​, and an element weighting y:E→Ry : E \to \mathbb{R}y:E→R, this is the conjunction

(∀ e∈E, 0≤ye)and(∀ s∈S, ∑e∈Asye  ≤  cs):\bigl(\forall\, e \in E,\ 0 \le y_e\bigr) \quad\text{and}\quad \Bigl(\forall\, s \in S,\ \sum_{e \in A_s} y_e \;\le\; c_s\Bigr):(∀e∈E, 0≤ye​)and(∀s∈S, e∈As​∑​ye​≤cs​):

the element weights are nonnegative, and for every index — all of SSS, not merely some subcollection — the total weight of the elements of AsA_sAs​ does not exceed that index's cost. The definition does not assume nonnegative cost but it implies it: for each sss, the sum ∑e∈Asye\sum_{e \in A_s} y_e∑e∈As​​ye​ is a finite sum of nonnegative terms by the first clause, so 0≤∑e∈Asye≤cs0 \le \sum_{e \in A_s} y_e \le c_s0≤∑e∈As​​ye​≤cs​ and hence 0≤cs0 \le c_s0≤cs​ for every sss; any yyy satisfying this condition therefore witnesses NonnegCost(c)\mathrm{NonnegCost}(c)NonnegCost(c), and the condition is unsatisfiable whenever some cost is negative. It does not require that every element lie in some set: an element belonging to no AsA_sAs​ is constrained only by 0≤ye0 \le y_e0≤ye​ and may carry arbitrarily large weight. Degenerate cases: if EEE is empty every AsA_sAs​ is empty, each sum is 000, and the condition reduces to 0≤cs0 \le c_s0≤cs​ for all sss; if SSS is empty the second clause is vacuous and the condition reduces to nonnegativity of yyy; if As=∅A_s = \varnothingAs​=∅ for a particular sss that index's constraint reduces to 0≤cs0 \le c_s0≤cs​; if cs=0c_s = 0cs​=0 for some sss — in particular if the cost is identically zero — then with y≥0y \ge 0y≥0 the constraint forces ye=0y_e = 0ye​=0 for every e∈Ase \in A_se∈As​.

packingValue

Given an element weighting y:E→Ry : E \to \mathbb{R}y:E→R, this is the real number

packingValue(y)  =  ∑e∈Eye,\mathrm{packingValue}(y) \;=\; \sum_{e \in E} y_e,packingValue(y)=e∈E∑​ye​,

the sum of the weights over the entire element type, using finiteness of EEE. It takes no family and no cost, so it constrains neither the sign of cost nor coverage, and it does not require yyy to be nonnegative — on an arbitrary real vector its value may be negative. If EEE is empty the value is the empty sum 000. Every element of EEE is counted, including elements belonging to no set of the family.

frequency

Given decidable equality on SSS, a family s↦Ass \mapsto A_ss↦As​, and an element e:Ee : Ee:E, this is the natural number

fA(e)  =  ∣{ s∈S  :  e∈As }∣,f_A(e) \;=\; \bigl|\{\, s \in S \;:\; e \in A_s \,\}\bigr|,fA​(e)=​{s∈S:e∈As​}​,

the cardinality of containing(A,e)\mathrm{containing}(A,e)containing(A,e) — the number of indices of the whole type SSS whose set contains eee. Being a natural number it is automatically nonnegative, and it equals 000 exactly when eee belongs to no set of the family, in particular when SSS is empty or when every AsA_sAs​ is empty. No cost appears, so there is no constraint on the sign of any cost, and the definition does not require that every element lie in some set — the value 000 is precisely the record of an element that lies in none.

maxFrequency

Given decidable equality on SSS and a family s↦Ass \mapsto A_ss↦As​, this is the natural number

Δ(A)  =  sup⁡e∈EfA(e)  =  max⁡e∈E ∣{ s∈S:e∈As }∣,\Delta(A) \;=\; \sup_{e \in E} f_A(e) \;=\; \max_{e \in E}\, \bigl|\{\, s \in S : e \in A_s \,\}\bigr|,Δ(A)=e∈Esup​fA​(e)=e∈Emax​​{s∈S:e∈As​}​,

the supremum, taken over the universal finite set of all elements of EEE, of the frequencies above. Because it is a finite supremum in the naturals, whose least element is 000, an empty supremum takes the value 000 rather than being undefined. It is a natural number, hence nonnegative by type; no cost function appears, so there is no constraint on the sign of any cost; and it does not require that every element lie in some set.

When it is 000. Exactly when every element has frequency 000, i.e. when no element of EEE lies in any AsA_sAs​. Concretely: (i) EEE empty — the supremum is over an empty range and takes its default value 000, for any family whatsoever, including SSS empty; (ii) SSS empty with EEE arbitrary, since then no index exists to contain anything; (iii) SSS nonempty but As=∅A_s = \varnothingAs​=∅ for every sss. Cases (ii) and (iii) with EEE nonempty are exactly the failure of Coverable, so a coverable family over a nonempty EEE has Δ(A)≥1\Delta(A) \ge 1Δ(A)≥1 — though the file states no such connection.

What the declarations mentioning it reduce to. No other declaration in the file mentions maxFrequency: no definition's body refers to it, and the free parameter ρ\rhoρ of IsGreedyCertificate is never tied to it or to any frequency. Within this file maxFrequency is defined and unused, so the Δ(A)=0\Delta(A) = 0Δ(A)=0 cases affect nothing else in the bundle. Correspondingly frequency is used only inside maxFrequency, and containing is used only inside frequency and in the covering clause of IsFractionalCover.

IsOptIntegral

Given a family s↦Ass \mapsto A_ss↦As​, a cost function s↦css \mapsto c_ss↦cs​, and a real number vvv, this asserts that vvv is the least element of the set of achievable cover costs:

v  =  min⁡  { w∈R  :  ∃ C⊆S finite, (∀e∈E, ∃s∈C, e∈As)∧∑s∈Ccs=w },v \;=\; \min\;\Bigl\{\, w \in \mathbb{R} \;:\; \exists\, C \subseteq S \text{ finite},\ \bigl(\forall e \in E,\ \exists s \in C,\ e \in A_s\bigr) \wedge \textstyle\sum_{s \in C} c_s = w \,\Bigr\},v=min{w∈R:∃C⊆S finite, (∀e∈E, ∃s∈C, e∈As​)∧∑s∈C​cs​=w},

with the cover condition and the cost sum unfolded. "Least element" is a two-part condition: vvv is itself achieved by some covering collection (membership in the set) and v≤wv \le wv≤w for every achievable cover cost www (lower bound); both halves matter, so the optimum must be attained rather than merely approached. The definition does not assume nonnegative cost and does not imply it: with negative costs a least element still exists whenever any cover exists, since SSS is finite and so only finitely many values are achievable; the optimum may then be negative and may be attained by a redundant CCC whose extra negative-cost members lower the total. It does require, for satisfiability, that every element lie in some set: if no C⊆SC \subseteq SC⊆S covers EEE the defining set is empty and no real vvv satisfies the condition, so the predicate is then unsatisfiable. Degenerate cases: if EEE is empty every CCC is a cover, so vvv is the minimum of ∑s∈Ccs\sum_{s\in C} c_s∑s∈C​cs​ over all finite subsets of SSS — which is 000 when all costs are nonnegative and otherwise the sum of the negative costs; if SSS is empty the only candidate is C=∅C = \varnothingC=∅, so the predicate holds exactly at v=0v = 0v=0 when EEE is empty and for no vvv when EEE is nonempty; if the cost is identically zero the predicate holds exactly at v=0v = 0v=0 provided some cover exists, and for no vvv otherwise; zero-cost indices may be added freely to an optimal CCC without changing vvv.

IsOptFractional

Given decidable equality on SSS, a family s↦Ass \mapsto A_ss↦As​, a cost function s↦css \mapsto c_ss↦cs​, and a real number vvv, this asserts that vvv is the least element of the set of achievable fractional-cover costs:

v  =  min⁡  { w∈R  :  ∃ x:S→R, (∀s, 0≤xs)∧(∀e, 1≤∑s:e∈Asxs)∧∑s∈Scsxs=w },v \;=\; \min\;\Bigl\{\, w \in \mathbb{R} \;:\; \exists\, x : S \to \mathbb{R},\ \bigl(\forall s,\ 0 \le x_s\bigr) \wedge \Bigl(\forall e,\ 1 \le \textstyle\sum_{s : e \in A_s} x_s\Bigr) \wedge \textstyle\sum_{s \in S} c_s x_s = w \,\Bigr\},v=min{w∈R:∃x:S→R, (∀s, 0≤xs​)∧(∀e, 1≤∑s:e∈As​​xs​)∧∑s∈S​cs​xs​=w},

with the fractional-cover condition and the cost functional unfolded. Again "least element" means both that vvv is attained by some feasible xxx and that v≤wv \le wv≤w for every feasible value, so this asserts that the infimum is achieved, not merely that it is a lower bound. Weights are required nonnegative but are not bounded above by 111; arbitrarily large weights are feasible. The definition does not assume nonnegative cost but implies it whenever it holds: suppose cs0<0c_{s_0} < 0cs0​​<0 for some s0s_0s0​; the predicate requires the value set to be nonempty, so some feasible xxx exists, and for every t≥0t \ge 0t≥0 the vector x+t 1s0x + t\,\mathbf{1}_{s_0}x+t1s0​​ is still feasible — nonnegativity is preserved and each element's covering sum only increases — with cost ∑scsxs+t cs0→−∞\sum_s c_s x_s + t\,c_{s_0} \to -\infty∑s​cs​xs​+tcs0​​→−∞ as t→∞t \to \inftyt→∞; the value set is then unbounded below and has no least element, a contradiction. Hence IsOptFractional\mathrm{IsOptFractional}IsOptFractional holding for some vvv forces 0≤cs0 \le c_s0≤cs​ for all sss. It likewise requires, for satisfiability, that every element lie in some set, since otherwise no feasible xxx exists (an uncovered element's covering sum is the empty sum 0≱10 \not\ge 10≥1) and the value set is empty. Degenerate cases: if EEE is empty, feasibility reduces to x≥0x \ge 0x≥0, so with nonnegative costs x≡0x \equiv 0x≡0 is feasible and the predicate holds exactly at v=0v = 0v=0, while with some negative cost it holds for no vvv by the unboundedness argument; if SSS is empty it holds exactly at v=0v = 0v=0 when EEE is empty and for no vvv when EEE is nonempty; if the cost is identically zero it holds exactly at v=0v = 0v=0 provided some feasible xxx exists; a single zero-cost index may carry unbounded weight at no cost.

indicator

Given decidable equality on SSS and a finite subset C⊆SC \subseteq SC⊆S, this is the function S→RS \to \mathbb{R}S→R

1C(s)  =  {1if s∈C,0if s∉C,\mathbf{1}_C(s) \;=\; \begin{cases} 1 & \text{if } s \in C,\\ 0 & \text{if } s \notin C,\end{cases}1C​(s)={10​if s∈C,if s∈/C,​

a real-valued 0/10/10/1 vector on the index type; the decidable-equality-on-SSS instance is what makes the membership test s∈Cs \in Cs∈C decidable. It takes no family and no cost, so it constrains neither the sign of cost nor coverage. If CCC is empty — in particular if SSS is empty — the function is identically 000. No declaration in this file applies indicator to anything: it appears neither in IsFractionalCover nor in IsOptFractional nor anywhere else, and the file contains no statement relating 1C\mathbf{1}_C1C​ to fractional covers or relating coverCost to fractionalCost. Within this file it is inert.

IsGreedyCertificate

Given a family s↦Ass \mapsto A_ss↦As​, a cost function s↦css \mapsto c_ss↦cs​, a finite subset C⊆SC \subseteq SC⊆S, an element weighting y:E→Ry : E \to \mathbb{R}y:E→R, and a real number ρ\rhoρ — five explicit arguments, together with the ambient implicit type and instance arguments — this is the conjunction of four conditions:

  1. CCC is a cover: every e∈Ee \in Ee∈E lies in AsA_sAs​ for some s∈Cs \in Cs∈C;
  2. yyy is nonnegative: 0≤ye0 \le y_e0≤ye​ for every e∈Ee \in Ee∈E;
  3. exact cost matching: ∑s∈Ccs  =  ∑e∈Eye\displaystyle \sum_{s \in C} c_s \;=\; \sum_{e \in E} y_es∈C∑​cs​=e∈E∑​ye​, the cost of CCC equalling (not merely bounding) the total element weight, the right-hand sum being over all of EEE;
  4. ρ\rhoρ-relaxed dual feasibility: ∑e∈Asye  ≤  ρ cs\displaystyle \sum_{e \in A_s} y_e \;\le\; \rho\, c_se∈As​∑​ye​≤ρcs​ for every s∈Ss \in Ss∈S.

The parameter ρ\rhoρ is an arbitrary real: the definition places no constraint on it — it need not be positive, need not be at least 111, and is not related to maxFrequency\mathrm{maxFrequency}maxFrequency or to any other quantity in the file. The definition does not assume nonnegative cost; what it implies depends on ρ\rhoρ, since clauses 2 and 4 give 0≤∑e∈Asye≤ρ cs0 \le \sum_{e \in A_s} y_e \le \rho\,c_s0≤∑e∈As​​ye​≤ρcs​ and hence 0≤ρ cs0 \le \rho\,c_s0≤ρcs​ for every sss. Thus if ρ>0\rho > 0ρ>0 it implies 0≤cs0 \le c_s0≤cs​ for all sss; if ρ<0\rho < 0ρ<0 it implies cs≤0c_s \le 0cs​≤0 for all sss, so only families with all costs nonpositive admit a certificate with negative ρ\rhoρ; and if ρ=0\rho = 0ρ=0, clause 4 becomes ∑e∈Asye≤0\sum_{e \in A_s} y_e \le 0∑e∈As​​ye​≤0 for every sss, which with clause 2 forces ye=0y_e = 0ye​=0 for every element lying in any AsA_sAs​, whereupon clause 1 — which places every element of EEE in some AsA_sAs​ with s∈Cs \in Cs∈C — forces y≡0y \equiv 0y≡0 on all of EEE, so the right-hand side of clause 3 is 000 and the predicate collapses to: CCC covers EEE, yyy is identically zero, and ∑s∈Ccs=0\sum_{s \in C} c_s = 0∑s∈C​cs​=0 (individual member costs may be nonzero and cancel). Clause 1 is the "every element lies in some set" requirement, localised to CCC. Further degenerate cases: if EEE is empty, clause 1 holds for every CCC, clause 3 reduces to ∑s∈Ccs=0\sum_{s\in C} c_s = 0∑s∈C​cs​=0 (its right side an empty sum), and clause 4 to 0≤ρ cs0 \le \rho\,c_s0≤ρcs​ for all sss; if CCC is empty and EEE nonempty, clause 1 fails; if both are empty, clause 3 reads 0=00 = 00=0; if SSS is empty, clause 4 is vacuous and clauses 1 and 3 force EEE empty with nothing required of yyy beyond nonnegativity; if cs=0c_s = 0cs​=0 for a particular sss, clause 4 forces ye=0y_e = 0ye​=0 for every e∈Ase \in A_se∈As​ whatever ρ\rhoρ is; if the cost is identically zero then, given clause 1, the predicate holds precisely when y≡0y \equiv 0y≡0, for every covering CCC and every ρ\rhoρ. No clause asserts any relation between ∑s∈Ccs\sum_{s\in C} c_s∑s∈C​cs​ and any optimum: the definition mentions neither IsOptIntegral nor IsOptFractional, and nothing in the file connects them.

IsPrimalDualCertificate

Given a family s↦Ass \mapsto A_ss↦As​, a cost function s↦css \mapsto c_ss↦cs​, a finite subset C⊆SC \subseteq SC⊆S, and an element weighting y:E→Ry : E \to \mathbb{R}y:E→R — four explicit arguments plus the ambient implicit and instance arguments — this is the conjunction of three conditions:

  1. CCC is a cover: every e∈Ee \in Ee∈E lies in AsA_sAs​ for some s∈Cs \in Cs∈C;
  2. yyy is a dual packing for the family and the cost, i.e. IsDualPacking unfolded: 0≤ye0 \le y_e0≤ye​ for every e∈Ee \in Ee∈E, and ∑e∈Asye≤cs\displaystyle \sum_{e \in A_s} y_e \le c_se∈As​∑​ye​≤cs​ for every s∈Ss \in Ss∈S — the bound holding at all indices, with coefficient exactly 111;
  3. tightness on the chosen collection: ∑e∈Asye  =  cs\displaystyle \sum_{e \in A_s} y_e \;=\; c_se∈As​∑​ye​=cs​ for every s∈Cs \in Cs∈C, each selected index's constraint being met with equality.

There is no clause equating ∑s∈Ccs\sum_{s \in C} c_s∑s∈C​cs​ with ∑e∈Eye\sum_{e \in E} y_e∑e∈E​ye​: unlike IsGreedyCertificate, this definition mentions neither packingValue nor coverCost, and it asserts no inequality against any optimum. It does not assume nonnegative cost but implies it, exactly as in IsDualPacking: each ∑e∈Asye\sum_{e \in A_s} y_e∑e∈As​​ye​ is a sum of nonnegative terms, so 0≤cs0 \le c_s0≤cs​ for every s∈Ss \in Ss∈S (not only for s∈Cs \in Cs∈C), and the predicate is unsatisfiable when any cost is negative. Clause 1 is the "every element lies in some set" requirement, localised to CCC. Degenerate cases: if EEE is empty, clause 1 is vacuous and every AsA_sAs​ is empty, so clause 2 reduces to 0≤cs0 \le c_s0≤cs​ for all sss while clause 3 forces cs=0c_s = 0cs​=0 for every s∈Cs \in Cs∈C — with EEE empty only zero-cost indices may appear in CCC; if CCC is empty, clause 3 is vacuous and clause 1 requires EEE empty; if SSS is empty, clauses 2 and 3 are vacuous and clause 1 requires EEE empty; if As=∅A_s = \varnothingAs​=∅ for some s∈Cs \in Cs∈C, clause 3 forces cs=0c_s = 0cs​=0; if cs=0c_s = 0cs​=0 for some sss, clause 2 with nonnegativity forces ye=0y_e = 0ye​=0 throughout AsA_sAs​, and when such an sss lies in CCC clause 3 is then automatic; if the cost is identically zero, the predicate holds precisely when CCC covers EEE and yyy vanishes on ⋃sAs\bigcup_s A_s⋃s​As​, which by clause 1 is all of EEE, so y≡0y \equiv 0y≡0.


Cross-cutting summary

Sign of cost, declaration by declaration. Assumed outright: NonnegCost (its whole content) and the cost_nonneg field of SetCoverInstance. Implied without being assumed: IsDualPacking and IsPrimalDualCertificate, where a nonnegative yyy bounded above by csc_scs​ gives 0≤cs0 \le c_s0≤cs​ for every s∈Ss \in Ss∈S; IsOptFractional, where a negative cost makes the feasible value set unbounded below so that no least element can exist; and IsGreedyCertificate conditionally on ρ\rhoρ — ρ>0\rho > 0ρ>0 gives c≥0c \ge 0c≥0 everywhere, ρ<0\rho < 0ρ<0 gives c≤0c \le 0c≤0 everywhere, and ρ=0\rho = 0ρ=0 gives no sign information but forces y≡0y \equiv 0y≡0 and ∑s∈Ccs=0\sum_{s \in C} c_s = 0∑s∈C​cs​=0. Neither assumed nor implied: containing, Coverable, IsCover, coverCost, IsFractionalCover (which constrains the sign of xxx instead), fractionalCost, packingValue, frequency, maxFrequency, IsOptIntegral, indicator.

"Every element lies in some set", declaration by declaration. Asserted over all of SSS: Coverable. Asserted over the given collection CCC: IsCover, and clause 1 of both IsGreedyCertificate and IsPrimalDualCertificate. Asserted in a fractional form that entails it: IsFractionalCover, and hence the feasibility condition inside IsOptFractional. Required only for satisfiability, via the existential over covers: IsOptIntegral and IsOptFractional are false for every vvv when no cover, respectively no fractional cover, exists. Not required at all: containing, NonnegCost, coverCost, fractionalCost, IsDualPacking (elements in no set are constrained only by ye≥0y_e \ge 0ye​≥0), packingValue, frequency, maxFrequency, indicator. Packaged as a field: SetCoverInstance, through coverable.

Nature of the coverage relation. Coverage is not a separately declared Prop\mathrm{Prop}Prop-valued relation on S×ES \times ES×E; it is finite-set membership e∈Ase \in A_se∈As​, where AsA_sAs​ is the finite subset of EEE produced by the total function sets. Membership in a finite subset is a proposition, and the quantified statements built from it — Coverable, IsCover, and the clauses of both certificate predicates — are ordinary propositions requiring no decidability. Decidability is needed only where membership must be computed into data: forming containing(A,e)\mathrm{containing}(A,e)containing(A,e) by filtering the universal finite set of SSS needs the membership predicate to be decidable, which follows from decidable equality on EEE, and needs SSS finite; indicator needs decidability of s∈Cs \in Cs∈C for a finite subset of SSS, which follows from decidable equality on SSS. Decidable equality on SSS is demanded as an extra instance argument by containing, frequency, maxFrequency, IsFractionalCover, and IsOptFractional. Every sum or supremum over a whole type — ∑s∈S\sum_{s \in S}∑s∈S​ in fractionalCost, ∑e∈E\sum_{e \in E}∑e∈E​ in packingValue, the supremum over EEE in maxFrequency, the filter over SSS in containing — relies on the ambient finiteness instances.

Degenerate cases across the bundle. EEE empty: Coverable and IsCover hold for every family and every CCC; IsFractionalCover reduces to x≥0x \ge 0x≥0; packingValue and every sum over EEE is 000; maxFrequency is 000; IsDualPacking reduces to 0≤cs0 \le c_s0≤cs​ for all sss; IsPrimalDualCertificate forces cs=0c_s = 0cs​=0 for every s∈Cs \in Cs∈C; IsGreedyCertificate reduces to ∑s∈Ccs=0\sum_{s\in C} c_s = 0∑s∈C​cs​=0 together with 0≤ρ cs0 \le \rho\,c_s0≤ρcs​; IsOptIntegral becomes the minimum of ∑s∈Ccs\sum_{s\in C} c_s∑s∈C​cs​ over all subsets of SSS; IsOptFractional holds exactly at v=0v = 0v=0 when costs are nonnegative. SSS empty: containing\mathrm{containing}containing is empty, all frequencies and maxFrequency are 000, coverCost and fractionalCost are 000, Coverable, IsCover and IsFractionalCover are unsatisfiable unless EEE is empty, and both optimality predicates hold only at v=0v = 0v=0 with EEE empty. CCC empty: coverCost is 000; IsCover holds only if EEE is empty; the tightness clause of IsPrimalDualCertificate is vacuous; IsGreedyCertificate requires ∑e∈Eye=0\sum_{e \in E} y_e = 0∑e∈E​ye​=0. Cost identically zero: permitted by NonnegCost and by SetCoverInstance; makes every coverCost and fractionalCost zero; forces yyy to vanish on all covered elements in IsDualPacking, IsGreedyCertificate and IsPrimalDualCertificate; both optima equal 000 when feasible. Individual zero-cost indices: forced by IsDualPacking to have ye=0y_e = 0ye​=0 throughout AsA_sAs​; addable to or removable from CCC without changing coverCost; able to carry unbounded fractional weight at no cost in IsFractionalCover and IsOptFractional; automatically satisfying the tightness clause of IsPrimalDualCertificate once yyy vanishes on AsA_sAs​. ρ\rhoρ zero or negative: both permitted by IsGreedyCertificate, with the consequences above — ρ=0\rho = 0ρ=0 collapsing the certificate to a zero dual and a zero-total-cost cover, ρ<0\rho < 0ρ<0 requiring all costs nonpositive. Weights above 111 in a fractional cover: permitted without restriction, IsFractionalCover imposing only xs≥0x_s \ge 0xs​≥0 and a lower bound of 111 on each element's covering sum, with no upper bound on any xsx_sxs​, on any covering sum, or on ∑sxs\sum_s x_s∑s​xs​.

Human review
  • Endorsed by Shuze Chen · Sep 17, 2026

  • Endorsed by moutei · Sep 17, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me