Mathlib.Probability.Birthday
Draw labels independently and uniformly from an alphabet of size m, where the number of draws is Binomial(T, η).
Basic 6 core · 0 supporting This module defines the collision probability for independent uniform labels, its binomial average, and the mean and pair scales used by the limit theorem.
Binomially averaged birthday collisions
This module defines the collision probability for independent uniform labels, its binomial average, and the mean and pair scales used by the limit theorem. The falling factorial is zero when the number of draws exceeds the alphabet.
For an alphabet size and draw count, the no-repeat kernel is given by the falling factorial divided by the number of all label sequences.
Definition (Lean source)
For an alphabet size and draw count, the repeat kernel is given by the complement of the no-repeat kernel.
Definition (Lean source)
For a trial count, success probability, and count function, the binomial average is given by weighting each possible success count by its binomial probability.
Definition (Lean source)
For a trial count, alphabet size, and success probability, the averaged repeat probability is the binomial average of the finite uniform birthday collision kernel.
Definition (Lean source)
The mean number of successes in T trials with success probability η is the product T·η.
Definition (Lean source)
For a trial count and success probability, the expected number of unordered pairs is given by the binomial pair count times the squared success probability.
Definition (Lean source)
Rounding 3 core · 3 supporting Ceiling and floor choices with a positive minimum allow an arbitrary diverging real scale to be instantiated as positive alphabet sizes. ★ positiveCeil_mul_div_tendsto
Positive integer rounding of real scales
Ceiling and floor choices with a positive minimum allow an arbitrary diverging real scale to be instantiated as positive alphabet sizes.
For a real scale, the positive ceiling is given by the larger of one and its natural-number ceiling.
For a real scale, the positive floor is given by the larger of one and its natural-number floor.
Definition (Lean source)
For a diverging positive scale and positive multiplier, the positive ceiling divided by the original scale converges to the multiplier.
Formal statement
Proof (Lean source)
3 supporting declarations (lemmas, instances)
-
positiveCeil_postheorem — For every real scale, its positive ceiling is positive.Proof (Lean source)
-
positiveFloor_postheorem — For every real scale, its positive floor is positive.Proof (Lean source)
-
positiveFloor_mul_div_tendstotheorem — For a diverging positive scale and positive multiplier, the positive floor divided by the original scale converges to the multiplier.hypothesesconclusionProof (Lean source)
theorem positiveFloor_mul_div_tendsto (a : ℕ → ℝ) {c : ℝ} (ha : Tendsto a atTop atTop) (hc : 0 < c) : Tendsto (fun j => (positiveFloor (c * a j) : ℝ) / a j) atTop (nhds c) := by have hlarge : ∀ᶠ j in atTop, (1 : ℝ) ≤ c * a j := (ha.const_mul_atTop hc).eventually_ge_atTop 1 apply (tendsto_nat_floor_mul_div_atTop hc.le).comp ha |>.congr' filter_upwards [hlarge] with j hj simp [positiveFloor, (Nat.one_le_floor_iff _).mpr hj]
ThresholdFinite 2 core · 2 supporting The averaged collision probability eventually falls below every positive tolerance as the alphabet grows. ★ repeat_le_iff_mStar_le
The least positive birthday threshold at finite parameters
The averaged collision probability eventually falls below every positive tolerance as the alphabet grows. This gives a least positive threshold and its monotone characterization.
For a trial count, success probability, and collision tolerance, the least positive threshold is given by the infimum of positive alphabet sizes whose averaged repeat probability is at most the tolerance; it is zero by convention when no positive alphabet size meets the tolerance.
Definition (Lean source)
For a valid success probability, positive tolerance, and positive alphabet, the averaged repeat probability is at most the tolerance exactly when the alphabet size is at least the least threshold.
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
threshold_set_nonemptytheorem — For a valid success probability and positive tolerance, some positive alphabet size has averaged repeat probability at most the tolerance.hypothesesProof (Lean source)
theorem threshold_set_nonempty (T : ℕ) (eta delta : ℝ) (heta : eta ∈ Icc (0 : ℝ) 1) (hdelta : 0 < delta) : ∃ m : ℕ, 0 < m ∧ birthdayRepeat T m eta ≤ delta := by -- Use `repeat_le_pairScale_div`; choose a natural m larger than A/delta. obtain ⟨n, hn⟩ := exists_nat_gt (pairScale T eta / delta) refine ⟨n + 1, Nat.succ_pos n, ?_⟩ have hA : pairScale T eta < (n : ℝ) * delta := (div_lt_iff₀ hdelta).mp hn have hpos : (0 : ℝ) < (n + 1 : ℕ) := by exact_mod_cast Nat.succ_pos n have hdiv : pairScale T eta / (↑(n + 1) : ℝ) ≤ delta := by apply (div_le_iff₀ hpos).mpr push_cast nlinarith exact (repeat_le_pairScale_div T (n + 1) eta (Nat.succ_pos n) heta).trans hdiv -
mStar_postheorem — For a valid success probability and positive tolerance, the least threshold is positive.hypothesesconclusion0 < mStar T eta deltaProof (Lean source)
theorem mStar_pos (T : ℕ) (eta delta : ℝ) (heta : eta ∈ Icc (0 : ℝ) 1) (hdelta : 0 < delta) : 0 < mStar T eta delta := by -- Apply `Nat.sInf_mem` to `threshold_set_nonempty`. obtain ⟨m, hm, hle⟩ := threshold_set_nonempty T eta delta heta hdelta have hs : 0 < mStar T eta delta ∧ birthdayRepeat T (mStar T eta delta) eta ≤ delta := by simpa only [mStar, Set.mem_ofPred_eq] using (Nat.sInf_mem (s := {m : ℕ | 0 < m ∧ birthdayRepeat T m eta ≤ delta}) ⟨m, hm, hle⟩) exact hs.1
Concentration 1 core · 5 supporting The variance identity and a relative-deviation estimate are stated for the finite averaging operator used by the birthday kernel. ★ binomial_relative_deviation_tendsto_zero
Binomial concentration at a diverging mean
The variance identity and a relative-deviation estimate are stated for the finite averaging operator used by the birthday kernel.
For valid success probabilities, a diverging expected count makes every relative-deviation binomial mass for a positive relative radius vanish.
Formal statement
Proof (Lean source)
5 supporting declarations (lemmas, instances)
-
binomialAverage_monotheorem — For a valid success probability, pointwise ordered count functions have ordered binomial averages.hypothesesconclusionbinomialAverage T eta f ≤ binomialAverage T eta gProof (Lean source)
theorem binomialAverage_mono (T : ℕ) (eta : ℝ) (f g : ℕ → ℝ) (heta : eta ∈ Icc (0 : ℝ) 1) (hfg : ∀ r, r ≤ T → f r ≤ g r) : binomialAverage T eta f ≤ binomialAverage T eta g := by unfold binomialAverage apply Finset.sum_le_sum intro r hr have hw : 0 ≤ binomialWeight T eta r := by simp only [binomialWeight] exact mul_nonneg (mul_nonneg (Nat.cast_nonneg _) (pow_nonneg heta.1 _)) (pow_nonneg (sub_nonneg.mpr heta.2) _) have hrT : r ≤ T := Nat.lt_succ_iff.mp (Finset.mem_range.mp hr) exact mul_le_mul_of_nonneg_left (hfg r hrT) hw -
binomialAverage_nonnegtheorem — For a valid success probability, a nonnegative count function has a nonnegative binomial average.hypothesesconclusion0 ≤ binomialAverage T eta fProof (Lean source)
theorem binomialAverage_nonneg (T : ℕ) (eta : ℝ) (f : ℕ → ℝ) (heta : eta ∈ Icc (0 : ℝ) 1) (hf : ∀ r, r ≤ T → 0 ≤ f r) : 0 ≤ binomialAverage T eta f := by have h := binomialAverage_mono T eta (fun _ => 0) f heta (by intro r hr exact hf r hr) simpa [binomialAverage] using h -
repeat_le_pairScale_divtheorem — For a valid success probability and positive alphabet, the averaged repeat probability is at most the expected pair count divided by the alphabet size.hypothesesconclusionbirthdayRepeat T m eta ≤ pairScale T eta / (m : ℝ)Proof (Lean source)
theorem repeat_le_pairScale_div (T m : ℕ) (eta : ℝ) (hm : 0 < m) (heta : eta ∈ Icc (0 : ℝ) 1) : birthdayRepeat T m eta ≤ pairScale T eta / (m : ℝ) := by have h := binomialAverage_mono T eta (repeatKernel m) (fun r => (r.choose 2 : ℝ) / (m : ℝ)) heta (by intro r _ exact repeatKernel_le_pairs m r hm) rw [← birthdayRepeat] at h have havg : binomialAverage T eta (fun r => (r.choose 2 : ℝ) / (m : ℝ)) = pairScale T eta / (m : ℝ) := by unfold binomialAverage calc _ = (∑ r ∈ range (T + 1), binomialWeight T eta r * (r.choose 2 : ℝ)) / (m : ℝ) := by rw [Finset.sum_div] apply Finset.sum_congr rfl intro r _ ring _ = _ := by rw [← binomialAverage, binomialAverage_pairs] exact h.trans_eq havg -
binomialAverage_centered_sqtheorem — The binomial average for a trial count and success probability of the squared centered count is the ordinary binomial variance.hypothesesT :ℕeta :ℝconclusionbinomialAverage T eta (fun r => ((r : ℝ) - mean T eta) ^ 2) = mean T eta * (1 - eta)Proof (Lean source)
theorem binomialAverage_centered_sq (T : ℕ) (eta : ℝ) : binomialAverage T eta (fun r => ((r : ℝ) - mean T eta) ^ 2) = mean T eta * (1 - eta) := by have hpoly (r : ℕ) : ((r : ℝ) - mean T eta) ^ 2 = 2 * (r.choose 2 : ℝ) + (1 - 2 * mean T eta) * r + mean T eta ^ 2 := by rw [Nat.cast_choose_two ℝ] ring have hsum : binomialAverage T eta (fun r => ((r : ℝ) - mean T eta) ^ 2) = 2 * binomialAverage T eta (fun r => (r.choose 2 : ℝ)) + (1 - 2 * mean T eta) * binomialAverage T eta (fun r => (r : ℝ)) + mean T eta ^ 2 * binomialAverage T eta (fun _ => 1) := by unfold binomialAverage calc _ = ∑ r ∈ range (T + 1), (2 * (binomialWeight T eta r * (r.choose 2 : ℝ)) + (1 - 2 * mean T eta) * (binomialWeight T eta r * (r : ℝ)) + mean T eta ^ 2 * (binomialWeight T eta r * 1)) := by apply Finset.sum_congr rfl intro r _ change binomialWeight T eta r * ((r : ℝ) - mean T eta) ^ 2 = _ rw [hpoly] ring _ = _ := by simp only [Finset.sum_add_distrib, ← Finset.mul_sum] rw [hsum, binomialAverage_pairs, binomialAverage_count, binomialAverage_one] unfold pairScale mean rw [Nat.cast_choose_two ℝ] ring -
binomialAverage_deviation_letheorem — For a valid success probability, the binomial mass outside a band with positive radius is at most variance divided by the squared band radius.hypothesesconclusionbinomialAverage T eta (fun r => if a ≤ |(r : ℝ) - mean T eta| then 1 else 0)≤ mean T eta * (1 - eta) / a ^ 2Proof (Lean source)
theorem binomialAverage_deviation_le (T : ℕ) {eta a : ℝ} (heta : eta ∈ Icc (0 : ℝ) 1) (ha : 0 < a) : binomialAverage T eta (fun r => if a ≤ |(r : ℝ) - mean T eta| then 1 else 0) ≤ mean T eta * (1 - eta) / a ^ 2 := by have hpoint (r : ℕ) : (if a ≤ |(r : ℝ) - mean T eta| then (1 : ℝ) else 0) ≤ ((r : ℝ) - mean T eta) ^ 2 / a ^ 2 := by have ha2 : 0 < a ^ 2 := sq_pos_of_pos ha split_ifs with h · apply (le_div_iff₀ ha2).2 have hs : a ^ 2 ≤ |(r : ℝ) - mean T eta| ^ 2 := by nlinarith nlinarith [sq_abs ((r : ℝ) - mean T eta)] · exact div_nonneg (sq_nonneg _) (le_of_lt ha2) have h := binomialAverage_mono T eta (fun r => if a ≤ |(r : ℝ) - mean T eta| then 1 else 0) (fun r => ((r : ℝ) - mean T eta) ^ 2 / a ^ 2) heta (by intro r _; exact hpoint r) have havg : binomialAverage T eta (fun r => ((r : ℝ) - mean T eta) ^ 2 / a ^ 2) = mean T eta * (1 - eta) / a ^ 2 := by unfold binomialAverage calc _ = (∑ r ∈ range (T + 1), binomialWeight T eta r * ((r : ℝ) - mean T eta) ^ 2) / a ^ 2 := by rw [Finset.sum_div] apply Finset.sum_congr rfl intro r _ ring _ = _ := by rw [← binomialAverage, binomialAverage_centered_sq] exact h.trans_eq havg
Finite 1 core · 7 supporting Pointwise collision estimates, monotonicity in the alphabet, and a finite binomial pair bound. ★ repeat_antitone
Finite birthday and binomial bounds
Pointwise collision estimates, monotonicity in the alphabet, and a finite binomial pair bound. These are the quantitative inputs for asymptotics and least-threshold existence.
For a valid success probability, positive smaller alphabet, and ordered alphabet sizes, the averaged repeat probability is antitone.
Formal statement
Proof (Lean source)
7 supporting declarations (lemmas, instances)
-
repeatKernel_mem_Icctheorem — A positive alphabet gives a collision probability between zero and one for every draw count.Proof (Lean source)
theorem repeatKernel_mem_Icc (m r : ℕ) (hm : 0 < m) : repeatKernel m r ∈ Icc (0 : ℝ) 1 := by have hmpos : (0 : ℝ) < m := by exact_mod_cast hm have hfac : (m.descFactorial r : ℝ) ≤ (m : ℝ) ^ r := by exact_mod_cast Nat.descFactorial_le_pow m r have hq : noRepeat m r ≤ 1 := by unfold noRepeat exact (div_le_iff₀ (pow_pos hmpos _)).2 (by simpa using hfac) change 0 ≤ repeatKernel m r ∧ repeatKernel m r ≤ 1 unfold repeatKernel constructor · linarith · have : 0 ≤ noRepeat m r := by unfold noRepeat; positivity linarith -
repeatKernel_eq_one_of_lttheorem — If the draw count exceeds the alphabet, the repeat probability is one.Proof (Lean source)
theorem repeatKernel_eq_one_of_lt (m r : ℕ) (hr : m < r) : repeatKernel m r = 1 := by simp [repeatKernel, noRepeat, Nat.descFactorial_eq_zero_iff_lt.mpr hr] -
repeatKernel_le_pairstheorem — For a positive alphabet, the repeat probability is at most the number of unordered draw pairs divided by the alphabet size.Proof (Lean source)
theorem repeatKernel_le_pairs (m r : ℕ) (hm : 0 < m) : repeatKernel m r ≤ (r.choose 2 : ℝ) / (m : ℝ) := by induction r with | zero => simp [repeatKernel, noRepeat] | succ r ih => have hmpos : (0 : ℝ) < m := by exact_mod_cast hm have hpow : 0 < (m : ℝ) ^ r := pow_pos hmpos _ have hfac : (m.descFactorial r : ℝ) ≤ (m : ℝ) ^ r := by exact_mod_cast Nat.descFactorial_le_pow m r have hq0 : 0 ≤ (m.descFactorial r : ℝ) / (m : ℝ) ^ r := by positivity have hq1 : (m.descFactorial r : ℝ) / (m : ℝ) ^ r ≤ 1 := by exact (div_le_iff₀ hpow).2 (by simpa using hfac) have hsub : (m : ℝ) - r ≤ (m - r : ℕ) := by by_cases h : r ≤ m · rw [Nat.cast_sub h] · have : (m : ℝ) ≤ r := by exact_mod_cast (le_of_lt (Nat.lt_of_not_ge h)) simp only [Nat.sub_eq_zero_of_le (le_of_lt (Nat.lt_of_not_ge h)), Nat.cast_zero] linarith have hsub1 : ((m - r : ℕ) : ℝ) ≤ m := by exact_mod_cast Nat.sub_le m r have hrec : (m.descFactorial (r + 1) : ℝ) / (m : ℝ) ^ (r + 1) = ((m - r : ℕ) : ℝ) / (m : ℝ) * ((m.descFactorial r : ℝ) / (m : ℝ) ^ r) := by rw [Nat.descFactorial_succ, Nat.cast_mul, pow_succ] ring have hchoose : ((r + 1).choose 2 : ℝ) = (r.choose 2 : ℝ) + r := by rw [Nat.choose_succ_succ'] simp ring unfold repeatKernel noRepeat at ih ⊢ rw [hrec, hchoose] have hratio0 : 0 ≤ 1 - ((m - r : ℕ) : ℝ) / (m : ℝ) := by apply sub_nonneg.mpr exact (div_le_iff₀ hmpos).2 (by simp [hsub1]) have hratio : 1 - ((m - r : ℕ) : ℝ) / (m : ℝ) ≤ (r : ℝ) / (m : ℝ) := by apply (le_div_iff₀ hmpos).2 have : (1 - ((m - r : ℕ) : ℝ) / (m : ℝ)) * (m : ℝ) = (m : ℝ) - (m - r : ℕ) := by field_simp rw [this] linarith have hmul : (1 - ((m - r : ℕ) : ℝ) / (m : ℝ)) * ((m.descFactorial r : ℝ) / (m : ℝ) ^ r) ≤ (r : ℝ) / (m : ℝ) := by calc _ ≤ 1 - ((m - r : ℕ) : ℝ) / (m : ℝ) := by nlinarith _ ≤ _ := hratio have hstep : 1 - ((m - r : ℕ) : ℝ) / (m : ℝ) * ((m.descFactorial r : ℝ) / (m : ℝ) ^ r) ≤ (1 - (m.descFactorial r : ℝ) / (m : ℝ) ^ r) + r / (m : ℝ) := by nlinarith [hmul] exact hstep.trans (by have := add_le_add_right ih (r / (m : ℝ)) simpa [add_div] using this) -
noRepeat_le_exptheorem — For a positive alphabet, the no-repeat probability is at most the exponential of minus the pair count over the alphabet size.Proof (Lean source)
theorem noRepeat_le_exp (m r : ℕ) (hm : 0 < m) : noRepeat m r ≤ exp (-((r.choose 2 : ℕ) : ℝ) / (m : ℝ)) := by have hmpos : (0 : ℝ) < m := by exact_mod_cast hm induction r with | zero => simp [noRepeat] | succ r ih => by_cases h : r < m · have hcast : ((m - r : ℕ) : ℝ) = (m : ℝ) - r := Nat.cast_sub h.le have hfactor : ((m - r : ℕ) : ℝ) / m ≤ exp (-(r : ℝ) / m) := by rw [hcast] have hbasic := Real.one_sub_le_exp_neg ((r : ℝ) / m) have heq : ((m : ℝ) - r) / m = 1 - (r : ℝ) / m := by field_simp rw [heq] simpa only [neg_div] using hbasic have hrec : noRepeat m (r + 1) = ((m - r : ℕ) : ℝ) / m * noRepeat m r := by unfold noRepeat rw [Nat.descFactorial_succ, Nat.cast_mul, pow_succ] ring have hchoose : ((r + 1).choose 2 : ℝ) = (r.choose 2 : ℝ) + r := by rw [Nat.choose_succ_succ'] simp ring rw [hrec, hchoose] calc _ ≤ exp (-(r : ℝ) / m) * noRepeat m r := mul_le_mul_of_nonneg_right hfactor (by unfold noRepeat; positivity) _ ≤ exp (-(r : ℝ) / m) * exp (-((r.choose 2 : ℕ) : ℝ) / m) := mul_le_mul_of_nonneg_left ih (Real.exp_nonneg _) _ = exp (-(((r.choose 2 : ℕ) : ℝ) + r) / m) := by rw [← Real.exp_add] congr 1 ring · have hzero : m - r = 0 := Nat.sub_eq_zero_of_le (Nat.le_of_not_gt h) simpa [noRepeat, Nat.descFactorial_succ, hzero] using (Real.exp_nonneg (-(((r + 1).choose 2 : ℕ) : ℝ) / m)) -
exp_le_noRepeattheorem — For a positive alphabet and draw count within it, the no-repeat probability is at least the exponential pair bound with the remaining alphabet size in its denominator.hypothesesm r :ℕhm :0 < mhr :r ≤ mProof (Lean source)
theorem exp_le_noRepeat (m r : ℕ) (hm : 0 < m) (hr : r ≤ m) : exp (-((r.choose 2 : ℕ) : ℝ) / (m + 1 - r : ℕ)) ≤ noRepeat m r := by induction r with | zero => simp [noRepeat] | succ r ih => have hrm : r < m := Nat.lt_of_succ_le hr have hmpos : (0 : ℝ) < m := by exact_mod_cast hm have hden_nat : m + 1 - (r + 1) = m - r := by omega have hden_pos_nat : 0 < m - r := Nat.sub_pos_of_lt hrm have hden_pos : (0 : ℝ) < (m - r : ℕ) := by exact_mod_cast hden_pos_nat have hfactor : exp (-(r : ℝ) / (m - r : ℕ)) ≤ ((m - r : ℕ) : ℝ) / m := by have hx1 : (r : ℝ) / m < 1 := (div_lt_one hmpos).2 (by exact_mod_cast hrm) have hpos : 0 < 1 - (r : ℝ) / m := sub_pos.mpr hx1 have hlog := Real.one_sub_inv_le_log_of_pos hpos have hid : 1 - (1 - (r : ℝ) / m)⁻¹ = -((r : ℝ) / m) / (1 - (r : ℝ) / m) := by have hmr : (m : ℝ) - r ≠ 0 := by rw [← Nat.cast_sub hrm.le] exact ne_of_gt hden_pos field_simp [ne_of_gt hmpos, ne_of_gt hpos, hmr] ring rw [hid] at hlog have h := (Real.exp_le_exp.mpr hlog).trans (le_of_eq (Real.exp_log hpos)) have hone : 1 - (r : ℝ) / m = ((m - r : ℕ) : ℝ) / m := by rw [Nat.cast_sub hrm.le] field_simp have hexp : -((r : ℝ) / m) / (1 - (r : ℝ) / m) = -(r : ℝ) / (m - r : ℕ) := by rw [Nat.cast_sub hrm.le] field_simp rw [hexp, hone] at h exact h have ih' := ih (le_of_lt hrm) have hden_le : (m - r : ℕ) ≤ m + 1 - r := by omega have hchoose_nonneg : (0 : ℝ) ≤ (r.choose 2 : ℕ) := Nat.cast_nonneg _ have hweak : exp (-((r.choose 2 : ℕ) : ℝ) / (m - r : ℕ)) ≤ exp (-((r.choose 2 : ℕ) : ℝ) / (m + 1 - r : ℕ)) := by apply Real.exp_le_exp.mpr have hsmall_nat : 0 < m + 1 - r := by omega have hsmall : (0 : ℝ) < (m + 1 - r : ℕ) := by exact_mod_cast hsmall_nat have hcastle : ((m - r : ℕ) : ℝ) ≤ (m + 1 - r : ℕ) := by exact_mod_cast hden_le have := div_le_div_of_nonneg_left hchoose_nonneg hden_pos hcastle simpa only [neg_div] using neg_le_neg this have hrec : noRepeat m (r + 1) = (((m - r : ℕ) : ℝ) / m) * noRepeat m r := by unfold noRepeat rw [Nat.descFactorial_succ, Nat.cast_mul, pow_succ] ring rw [hden_nat, hrec] calc exp (-(((r + 1).choose 2 : ℕ) : ℝ) / (m - r : ℕ)) = exp (-(r : ℝ) / (m - r : ℕ)) * exp (-((r.choose 2 : ℕ) : ℝ) / (m - r : ℕ)) := by rw [← Real.exp_add, Nat.choose_succ_succ'] simp ring _ ≤ (((m - r : ℕ) : ℝ) / m) * exp (-((r.choose 2 : ℕ) : ℝ) / (m + 1 - r : ℕ)) := mul_le_mul hfactor hweak (Real.exp_nonneg _) (by positivity) _ ≤ (((m - r : ℕ) : ℝ) / m) * noRepeat m r := mul_le_mul_of_nonneg_left ih' (by positivity) -
noRepeat_mono_succtheorem — As the positive alphabet grows by one, the no-repeat probability increases.Proof (Lean source)
theorem noRepeat_mono_succ (m r : ℕ) (hm : 0 < m) : noRepeat m r ≤ noRepeat (m + 1) r := by induction r with | zero => simp [noRepeat] | succ r ih => by_cases hr : r < m · have hmpos : (0 : ℝ) < m := by exact_mod_cast hm have hm1pos : (0 : ℝ) < m + 1 := by positivity have hfac : ((m - r : ℕ) : ℝ) / m ≤ (((m + 1) - r : ℕ) : ℝ) / (m + 1) := by rw [Nat.cast_sub hr.le, Nat.cast_sub (by omega : r ≤ m + 1)] apply (div_le_div_iff₀ hmpos hm1pos).2 push_cast nlinarith have hleft : 0 ≤ noRepeat m r := by unfold noRepeat; positivity have hright : (0 : ℝ) ≤ (((m + 1) - r : ℕ) : ℝ) / (m + 1) := by positivity have hrecL : noRepeat m (r + 1) = (((m - r : ℕ) : ℝ) / m) * noRepeat m r := by unfold noRepeat rw [Nat.descFactorial_succ, Nat.cast_mul, pow_succ] ring have hrecR : noRepeat (m + 1) (r + 1) = ((((m + 1) - r : ℕ) : ℝ) / (m + 1 : ℝ)) * noRepeat (m + 1) r := by unfold noRepeat rw [Nat.descFactorial_succ, Nat.cast_mul, pow_succ] field_simp [ne_of_gt hm1pos] push_cast ring rw [hrecL, hrecR] exact mul_le_mul hfac ih hleft hright · have hzero : m.descFactorial (r + 1) = 0 := Nat.descFactorial_of_lt (by omega) rw [noRepeat, hzero, Nat.cast_zero, zero_div] unfold noRepeat positivity -
repeat_antitone_succtheorem — For a valid success probability and positive alphabet, increasing the alphabet cannot raise the averaged repeat probability.hypothesesconclusionbirthdayRepeat T (m + 1) eta ≤ birthdayRepeat T m etaProof (Lean source)
theorem repeat_antitone_succ (T m : ℕ) (eta : ℝ) (hm : 0 < m) (heta : eta ∈ Icc (0 : ℝ) 1) : birthdayRepeat T (m + 1) eta ≤ birthdayRepeat T m eta := by unfold birthdayRepeat binomialAverage apply Finset.sum_le_sum intro r hr have hw : 0 ≤ binomialWeight T eta r := by simp only [binomialWeight] exact mul_nonneg (mul_nonneg (Nat.cast_nonneg _) (pow_nonneg heta.1 _)) (pow_nonneg (sub_nonneg.mpr heta.2) _) apply mul_le_mul_of_nonneg_left _ hw unfold repeatKernel linarith [noRepeat_mono_succ m r hm]
Limit 1 core · 1 supporting The finite birthday sandwich gives uniform control on a relative mean band. ★ repeat_tendsto
The binomial birthday collision limit
The finite birthday sandwich gives uniform control on a relative mean band. Together with concentration, this yields the averaged collision limit.
For valid success probabilities, a diverging expected draw count, positive alphabets, and pair scale per label tending to a positive value q, the binomially averaged repeat probability tends to 1 − exp(−q), one minus the Poisson no-collision probability at that limiting scale.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
repeatKernel_uniform_on_relative_bandtheorem — If valid success probabilities have a diverging expected count, positive alphabets, and positive finite pair scale, then the birthday kernel approaches its Poisson collision value uniformly on a sufficiently narrow relative band around the binomial mean.hypothesesTseq mseq :ℕ → ℕetaseq :ℕ → ℝq :ℝheta :∀ j, etaseq j ∈ Icc (0 : ℝ) 1hm :∀ j, 0 < mseq jhq :0 < qδ :ℝ0 < δconclusion∃ ε : ℝ,conclusion 10 < εconclusion 2∀ᶠ j in atTop, ∀ r : ℕ, r≤ Tseq j → |(r : ℝ)- mean (Tseq j) (etaseq j)| < ε * mean (Tseq j) (etaseq j) → |repeatKernel (mseq j) r- (1 - exp (-q))| ≤ δProof (Lean source)
theorem repeatKernel_uniform_on_relative_band (Tseq mseq : ℕ → ℕ) (etaseq : ℕ → ℝ) {q : ℝ} (heta : ∀ j, etaseq j ∈ Icc (0 : ℝ) 1) (hmean : Tendsto (fun j => mean (Tseq j) (etaseq j)) atTop atTop) (hm : ∀ j, 0 < mseq j) (hscale : Tendsto (fun j => pairScale (Tseq j) (etaseq j) / (mseq j : ℝ)) atTop (nhds q)) (hq : 0 < q) : ∀ δ : ℝ, 0 < δ → ∃ ε : ℝ, 0 < ε ∧ ∀ᶠ j in atTop, ∀ r : ℕ, r ≤ Tseq j → |(r : ℝ) - mean (Tseq j) (etaseq j)| < ε * mean (Tseq j) (etaseq j) → |repeatKernel (mseq j) r - (1 - exp (-q))| ≤ δ := by -- Given δ, use continuity of x ↦ exp (-x) at q to choose a smaller -- exponent tolerance. Intersect the two uniform scale bands from -- LimitBand and shrink their widths with `min`; include the eventual -- `relative_band_below_alphabet` condition. The finite sandwich -- `exp_le_noRepeat` / `noRepeat_le_exp` then bounds noRepeat between -- exponentials whose arguments are both close to q. Subtract from 1. intro δ hδ have hcont : ContinuousAt (fun x : ℝ => exp (-x)) q := by fun_prop obtain ⟨ρ, hρ, hρexp⟩ := (Metric.continuousAt_iff.mp hcont) δ hδ obtain ⟨εa, hεa, ha⟩ := pairCount_div_alphabet_uniform_on_relative_band Tseq mseq etaseq heta hmean hm hscale hq (ρ / 2) (by positivity) obtain ⟨εb, hεb, hb⟩ := pairCount_div_remaining_uniform_on_relative_band Tseq mseq etaseq heta hmean hm hscale hq (ρ / 2) (by positivity) let ε : ℝ := min εa εb have hε : 0 < ε := lt_min hεa hεb have hbelow := relative_band_below_alphabet Tseq mseq etaseq heta hmean hm hscale hε refine ⟨ε, hε, ?_⟩ filter_upwards [ha, hb, hbelow, hmean.eventually_gt_atTop 0] with j haj hbj hjbelow hμ r hrT hrband have hbandA : |(r : ℝ) - mean (Tseq j) (etaseq j)| < εa * mean (Tseq j) (etaseq j) := lt_of_lt_of_le hrband (mul_le_mul_of_nonneg_right (min_le_left _ _) (le_of_lt hμ)) have hbandB : |(r : ℝ) - mean (Tseq j) (etaseq j)| < εb * mean (Tseq j) (etaseq j) := lt_of_lt_of_le hrband (mul_le_mul_of_nonneg_right (min_le_right _ _) (le_of_lt hμ)) have hrm : r ≤ mseq j := hjbelow r hrband have hA := haj r hbandA have hB := hbj r hrm hbandB have hAexp : |exp (-((r.choose 2 : ℝ) / (mseq j : ℝ))) - exp (-q)| ≤ δ := by have ht := hρexp (x := (r.choose 2 : ℝ) / (mseq j : ℝ)) (by simpa [Real.dist_eq] using (lt_of_le_of_lt hA (by linarith : ρ / 2 < ρ))) exact le_of_lt (by simpa [Real.dist_eq] using ht) have hBexp : |exp (-((r.choose 2 : ℝ) / (mseq j + 1 - r : ℕ))) - exp (-q)| ≤ δ := by have ht := hρexp (x := (r.choose 2 : ℝ) / (mseq j + 1 - r : ℕ)) (by simpa [Real.dist_eq] using (lt_of_le_of_lt hB (by linarith : ρ / 2 < ρ))) exact le_of_lt (by simpa [Real.dist_eq] using ht) have hlo := exp_le_noRepeat (mseq j) r (hm j) hrm have hhi := noRepeat_le_exp (mseq j) r (hm j) have hlo' : exp (-((r.choose 2 : ℝ) / (mseq j + 1 - r : ℕ))) ≤ noRepeat (mseq j) r := by convert hlo using 1 <;> ring have hhi' : noRepeat (mseq j) r ≤ exp (-((r.choose 2 : ℝ) / (mseq j : ℝ))) := by convert hhi using 1 <;> ring change |(1 - noRepeat (mseq j) r) - (1 - exp (-q))| ≤ δ rw [show (1 - noRepeat (mseq j) r) - (1 - exp (-q)) = exp (-q) - noRepeat (mseq j) r by ring] apply abs_le.mpr constructor · have := (abs_le.mp hAexp).2 linarith [hhi'] · have := (abs_le.mp hBexp).1 linarith [hlo']
LimitAverage 1 core · 0 supporting A bounded count kernel converges in binomial average when it is uniformly close to its target on a fixed relative band around a diverging mean. ★ binomialAverage_tendsto_of_relative_band
Averaging a kernel concentrated around the binomial mean
A bounded count kernel converges in binomial average when it is uniformly close to its target on a fixed relative band around a diverging mean.
A bounded count kernel that is uniformly close on a relative mean band has a convergent binomial average when the success parameters are valid, the mean diverges, and the target lies in the unit interval.
Formal statement
Proof (Lean source)
LimitBand 1 core · 3 supporting The binomial mean is negligible relative to the alphabet at positive finite collision scale. ★ pairCount_div_remaining_uniform_on_relative_band
Relative-band scale estimates for the birthday limit
The binomial mean is negligible relative to the alphabet at positive finite collision scale. Pair counts on a relative mean band have uniform limits with both the full and the remaining-alphabet denominators.
For valid success probabilities, a diverging mean, positive alphabets, and a positive finite collision scale, for every tolerance there is a relative band width such that, eventually, every draw count r not exceeding the alphabet size m and within that relative band of the mean has its pair count divided by the remaining alphabet m + 1 − r within the tolerance of that scale.
Formal statement
Proof (Lean source)
3 supporting declarations (lemmas, instances)
-
mean_div_alphabet_tendsto_zerotheorem — For valid success probabilities, a diverging mean, positive alphabets, and a convergent collision scale, the mean divided by the alphabet tends to zero.hypothesesProof (Lean source)
theorem mean_div_alphabet_tendsto_zero (Tseq mseq : ℕ → ℕ) (etaseq : ℕ → ℝ) {q : ℝ} (heta : ∀ j, etaseq j ∈ Icc (0 : ℝ) 1) (hmean : Tendsto (fun j => mean (Tseq j) (etaseq j)) atTop atTop) (hm : ∀ j, 0 < mseq j) (hscale : Tendsto (fun j => pairScale (Tseq j) (etaseq j) / (mseq j : ℝ)) atTop (nhds q)) : Tendsto (fun j => mean (Tseq j) (etaseq j) / (mseq j : ℝ)) atTop (nhds 0) := by -- Factor μ/m as (A/m)·(μ/A); A/(μ²/2)→1 and μ→∞. -- Alternatively derive m/μ→∞ from A/m→q and A~μ²/2. have hd : Tendsto (fun j => mean (Tseq j) (etaseq j) - etaseq j) atTop atTop := by apply tendsto_atTop.2 intro b filter_upwards [hmean.eventually_ge_atTop (b + 1)] with j hj have he := (heta j).2 linarith have hinv : Tendsto (fun j => (mean (Tseq j) (etaseq j) - etaseq j)⁻¹) atTop (nhds 0) := tendsto_inv_atTop_zero.comp hd have hprod := (hscale.const_mul 2).mul hinv have hpos := hd.eventually_gt_atTop 0 have hprod' : Tendsto (fun j => 2 * (pairScale (Tseq j) (etaseq j) / (mseq j : ℝ)) * (mean (Tseq j) (etaseq j) - etaseq j)⁻¹) atTop (nhds 0) := by simpa using hprod apply hprod'.congr' filter_upwards [hpos] with j hj have hmj : (mseq j : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (hm j)) have hdj : mean (Tseq j) (etaseq j) - etaseq j ≠ 0 := ne_of_gt hj have hident : 2 * pairScale (Tseq j) (etaseq j) = mean (Tseq j) (etaseq j) * (mean (Tseq j) (etaseq j) - etaseq j) := by simp only [pairScale, mean, Nat.cast_choose_two] ring field_simp [hmj, hdj] nlinarith [hident] -
relative_band_below_alphabettheorem — For valid success probabilities, a diverging mean, positive alphabets, a convergent collision scale, and a fixed relative band width, draw counts in that band are eventually below the alphabet.hypothesesTseq mseq :ℕ → ℕetaseq :ℕ → ℝq ε :ℝheta :∀ j, etaseq j ∈ Icc (0 : ℝ) 1hm :∀ j, 0 < mseq jhε :0 < εconclusion∀ᶠ j in atTop, ∀ r : ℕ, |(r : ℝ)- mean (Tseq j) (etaseq j)| < ε * mean (Tseq j) (etaseq j) → r≤ mseq jProof (Lean source)
theorem relative_band_below_alphabet (Tseq mseq : ℕ → ℕ) (etaseq : ℕ → ℝ) {q ε : ℝ} (heta : ∀ j, etaseq j ∈ Icc (0 : ℝ) 1) (hmean : Tendsto (fun j => mean (Tseq j) (etaseq j)) atTop atTop) (hm : ∀ j, 0 < mseq j) (hscale : Tendsto (fun j => pairScale (Tseq j) (etaseq j) / (mseq j : ℝ)) atTop (nhds q)) (hε : 0 < ε) : ∀ᶠ j in atTop, ∀ r : ℕ, |(r : ℝ) - mean (Tseq j) (etaseq j)| < ε * mean (Tseq j) (etaseq j) → r ≤ mseq j := by -- The band gives r < (1+ε)μ; μ/m→0 implies (1+ε)μ<m eventually. have hzero := mean_div_alphabet_tendsto_zero Tseq mseq etaseq heta hmean hm hscale have hc : (0 : ℝ) < 1 / (1 + ε) := by positivity have hsmall := hzero.eventually (eventually_lt_nhds hc) have hpos := hmean.eventually_gt_atTop 0 filter_upwards [hsmall, hpos] with j hs hμ r hr have hmj : (0 : ℝ) < (mseq j : ℝ) := by exact_mod_cast hm j have hmul : mean (Tseq j) (etaseq j) / (mseq j : ℝ) * (1 + ε) < 1 := (lt_div_iff₀ (by linarith : (0 : ℝ) < 1 + ε)).mp hs have hbound : mean (Tseq j) (etaseq j) * (1 + ε) < (mseq j : ℝ) := by have ht : mean (Tseq j) (etaseq j) * (1 + ε) / (mseq j : ℝ) < 1 := by calc mean (Tseq j) (etaseq j) * (1 + ε) / (mseq j : ℝ) = mean (Tseq j) (etaseq j) / (mseq j : ℝ) * (1 + ε) := by ring _ < 1 := hmul exact (div_lt_iff₀ hmj).mp ht |>.trans_eq (one_mul _) have hrlt : (r : ℝ) < (mseq j : ℝ) := by rw [abs_lt] at hr nlinarith [hr.2] exact le_of_lt (by exact_mod_cast hrlt) -
pairCount_div_alphabet_uniform_on_relative_bandtheorem — For valid success probabilities, a diverging mean, positive alphabets, and a positive finite collision scale, the pair count per alphabet is uniformly close to that scale on a sufficiently narrow relative mean band.hypothesesTseq mseq :ℕ → ℕetaseq :ℕ → ℝq :ℝheta :∀ j, etaseq j ∈ Icc (0 : ℝ) 1hm :∀ j, 0 < mseq jhq :0 < qδ :ℝ0 < δconclusion∃ ε : ℝ,conclusion 10 < εconclusion 2∀ᶠ j in atTop, ∀ r : ℕ, |(r : ℝ)- mean (Tseq j) (etaseq j)| < ε * mean (Tseq j) (etaseq j) → |(r.choose 2 : ℝ) / (mseq j : ℝ)- q|≤ δProof (Lean source)
theorem pairCount_div_alphabet_uniform_on_relative_band (Tseq mseq : ℕ → ℕ) (etaseq : ℕ → ℝ) {q : ℝ} (heta : ∀ j, etaseq j ∈ Icc (0 : ℝ) 1) (hmean : Tendsto (fun j => mean (Tseq j) (etaseq j)) atTop atTop) (hm : ∀ j, 0 < mseq j) (hscale : Tendsto (fun j => pairScale (Tseq j) (etaseq j) / (mseq j : ℝ)) atTop (nhds q)) (hq : 0 < q) : ∀ δ : ℝ, 0 < δ → ∃ ε : ℝ, 0 < ε ∧ ∀ᶠ j in atTop, ∀ r : ℕ, |(r : ℝ) - mean (Tseq j) (etaseq j)| < ε * mean (Tseq j) (etaseq j) → |(r.choose 2 : ℝ) / (mseq j : ℝ) - q| ≤ δ := by -- Write choose(r,2)=r(r-1)/2 and A~μ²/2; choose ε to bound -- |(r/μ)²-1| and use μ/m→0 for the linear r term. intro δ hδ let C : ℝ := 2 * q + 3 have hC : 0 < C := by dsimp [C]; linarith let ε : ℝ := min (1 / 2) (δ / (12 * C)) have hε : 0 < ε := lt_min (by norm_num) (by positivity) have hεhalf : ε ≤ 1 / 2 := min_le_left _ _ have hεC : ε * C ≤ δ / 12 := by calc ε * C ≤ (δ / (12 * C)) * C := mul_le_mul_of_nonneg_right (min_le_right _ _) (le_of_lt hC) _ = δ / 12 := by field_simp refine ⟨ε, hε, ?_⟩ have hzero := mean_div_alphabet_tendsto_zero Tseq mseq etaseq heta hmean hm hscale have hsmall := hzero.eventually (eventually_lt_nhds (show (0 : ℝ) < δ / 12 by positivity)) have hone := hzero.eventually (eventually_lt_nhds (show (0 : ℝ) < 1 by norm_num)) have hμpos := hmean.eventually_gt_atTop 0 have hAnear := (Metric.tendsto_nhds.mp hscale) (δ / 4) (by positivity) have hAupper := hscale.eventually (eventually_lt_nhds (show q < q + 1 by linarith)) filter_upwards [hsmall, hone, hμpos, hAnear, hAupper] with j hs hμone hμ hn hAu r hr let μ : ℝ := mean (Tseq j) (etaseq j) let A : ℝ := pairScale (Tseq j) (etaseq j) let m : ℝ := mseq j have hmpos : 0 < m := by dsimp [m]; exact_mod_cast hm j have hmne : m ≠ 0 := ne_of_gt hmpos have hsmall' : μ < (δ / 12) * m := (div_lt_iff₀ hmpos).mp hs have hμone' : μ < m := by simpa using (div_lt_iff₀ hmpos).mp hμone have hAupper' : A < (q + 1) * m := (div_lt_iff₀ hmpos).mp hAu have hident : 2 * A = μ * (μ - etaseq j) := by dsimp [A, μ] simp only [pairScale, mean, Nat.cast_choose_two] ring have he0 : 0 ≤ etaseq j := (heta j).1 have he1 : etaseq j ≤ 1 := (heta j).2 have heμ : μ * etaseq j ≤ μ := by nlinarith [mul_nonneg (le_of_lt hμ) (sub_nonneg.mpr he1)] have hμsq : μ ^ 2 ≤ C * m := by dsimp [C] nlinarith [hident] have hsqcap : 3 * ε * μ ^ 2 ≤ (δ / 4) * m := by calc 3 * ε * μ ^ 2 ≤ (3 * ε) * (C * m) := mul_le_mul_of_nonneg_left hμsq (by positivity) _ = (3 * (ε * C)) * m := by ring _ ≤ (δ / 4) * m := mul_le_mul_of_nonneg_right (by nlinarith [hεC]) (le_of_lt hmpos) have hrband := (abs_lt.mp hr) have hrupper : (r : ℝ) ≤ 2 * μ := by have hh := mul_le_mul_of_nonneg_right hεhalf (le_of_lt hμ) nlinarith have hsum : 0 ≤ (r : ℝ) + μ := by positivity have hsumupper : (r : ℝ) + μ ≤ 3 * μ := by linarith have hsqabs : |(r : ℝ) ^ 2 - μ ^ 2| ≤ 3 * ε * μ ^ 2 := by have hf : (r : ℝ) ^ 2 - μ ^ 2 = ((r : ℝ) - μ) * ((r : ℝ) + μ) := by ring rw [hf, abs_mul, abs_of_nonneg hsum] calc |(r : ℝ) - μ| * ((r : ℝ) + μ) ≤ (ε * μ) * ((r : ℝ) + μ) := mul_le_mul_of_nonneg_right (le_of_lt hr) hsum _ ≤ (ε * μ) * (3 * μ) := mul_le_mul_of_nonneg_left hsumupper (by positivity) _ = 3 * ε * μ ^ 2 := by ring have hnum : |(r : ℝ) ^ 2 - (r : ℝ) - 2 * A| ≤ (δ / 2) * m := by rw [abs_le] have hsqbounds := abs_le.mp hsqabs constructor <;> nlinarith [hident, hsqcap, hsmall', hrupper, heμ] have hpairident : (r.choose 2 : ℝ) / m - A / m = ((r : ℝ) ^ 2 - (r : ℝ) - 2 * A) / (2 * m) := by rw [Nat.cast_choose_two] field_simp have hpair : |(r.choose 2 : ℝ) / m - A / m| ≤ δ / 4 := by rw [hpairident, abs_div, abs_of_pos (show 0 < 2 * m by positivity)] calc |(r : ℝ) ^ 2 - (r : ℝ) - 2 * A| / (2 * m) ≤ ((δ / 2) * m) / (2 * m) := div_le_div_of_nonneg_right hnum (by positivity) _ = δ / 4 := by field_simp; ring have hAnear' : |A / m - q| < δ / 4 := by simpa [Real.dist_eq, A, m] using hn have hfinal : |(r.choose 2 : ℝ) / m - q| ≤ δ := by calc |(r.choose 2 : ℝ) / m - q| ≤ |(r.choose 2 : ℝ) / m - A / m| + |A / m - q| := by calc |(r.choose 2 : ℝ) / m - q| = |((r.choose 2 : ℝ) / m - A / m) + (A / m - q)| := by congr 1; ring _ ≤ _ := abs_add_le _ _ _ ≤ δ := by linarith simpa [m] using hfinal
LimitScale 1 core · 0 supporting For T trials with success probability η, the expected number of unordered pairs of successes is C(T, 2)·η², and the mean number of successes is T·η. ★ pairScale_div_half_mean_sq_tendsto_one
The binomial pair scale is asymptotically half the squared mean
For T trials with success probability η, the expected number of unordered pairs of successes is C(T, 2)·η², and the mean number of successes is T·η. Along any sequence of trial counts and probabilities in [0, 1] whose mean T·η tends to infinity, the ratio of C(T, 2)·η² to (T·η)²/2 tends to one, so the two normalizations of the birthday-collision scale are interchangeable in the limit.
Main results
* pairScale_div_half_mean_sq_tendsto_one — the ratio of the pair scale to half the squared mean
converges to one when the mean diverges.
For valid success probabilities and a diverging expected count, the pair scale divided by half the squared mean converges to one.
Formal statement
Proof (Lean source)
Moments 1 core · 2 supporting The binomial weights have unit mass, expected count equal to the trial mean, and expected unordered pair count equal to the pair scale. ★ binomialAverage_pairs
Binomial count moments for birthday averaging
The binomial weights have unit mass, expected count equal to the trial mean, and expected unordered pair count equal to the pair scale.
The binomial average for a trial count and success probability of the unordered pair count is the expected pair scale.
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
binomialAverage_onetheorem — The binomial weights for a trial count and success probability sum to one.Proof (Lean source)
theorem binomialAverage_one (T : ℕ) (eta : ℝ) : binomialAverage T eta (fun _ => 1) = 1 := by unfold binomialAverage simp only [mul_one] calc (∑ r ∈ range (T + 1), binomialWeight T eta r) = (eta + (1 - eta)) ^ T := by rw [add_pow] apply Finset.sum_congr rfl intro r hr simp only [binomialWeight] ring _ = 1 := by ring -
binomialAverage_counttheorem — The binomial average for a trial count and success probability of the count equals its mean.Proof (Lean source)
theorem binomialAverage_count (T : ℕ) (eta : ℝ) : binomialAverage T eta (fun r => (r : ℝ)) = mean T eta := by by_cases hT : T = 0 · subst T simp [binomialAverage, mean] · have hpos : 0 < T := Nat.pos_of_ne_zero hT unfold binomialAverage mean calc (∑ r ∈ range (T + 1), binomialWeight T eta r * (r : ℝ)) = ∑ j ∈ range T, (T : ℝ) * eta * binomialWeight (T - 1) eta j := by rw [Finset.sum_range_succ' (f := fun r => binomialWeight T eta r * (r : ℝ))] simp only [Nat.cast_zero, mul_zero, add_zero] apply Finset.sum_congr rfl intro j hj have hjlt : j < T := Finset.mem_range.mp hj have hchoose : (T.choose (j + 1) : ℝ) * (j + 1 : ℕ) = (T : ℝ) * ((T - 1).choose j : ℝ) := by rw [show T = (T - 1) + 1 by omega] exact_mod_cast (Nat.add_one_mul_choose_eq (T - 1) j).symm have hsub : T - (j + 1) = (T - 1) - j := by omega simp only [binomialWeight, hsub, pow_succ] push_cast rw [show (j : ℝ) + 1 = ((j + 1 : ℕ) : ℝ) by norm_num] calc (T.choose (j + 1) : ℝ) * (eta ^ j * eta) * (1 - eta) ^ (T - 1 - j) * ((j + 1 : ℕ) : ℝ) = ((T.choose (j + 1) : ℝ) * (j + 1 : ℕ)) * eta * (eta ^ j * (1 - eta) ^ (T - 1 - j)) := by ring _ = _ := by rw [hchoose]; ring _ = (T : ℝ) * eta * binomialAverage (T - 1) eta (fun _ => 1) := by simp only [binomialAverage, mul_one] rw [Nat.sub_add_cancel (show 1 ≤ T by omega), Finset.mul_sum] _ = (T : ℝ) * eta := by rw [binomialAverage_one]; ring
Threshold 1 core · 0 supporting The least positive alphabet size that meets a fixed collision tolerance is asymptotic to the binomial pair scale divided by its logarithmic constant. ★ mStar_div_calibratedScale_tendsto_one
Asymptotic inversion of the least birthday threshold
The least positive alphabet size that meets a fixed collision tolerance is asymptotic to the binomial pair scale divided by its logarithmic constant.
For valid success probabilities, a diverging expected draw count, and a tolerance strictly between zero and one, the least positive alphabet threshold divided by the calibrated pair scale converges to one.
Formal statement
Proof (Lean source)
ThresholdScale 1 core · 2 supporting The logarithmic tolerance constant is positive, the calibrated pair scale diverges, and positive integer ceilings preserve its collision scale. ★ pairScale_div_positiveCeil_tendsto
Calibrating the birthday collision scale
The logarithmic tolerance constant is positive, the calibrated pair scale diverges, and positive integer ceilings preserve its collision scale.
For valid success probabilities, a diverging expected count, a tolerance between zero and one, and a positive multiplier, the pair scale per positive-ceiling alphabet tends to the logarithmic scale divided by that multiplier.
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
neg_log_one_sub_postheorem — A tolerance strictly between zero and one has a positive logarithmic collision scale.Proof (Lean source)
theorem neg_log_one_sub_pos {delta : ℝ} (hdelta : delta ∈ Ioo (0 : ℝ) 1) : 0 < -log (1 - delta) := by have hpos : 0 < 1 - delta := by linarith [hdelta.2] have hlt : 1 - delta < 1 := by linarith [hdelta.1] exact neg_pos.mpr (Real.log_neg hpos hlt) -
calibratedScale_tendsto_atToptheorem — For valid success probabilities, a diverging expected count, and a tolerance between zero and one, the calibrated pair scale diverges.hypothesesProof (Lean source)
theorem calibratedScale_tendsto_atTop (Tseq : ℕ → ℕ) (etaseq : ℕ → ℝ) {delta : ℝ} (heta : ∀ j, etaseq j ∈ Icc (0 : ℝ) 1) (hmean : Tendsto (fun j => mean (Tseq j) (etaseq j)) atTop atTop) (hdelta : delta ∈ Ioo (0 : ℝ) 1) : Tendsto (fun j => pairScale (Tseq j) (etaseq j) / (-log (1 - delta))) atTop atTop := by have hden : Tendsto (fun j => mean (Tseq j) (etaseq j) ^ 2 / 2) atTop atTop := by simpa [pow_two] using (tendsto_mul_self_atTop.comp hmean).atTop_div_const (by norm_num : (0 : ℝ) < 2) have hpair : Tendsto (fun j => pairScale (Tseq j) (etaseq j)) atTop atTop := by exact Filter.Tendsto.num hden zero_lt_one (pairScale_div_half_mean_sq_tendsto_one Tseq etaseq heta hmean) exact hpair.atTop_div_const (neg_log_one_sub_pos hdelta)