Finite greedy allocation with uniform independent choices
DefinitionABKUFinite_ModelTrace. For natural numbers , a trace is an ordered array with rows and entries per row, each entry belonging to . Repeated entries within and between rows are permitted.
step. Given natural numbers , a load function from to the natural numbers, and an ordered list of choices in , select a choice having the smallest current load, breaking ties by the earliest occurrence in the list. Increase that selected bin’s load by one and leave all other loads unchanged.
finalLoads. For natural numbers and a trace with rows of bin choices each, start all bin loads at zero and process the rows in order. At each row, increase by one the load of the earliest minimum-load choice in that row. The result is the load function after exactly increments.
maxLoad. For natural numbers and a trace, take the largest of the bin loads obtained by starting all loads at zero and applying the preceding selection-and-increment procedure to its rows.
probability. For natural numbers and any predicate on the finite set of arrays of rows and entries per row, with each entry in , the probability of is the number of arrays satisfying , divided in the real numbers by the total number of such arrays. This is uniform probability on all arrays; equivalently, every individual choice is independent and uniform, with replacement.
center. For natural numbers , the center is the real number , where is the natural logarithm as defined by Lean’s total real logarithm. In particular, at , its value is zero because Lean defines .
Upper. For a natural number , this property means that there exists a nonnegative real constant such that for every positive real , there exists a natural number such that every natural number satisfies
Here is the maximum load after allocating balls sequentially to initially empty bins, each ball taking independent uniform choices with replacement and entering the earliest chosen bin of minimum current load. Probability is uniform counting over all complete choice arrays.
Lower. For a natural number , this property means that there exists a nonnegative real constant such that for every positive real , there exists a natural number such that every natural number satisfies
Here is the maximum load after allocating balls sequentially to initially empty bins, using independent uniform choices with replacement for each ball and selecting the earliest choice of minimum current load; probability is uniform counting over the complete arrays.
TwoSided. For a natural number , this property means that there exists a nonnegative real constant such that for every positive real , there exists a natural number such that every natural number satisfies
Here is the maximum load after allocating balls sequentially to initially empty bins, each ball making independent uniform choices with replacement and entering the earliest minimum-load choice; probability is uniform counting over all complete choice arrays.
import Mathlib
noncomputable section
namespace ABKUFinite
abbrev Trace (n d : ℕ) := Fin (n + 1) → Fin (d + 2) → Fin (n + 1)
def step {n d : ℕ} (loads : Fin (n + 1) → ℕ)
(choices : Fin (d + 2) → Fin (n + 1)) : Fin (n + 1) → ℕ :=
let selected := (List.ofFn choices).foldl
(fun best candidate => if loads candidate < loads best then candidate else best)
(choices 0)
Function.update loads selected (loads selected + 1)
def finalLoads (n d : ℕ) (w : Trace n d) : Fin (n + 1) → ℕ :=
(List.ofFn w).foldl step (fun _ => 0)
def maxLoad (n d : ℕ) (w : Trace n d) : ℕ :=
Finset.univ.sup (finalLoads n d w)
def probability (n d : ℕ) (event : Trace n d → Prop) : ℝ := by
classical
exact (Fintype.card {w : Trace n d // event w} : ℝ) / Fintype.card (Trace n d)
def center (n d : ℕ) : ℝ :=
Real.log (Real.log (n + 1 : ℝ)) / Real.log (d + 2 : ℝ)
def Upper (d : ℕ) : Prop :=
∃ C : ℝ, 0 ≤ C ∧ ∀ ε : ℝ, 0 < ε → ∃ N : ℕ, ∀ n ≥ N,
1 - ε ≤ probability n d (fun w => (maxLoad n d w : ℝ) ≤ center n d + C)
def Lower (d : ℕ) : Prop :=
∃ C : ℝ, 0 ≤ C ∧ ∀ ε : ℝ, 0 < ε → ∃ N : ℕ, ∀ n ≥ N,
1 - ε ≤ probability n d (fun w => center n d - C ≤ (maxLoad n d w : ℝ))
def TwoSided (d : ℕ) : Prop :=
∃ C : ℝ, 0 ≤ C ∧ ∀ ε : ℝ, 0 < ε → ∃ N : ℕ, ∀ n ≥ N,
1 - ε ≤ probability n d (fun w => |(maxLoad n d w : ℝ) - center n d| ≤ C)
end ABKUFinite
Read-back
What the Lean code literally says, in plain math · gpt-6.1-sol
Trace. For natural numbers , a trace is an ordered array with rows and entries per row, each entry belonging to . Repeated entries within and between rows are permitted.
step. Given natural numbers , a load function from to the natural numbers, and an ordered list of choices in , select a choice having the smallest current load, breaking ties by the earliest occurrence in the list. Increase that selected bin’s load by one and leave all other loads unchanged.
finalLoads. For natural numbers and a trace with rows of bin choices each, start all bin loads at zero and process the rows in order. At each row, increase by one the load of the earliest minimum-load choice in that row. The result is the load function after exactly increments.
maxLoad. For natural numbers and a trace, take the largest of the bin loads obtained by starting all loads at zero and applying the preceding selection-and-increment procedure to its rows.
probability. For natural numbers and any predicate on the finite set of arrays of rows and entries per row, with each entry in , the probability of is the number of arrays satisfying , divided in the real numbers by the total number of such arrays. This is uniform probability on all arrays; equivalently, every individual choice is independent and uniform, with replacement.
center. For natural numbers , the center is the real number , where is the natural logarithm as defined by Lean’s total real logarithm. In particular, at , its value is zero because Lean defines .
Upper. For a natural number , this property means that there exists a nonnegative real constant such that for every positive real , there exists a natural number such that every natural number satisfies
Here is the maximum load after allocating balls sequentially to initially empty bins, each ball taking independent uniform choices with replacement and entering the earliest chosen bin of minimum current load. Probability is uniform counting over all complete choice arrays.
Lower. For a natural number , this property means that there exists a nonnegative real constant such that for every positive real , there exists a natural number such that every natural number satisfies
Here is the maximum load after allocating balls sequentially to initially empty bins, using independent uniform choices with replacement for each ball and selecting the earliest choice of minimum current load; probability is uniform counting over the complete arrays.
TwoSided. For a natural number , this property means that there exists a nonnegative real constant such that for every positive real , there exists a natural number such that every natural number satisfies
Here is the maximum load after allocating balls sequentially to initially empty bins, each ball making independent uniform choices with replacement and entering the earliest minimum-load choice; probability is uniform counting over all complete choice arrays.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.