Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

§3.4 — weighted swaps with total weight one per o ∈ O and at most (p+1)/p per s ∈ S

Proved
LocalSearchFL.MultiSwap.exists_weighted_swaps

by mikedeng1 · Sep 27, 2026 · Mathlib 0df444a (Lean v4.33.1)

combinatoricsfacility-locationk-medianlocal-searchp2o-batch-p100ap2o-gran-per-chapterp2o-plan-paperp2o-v1

Let SSS and OOO be two sets of facilities with ∣S∣=∣O∣|S| = |O|∣S∣=∣O∣, let σS,σO\sigma_S, \sigma_OσS​,σO​ be client assignments, and let p≥1p \ge 1p≥1 be an integer. Then there is a finite collection WWW of swaps ⟨A,B⟩\langle A, B\rangle⟨A,B⟩, with A⊆SA \subseteq SA⊆S, B⊆OB \subseteq OB⊆O and ∣A∣=∣B∣≤p|A| = |B| \le p∣A∣=∣B∣≤p, and a positive real weight w(A,B)w(A,B)w(A,B) on each, such that

  1. for every facility o∈Oo \in Oo∈O,
∑⟨A,B⟩∈W, o∈Bw(A,B)=1;\sum_{\langle A,B\rangle \in W,\ o \in B} w(A,B) = 1;⟨A,B⟩∈W, o∈B∑​w(A,B)=1;
  1. for every facility s∈Ss \in Ss∈S,
∑⟨A,B⟩∈W, s∈Aw(A,B)≤p+1p;\sum_{\langle A,B\rangle \in W,\ s \in A} w(A,B) \le \frac{p+1}{p};⟨A,B⟩∈W, s∈A∑​w(A,B)≤pp+1​;
  1. if ⟨A,B⟩∈W\langle A, B\rangle \in W⟨A,B⟩∈W, then capture(A)⊆B\mathrm{capture}(A) \subseteq Bcapture(A)⊆B;
  2. the deleted sets AAA of any two swaps of WWW are equal or disjoint.

Each swap in WWW lies in the ppp-swap neighbourhood, so local optimality gives cost((S∖A)∪B)−cost(S)≥0\mathrm{cost}((S \setminus A) \cup B) - \mathrm{cost}(S) \ge 0cost((S∖A)∪B)−cost(S)≥0 for each; the weights are what the analysis uses to add these inequalities up.

Formalization Note The swaps are built in the paper from the partition of Claim 3.1: a block with ∣Ai∣=∣Bi∣≤p|A_i| = |B_i| \le p∣Ai​∣=∣Bi​∣≤p gives the swap ⟨Ai,Bi⟩\langle A_i, B_i\rangle⟨Ai​,Bi​⟩ with weight 111, and a block with ∣Ai∣=∣Bi∣=q>p|A_i| = |B_i| = q > p∣Ai​∣=∣Bi​∣=q>p gives the q(q−1)q(q-1)q(q−1) swaps ⟨s,o⟩\langle s, o\rangle⟨s,o⟩ (sss one of q−1q-1q−1 good facilities of AiA_iAi​, o∈Bio \in B_io∈Bi​) with weight 1/(q−1)1/(q-1)1/(q−1). Property 4 is not printed as a property but is immediate from that construction (each deleted set is a block AiA_iAi​ or a single facility of a block); it records the structure that the partition of NO(o)N_O(o)NO​(o) in Property 3.2 relies on. The inequalities from local optimality are not restated here; they follow from the definition of local optimality.

Preamble
import Mathlib
import Definitions.Def_LocalSearchFL_MultiSwap_capture
Formal statement
namespace LocalSearchFL.MultiSwap

