File size: 2,406 Bytes
4a56cd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import Mathlib

namespace OAI

namespace PiExponent.Collision

open scoped BigOperators

variable {G : Type*}

theorem sum_sq_le_card_mul_sum_sq (S : Finset G) (n : G β†’ ℝ) :
    (βˆ‘ a ∈ S, n a) ^ 2 ≀ (S.card : ℝ) * βˆ‘ a ∈ S, n a ^ 2 := by
  simpa using Finset.sum_mul_sq_le_sq_mul_sq S (fun _ : G => (1 : ℝ)) n

theorem sum_sq_le_card_mul_total_sq (S U : Finset G) (hSU : S βŠ† U)
    (n : G β†’ ℝ) :
    (βˆ‘ a ∈ S, n a) ^ 2 ≀ (S.card : ℝ) * βˆ‘ a ∈ U, n a ^ 2 := by
  apply (sum_sq_le_card_mul_sum_sq S n).trans
  apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _)
  exact Finset.sum_le_sum_of_subset_of_nonneg hSU (fun a _ _ => sq_nonneg (n a))

theorem mass_sq_div_card_le_total_sq (S U : Finset G) (hSU : S βŠ† U)
    (n : G β†’ ℝ) {mass : ℝ} (hmass : 0 ≀ mass)
    (hlow : mass ≀ βˆ‘ a ∈ S, n a) (hcard : 0 < S.card) :
    mass ^ 2 / (S.card : ℝ) ≀ βˆ‘ a ∈ U, n a ^ 2 := by
  have hsq : mass ^ 2 ≀ (βˆ‘ a ∈ S, n a) ^ 2 := by
    exact pow_le_pow_leftβ‚€ hmass hlow 2
  have hc : (0 : ℝ) < S.card := by exact_mod_cast hcard
  apply (div_le_iffβ‚€ hc).2
  calc
    mass ^ 2 ≀ (βˆ‘ a ∈ S, n a) ^ 2 := hsq
    _ ≀ (S.card : ℝ) * βˆ‘ a ∈ U, n a ^ 2 :=
      sum_sq_le_card_mul_total_sq S U hSU n
    _ = (βˆ‘ a ∈ U, n a ^ 2) * (S.card : ℝ) := mul_comm _ _

theorem fraction_sq_mul_mass_sq_div_card_le_total_sq
    (S U : Finset G) (hSU : S βŠ† U) (n : G β†’ ℝ)
    {Ξ· M : ℝ} (hΞ· : 0 ≀ Ξ·) (hM : 0 ≀ M)
    (hlow : Ξ· * M ≀ βˆ‘ a ∈ S, n a) (hcard : 0 < S.card) :
    Ξ· ^ 2 * M ^ 2 / (S.card : ℝ) ≀ βˆ‘ a ∈ U, n a ^ 2 := by
  simpa only [mul_pow] using
    mass_sq_div_card_le_total_sq S U hSU n (mul_nonneg hΞ· hM) hlow hcard

variable [Fintype G]

theorem sum_sq_le_card_mul_univ_sq (S : Finset G) (n : G β†’ ℝ) :
    (βˆ‘ a ∈ S, n a) ^ 2 ≀ (S.card : ℝ) * βˆ‘ a, n a ^ 2 := by
  exact sum_sq_le_card_mul_total_sq S Finset.univ (Finset.subset_univ S) n

theorem nat_occupancy_square_lower_bound (S : Finset G) (n : G β†’ β„•)
    {Ξ· : ℝ} {M : β„•} (hΞ· : 0 ≀ Ξ·)
    (hlow : Ξ· * (M : ℝ) ≀ βˆ‘ a ∈ S, (n a : ℝ)) (hcard : 0 < S.card) :
    Ξ· ^ 2 * (M : ℝ) ^ 2 / (S.card : ℝ) ≀ βˆ‘ a, (n a : ℝ) ^ 2 := by
  exact fraction_sq_mul_mass_sq_div_card_le_total_sq S Finset.univ
    (Finset.subset_univ S) (fun a => (n a : ℝ)) hΞ· (Nat.cast_nonneg M) hlow hcard

end PiExponent.Collision

end OAI