| | @@ -243,4 +243,159 @@ theorem indepNum_ge_of_cliqueNum_le {V : Type*} [Fintype V] (G : SimpleGraph V) |
| 243 | 243 | |
| 244 | 244 | end ramsey |
| 245 | 245 | |
| 246 | + |
| 247 | +section binomial_choice |
| 248 | + |
| 249 | +open Nat |
| 250 | + |
| 251 | +/-! ## Choosing `t` and `m`: `C(k+t-1,k) ≤ exp(5√(k(t-1)))`, then the estimate. -/ |
| 252 | + |
| 253 | +theorem choose_add_le_exp_aux (a b : ℕ) (h : a ≤ b) : |
| 254 | + (((a + b).choose a : ℕ) : ℝ) ≤ Real.exp (5 * √((a : ℝ) * b)) := by |
| 255 | + rcases Nat.eq_zero_or_pos a with rfl | ha |
| 256 | + · simp |
| 257 | + have haR : (0 : ℝ) < a := by exact_mod_cast ha |
| 258 | + have hbR : (a : ℝ) ≤ b := by exact_mod_cast h |
| 259 | + set y : ℝ := 2 * b / a with hy |
| 260 | + have hbpos : (0 : ℝ) < b := lt_of_lt_of_le haR hbR |
| 261 | + have hy0 : 0 < y := by positivity |
| 262 | + have h1 : (((a + b).choose a : ℕ) : ℝ) ≤ ((a + b : ℕ) : ℝ) ^ a / (a ! : ℝ) := |
| 263 | + Nat.choose_le_pow_div a (a + b) |
| 264 | + have h2 := Real.pow_div_factorial_le_exp (a : ℝ) haR.le a |
| 265 | + have hfac : (0 : ℝ) < (a ! : ℝ) := by exact_mod_cast Nat.factorial_pos a |
| 266 | + have h3 : ((a + b : ℕ) : ℝ) ^ a / (a ! : ℝ) ≤ y ^ a * Real.exp a := by |
| 267 | + have e1 : (a : ℝ) ^ a / (a ! : ℝ) ≤ Real.exp a := h2 |
| 268 | + rw [div_le_iff₀ hfac] at e1 |
| 269 | + have hap : (0 : ℝ) < (a : ℝ) ^ a := by positivity |
| 270 | + have : ((a + b : ℕ) : ℝ) ^ a ≤ (2 * b : ℝ) ^ a := by |
| 271 | + apply pow_le_pow_left₀ (by positivity) |
| 272 | + push_cast; linarith |
| 273 | + rw [div_le_iff₀ hfac] |
| 274 | + calc ((a + b : ℕ) : ℝ) ^ a ≤ (2 * b : ℝ) ^ a := this |
| 275 | + _ = y ^ a * (a : ℝ) ^ a := by rw [hy, div_pow, div_mul_cancel₀ _ hap.ne'] |
| 276 | + _ ≤ y ^ a * (Real.exp a * (a ! : ℝ)) := by gcongr |
| 277 | + _ = y ^ a * Real.exp a * (a ! : ℝ) := by ring |
| 278 | + have hs : Real.sqrt y ≤ Real.exp (Real.sqrt y - 1) := by |
| 279 | + have := Real.add_one_le_exp (Real.sqrt y - 1); linarith |
| 280 | + have hy1 : y ≤ Real.exp (2 * (Real.sqrt y - 1)) := by |
| 281 | + have hsq : y = Real.sqrt y ^ 2 := (Real.sq_sqrt hy0.le).symm |
| 282 | + calc y = Real.sqrt y ^ 2 := hsq |
| 283 | + _ ≤ Real.exp (Real.sqrt y - 1) ^ 2 := by gcongr |
| 284 | + _ = Real.exp (2 * (Real.sqrt y - 1)) := by rw [← Real.exp_nat_mul]; push_cast; ring_nf |
| 285 | + have h4 : y ^ a ≤ Real.exp (a * (2 * (Real.sqrt y - 1))) := by |
| 286 | + rw [Real.exp_nat_mul]; exact pow_le_pow_left₀ hy0.le hy1 a |
| 287 | + have h5 : (a : ℝ) * Real.sqrt y ≤ 2 * √((a : ℝ) * b) := by |
| 288 | + have : (a : ℝ) * Real.sqrt y = Real.sqrt (2 * ((a : ℝ) * b)) := by |
| 289 | + have : 2 * ((a : ℝ) * b) = (a : ℝ) ^ 2 * y := by rw [hy]; field_simp |
| 290 | + rw [this, Real.sqrt_mul (sq_nonneg _), Real.sqrt_sq haR.le] |
| 291 | + rw [this, Real.sqrt_mul (by norm_num)] |
| 292 | + have : Real.sqrt 2 ≤ 2 := by |
| 293 | + rw [Real.sqrt_le_left (by norm_num)]; norm_num |
| 294 | + gcongr |
| 295 | + calc (((a + b).choose a : ℕ) : ℝ) ≤ y ^ a * Real.exp a := h1.trans h3 |
| 296 | + _ ≤ Real.exp (a * (2 * (Real.sqrt y - 1))) * Real.exp a := by gcongr |
| 297 | + _ = Real.exp (a * (2 * (Real.sqrt y - 1)) + a) := (Real.exp_add _ _).symm |
| 298 | + _ ≤ Real.exp (5 * √((a : ℝ) * b)) := by |
| 299 | + apply Real.exp_le_exp.mpr |
| 300 | + nlinarith [Real.sqrt_nonneg ((a : ℝ) * b)] |
| 301 | + |
| 302 | +theorem choose_add_le_exp (a b : ℕ) : |
| 303 | + (((a + b).choose a : ℕ) : ℝ) ≤ Real.exp (5 * √((a : ℝ) * b)) := by |
| 304 | + rcases le_total a b with h | h |
| 305 | + · exact choose_add_le_exp_aux a b h |
| 306 | + · have := choose_add_le_exp_aux b a h |
| 307 | + rw [add_comm b a, mul_comm (b : ℝ) a] at this |
| 308 | + rwa [Nat.choose_symm_add] |
| 309 | + |
| 310 | +theorem exists_t_m : ∃ C : ℝ, 0 < C ∧ ∀ᶠ n : ℕ in Filter.atTop, ∀ k : ℕ, 1 ≤ k → |
| 311 | + ∃ t m : ℕ, 0 < t ∧ Nat.choose (k + t - 1) k ≤ m ∧ |
| 312 | + ((n / t + m : ℕ) : ℝ) ≤ C * k * ((n : ℝ) / Real.logb 2 n ^ 2) := by |
| 313 | + refine ⟨1024, by norm_num, ?_⟩ |
| 314 | + filter_upwards [Filter.eventually_ge_atTop 2] with n hn k hk |
| 315 | + have hn2 : (2 : ℝ) ≤ n := by exact_mod_cast hn |
| 316 | + have hnpos : (0 : ℝ) < n := by linarith |
| 317 | + set L : ℝ := Real.logb 2 n with hLdef |
| 318 | + have hL1 : 1 ≤ L := by |
| 319 | + have := Real.logb_le_logb_of_le (b := 2) (by norm_num) (by norm_num) hn2 |
| 320 | + simpa [hLdef] using this |
| 321 | + have hL0 : 0 < L := by linarith |
| 322 | + have hnexp : (n : ℝ) = Real.exp (Real.log 2 * L) := by |
| 323 | + have h := Real.rpow_logb (b := 2) (x := n) (by norm_num) (by norm_num) hnpos |
| 324 | + rw [← h, Real.rpow_def_of_pos (by norm_num)] |
| 325 | + have hl2 := Real.log_two_gt_d9 |
| 326 | + -- key estimate |
| 327 | + have hkey : Real.exp (5 * L / 16) * L ^ 2 ≤ 256 * n := by |
| 328 | + have h1 : Real.exp (Real.log 2 * L) = Real.exp (5 * L / 16) * Real.exp (L * (Real.log 2 - 5 / 16)) := by |
| 329 | + rw [← Real.exp_add]; ring_nf |
| 330 | + have hd : 0 ≤ Real.log 2 - 5 / 16 - 0.38 := by linarith |
| 331 | + have hmd := mul_nonneg hL0.le hd |
| 332 | + have hxn : 0 ≤ L * (Real.log 2 - 5 / 16) := by linarith |
| 333 | + have h2 := Real.quadratic_le_exp_of_nonneg hxn |
| 334 | + have h3 : L ^ 2 ≤ 256 * Real.exp (L * (Real.log 2 - 5 / 16)) := by |
| 335 | + have hx : 0.38 * L ≤ L * (Real.log 2 - 5 / 16) := by linarith |
| 336 | + have hx2 : (0.38 * L) ^ 2 ≤ (L * (Real.log 2 - 5 / 16)) ^ 2 := |
| 337 | + pow_le_pow_left₀ (by positivity) hx 2 |
| 338 | + nlinarith [mul_pos hL0 hL0] |
| 339 | + rw [hnexp, h1] |
| 340 | + have := mul_le_mul_of_nonneg_left h3 (Real.exp_pos (5 * L / 16)).le |
| 341 | + linarith |
| 342 | + have hexp1 : 1 ≤ Real.exp (5 * L / 16) := Real.one_le_exp (by linarith) |
| 343 | + have hL2n : L ^ 2 ≤ 256 * n := by |
| 344 | + have := mul_le_mul_of_nonneg_right hexp1 (sq_nonneg L) |
| 345 | + linarith |
| 346 | + set Q : ℝ := (n : ℝ) / L ^ 2 with hQ |
| 347 | + have hL2pos : 0 < L ^ 2 := by positivity |
| 348 | + have hQpos : 0 < Q := by positivity |
| 349 | + have hQ1 : 1 ≤ 256 * Q := by |
| 350 | + rw [hQ, mul_div_assoc', le_div_iff₀ hL2pos]; linarith |
| 351 | + have hQexp : Real.exp (5 * L / 16) ≤ 256 * Q := by |
| 352 | + rw [hQ, mul_div_assoc', le_div_iff₀ hL2pos]; exact hkey |
| 353 | + have hkR : (1 : ℝ) ≤ k := by exact_mod_cast hk |
| 354 | + have hk0 : (0 : ℝ) < k := by linarith |
| 355 | + set s : ℝ := L ^ 2 / (256 * k) with hs |
| 356 | + have hs0 : 0 < s := by positivity |
| 357 | + have hns : (n : ℝ) / s = 256 * k * Q := by |
| 358 | + rw [hs, hQ]; field_simp |
| 359 | + set t : ℕ := max 1 ⌈s⌉₊ with ht |
| 360 | + have ht1 : 1 ≤ t := le_max_left _ _ |
| 361 | + have hst : s ≤ t := (Nat.le_ceil s).trans (by exact_mod_cast le_max_right _ _) |
| 362 | + have hy : ((t - 1 : ℕ) : ℝ) ≤ s := by |
| 363 | + rw [Nat.cast_sub ht1] |
| 364 | + have := Nat.ceil_lt_add_one hs0.le |
| 365 | + rcases max_cases 1 ⌈s⌉₊ with ⟨h, _⟩ | ⟨h, _⟩ |
| 366 | + · rw [ht, h]; simp; exact hs0.le |
| 367 | + · rw [ht, h]; push_cast; linarith |
| 368 | + set m : ℕ := ⌈(n : ℝ) / s⌉₊ with hm |
| 369 | + refine ⟨t, m, by omega, ?_, ?_⟩ |
| 370 | + · have hkt : k + t - 1 = k + (t - 1) := by omega |
| 371 | + rw [hkt] |
| 372 | + have hc := choose_add_le_exp k (t - 1) |
| 373 | + have hky : (k : ℝ) * ((t - 1 : ℕ) : ℝ) ≤ L ^ 2 / 256 := by |
| 374 | + have := mul_le_mul_of_nonneg_left hy hk0.le |
| 375 | + have e : (k : ℝ) * s = L ^ 2 / 256 := by rw [hs]; field_simp |
| 376 | + linarith |
| 377 | + have hsq : √((k : ℝ) * ((t - 1 : ℕ) : ℝ)) ≤ L / 16 := by |
| 378 | + rw [Real.sqrt_le_iff] |
| 379 | + refine ⟨by positivity, ?_⟩ |
| 380 | + have : (L / 16) ^ 2 = L ^ 2 / 256 := by ring |
| 381 | + linarith |
| 382 | + have h5 : (((k + (t - 1)).choose k : ℕ) : ℝ) ≤ (m : ℝ) := by |
| 383 | + calc (((k + (t - 1)).choose k : ℕ) : ℝ) ≤ Real.exp (5 * √((k : ℝ) * ((t - 1 : ℕ) : ℝ))) := hc |
| 384 | + _ ≤ Real.exp (5 * L / 16) := Real.exp_le_exp.mpr (by linarith) |
| 385 | + _ ≤ 256 * Q := hQexp |
| 386 | + _ ≤ 256 * k * Q := by nlinarith |
| 387 | + _ = (n : ℝ) / s := hns.symm |
| 388 | + _ ≤ m := Nat.le_ceil _ |
| 389 | + exact_mod_cast h5 |
| 390 | + · have h1 : ((n / t : ℕ) : ℝ) ≤ (n : ℝ) / s := by |
| 391 | + calc ((n / t : ℕ) : ℝ) ≤ (n : ℝ) / (t : ℝ) := Nat.cast_div_le |
| 392 | + _ ≤ (n : ℝ) / s := div_le_div_of_nonneg_left hnpos.le hs0 hst |
| 393 | + have h2 : (m : ℝ) < (n : ℝ) / s + 1 := Nat.ceil_lt_add_one (by positivity) |
| 394 | + have h3 := mul_le_mul_of_nonneg_right hkR hQpos.le |
| 395 | + push_cast |
| 396 | + rw [hns] at h1 h2 |
| 397 | + linarith |
| 398 | + |
| 399 | +end binomial_choice |
| 400 | + |
| 246 | 401 | end ErdosSwarm.Erdos627 |