File size: 9,438 Bytes
e320e82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import OAI.Combinatorics.GraphThreshold.Basic
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Algebra.BigOperators.Group.Finset.Piecewise
import Mathlib.Data.Nat.Choose.Sum
import Mathlib.Tactic

namespace OAI

/-! Exact intersection counting for a finite, weighted spread family.

No injectivity of the label map and no strict positivity of individual weights
is required. The fixed target is an arbitrary finite set, and may be empty.
-/

noncomputable section

open scoped BigOperators

namespace LeanBlast.SecondKahnKalai

variable {X B : Type*} [DecidableEq X] [Fintype B]

/-- The spread bound also holds for the empty test set, by normalization. -/
theorem IsSpread.containment_le {μ : FiniteLaw B} {A : B → Finset X} {a : ℝ}
    (hs : IsSpread μ A a) (J : Finset X) :
    μ.prob (fun c => J ⊆ A c) ≤ a ^ J.card := by
  classical
  by_cases hJ : J.Nonempty
  · exact hs J hJ
  · have hJ' : J = ∅ := Finset.not_nonempty_iff_eq_empty.mp hJ
    simp [hJ', FiniteLaw.prob, μ.total]

/-- If the intersection has at least `r` points, it contains an `r`-set
from the target. This is the weighted finite union bound. -/
theorem intersection_card_ge_le_subsets (μ : FiniteLaw B) (A : B → Finset X)
    (T : Finset X) (r : ℕ) :
    μ.prob (fun c => r ≤ (A c ∩ T).card) ≤
      ∑ J ∈ T.powersetCard r, μ.prob (fun c => J ⊆ A c) := by
  classical
  unfold FiniteLaw.prob
  rw [Finset.sum_comm]
  apply Finset.sum_le_sum
  intro c hc
  by_cases hcr : r ≤ (A c ∩ T).card
  · rw [ite_eq_left hcr]
    obtain ⟨J, hJ, hJr⟩ := Finset.exists_subset_card_eq hcr
    have hJA : J ⊆ A c := hJ.trans Finset.inter_subset_left
    have hJT : J ⊆ T := hJ.trans Finset.inter_subset_right
    have hm : J ∈ T.powersetCard r := Finset.mem_powersetCard.mpr ⟨hJT, hJr⟩
    have hsingle := Finset.single_le_sum
      (f := fun J : Finset X => if J ⊆ A c then μ.weight c else 0)
      (fun J _ => by split_ifs <;>
        first | exact μ.nonneg c | exact le_rfl) hm
    have hsingle' : μ.weight c ≤
        ∑ J ∈ T.powersetCard r, if J ⊆ A c then μ.weight c else 0 := by
      simpa only [ite_eq_left hJA] using hsingle
    refine hsingle'.trans_eq ?_
    apply Finset.sum_congr rfl
    intro L hL
    by_cases hLA : L ⊆ A c <;> simp [hLA]
  · rw [ite_eq_right hcr]
    exact Finset.sum_nonneg fun J _ => by
      split_ifs <;> first | exact μ.nonneg c | exact le_rfl

/-- Exact binomial count of potential witnesses bounds the intersection tail. -/
theorem intersection_card_ge_le_target {μ : FiniteLaw B} {A : B → Finset X}
    {a : ℝ} (hs : IsSpread μ A a) (T : Finset X) (r : ℕ) :
    μ.prob (fun c => r ≤ (A c ∩ T).card) ≤
      (T.card.choose r : ℝ) * a ^ r := by
  classical
  calc
    μ.prob (fun c => r ≤ (A c ∩ T).card) ≤
        ∑ J ∈ T.powersetCard r, μ.prob (fun c => J ⊆ A c) :=
      intersection_card_ge_le_subsets μ A T r
    _ ≤ ∑ J ∈ T.powersetCard r, a ^ r := by
      apply Finset.sum_le_sum
      intro J hJ
      simpa [(Finset.mem_powersetCard.mp hJ).2] using hs.containment_le J
    _ = (T.card.choose r : ℝ) * a ^ r := by simp

/-- Uniform capacity version, including `r = 0` and empty target sets. -/
theorem intersection_card_ge_le {μ : FiniteLaw B} {A : B → Finset X}
    {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ}
    {T : Finset X} (hT : T.card ≤ m) (r : ℕ) :
    μ.prob (fun c => r ≤ (A c ∩ T).card) ≤
      (m.choose r : ℝ) * a ^ r := by
  apply (intersection_card_ge_le_target hs T r).trans
  apply mul_le_mul_of_nonneg_right _ (pow_nonneg ha r)
  exact_mod_cast Nat.choose_le_choose r hT

/-- The exact intersection histogram is bounded by the same binomial count. -/
theorem intersection_card_eq_le {μ : FiniteLaw B} {A : B → Finset X}
    {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ}
    {T : Finset X} (hT : T.card ≤ m) (r : ℕ) :
    μ.prob (fun c => (A c ∩ T).card = r) ≤
      (m.choose r : ℝ) * a ^ r := by
  classical
  apply le_trans _ (intersection_card_ge_le hs ha hT r)
  unfold FiniteLaw.prob
  apply Finset.sum_le_sum
  intro c hc
  by_cases hcr : (A c ∩ T).card = r
  · simp [hcr]
  · simp only [ite_eq_right hcr]
    split_ifs <;> first | exact μ.nonneg c | exact le_rfl

/-- Reindex any function of the intersection by the exact finite histogram. -/
theorem expectation_intersection_eq_sum (μ : FiniteLaw B) (A : B → Finset X)
    {m : ℕ} {T : Finset X} (hT : T.card ≤ m) (g : ℕ → ℝ) :
    μ.expectation (fun c => g (A c ∩ T).card) =
      ∑ r ∈ Finset.range (m + 1),
        μ.prob (fun c => (A c ∩ T).card = r) * g r := by
  classical
  unfold FiniteLaw.expectation FiniteLaw.prob
  simp_rw [Finset.sum_mul, ite_mul, zero_mul]
  rw [Finset.sum_comm]
  apply Finset.sum_congr rfl
  intro c hc
  have hcm : (A c ∩ T).card ∈ Finset.range (m + 1) := by
    apply Finset.mem_range.mpr
    have hct := Finset.card_le_card (Finset.inter_subset_right (s₁ := A c) (s₂ := T))
    omega
  simp [hcm]

/-- Any nonnegative function of the intersection admits a binomial majorant. -/
theorem expectation_intersection_le_binomial {μ : FiniteLaw B} {A : B → Finset X}
    {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ}
    {T : Finset X} (hT : T.card ≤ m) (g : ℕ → ℝ) (hg : ∀ r, 0 ≤ g r) :
    μ.expectation (fun c => g (A c ∩ T).card) ≤
      ∑ r ∈ Finset.range (m + 1), (m.choose r : ℝ) * a ^ r * g r := by
  rw [expectation_intersection_eq_sum μ A hT g]
  exact Finset.sum_le_sum fun r _ =>
    mul_le_mul_of_nonneg_right (intersection_card_eq_le hs ha hT r) (hg r)

/-- A predicate can truncate the intersection generating function arbitrarily. -/
theorem intersection_truncated_moment_le {μ : FiniteLaw B} {A : B → Finset X}
    {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ}
    {T : Finset X} (hT : T.card ≤ m) {t : ℝ} (ht : 0 ≤ t)
    (Q : ℕ → Prop) [DecidablePred Q] :
    μ.expectation (fun c => if Q (A c ∩ T).card then t ^ (A c ∩ T).card else 0) ≤
      ∑ r ∈ Finset.range (m + 1),
        if Q r then (m.choose r : ℝ) * (a * t) ^ r else 0 := by
  calc
    _ ≤ ∑ r ∈ Finset.range (m + 1),
        (m.choose r : ℝ) * a ^ r * (if Q r then t ^ r else 0) := by
      apply expectation_intersection_le_binomial hs ha hT
        (fun r => if Q r then t ^ r else 0)
      intro r
      split_ifs <;> first | exact pow_nonneg ht r | exact le_rfl
    _ = _ := by
      apply Finset.sum_congr rfl
      intro r hr
      by_cases hQ : Q r <;> simp [hQ, mul_pow, mul_assoc]

/-- Raw-sum form of the truncated moment estimate. -/
theorem intersection_truncated_sum_le {μ : FiniteLaw B} {A : B → Finset X}
    {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ}
    {T : Finset X} (hT : T.card ≤ m) {t : ℝ} (ht : 0 ≤ t)
    (Q : ℕ → Prop) [DecidablePred Q] :
    (∑ c, if Q (A c ∩ T).card then μ.weight c * t ^ (A c ∩ T).card else 0) ≤
      ∑ r ∈ Finset.range (m + 1),
        if Q r then (m.choose r : ℝ) * (a * t) ^ r else 0 := by
  simpa only [FiniteLaw.expectation, mul_ite, mul_zero] using
    intersection_truncated_moment_le hs ha hT ht Q

/-- The full generating-function bound needs only a nonnegative argument. -/
theorem intersection_moment_le {μ : FiniteLaw B} {A : B → Finset X}
    {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ}
    {T : Finset X} (hT : T.card ≤ m) {t : ℝ} (ht : 0 ≤ t) :
    μ.expectation (fun c => t ^ (A c ∩ T).card) ≤ (1 + a * t) ^ m := by
  calc
    _ ≤ ∑ r ∈ Finset.range (m + 1), (m.choose r : ℝ) * a ^ r * t ^ r :=
      expectation_intersection_le_binomial hs ha hT _ (fun r => pow_nonneg ht r)
    _ = (1 + a * t) ^ m := by
      rw [add_comm 1 (a * t), add_pow]
      apply Finset.sum_congr rfl
      intro r hr
      simp only [one_pow, mul_one, mul_pow]
      ring

/-- Inverse-parameter moment used by the resampling density estimate. -/
theorem intersection_inverse_moment_le {μ : FiniteLaw B} {A : B → Finset X}
    {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ}
    {T : Finset X} (hT : T.card ≤ m) {ρ : ℝ} (hρ : 0 < ρ) :
    μ.expectation (fun c => (ρ⁻¹) ^ (A c ∩ T).card) ≤ (1 + a / ρ) ^ m := by
  simpa only [div_eq_mul_inv] using
    intersection_moment_le hs ha hT (inv_nonneg.mpr hρ.le)

/-- Raw-sum form of the inverse-parameter moment. -/
theorem intersection_inverse_sum_le {μ : FiniteLaw B} {A : B → Finset X}
    {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ}
    {T : Finset X} (hT : T.card ≤ m) {ρ : ℝ} (hρ : 0 < ρ) :
    (∑ c, μ.weight c * (ρ⁻¹) ^ (A c ∩ T).card) ≤ (1 + a / ρ) ^ m :=
  intersection_inverse_moment_le hs ha hT hρ

/-- Inverse-parameter truncated moment, retaining an arbitrary tail predicate. -/
theorem intersection_inverse_truncated_sum_le
    {μ : FiniteLaw B} {A : B → Finset X} {a : ℝ}
    (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ}
    {T : Finset X} (hT : T.card ≤ m) {ρ : ℝ} (hρ : 0 < ρ)
    (Q : ℕ → Prop) [DecidablePred Q] :
    (∑ c, if Q (A c ∩ T).card then μ.weight c * (ρ⁻¹) ^ (A c ∩ T).card else 0) ≤
      ∑ r ∈ Finset.range (m + 1),
        if Q r then (m.choose r : ℝ) * (a / ρ) ^ r else 0 := by
  simpa only [div_eq_mul_inv] using
    intersection_truncated_sum_le hs ha hT (inv_nonneg.mpr hρ.le) Q

end LeanBlast.SecondKahnKalai

end

end OAI