Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The kkk swaps of §3.2 and their four properties

Proved
LocalSearchFL.KMedian.exists_swaps_four_properties

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

combinatoricsk-medianlocal-searchp2o-batch-p100ap2o-gran-per-chapterp2o-plan-paperp2o-v1

Let SSS and OOO be finite sets of facilities with ∣S∣=∣O∣|S| = |O|∣S∣=∣O∣, and let σS,σO:C→F\sigma_S, \sigma_O : C \to FσS​,σO​:C→F be assignments of the clients, with capture, good and bad facilities as in Definition 3.1. Then there is a choice, for every o∈Oo \in Oo∈O, of a facility η(o)∈S\eta(o) \in Sη(o)∈S — the swap ⟨η(o),o⟩\langle \eta(o), o\rangle⟨η(o),o⟩ — such that

  1. each o∈Oo \in Oo∈O is considered in exactly one swap;
  2. a facility s∈Ss \in Ss∈S which captures more than one facility in OOO is not considered in any swap;
  3. each good facility s∈Ss \in Ss∈S is considered in at most two swaps: ∣{o∈O:η(o)=s}∣≤2|\{o \in O : \eta(o) = s\}| \le 2∣{o∈O:η(o)=s}∣≤2;
  4. if the swap ⟨s,o⟩\langle s, o\rangle⟨s,o⟩ is considered, then sss captures no facility o′∈Oo' \in Oo′∈O with o′≠oo' \ne oo′=o.

These are the swaps whose inequalities (2) are added up in the proof of Theorem 3.2.

Formalization Note Property 1 is built into η\etaη being a function on OOO. The hypothesis ∣S∣=∣O∣|S| = |O|∣S∣=∣O∣ is the case the paper treats ("we now consider kkk swaps, one for each facility in OOO"). The assignments are arbitrary maps; the paper's are nearest-facility assignments.

Preamble
import Mathlib
import Definitions.Def_LocalSearchFL_KMedian_captures
Formal statement
namespace LocalSearchFL.KMedian

/-- The k swaps of §3.2 (pp. 549–550): when `|S| = |O|`, one can assign to each `o ∈ O` a
facility `η o ∈ S` (the swap `⟨η o, o⟩`) such that
(1) each `o ∈ O` is in exactly one swap (built into `η` being a function on `O`);
(2) a facility of `S` capturing more than one facility of `O` is in no swap;
(3) each good facility of `S` is in at most two swaps;
(4) if `⟨s, o⟩` is a swap, then `s` captures no facility `o' ∈ O` with `o' ≠ o`. -/
theorem exists_swaps_four_properties {Cl Fa : Type} [Fintype Cl] [DecidableEq Cl]
    [DecidableEq Fa]
    (σS σO : Cl → Fa) (S O : Finset Fa) (hcard : S.card = O.card) :
    ∃ η : Fa → Fa,
      (∀ o ∈ O, η o ∈ S) ∧
      (∀ s ∈ S, (∃ o₁ ∈ O, ∃ o₂ ∈ O, o₁ ≠ o₂ ∧ captures σS σO s o₁ ∧ captures σS σO s o₂) →
        ∀ o ∈ O, η o ≠ s) ∧
      (∀ s ∈ S, IsGood σS σO O s → (O.filter (fun o => η o = s)).card ≤ 2) ∧
      (∀ o ∈ O, ∀ o' ∈ O, o' ≠ o → ¬ captures σS σO (η o) o') := by sorry

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

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

Setting.

  • CCC is a finite type of clients with decidable equality.
  • FFF is a type of facilities with decidable equality.
  • σS,σO:C→F\sigma_S, \sigma_O : C \to FσS​,σO​:C→F are arbitrary maps.
  • S,O⊆FS, O \subseteq FS,O⊆F are finite sets with ∣S∣=∣O∣|S| = |O|∣S∣=∣O∣.

No relation is assumed between σS,σO\sigma_S, \sigma_OσS​,σO​ and S,OS, OS,O: the maps need not take values in SSS or OOO, and need not be nearest assignments. SSS and OOO may overlap.

Capture is defined from the maps alone, with NO(o)={j:σO(j)=o}N_O(o) = \{j : \sigma_O(j) = o\}NO​(o)={j:σO​(j)=o} and NS(s)={j:σS(j)=s}N_S(s) = \{j : \sigma_S(j) = s\}NS​(s)={j:σS​(j)=s}: "sss captures ooo" means ∣NO(o)∣<2 ∣NO(o)∩NS(s)∣|N_O(o)| < 2\,|N_O(o) \cap N_S(s)|∣NO​(o)∣<2∣NO​(o)∩NS​(s)∣. sss is good when it captures no element of OOO.

Claim. There exists a function η:F→F\eta : F \to Fη:F→F with all four of the following properties:

  1. η(o)∈S\eta(o) \in Sη(o)∈S for every o∈Oo \in Oo∈O.
  2. If s∈Ss \in Ss∈S captures two distinct elements o1≠o2o_1 \ne o_2o1​=o2​ of OOO, then η(o)≠s\eta(o) \ne sη(o)=s for every o∈Oo \in Oo∈O.
  3. If s∈Ss \in Ss∈S is good, then
∣{o∈O:η(o)=s}∣≤2.\big|\{ o \in O : \eta(o) = s\}\big| \le 2.​{o∈O:η(o)=s}​≤2.
  1. For every o∈Oo \in Oo∈O and every o′∈Oo' \in Oo′∈O with o′≠oo' \ne oo′=o, η(o)\eta(o)η(o) does not capture o′o'o′.

The values of η\etaη outside OOO are unconstrained. No further condition is placed on η\etaη: it need not be injective, and η(o)=o\eta(o) = oη(o)=o is not excluded.

Degenerate cases.

  • If S=O=∅S = O = \emptysetS=O=∅, every function η\etaη satisfies the claim.
  • If CCC is empty, no capture holds and every facility is good. Conditions 2 and 4 are then automatic, and the claim reduces to a map O→SO \to SO→S with each element of SSS hit at most twice.
Human review
  • Endorsed by Shuze Chen · Sep 27, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Sep 27, 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