import Mathlib namespace PermutohedronMatching noncomputable section /-- Monotonicity comparison used for successive decrements of the reciprocal binomial. -/ theorem reciprocal_binomial_decrement_ratio (c t : ℝ) (hc : 0 ≤ c) (ht : 0 ≤ t) : (t + 2) ^ 2 ≤ (t + 1) * (c + t + 4) := by nlinarith [mul_nonneg hc ht] /-- One adjacent run empty, including the empty configuration. -/ theorem single_run_bound (b : ℝ) (hb : 0 ≤ b) : 1 / 2 + 2 / ((b + 2) * (b + 3)) ≤ (5 / 6 : ℝ) := by have hp : 0 < (b + 2) * (b + 3) := by positivity have hd : 6 ≤ (b + 2) * (b + 3) := by nlinarith [sq_nonneg b] have hh : 2 / ((b + 2) * (b + 3)) ≤ (1 / 3 : ℝ) := by apply (div_le_iff₀ hp).2 linarith linarith /-- The exact quadratic remaining from the Poisson-equation flow bound. -/ theorem analytic_margin_identity (m k : ℝ) : (m / 2 - 5 / 6 * k) * (m / 2 - 2 * (5 / 6) * k) - k * ((m - k) / 2) * (5 / 6) = (9 * m ^ 2 - 60 * m * k + 65 * k ^ 2) / 36 := by ring theorem margin_nonneg (m k : ℝ) (hk : 0 ≤ k) (h : (10 + Real.sqrt 35) * k ≤ 3 * m) : 0 ≤ 9 * m ^ 2 - 60 * m * k + 65 * k ^ 2 := by have hs := Real.sq_sqrt (show (0 : ℝ) ≤ 35 by norm_num) have ha : 0 ≤ 3 * m - 10 * k - Real.sqrt 35 * k := by linarith have hb : 0 ≤ 3 * m - 10 * k + Real.sqrt 35 * k := by linarith [mul_nonneg (Real.sqrt_nonneg 35) hk] calc 0 ≤ (3 * m - 10 * k - Real.sqrt 35 * k) * (3 * m - 10 * k + Real.sqrt 35 * k) := mul_nonneg ha hb _ = 9 * m ^ 2 - 60 * m * k + 65 * k ^ 2 := by linear_combination -k ^ 2 * hs def b (m : ℝ) : ℝ := m * (m - 2) / ((m - 1) * (3 * m - 2)) def scale (m : ℝ) : ℝ := (m - 2) ^ 2 / (3 * m - 2) /-- Column equalization and the two strict edge margins for the codimension-three formula. -/ theorem third_codimension_constants (m : ℝ) (hm : 3 ≤ m) : 2 * b m * (m - 3) + 4 * b m / m = 2 * scale m ∧ (1 - 2 * b m) * (m - 2) - 2 * b m = scale m ∧ 0 < b m - 2 * b m / m ∧ 0 < 1 - 2 * b m - 2 * b m / m := by have hm0 : m ≠ 0 := by linarith have h1 : 0 < m - 1 := by linarith have h2 : 0 < 3 * m - 2 := by linarith have h3 : 0 < m - 2 := by linarith have h4 : 0 ≤ m - 3 := by linarith have hmpos : 0 < m := by linarith have hb : 0 < b m := by unfold b; positivity refine ⟨?_, ?_, ?_, ?_⟩ · unfold b scale field_simp [hm0, ne_of_gt h1, ne_of_gt h2] ring · unfold b scale field_simp [ne_of_gt h1, ne_of_gt h2] ring_nf field_simp [ne_of_gt (show 0 < -2 + m * 3 by linarith)] ring · have ha : 2 * b m / m < b m := by apply (div_lt_iff₀ hmpos).2 nlinarith [mul_pos hb h3] linarith · have he : 1 - 2 * b m - 2 * b m / m = (m * (m - 3) + 6) / ((m - 1) * (3 * m - 2)) := by unfold b field_simp [hm0, ne_of_gt h1, ne_of_gt h2] ring_nf field_simp [ne_of_gt (show 0 < -2 + m * 3 by linarith)] ring rw [he] positivity end end PermutohedronMatching