Catalog/VC/EpsilonNetTheorem/Full.lean
| 1 | import Catalog.VC.VCDimension.Full |
| 2 | import Catalog.VC.EpsilonNet.Full |
| 3 | import Catalog.VC.EpsilonApproximation.Full |
| 4 | import Catalog.VC.EpsilonApproximationBound.Full |
| 5 | import Catalog.VC.EasyEpsilonNetLemma.Full |
| 6 | import Mathlib.Analysis.SpecialFunctions.Log.Basic |
| 7 | import Mathlib.Analysis.Complex.ExponentialBounds |
| 8 | |
| 9 | namespace Catalog.VC.EpsilonNetTheorem |
| 10 | |
| 11 | open Real |
| 12 | |
| 13 | /-! ## Helper lemmas -/ |
| 14 | |
| 15 | /-- The trace family obtained by restricting each `S β π` to `Y`, |
| 16 | viewed as a family on the subtype `Y`. -/ |
| 17 | private noncomputable def traceFamily {Ξ± : Type*} [DecidableEq Ξ±] |
| 18 | (π : Finset (Finset Ξ±)) (Y : Finset Ξ±) : Finset (Finset Y) := |
| 19 | π.image (fun S => S.subtype (Β· β Y)) |
| 20 | |
| 21 | /-- If the trace family on `Y` shatters `s`, then `π` shatters |
| 22 | `s.map Subtype.val` (which has the same cardinality). -/ |
| 23 | private lemma traceFamily_shatters {Ξ± : Type*} [DecidableEq Ξ±] |
| 24 | (π : Finset (Finset Ξ±)) (Y : Finset Ξ±) (s : Finset Y) |
| 25 | (hs : (traceFamily π Y).Shatters s) : |
| 26 | π.Shatters (s.map (Function.Embedding.subtype _)) := by |
| 27 | intro tΞ± htΞ± |
| 28 | -- tΞ± β s.map val. Pull back to Y. |
| 29 | set sΞ± : Finset Ξ± := s.map (Function.Embedding.subtype _) with hsΞ± |
| 30 | -- Each element of tΞ± belongs to Y. |
| 31 | have htΞ±_Y : β x β tΞ±, x β Y := by |
| 32 | intro x hx |
| 33 | have : x β sΞ± := htΞ± hx |
| 34 | rw [hsΞ±, Finset.mem_map] at this |
| 35 | obtain β¨y, _, rflβ© := this |
| 36 | exact y.2 |
| 37 | -- Build t : Finset Y as the subtype of tΞ± |
| 38 | let t : Finset Y := tΞ±.subtype (Β· β Y) |
| 39 | have ht_sub : t β s := by |
| 40 | intro y hy |
| 41 | simp only [t, Finset.mem_subtype] at hy |
| 42 | have hy_sΞ± : (y : Ξ±) β sΞ± := htΞ± hy |
| 43 | rw [hsΞ±, Finset.mem_map] at hy_sΞ± |
| 44 | obtain β¨y', hy', heqβ© := hy_sΞ± |
| 45 | have : y = y' := Subtype.ext heq.symm |
| 46 | rw [this]; exact hy' |
| 47 | obtain β¨u', hu'_mem, hu'_eqβ© := hs ht_sub |
| 48 | rw [traceFamily, Finset.mem_image] at hu'_mem |
| 49 | obtain β¨S, hS_mem, rflβ© := hu'_mem |
| 50 | refine β¨S, hS_mem, ?_β© |
| 51 | ext x |
| 52 | simp only [Finset.mem_inter, hsΞ±, Finset.mem_map, Function.Embedding.subtype] |
| 53 | constructor |
| 54 | Β· rintro β¨β¨y, hy_s, rflβ©, hySβ© |
| 55 | have hy_in : y β s β© S.subtype (Β· β Y) := by |
| 56 | refine Finset.mem_inter.mpr β¨hy_s, ?_β© |
| 57 | simpa [Finset.mem_subtype] using hyS |
| 58 | rw [hu'_eq] at hy_in |
| 59 | simp only [t, Finset.mem_subtype] at hy_in |
| 60 | exact hy_in |
| 61 | Β· intro hxt |
| 62 | have hxY : x β Y := htΞ±_Y x hxt |
| 63 | have : (β¨x, hxYβ© : Y) β t := by |
| 64 | simp [t, Finset.mem_subtype, hxt] |
| 65 | rw [β hu'_eq] at this |
| 66 | rw [Finset.mem_inter] at this |
| 67 | obtain β¨h1, h2β© := this |
| 68 | refine β¨β¨β¨x, hxYβ©, h1, rflβ©, ?_β© |
| 69 | simpa [Finset.mem_subtype] using h2 |
| 70 | |
| 71 | /-- Restricting the family to `Y` cannot increase VC-dimension. -/ |
| 72 | private lemma traceFamily_vcDim_le {Ξ± : Type*} [DecidableEq Ξ±] |
| 73 | (π : Finset (Finset Ξ±)) (Y : Finset Ξ±) : |
| 74 | (traceFamily π Y).vcDim β€ π.vcDim := by |
| 75 | unfold Finset.vcDim |
| 76 | refine Finset.sup_le ?_ |
| 77 | intro s hs |
| 78 | rw [Finset.mem_shatterer] at hs |
| 79 | have h := traceFamily_shatters π Y s hs |
| 80 | have hcard := h.card_le_vcDim |
| 81 | rwa [Finset.card_map] at hcard |
| 82 | |
| 83 | /-- Cardinality of the subtype-restricted set in real numbers. -/ |
| 84 | private lemma card_subtype_eq_inter {Ξ± : Type*} [DecidableEq Ξ±] |
| 85 | (Y S : Finset Ξ±) : |
| 86 | ((S.subtype (Β· β Y) : Finset Y).card : β) = ((S β© Y).card : β) := by |
| 87 | norm_cast |
| 88 | rw [Finset.card_subtype, β Finset.filter_mem_eq_inter] |
| 89 | |
| 90 | /-- Sauer-Shelah bound applied to the trace family on `Y`: |
| 91 | `|traceFamily π Y| β€ β_{kβ€d} (|Y| choose k) β€ (d+1)*(|Y|+1)^d`. -/ |
| 92 | private lemma traceFamily_card_le {Ξ± : Type*} [DecidableEq Ξ±] |
| 93 | (π : Finset (Finset Ξ±)) (d : β) (hd : π.vcDim β€ d) (Y : Finset Ξ±) : |
| 94 | ((traceFamily π Y).card : β) β€ (d + 1 : β) * (Y.card + 1 : β) ^ d := by |
| 95 | classical |
| 96 | set π' := traceFamily π Y |
| 97 | have h1 : π'.card β€ β k β Finset.Iic π'.vcDim, (Fintype.card Y).choose k := |
| 98 | le_trans π'.card_le_card_shatterer Finset.card_shatterer_le_sum_vcDim |
| 99 | have hdim : π'.vcDim β€ d := |
| 100 | le_trans (traceFamily_vcDim_le π Y) hd |
| 101 | have h2 : β k β Finset.Iic π'.vcDim, (Fintype.card Y).choose k |
| 102 | β€ β k β Finset.Iic d, (Fintype.card Y).choose k := by |
| 103 | apply Finset.sum_le_sum_of_subset |
| 104 | intro k hk |
| 105 | simp only [Finset.mem_Iic] at * |
| 106 | exact le_trans hk hdim |
| 107 | have h3 : π'.card β€ β k β Finset.Iic d, (Y.card).choose k := by |
| 108 | have := h1.trans h2 |
| 109 | simpa [Fintype.card_coe] using this |
| 110 | -- Now β_{kβ€d} (n.choose k) β€ (d+1) * (n+1)^d |
| 111 | have hbound : (β k β Finset.Iic d, (Y.card).choose k : β) |
| 112 | β€ (d + 1 : β) * (Y.card + 1 : β) ^ d := by |
| 113 | have hsum : (β k β Finset.Iic d, ((Y.card).choose k : β)) |
| 114 | β€ β _k β Finset.Iic d, ((Y.card + 1 : β) ^ d) := by |
| 115 | apply Finset.sum_le_sum |
| 116 | intro k hk |
| 117 | simp only [Finset.mem_Iic] at hk |
| 118 | have h_nat : ((Y.card).choose k : β) β€ (Y.card : β) ^ k := by |
| 119 | exact_mod_cast Nat.choose_le_pow Y.card k |
| 120 | have h_pow : (Y.card : β) ^ k β€ (Y.card + 1 : β) ^ d := by |
| 121 | have h_le : (Y.card : β) β€ Y.card + 1 := by linarith |
| 122 | have h_nn : (0 : β) β€ Y.card := by positivity |
| 123 | have h1 : (Y.card : β) ^ k β€ (Y.card + 1 : β) ^ k := |
| 124 | pow_le_pow_leftβ h_nn h_le k |
| 125 | have h2 : (Y.card + 1 : β) ^ k β€ (Y.card + 1 : β) ^ d := by |
| 126 | apply pow_le_pow_rightβ |
| 127 | Β· linarith |
| 128 | Β· exact hk |
| 129 | linarith |
| 130 | linarith |
| 131 | have : (β k β Finset.Iic d, (Y.card).choose k : β) |
| 132 | = β k β Finset.Iic d, ((Y.card).choose k : β) := rfl |
| 133 | rw [this] |
| 134 | refine hsum.trans ?_ |
| 135 | rw [Finset.sum_const, Nat.card_Iic, nsmul_eq_mul] |
| 136 | have h4 : ((traceFamily π Y).card : β) β€ (β k β Finset.Iic d, (Y.card).choose k : β) := by |
| 137 | exact_mod_cast h3 |
| 138 | exact h4.trans hbound |
| 139 | |
| 140 | /-- Analytic constant: given `Cβ > 0` and `d : β`, produce `C > 0` such that |
| 141 | for all `r β₯ 2` and all `m β₯ 0` with |
| 142 | `m β€ (d+1) * (Cβ Β· (4r)Β² Β· log(4r) + 1)^d`, |
| 143 | we have `2r Β· log m + 1 β€ C Β· r Β· log r`. -/ |
| 144 | private lemma analytic_constant (Cβ : β) (hCβ : 0 < Cβ) (d : β) : |
| 145 | β C : β, 1 β€ C β§ β (r : β), 2 β€ r β |
| 146 | β (m : β), 0 < m β m β€ ((d : β) + 1) * (Cβ * (4*r)^2 * Real.log (4*r) + 1)^d β |
| 147 | 2 * r * Real.log m + 1 β€ C * r * Real.log r := by |
| 148 | have hlog2_pos : 0 < Real.log 2 := Real.log_pos one_lt_two |
| 149 | have hlog2_gt : (1 : β) / 2 < Real.log 2 := by |
| 150 | have := Real.log_two_gt_d9; linarith |
| 151 | have hbase_pos : (0 : β) < 64 * Cβ + 1 := by linarith |
| 152 | have hbase_gt1 : (1 : β) < 64 * Cβ + 1 := by linarith |
| 153 | set K : β := Real.log ((d : β) + 1) + (d : β) * Real.log (64 * Cβ + 1) with hK_def |
| 154 | have hd_nn : (0 : β) β€ (d : β) := by exact_mod_cast Nat.zero_le d |
| 155 | have hK_nn : 0 β€ K := by |
| 156 | have h1 : (0 : β) β€ Real.log ((d : β) + 1) := |
| 157 | Real.log_nonneg (by linarith) |
| 158 | have h2 : (0 : β) β€ (d : β) * Real.log (64 * Cβ + 1) := |
| 159 | mul_nonneg hd_nn (Real.log_nonneg hbase_gt1.le) |
| 160 | linarith |
| 161 | set L : β := K / Real.log 2 + 3 * (d : β) with hL_def |
| 162 | have hL_nn : 0 β€ L := by |
| 163 | have h1 : 0 β€ K / Real.log 2 := div_nonneg hK_nn hlog2_pos.le |
| 164 | have h2 : 0 β€ 3 * (d : β) := by linarith |
| 165 | linarith |
| 166 | set C : β := 2 * L + 1 / Real.log 2 + 1 with hC_def |
| 167 | have hlog2_lt1 : Real.log 2 < 1 := by |
| 168 | have := Real.log_two_lt_d9; linarith |
| 169 | have hinv_ge : (1 : β) β€ 1 / Real.log 2 := by |
| 170 | rw [le_div_iffβ hlog2_pos]; linarith |
| 171 | refine β¨C, by linarith, ?_β© |
| 172 | intro r hr m hm_pos hm_le |
| 173 | have hr_pos : 0 < r := by linarith |
| 174 | have hlogr_pos : 0 < Real.log r := Real.log_pos (by linarith) |
| 175 | have hlogr_ge_log2 : Real.log 2 β€ Real.log r := |
| 176 | Real.log_le_log (by norm_num) hr |
| 177 | -- r Β· log r β₯ 1 |
| 178 | have hrlogr_ge1 : (1 : β) β€ r * Real.log r := by |
| 179 | nlinarith [hlogr_ge_log2, hlog2_gt, hr] |
| 180 | -- Bound on M := CβΒ·(4r)Β² Β· log(4r) + 1 |
| 181 | set M : β := Cβ * (4 * r) ^ 2 * Real.log (4 * r) + 1 with hM_def |
| 182 | have h4r_pos : 0 < 4 * r := by linarith |
| 183 | have h4r_ge1 : (1 : β) β€ 4 * r := by linarith |
| 184 | have hlog4r_nn : 0 β€ Real.log (4 * r) := Real.log_nonneg h4r_ge1 |
| 185 | have hlog4r_le : Real.log (4 * r) β€ 4 * r := Real.log_le_self h4r_pos.le |
| 186 | have hM_pos : 0 < M := by |
| 187 | have : 0 β€ Cβ * (4 * r) ^ 2 * Real.log (4 * r) := by positivity |
| 188 | linarith |
| 189 | have hr3_ge1 : (1 : β) β€ r ^ 3 := by nlinarith |
| 190 | have hr3_pos : 0 < r ^ 3 := by positivity |
| 191 | have hM_le : M β€ (64 * Cβ + 1) * r ^ 3 := by |
| 192 | have hbody : Cβ * (4 * r) ^ 2 * Real.log (4 * r) β€ 64 * Cβ * r ^ 3 := by |
| 193 | have hsq : (4 * r) ^ 2 = 16 * r ^ 2 := by ring |
| 194 | rw [hsq] |
| 195 | have h1 : Cβ * (16 * r ^ 2) * Real.log (4 * r) |
| 196 | β€ Cβ * (16 * r ^ 2) * (4 * r) := |
| 197 | mul_le_mul_of_nonneg_left hlog4r_le (by positivity) |
| 198 | nlinarith [h1] |
| 199 | nlinarith [hbody, hr3_ge1, hCβ] |
| 200 | have hRHS_pos : 0 < (64 * Cβ + 1) * r ^ 3 := by positivity |
| 201 | have hlogM_le : Real.log M β€ Real.log (64 * Cβ + 1) + 3 * Real.log r := by |
| 202 | have h1 : Real.log M β€ Real.log ((64 * Cβ + 1) * r ^ 3) := |
| 203 | Real.log_le_log hM_pos hM_le |
| 204 | have h2 : Real.log ((64 * Cβ + 1) * r ^ 3) |
| 205 | = Real.log (64 * Cβ + 1) + 3 * Real.log r := by |
| 206 | rw [Real.log_mul hbase_pos.ne' hr3_pos.ne', Real.log_pow] |
| 207 | push_cast; ring |
| 208 | linarith |
| 209 | -- Bound on log of upper bound |
| 210 | set U : β := ((d : β) + 1) * M ^ d with hU_def |
| 211 | have hd1_pos : (0 : β) < (d : β) + 1 := by linarith |
| 212 | have hMd_pos : 0 < M ^ d := pow_pos hM_pos d |
| 213 | have hU_pos : 0 < U := mul_pos hd1_pos hMd_pos |
| 214 | have hlogU_eq : Real.log U |
| 215 | = Real.log ((d : β) + 1) + (d : β) * Real.log M := by |
| 216 | rw [hU_def, Real.log_mul hd1_pos.ne' hMd_pos.ne', Real.log_pow] |
| 217 | have hlogU_le : Real.log U β€ K + 3 * (d : β) * Real.log r := by |
| 218 | rw [hlogU_eq] |
| 219 | have h1 : (d : β) * Real.log M |
| 220 | β€ (d : β) * (Real.log (64 * Cβ + 1) + 3 * Real.log r) := |
| 221 | mul_le_mul_of_nonneg_left hlogM_le hd_nn |
| 222 | have h2 : (d : β) * (Real.log (64 * Cβ + 1) + 3 * Real.log r) |
| 223 | = (d : β) * Real.log (64 * Cβ + 1) + 3 * (d : β) * Real.log r := by |
| 224 | ring |
| 225 | rw [hK_def]; linarith |
| 226 | have hlogm_le : Real.log m β€ K + 3 * (d : β) * Real.log r := |
| 227 | le_trans (Real.log_le_log hm_pos hm_le) hlogU_le |
| 228 | -- K β€ (K / log 2) Β· log r since log r β₯ log 2 and K β₯ 0 |
| 229 | have hK_le : K β€ (K / Real.log 2) * Real.log r := by |
| 230 | rw [div_mul_eq_mul_div, le_div_iffβ hlog2_pos] |
| 231 | exact mul_le_mul_of_nonneg_left hlogr_ge_log2 hK_nn |
| 232 | -- 2 r log m β€ 2 L Β· r Β· log r |
| 233 | have h2r_nn : (0 : β) β€ 2 * r := by linarith |
| 234 | have hstep1 : 2 * r * Real.log m |
| 235 | β€ 2 * r * (K + 3 * (d : β) * Real.log r) := |
| 236 | mul_le_mul_of_nonneg_left hlogm_le h2r_nn |
| 237 | have hstep2 : 2 * r * (K + 3 * (d : β) * Real.log r) |
| 238 | β€ 2 * L * (r * Real.log r) := by |
| 239 | have hK_mul : 2 * r * K β€ 2 * r * ((K / Real.log 2) * Real.log r) := |
| 240 | mul_le_mul_of_nonneg_left hK_le h2r_nn |
| 241 | have hexpand : 2 * r * ((K / Real.log 2) * Real.log r) + 2 * r * (3 * (d : β) * Real.log r) |
| 242 | = 2 * L * (r * Real.log r) := by |
| 243 | rw [hL_def]; ring |
| 244 | linarith |
| 245 | -- 1 β€ (1/log 2 + 1) Β· r Β· log r |
| 246 | have htail : (1 : β) β€ (1 / Real.log 2 + 1) * (r * Real.log r) := by |
| 247 | have h1 : (1 : β) β€ 1 * (r * Real.log r) := by linarith |
| 248 | have h2 : 0 β€ (1 / Real.log 2) * (r * Real.log r) := by |
| 249 | apply mul_nonneg (by positivity) |
| 250 | linarith |
| 251 | nlinarith |
| 252 | have hCexpand : C * r * Real.log r |
| 253 | = 2 * L * (r * Real.log r) + (1 / Real.log 2 + 1) * (r * Real.log r) := by |
| 254 | rw [hC_def]; ring |
| 255 | rw [hCexpand] |
| 256 | linarith [hstep1, hstep2, htail] |
| 257 | |
| 258 | /-! ## Main theorem -/ |
| 259 | |
| 260 | theorem epsilonNetTheorem (d : β) : β C : β, 0 < C β§ |
| 261 | β (Ξ± : Type*) [DecidableEq Ξ±] [Fintype Ξ±] [Nonempty Ξ±] (π : Finset (Finset Ξ±)), |
| 262 | π.vcDim β€ d β |
| 263 | β (r : β), 2 β€ r β |
| 264 | β N : Finset Ξ±, Catalog.VC.EpsilonNet.IsEpsilonNet π (1 / r) N β§ |
| 265 | (N.card : β) β€ C * r * Real.log r := by |
| 266 | obtain β¨Cβ, hCβ_pos, happroxβ© := Catalog.VC.EpsilonApproximationBound.epsilonApproxBound d |
| 267 | obtain β¨C, hC_ge_one, hCboundβ© := analytic_constant Cβ hCβ_pos d |
| 268 | have hC_pos : 0 < C := lt_of_lt_of_le one_pos hC_ge_one |
| 269 | refine β¨C, hC_pos, ?_β© |
| 270 | intro Ξ± _ _ _ π hd r hr |
| 271 | -- Apply approxBound at parameter 4r |
| 272 | have hr_pos : 0 < r := by linarith |
| 273 | have h4r : (2 : β) β€ 4 * r := by linarith |
| 274 | have h4r_pos : 0 < 4 * r := by linarith |
| 275 | have h4r_one : (1 : β) < 4 * r := by linarith |
| 276 | obtain β¨Y, hY_approx, hY_sizeβ© := happrox Ξ± π hd (4 * r) h4r |
| 277 | set π' : Finset (Finset Y) := traceFamily π Y with hπ'_def |
| 278 | -- Case split on |π'| β₯ 2 |
| 279 | by_cases hcard : 2 β€ π'.card |
| 280 | Β· -- Apply easyEpsilonNetLemma with parameter 2r |
| 281 | have h2r_one : (1 : β) < 2 * r := by linarith |
| 282 | obtain β¨N_Ξ², hN_net, hN_sizeβ© := |
| 283 | Catalog.VC.EasyEpsilonNetLemma.easyEpsilonNetLemma π' hcard (r := 2 * r) h2r_one |
| 284 | refine β¨N_Ξ².image (Subtype.val), ?_, ?_β© |
| 285 | Β· -- IsEpsilonNet π (1/r) N |
| 286 | intro S hS hheavy |
| 287 | -- The trace S' = S.subtype (Β· β Y) |
| 288 | let S' : Finset Y := S.subtype (Β· β Y) |
| 289 | have hS'_mem : S' β π' := by |
| 290 | rw [hπ'_def, traceFamily, Finset.mem_image] |
| 291 | exact β¨S, hS, rflβ© |
| 292 | -- approx gives: |S'|/|Y| β₯ |S|/|Ξ±| - 1/(4r) β₯ 1/r - 1/(4r) = 3/(4r) β₯ 1/(2r) |
| 293 | have hY_approx_S := hY_approx S hS |
| 294 | have hΞ±_pos : (0 : β) < Fintype.card Ξ± := by |
| 295 | exact_mod_cast (Fintype.card_pos : 0 < Fintype.card Ξ±) |
| 296 | have hSdens_lb : (1 : β) / r β€ (S.card : β) / Fintype.card Ξ± := by |
| 297 | rw [le_div_iffβ hΞ±_pos] |
| 298 | linarith [hheavy] |
| 299 | have happrox_bound : |((S β© Y).card : β) / Y.card - (S.card : β) / Fintype.card Ξ±| β€ 1 / (4 * r) := |
| 300 | hY_approx S hS |
| 301 | have hcardY_pos : 0 < (Y.card : β) := by |
| 302 | -- if Y.card = 0, then 0/0 - S.card/|Ξ±| has |.| β€ 1/(4r) but S.card/|Ξ±| β₯ 1/r > 1/(4r) |
| 303 | rcases (Y.card.eq_zero_or_pos) with hY0 | hYp |
| 304 | Β· exfalso |
| 305 | have hYempty : Y = β := Finset.card_eq_zero.mp hY0 |
| 306 | rw [hYempty] at happrox_bound |
| 307 | simp at happrox_bound |
| 308 | have heq : (rβ»ΒΉ * 4β»ΒΉ : β) = 1 / (4 * r) := by ring |
| 309 | rw [heq] at happrox_bound |
| 310 | have habs := abs_le.mp happrox_bound |
| 311 | have h14 : (1 : β) / (4 * r) < 1 / r := by |
| 312 | apply one_div_lt_one_div_of_lt hr_pos; linarith |
| 313 | linarith [habs.2] |
| 314 | Β· exact_mod_cast hYp |
| 315 | have hcardYR_pos : 0 < (Fintype.card Y : β) := by |
| 316 | rw [Fintype.card_coe]; exact hcardY_pos |
| 317 | have hS'_card : (S'.card : β) = ((S β© Y).card : β) := card_subtype_eq_inter Y S |
| 318 | -- |S'|/|Y| β₯ 1/r - 1/(4r) β₯ 1/(2r) |
| 319 | have h_inner : 1 / (2 * r) β€ (S'.card : β) / (Fintype.card Y : β) := by |
| 320 | rw [hS'_card, Fintype.card_coe] |
| 321 | have habs := abs_le.mp happrox_bound |
| 322 | have h1 : (S.card : β) / Fintype.card Ξ± - 1/(4*r) β€ ((S β© Y).card : β) / Y.card := by |
| 323 | linarith |
| 324 | have h14 : (1 : β) / r - 1 / (4*r) = 3 / (4*r) := by field_simp; ring |
| 325 | have h_mono : (1 : β) / (2*r) β€ 3 / (4*r) := by |
| 326 | rw [div_le_div_iffβ (by linarith : (0:β) < 2*r) (by linarith : (0:β) < 4*r)] |
| 327 | linarith |
| 328 | linarith |
| 329 | have hS'_heavy : 1 / (2 * r) * (Fintype.card Y : β) β€ (S'.card : β) := by |
| 330 | rw [β le_div_iffβ hcardYR_pos] |
| 331 | exact h_inner |
| 332 | have hN_S' := hN_net S' hS'_mem hS'_heavy |
| 333 | obtain β¨x, hxβ© := hN_S' |
| 334 | rw [Finset.mem_inter] at hx |
| 335 | have hx_S : (x : Ξ±) β S := by |
| 336 | have := hx.2 |
| 337 | simp only [S', Finset.mem_subtype] at this |
| 338 | exact this |
| 339 | refine β¨(x : Ξ±), ?_β© |
| 340 | rw [Finset.mem_inter] |
| 341 | refine β¨?_, hx_Sβ© |
| 342 | exact Finset.mem_image.mpr β¨x, hx.1, rflβ© |
| 343 | Β· -- size bound |
| 344 | have h_image_le : ((N_Ξ².image Subtype.val).card : β) β€ (N_Ξ².card : β) := by |
| 345 | exact_mod_cast Finset.card_image_le |
| 346 | have hπ'_pos : (0 : β) < π'.card := by exact_mod_cast (by omega : 0 < π'.card) |
| 347 | have hπ'_bound : ((traceFamily π Y).card : β) β€ |
| 348 | ((d : β) + 1) * ((Y.card : β) + 1) ^ d := by |
| 349 | have := traceFamily_card_le π d hd Y |
| 350 | convert this using 2; push_cast; ring |
| 351 | have hY_size_R : (Y.card : β) β€ Cβ * (4 * r) ^ 2 * Real.log (4 * r) := hY_size |
| 352 | have hYcard_nn : (0 : β) β€ (Y.card : β) := by positivity |
| 353 | -- (Y.card+1)^d β€ (CβΒ·(4r)Β²Β·log(4r)+1)^d |
| 354 | have hYp1_bound : ((Y.card : β) + 1) ^ d |
| 355 | β€ (Cβ * (4 * r) ^ 2 * Real.log (4 * r) + 1) ^ d := by |
| 356 | apply pow_le_pow_leftβ (by linarith) (by linarith) |
| 357 | have hm_bound : ((d : β) + 1) * ((Y.card : β) + 1) ^ d |
| 358 | β€ ((d : β) + 1) * (Cβ * (4 * r) ^ 2 * Real.log (4 * r) + 1) ^ d := by |
| 359 | apply mul_le_mul_of_nonneg_left hYp1_bound (by positivity) |
| 360 | have hm_nn : (0 : β) < ((traceFamily π Y).card : β) := hπ'_pos |
| 361 | have hN_log_le : 2 * r * Real.log ((traceFamily π Y).card : β) + 1 β€ C * r * Real.log r := by |
| 362 | apply hCbound r hr |
| 363 | Β· exact hm_nn |
| 364 | Β· exact hπ'_bound.trans hm_bound |
| 365 | have hN_size' : (N_Ξ².card : β) β€ 2 * r * Real.log ((traceFamily π Y).card : β) + 1 := by |
| 366 | have := hN_size |
| 367 | show (N_Ξ².card : β) β€ 2 * r * Real.log (π'.card : β) + 1 |
| 368 | exact this |
| 369 | linarith |
| 370 | Β· -- π'.card < 2, i.e., β€ 1. |
| 371 | push_neg at hcard |
| 372 | have hcard' : π'.card β€ 1 := Nat.lt_succ_iff.mp hcard |
| 373 | -- We'll show |N| β€ 1 β€ C * r * log r. |
| 374 | have hlog2_pos : 0 < Real.log 2 := Real.log_pos (by norm_num) |
| 375 | have hlog_r_pos : 0 < Real.log r := Real.log_pos (by linarith) |
| 376 | have hlog2_lb : (1 : β) / 2 β€ Real.log 2 := by |
| 377 | have := Real.log_two_gt_d9; linarith |
| 378 | have hlogr_lb : Real.log 2 β€ Real.log r := Real.log_le_log (by norm_num) hr |
| 379 | have hone_le : (1 : β) β€ C * r * Real.log r := by |
| 380 | have h1 : (1 : β) β€ C := hC_ge_one |
| 381 | have hlogr_lb' : (1 : β) / 2 β€ Real.log r := le_trans hlog2_lb hlogr_lb |
| 382 | have h2 : (1 : β) β€ r * Real.log r := by |
| 383 | have : (1 : β) = 2 * (1/2) := by norm_num |
| 384 | rw [this] |
| 385 | exact mul_le_mul hr hlogr_lb' (by norm_num) (by linarith) |
| 386 | calc (1 : β) = 1 * 1 := by ring |
| 387 | _ β€ C * (r * Real.log r) := mul_le_mul h1 h2 (by norm_num) (by linarith) |
| 388 | _ = C * r * Real.log r := by ring |
| 389 | by_cases hπ_empty : π.Nonempty |
| 390 | Β· obtain β¨Sβ, hSββ© := hπ_empty |
| 391 | let T : Finset Y := Sβ.subtype (Β· β Y) |
| 392 | have hT_mem : T β π' := Finset.mem_image.mpr β¨Sβ, hSβ, rflβ© |
| 393 | -- All traces in π' equal T (since π'.card β€ 1) |
| 394 | have hall_T : β S β π, (S.subtype (Β· β Y) : Finset Y) = T := by |
| 395 | intro S hS |
| 396 | have hS_mem : (S.subtype (Β· β Y) : Finset Y) β π' := |
| 397 | Finset.mem_image.mpr β¨S, hS, rflβ© |
| 398 | -- π'.card β€ 1 and both elements in, so equal |
| 399 | have := Finset.card_le_one.mp hcard' |
| 400 | exact this _ hS_mem _ hT_mem |
| 401 | by_cases hT_empty : T.Nonempty |
| 402 | Β· obtain β¨x, hxTβ© := hT_empty |
| 403 | refine β¨{(x : Ξ±)}, ?_, ?_β© |
| 404 | Β· intro S hS _hheavy |
| 405 | have hSeq := hall_T S hS |
| 406 | have hxS' : x β (S.subtype (Β· β Y) : Finset Y) := by rw [hSeq]; exact hxT |
| 407 | rw [Finset.mem_subtype] at hxS' |
| 408 | refine β¨(x : Ξ±), ?_β© |
| 409 | rw [Finset.mem_inter, Finset.mem_singleton] |
| 410 | exact β¨rfl, hxS'β© |
| 411 | Β· simp only [Finset.card_singleton, Nat.cast_one] |
| 412 | exact hone_le |
| 413 | Β· -- T = β : no S in π is heavy |
| 414 | rw [Finset.not_nonempty_iff_eq_empty] at hT_empty |
| 415 | refine β¨β , ?_, ?_β© |
| 416 | Β· intro S hS hheavy |
| 417 | exfalso |
| 418 | have hSeq := hall_T S hS |
| 419 | rw [hT_empty] at hSeq |
| 420 | -- S β© Y = β |
| 421 | have hSY_empty : S β© Y = β := by |
| 422 | ext x |
| 423 | simp only [Finset.mem_inter, Finset.notMem_empty, iff_false, not_and] |
| 424 | intro hxS hxY |
| 425 | have : (β¨x, hxYβ© : Y) β (S.subtype (Β· β Y) : Finset Y) := by |
| 426 | rw [Finset.mem_subtype]; exact hxS |
| 427 | rw [hSeq] at this |
| 428 | exact (Finset.notMem_empty _ this) |
| 429 | have happrox_S := hY_approx S hS |
| 430 | rw [hSY_empty] at happrox_S |
| 431 | simp at happrox_S |
| 432 | have hΞ±_pos : (0 : β) < Fintype.card Ξ± := by |
| 433 | exact_mod_cast (Fintype.card_pos : 0 < Fintype.card Ξ±) |
| 434 | have hSdens : (1 : β) / r β€ S.card / Fintype.card Ξ± := by |
| 435 | rw [le_div_iffβ hΞ±_pos]; linarith [hheavy] |
| 436 | have habs := abs_le.mp happrox_S |
| 437 | have heq : (rβ»ΒΉ * 4β»ΒΉ : β) = 1 / (4 * r) := by ring |
| 438 | have h14 : (1 : β) / (4 * r) < 1 / r := by |
| 439 | apply one_div_lt_one_div_of_lt hr_pos; linarith |
| 440 | have : (S.card : β) / Fintype.card Ξ± β€ rβ»ΒΉ * 4β»ΒΉ := habs.2 |
| 441 | rw [heq] at this |
| 442 | linarith |
| 443 | Β· simp only [Finset.card_empty, Nat.cast_zero] |
| 444 | positivity |
| 445 | Β· -- π = β |
| 446 | rw [Finset.not_nonempty_iff_eq_empty] at hπ_empty |
| 447 | refine β¨β , ?_, ?_β© |
| 448 | Β· intro S hS; rw [hπ_empty] at hS; exact (Finset.notMem_empty _ hS).elim |
| 449 | Β· simp only [Finset.card_empty, Nat.cast_zero] |
| 450 | positivity |
| 451 | |
| 452 | end Catalog.VC.EpsilonNetTheorem |
| 453 |