Lean / Reader
Lean reader

Arithmetic.lean

82 lines7 declarationsno sorryimports Mathlib
  1. import Mathlib
  2. namespace PermutohedronMatching
  3. noncomputable section
  4. /-- Monotonicity comparison used for successive decrements of the reciprocal binomial. -/
  5. theorem reciprocal_binomial_decrement_ratio (c t : ℝ) (hc : 0 ≤ c) (ht : 0 ≤ t) :
  6. (t + 2) ^ 2 ≤ (t + 1) * (c + t + 4) := by
  7. nlinarith [mul_nonneg hc ht]
  8. /-- One adjacent run empty, including the empty configuration. -/
  9. theorem single_run_bound (b : ℝ) (hb : 0 ≤ b) :
  10. 1 / 2 + 2 / ((b + 2) * (b + 3)) ≤ (5 / 6 : ℝ) := by
  11. have hp : 0 < (b + 2) * (b + 3) := by positivity
  12. have hd : 6 ≤ (b + 2) * (b + 3) := by nlinarith [sq_nonneg b]
  13. have hh : 2 / ((b + 2) * (b + 3)) ≤ (1 / 3 : ℝ) := by
  14. apply (div_le_iff₀ hp).2
  15. linarith
  16. linarith
  17. /-- The exact quadratic remaining from the Poisson-equation flow bound. -/
  18. theorem analytic_margin_identity (m k : ℝ) :
  19. (m / 2 - 5 / 6 * k) * (m / 2 - 2 * (5 / 6) * k) -
  20. k * ((m - k) / 2) * (5 / 6) =
  21. (9 * m ^ 2 - 60 * m * k + 65 * k ^ 2) / 36 := by
  22. ring
  23. theorem margin_nonneg (m k : ℝ) (hk : 0 ≤ k)
  24. (h : (10 + Real.sqrt 35) * k ≤ 3 * m) :
  25. 0 ≤ 9 * m ^ 2 - 60 * m * k + 65 * k ^ 2 := by
  26. have hs := Real.sq_sqrt (show (0 : ℝ) ≤ 35 by norm_num)
  27. have ha : 0 ≤ 3 * m - 10 * k - Real.sqrt 35 * k := by linarith
  28. have hb : 0 ≤ 3 * m - 10 * k + Real.sqrt 35 * k := by
  29. linarith [mul_nonneg (Real.sqrt_nonneg 35) hk]
  30. calc
  31. 0 ≤ (3 * m - 10 * k - Real.sqrt 35 * k) *
  32. (3 * m - 10 * k + Real.sqrt 35 * k) := mul_nonneg ha hb
  33. _ = 9 * m ^ 2 - 60 * m * k + 65 * k ^ 2 := by
  34. linear_combination -k ^ 2 * hs
  35. def b (m : ℝ) : ℝ := m * (m - 2) / ((m - 1) * (3 * m - 2))
  36. def scale (m : ℝ) : ℝ := (m - 2) ^ 2 / (3 * m - 2)
  37. /-- Column equalization and the two strict edge margins for the codimension-three formula. -/
  38. theorem third_codimension_constants (m : ℝ) (hm : 3 ≤ m) :
  39. 2 * b m * (m - 3) + 4 * b m / m = 2 * scale m ∧
  40. (1 - 2 * b m) * (m - 2) - 2 * b m = scale m ∧
  41. 0 < b m - 2 * b m / m ∧ 0 < 1 - 2 * b m - 2 * b m / m := by
  42. have hm0 : m ≠ 0 := by linarith
  43. have h1 : 0 < m - 1 := by linarith
  44. have h2 : 0 < 3 * m - 2 := by linarith
  45. have h3 : 0 < m - 2 := by linarith
  46. have h4 : 0 ≤ m - 3 := by linarith
  47. have hmpos : 0 < m := by linarith
  48. have hb : 0 < b m := by unfold b; positivity
  49. refine ⟨?_, ?_, ?_, ?_⟩
  50. · unfold b scale
  51. field_simp [hm0, ne_of_gt h1, ne_of_gt h2]
  52. ring
  53. · unfold b scale
  54. field_simp [ne_of_gt h1, ne_of_gt h2]
  55. ring_nf
  56. field_simp [ne_of_gt (show 0 < -2 + m * 3 by linarith)]
  57. ring
  58. · have ha : 2 * b m / m < b m := by
  59. apply (div_lt_iff₀ hmpos).2
  60. nlinarith [mul_pos hb h3]
  61. linarith
  62. · have he : 1 - 2 * b m - 2 * b m / m =
  63. (m * (m - 3) + 6) / ((m - 1) * (3 * m - 2)) := by
  64. unfold b
  65. field_simp [hm0, ne_of_gt h1, ne_of_gt h2]
  66. ring_nf
  67. field_simp [ne_of_gt (show 0 < -2 + m * 3 by linarith)]
  68. ring
  69. rw [he]
  70. positivity
  71. end
  72. end PermutohedronMatching