Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Inequality (6) — swapping a bad facility with its nearest captured facility

Proved
LocalSearchFL.UFL.swap_bad_inequality_6

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

facility-locationlocal-searchp2o-batch-p100ap2o-gran-per-chapterp2o-plan-paperp2o-v1

Let fi≥0f_i \ge 0fi​≥0 be facility opening costs on a metric instance, let SSS be a nonempty set of facilities that is locally optimum for the add/drop/swap neighbourhood (4), and let OOO be any solution. Let σS\sigma_SσS​, σO\sigma_OσO​ be nearest-facility assignments for SSS and OOO, write Sj=cjσS(j)S_j = c_{j\sigma_S(j)}Sj​=cjσS​(j)​ and Oj=cjσO(j)O_j = c_{j\sigma_O(j)}Oj​=cjσO​(j)​, and let π\piπ be a permutation of the clients satisfying the three conditions of the mapping of the proof of Lemma 4.2.

Let s∈Ss \in Ss∈S capture o∈Oo \in Oo∈O, where ooo is nearest to sss among the facilities of OOO captured by sss: cso≤cso′c_{so} \le c_{so'}cso​≤cso′​ for every o′∈Oo' \in Oo′∈O captured by sss. Then

fo−fs+∑j∈NS(s)π(j)≠j(Oj+Oπ(j)+Sπ(j)−Sj)+∑j∈NO(o),π(j)=j∈NS(s)(Oj−Sj)+∑j∉NO(o),π(j)=j∈NS(s)(Sj+Sj+Oj−Sj) ≥ 0.\begin{aligned} f_o - f_s &+ \sum_{\substack{j \in N_S(s)\\ \pi(j) \neq j}} \bigl(O_j + O_{\pi(j)} + S_{\pi(j)} - S_j\bigr) \\ &+ \sum_{\substack{j \in N_O(o),\\ \pi(j) = j \in N_S(s)}} (O_j - S_j) + \sum_{\substack{j \notin N_O(o),\\ \pi(j) = j \in N_S(s)}} (S_j + S_j + O_j - S_j) \ \ge\ 0. \end{aligned}fo​−fs​​+j∈NS​(s)π(j)=j​∑​(Oj​+Oπ(j)​+Sπ(j)​−Sj​)+j∈NO​(o),π(j)=j∈NS​(s)​∑​(Oj​−Sj​)+j∈/NO​(o),π(j)=j∈NS​(s)​∑​(Sj​+Sj​+Oj​−Sj​) ≥ 0.​

This is the information extracted from the swap ⟨s,o⟩\langle s, o\rangle⟨s,o⟩ that closes a bad facility sss and opens ooo; it is the main ingredient of inequality (8).

Formalization Note The distance csoc_{so}cso​ between two facilities is I.cf s o. The summand Sj+Sj+Oj−SjS_j + S_j + O_j - S_jSj​+Sj​+Oj​−Sj​ is kept in the paper's unsimplified form.

Preamble
import Mathlib
import Definitions.Def_LocalSearchFL_UFL_captures
Formal statement
namespace LocalSearchFL.UFL

/-- Inequality (6), pp. 555–556: the swap `⟨s, o⟩` for a bad facility. Let `S` be a locally
optimum solution for the neighbourhood (4), `O` any solution, `σS`, `σO` nearest-facility
assignments, `π` the mapping of the proof of Lemma 4.2. Let `s ∈ S` capture `o ∈ O`, where `o`
is a facility nearest to `s` among the facilities of `O` captured by `s`
(`c_{so} ≤ c_{so'}` for every `o' ∈ O` captured by `s`). Then
`f_o − f_s + ∑_{j ∈ N_S(s), π(j) ≠ j} (O_j + O_{π(j)} + S_{π(j)} − S_j)
  + ∑_{j ∈ N_O(o), π(j) = j ∈ N_S(s)} (O_j − S_j)
  + ∑_{j ∉ N_O(o), π(j) = j ∈ N_S(s)} (S_j + S_j + O_j − S_j) ≥ 0`. -/
theorem swap_bad_inequality_6 {Cl Fa : Type} [Fintype Cl] [DecidableEq Cl]
    [Fintype Fa] [DecidableEq Fa]
    (I : MetricInstance Cl Fa) (f : Fa → ℝ) (hf : ∀ i, 0 ≤ f i)
    (S O : Finset Fa) (hS : S.Nonempty) (hloc : IsUFLLocalOpt I f S hS)
    (σS σO : Cl → Fa) (hσS : IsNearestAssignment I S σS) (hσO : IsNearestAssignment I O σO)
    (π : Equiv.Perm Cl) (hπ : IsRefinedPi σS σO π)
    (s o : Fa) (hs : s ∈ S) (ho : o ∈ O) (hcap : captures σS σO s o)
    (hnearest : ∀ o' ∈ O, captures σS σO s o' → I.cf s o ≤ I.cf s o') :
    0 ≤ f o - f s +
      ∑ j ∈ (nbhd σS s).filter (fun j => π j ≠ j),
        (I.c j (σO j) + I.c (π j) (σO (π j)) + I.c (π j) (σS (π j)) - I.c j (σS j)) +
      ∑ j ∈ (nbhd σS s).filter (fun j => π j = j ∧ σO j = o),
        (I.c j (σO j) - I.c j (σS j)) +
      ∑ j ∈ (nbhd σS s).filter (fun j => π j = j ∧ σO j ≠ o),
        (I.c j (σS j) + I.c j (σS j) + I.c j (σO j) - I.c j (σS j)) := by sorry

end LocalSearchFL.UFL
Source
Arya, Garg, Khandekar, Meyerson, Munagala, Pandit, Local Search Heuristics for k-Median and Facility Location Problems, SIAM J. Comput. 33(3), 2004, pp. 555–556, eq. (6)
Read-back

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

Setting. Let C\mathcal CC (clients) and F\mathcal FF (facilities) be finite types with decidable equality. Let III be a metric instance: ddd on pairs of points of C⊔F\mathcal C\sqcup\mathcal FC⊔F, nonnegative, symmetric, triangle inequality, self-distance not assumed zero. Write cji=d(j,i)c_{ji}=d(j,i)cji​=d(j,i) for a client and a facility, and cii′=d(i,i′)c_{ii'}=d(i,i')cii′​=d(i,i′) for two facilities. Let f:F→Rf:\mathcal F\to\mathbb Rf:F→R satisfy fi≥0f_i\ge0fi​≥0 for all iii. For nonempty A⊆FA\subseteq\mathcal FA⊆F, write cost(A)=∑i∈Afi+∑j∈Cmin⁡i∈Acji\mathrm{cost}(A)=\sum_{i\in A}f_i+\sum_{j\in\mathcal C}\min_{i\in A}c_{ji}cost(A)=∑i∈A​fi​+∑j∈C​mini∈A​cji​.

Hypotheses.

  • S,OS,OS,O are finite sets of facilities, and SSS is nonempty.

  • SSS is locally optimal:

    • cost(S)≤cost(S∪{s′})\mathrm{cost}(S)\le\mathrm{cost}(S\cup\{s'\})cost(S)≤cost(S∪{s′}) for every facility s′s's′;
    • cost(S)≤cost(S∖{s})\mathrm{cost}(S)\le\mathrm{cost}(S\setminus\{s\})cost(S)≤cost(S∖{s}) for every s∈Ss\in Ss∈S with S∖{s}≠∅S\setminus\{s\}\ne\emptysetS∖{s}=∅;
    • cost(S)≤cost((S∖{s})∪{s′})\mathrm{cost}(S)\le\mathrm{cost}((S\setminus\{s\})\cup\{s'\})cost(S)≤cost((S∖{s})∪{s′}) for all s∈Ss\in Ss∈S and all facilities s′s's′.
  • σS,σO:C→F\sigma_S,\sigma_O:\mathcal C\to\mathcal FσS​,σO​:C→F are nearest-facility assignments:

    • for every jjj: σS(j)∈S\sigma_S(j)\in SσS​(j)∈S and cjσS(j)=min⁡i∈Scjic_{j\sigma_S(j)}=\min_{i\in S}c_{ji}cjσS​(j)​=mini∈S​cji​;
    • for every jjj: σO(j)∈O\sigma_O(j)\in OσO​(j)∈O and cjσO(j)=min⁡i∈Ocjic_{j\sigma_O(j)}=\min_{i\in O}c_{ji}cjσO​(j)​=mini∈O​cji​.

    Write Sj=cjσS(j)S_j=c_{j\sigma_S(j)}Sj​=cjσS​(j)​ and Oj=cjσO(j)O_j=c_{j\sigma_O(j)}Oj​=cjσO​(j)​.

  • Write NS(s)={j:σS(j)=s}N_S(s)=\{j:\sigma_S(j)=s\}NS​(s)={j:σS​(j)=s}, NO(o)={j:σO(j)=o}N_O(o)=\{j:\sigma_O(j)=o\}NO​(o)={j:σO​(j)=o} and Nso=NO(o)∩NS(s)N^o_s=N_O(o)\cap N_S(s)Nso​=NO​(o)∩NS​(s). Say that sss captures ooo when ∣NO(o)∣<2∣Nso∣|N_O(o)|<2|N^o_s|∣NO​(o)∣<2∣Nso​∣.

  • π\piπ is a permutation of C\mathcal CC satisfying all three of:

    • (i) σO(π(j))=σO(j)\sigma_O(\pi(j))=\sigma_O(j)σO​(π(j))=σO​(j) for all jjj;
    • (ii) for all facilities s,os,os,o with sss not capturing ooo: j∈Nso⇒π(j)∉Nsoj\in N^o_s\Rightarrow\pi(j)\notin N^o_sj∈Nso​⇒π(j)∈/Nso​;
    • (iii) for all facilities s,os,os,o with sss capturing ooo: j,π(j)∈Nso⇒π(j)=jj,\pi(j)\in N^o_s\Rightarrow\pi(j)=jj,π(j)∈Nso​⇒π(j)=j.
  • s∈Ss\in Ss∈S and o∈Oo\in Oo∈O, and sss captures ooo.

  • For every o′∈Oo'\in Oo′∈O that sss captures: cso≤cso′c_{so}\le c_{so'}cso​≤cso′​.

Conclusion.

0≤fo−fs+∑j∈NS(s)π(j)≠j(Oj+Oπ(j)+Sπ(j)−Sj)+∑j∈NS(s), π(j)=jσO(j)=o(Oj−Sj)+∑j∈NS(s), π(j)=jσO(j)≠o(Sj+Sj+Oj−Sj),0\le f_o-f_s+\sum_{\substack{j\in N_S(s)\\ \pi(j)\ne j}}\big(O_j+O_{\pi(j)}+S_{\pi(j)}-S_j\big)+\sum_{\substack{j\in N_S(s),\ \pi(j)=j\\ \sigma_O(j)=o}}\big(O_j-S_j\big)+\sum_{\substack{j\in N_S(s),\ \pi(j)=j\\ \sigma_O(j)\ne o}}\big(S_j+S_j+O_j-S_j\big),0≤fo​−fs​+j∈NS​(s)π(j)=j​∑​(Oj​+Oπ(j)​+Sπ(j)​−Sj​)+j∈NS​(s), π(j)=jσO​(j)=o​∑​(Oj​−Sj​)+j∈NS​(s), π(j)=jσO​(j)=o​∑​(Sj​+Sj​+Oj​−Sj​),

where Oπ(j)=cπ(j)σO(π(j))O_{\pi(j)}=c_{\pi(j)\sigma_O(\pi(j))}Oπ(j)​=cπ(j)σO​(π(j))​ and Sπ(j)=cπ(j)σS(π(j))S_{\pi(j)}=c_{\pi(j)\sigma_S(\pi(j))}Sπ(j)​=cπ(j)σS​(π(j))​. The summand of the last sum is algebraically Sj+OjS_j+O_jSj​+Oj​.

Degenerate cases.

  • Capture forces ∣Nso∣≥1|N^o_s|\ge1∣Nso​∣≥1. So C\mathcal CC is nonempty, and sss serves at least one client assigned to ooo.
  • If sss captures only ooo within OOO, the nearest-captured condition holds trivially.
  • If o∈So\in So∈S as well, the facility cost fof_ofo​ still appears in the conclusion.
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 paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me