Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 4.3 — the first-in, first-out algorithm makes at most 4n24n^24n2 passes over the queue

Proved
GoldbergTarjan.FIFO.pass_count_le

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

fifonetwork-flowsp2o-batch-p100bp2o-gran-per-chapterp2o-plan-paperp2o-v1push-relabel

Let n=∣V∣n = |V|n=∣V∣. Pass one over the queue consists of the discharges of the vertices added to the queue during the initialization. Pass i+1i+1i+1 consists of the discharges of the vertices added to the queue during pass iii. In every run of the first-in, first-out algorithm,

#{passes over the queue}≤4n2.\#\{\text{passes over the queue}\} \le 4n^2.#{passes over the queue}≤4n2.

Within a pass each vertex is discharged at most once, so this bound turns into a bound on the number of discharges and, with Corollary 4.4, on the number of nonsaturating pushes.

Formalization Note The passes made by a run of KKK discharges are counted as the largest pass number of a discharged queue entry. The pass number of an entry is propagated as in the definition: 111 at initialization, and i+1i+1i+1 for every vertex added during a discharge of pass iii.

Preamble
import Mathlib
import Definitions.Def_GoldbergTarjan_FIFO_Network
import Definitions.Def_GoldbergTarjan_FIFO_PushRelabel
import Definitions.Def_GoldbergTarjan_FIFO_Algorithm
import Definitions.Def_GoldbergTarjan_FIFO_Counts
Formal statement
namespace GoldbergTarjan.FIFO

/-- Lemma 4.3 (Goldberg–Tarjan 1988, p. 930): the number of passes over the queue made by the
first-in, first-out algorithm is at most `4n²`, where `n = |V|`. Pass one consists of the
discharges of the vertices added to the queue during the initialization, and pass `i + 1` of the
discharges of the vertices added during pass `i`; the passes made by the first `K` discharges
number the largest pass tag of a discharged entry. -/
theorem pass_count_le {V : Type} [Fintype V] [DecidableEq V]
    (N : Network V) (L : V → List V) (K : ℕ) (S : ℕ → State V) (J : ℕ → ℕ)
    (hrun : IsFIFORun N L K S J) :
    passCount K S ≤ 4 * Fintype.card V ^ 2 := by sorry

end GoldbergTarjan.FIFO
Source
Goldberg, Tarjan, A New Approach to the Maximum-Flow Problem, J. ACM 35(4), 1988, p. 930, Lemma 4.3
Read-back

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

Setting. The theorem fixes:

  • a finite type VVV with n=∣V∣n = |V|n=∣V∣ and decidable equality;
  • a network NNN with nonnegative real capacities ccc (with c(v,v)=0c(v,v) = 0c(v,v)=0), source sss and sink t≠st \ne st=s;
  • a list assignment LLL, a natural number KKK, and sequences S0,S1,…S_0, S_1, \dotsS0​,S1​,… of states and J0,J1,…J_0, J_1, \dotsJ0​,J1​,… of natural numbers.

Hypothesis. (S,J)(S, J)(S,J) is a first-in, first-out run of KKK discharges. That is:

  • LLL is an edge list: LvL_vLv​ lists without repetition exactly the www with c(v,w)>0c(v,w) > 0c(v,w)>0 or c(w,v)>0c(w,v) > 0c(w,v)>0;
  • S0S_0S0​ has the initial flow, the labels d(s)=nd(s) = nd(s)=n and 000 elsewhere, and current positions 000;
  • the queue of S0S_0S0​ contains each x≠s,tx \ne s, tx=s,t with c(s,x)>0c(s,x) > 0c(s,x)>0 once, each tagged with pass number 111;
  • for each k<Kk < Kk<K, Sk+1S_{k+1}Sk+1​ results from one discharge of the front entry (v,i)(v, i)(v,i) of SkS_kSk​'s queue using JkJ_kJk​ push/relabel operations. Every vertex appended to the queue during that discharge is tagged i+1i + 1i+1.

Claim.

max⁡k<KfrontPass(Sk)≤4n2,\max_{k < K} \mathrm{frontPass}(S_k) \le 4n^2,k<Kmax​frontPass(Sk​)≤4n2,

where frontPass(Sk)\mathrm{frontPass}(S_k)frontPass(Sk​) is the pass tag of the first entry of SkS_kSk​'s queue, or 000 if that queue is empty. The maximum is taken to be 000 when K=0K = 0K=0.

Degenerate cases.

  • For K=0K = 0K=0 the claim is 0≤4n20 \le 4n^20≤4n2, which is trivial.
  • The theorem bounds only the largest tag of the entries discharged in the first KKK steps. It says nothing about KKK itself or about whether the run terminates.
  • n≥2n \ge 2n≥2 always holds.
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