/-- The weighted swaps of §3.4 (pp. 552–553). If `|S| = |O|` and `p ≥ 1`, there is a finite set
`W` of swaps `⟨A, B⟩` with `A ⊆ S`, `B ⊆ O`, `|A| = |B| ≤ p`, and positive real weights `w`, such
that
1. for every `o ∈ O`, the weights of the swaps `⟨A, B⟩` with `o ∈ B` sum to exactly one;
2. for every `s ∈ S`, the weights of the swaps `⟨A, B⟩` with `s ∈ A` sum to at most `(p + 1)/p`;
3. if `⟨A, B⟩ ∈ W`, then `capture(A) ⊆ B`.
Moreover (from the construction: the sets `A` are blocks `A_i` of the partition of Claim 3.1 or
single facilities of a block) the deleted sets of any two swaps are equal or disjoint. -/
theorem exists_weighted_swaps {Cl Fa : Type} [Fintype Cl] [DecidableEq Cl] [DecidableEq Fa]
    (σS σO : Cl → Fa) (S O : Finset Fa) (hcard : S.card = O.card) (p : ℕ) (hp : 1 ≤ p) :
    ∃ (W : Finset (Finset Fa × Finset Fa)) (w : Finset Fa × Finset Fa → ℝ),
      (∀ AB ∈ W, AB.1 ⊆ S ∧ AB.2 ⊆ O ∧ AB.1.card = AB.2.card ∧ AB.1.card ≤ p ∧ 0 < w AB) ∧
      (∀ o ∈ O, ∑ AB ∈ W.filter (fun AB => o ∈ AB.2), w AB = 1) ∧
      (∀ s ∈ S, ∑ AB ∈ W.filter (fun AB => s ∈ AB.1), w AB ≤ ((p : ℝ) + 1) / p) ∧
      (∀ AB ∈ W, capture σS σO O AB.1 ⊆ AB.2) ∧
      (∀ AB ∈ W, ∀ AB' ∈ W, AB.1 = AB'.1 ∨ Disjoint AB.1 AB'.1) := by sorry

end LocalSearchFL.MultiSwap
Source
Arya, Garg, Khandekar, Meyerson, Munagala, Pandit, Local Search Heuristics for k-Median and Facility Location Problems, SIAM J. Comput. 33(3), 2004, pp. 552–553, §3.4, the weighted swaps and their properties 1–3
Read-back

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

Data.

  • CCC is a finite type of clients and FFF is a type of facilities, both with decidable equality.
  • σS,σO:C→F\sigma_S, \sigma_O : C \to FσS​,σO​:C→F are arbitrary functions.
  • SSS and OOO are finite subsets of FFF.
  • ppp is a natural number.

Hypotheses. ∣S∣=∣O∣|S| = |O|∣S∣=∣O∣ and p≥1p \ge 1p≥1.

Definition used. capture⁡(A)={ o∈O:∣NO(o)∣<2 ∣NS(A)∩NO(o)∣ }\operatorname{capture}(A) = \{\, o \in O : |N_O(o)| < 2\,|N_S(A) \cap N_O(o)| \,\}capture(A)={o∈O:∣NO​(o)∣<2∣NS​(A)∩NO​(o)∣}, where NS(A)={j:σS(j)∈A}N_S(A) = \{j : \sigma_S(j) \in A\}NS​(A)={j:σS​(j)∈A} and NO(o)={j:σO(j)=o}N_O(o) = \{j : \sigma_O(j) = o\}NO​(o)={j:σO​(j)=o}.

Claim. There exist a finite set WWW of pairs (A,B)(A, B)(A,B) of finite subsets of FFF, and a function www assigning a real number to each such pair, such that the following hold.

  1. Shape and positivity. For every (A,B)∈W(A, B) \in W(A,B)∈W:
    • A⊆SA \subseteq SA⊆S and B⊆OB \subseteq OB⊆O;
    • ∣A∣=∣B∣≤p|A| = |B| \le p∣A∣=∣B∣≤p;
    • w(A,B)>0w(A, B) > 0w(A,B)>0.
  2. Coverage of OOO. For every o∈Oo \in Oo∈O:
∑(A,B)∈W, o∈Bw(A,B)=1.\sum_{(A,B) \in W,\ o \in B} w(A,B) = 1.(A,B)∈W, o∈B∑​w(A,B)=1.

In particular, every o∈Oo \in Oo∈O lies in the second component of some pair. 3. Load on SSS. For every s∈Ss \in Ss∈S:

∑(A,B)∈W, s∈Aw(A,B)≤p+1p,\sum_{(A,B) \in W,\ s \in A} w(A,B) \le \frac{p+1}{p},(A,B)∈W, s∈A∑​w(A,B)≤pp+1​,

computed as real numbers. 4. Capture. For every (A,B)∈W(A, B) \in W(A,B)∈W: capture⁡(A)⊆B\operatorname{capture}(A) \subseteq Bcapture(A)⊆B. 5. Equal or disjoint. For any two pairs (A,B)(A, B)(A,B) and (A′,B′)(A', B')(A′,B′) in WWW, either A=A′A = A'A=A′ or A∩A′=∅A \cap A' = \varnothingA∩A′=∅.

Only the values of www on WWW matter. WWW is a set, so it contains no pair twice. The pair (∅,∅)(\varnothing, \varnothing)(∅,∅) is not excluded.

Degenerate cases.

  • If S=O=∅S = O = \varnothingS=O=∅, then W=∅W = \varnothingW=∅ satisfies everything vacuously.
  • Because p≥1p \ge 1p≥1, the bound p+1p\frac{p+1}{p}pp+1​ never involves division by zero. For p=1p = 1p=1 it equals 222.
  • If CCC is empty or no ooo is captured, condition 4 is vacuous.
  • There is no ℕ-subtraction in the statement.
Human review
  • Endorsed by Shuze Chen · Sep 28, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Sep 28, 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 paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me