AFTD Auto-Formalizing Theoretical Domains

b5_gap_nonneg

theoremverified

For positive integers a, b, c, d, e with (a,b,c,d) ∉ {(1,1,1,1), (1,1,1,2), (1,2,1,1)}: tr ≤ n^2 (1 - 1/ω)^2 where tr = Σ (x-1)^2 + 2(ab + cd + bd + e(a+b+c+d)), n = a+b+c+d+e and ω = e + max(a+b, b+d, c+d).

Statement

theorem b5_gap_nonneg (a b c d e : ℕ) (ha : 1 ≤ a) (hb : 1 ≤ b) (hc : 1 ≤ c) (hd : 1 ≤ d) (he : 1 ≤ e)
    (hx : ¬ (a = 1 ∧ c = 1 ∧ ((b = 1 ∧ d = 1) ∨ (b = 1 ∧ d = 2) ∨ (b = 2 ∧ d = 1)))) :
    ((a : ℝ) - 1) ^ 2 + ((b : ℝ) - 1) ^ 2 + ((c : ℝ) - 1) ^ 2 + ((d : ℝ) - 1) ^ 2 + ((e : ℝ) - 1) ^ 2
        + 2 * ((a : ℝ) * b + c * d + b * d + e * (a + b + c + d))
      ≤ ((a : ℝ) + b + c + d + e) ^ 2 * (1 - 1 / ((e + max (max (a + b) (b + d)) (c + d) : ℕ) : ℝ)) ^ 2
Source
the polynomial core of b5_clique_bound_iff (the B_5 analogue of the computation in the proof of Theorem 3.1 of arXiv:2610.21388 (Stronger spectral bound for clique number))
Verified
29 Oct 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 1
  • b5_clique_bound_iffFor B_5(n_0..n_4) with all n_i ≥ 1, the strong spectral clique bound sqrt(Σ_{λ ≠ -1} λ^2) ≤ n(1 - 1/ω) (with Σ_{λ≠-1} λ^2 = tr(M^2) for…

The proof, explained

The inequality tr ≤ n^2 (1 - 1/ω)^2 is cleared of denominators to become n^2 (ω - 1)^2 - tr * ω^2 ≥ 0, where ω = e + m and m = max(a+b, b+d, c+d). Depending on which of the three sums a+b, b+d, or c+d achieves the maximum m, the difference is expanded as a quadratic polynomial G_m + D_m (e - 1) + A_m (e - 1)^2 in the non-negative variable e - 1. The case m = a+b reduces to m = c+d by reflection symmetry (a, b) ↔ (c, d). In each case, shifting variables by their lower bounds shows that the coefficients A_m, D_m, G_m are non-negative, concluding the proof.

  1. Under the case m = b + d, the quadratic coefficient A_{m2} = 2ac + 2ad - 2a + 2bc - 2c - 4 is non-negative. automation

    Since a + b ≤ b + d and c + d ≤ b + d, we write d = a + s and b = c + r with s, r ≥ 0. The hypothesis 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b + d splits into five cases: a ≥ 2; c ≥ 2; a = c = 1 with r ≥ 2; a = c = 1 with s ≥ 2; or a = c = 1 with r ≥ 1, s ≥ 1. In each case, substituting variable shifts by lower bounds produces an algebraic expression with manifestly positive coefficients, which `positivity` verifies.

    lines 5–21

      obtain ⟨s, rfl⟩ : ∃ s, d = a + s := ⟨d - a, by omega⟩
      obtain ⟨r, rfl⟩ : ∃ r, b = c + r := ⟨b - c, by omega⟩
      rcases (show 2 ≤ a ∨ 2 ≤ c ∨ (a = 1 ∧ c = 1 ∧ 2 ≤ r) ∨ (a = 1 ∧ c = 1 ∧ 2 ≤ s) ∨
          (a = 1 ∧ c = 1 ∧ 1 ≤ r ∧ 1 ≤ s) by omega) with h | h | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h, h'⟩
      · obtain ⟨p, rfl⟩ : ∃ p, a = 2 + p := ⟨a - 2, by omega⟩
        obtain ⟨q, rfl⟩ : ∃ q, c = 1 + q := ⟨c - 1, by omega⟩
        push_cast; ring_nf; positivity
      · obtain ⟨p, rfl⟩ : ∃ p, a = 1 + p := ⟨a - 1, by omega⟩
        obtain ⟨q, rfl⟩ : ∃ q, c = 2 + q := ⟨c - 2, by omega⟩
        push_cast; ring_nf; positivity
      · obtain ⟨t, rfl⟩ : ∃ t, r = 2 + t := ⟨r - 2, by omega⟩
        push_cast; ring_nf; positivity
      · obtain ⟨t, rfl⟩ : ∃ t, s = 2 + t := ⟨s - 2, by omega⟩
        push_cast; ring_nf; positivity
      · obtain ⟨t, rfl⟩ : ∃ t, r = 1 + t := ⟨r - 1, by omega⟩
        obtain ⟨u, rfl⟩ : ∃ u, s = 1 + u := ⟨s - 1, by omega⟩
        push_cast; ring_nf; positivity
  2. Under the case m = c + d, the quadratic coefficient A_{m3} = 2ac + 2ad - 2a + 2bc - 2b - 4 is non-negative. automation

    Since b + d ≤ c + d, we write c = b + r with r ≥ 0, and split into cases on whether a ≤ d. If a ≤ d, we write d = a + s and divide into six subcases for (a, b, r, s), each verified non-negative by `positivity` after shifting variables. If a > d, we write a = d + t with t ≥ 1; then a + b ≤ c + d implies r = t + u with u ≥ 0. Shifting variables to non-negative slack variables produces a polynomial with strictly positive coefficients, closed by `positivity`.

    lines 27–50

      obtain ⟨r, rfl⟩ : ∃ r, c = b + r := ⟨c - b, by omega⟩
      by_cases had : a ≤ d
      · obtain ⟨s, rfl⟩ : ∃ s, d = a + s := ⟨d - a, by omega⟩
        rcases (show 2 ≤ a ∨ (a = 1 ∧ 3 ≤ b) ∨ (a = 1 ∧ b = 2 ∧ s = 0) ∨ (a = 1 ∧ b = 2 ∧ 1 ≤ s) ∨
            (a = 1 ∧ b = 1 ∧ 1 ≤ r) ∨ (a = 1 ∧ b = 1 ∧ r = 0 ∧ 2 ≤ s) by omega) with
          h | ⟨rfl, h⟩ | ⟨rfl, rfl, rfl⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, rfl, h⟩
        · obtain ⟨p, rfl⟩ : ∃ p, a = 2 + p := ⟨a - 2, by omega⟩
          obtain ⟨q, rfl⟩ : ∃ q, b = 1 + q := ⟨b - 1, by omega⟩
          push_cast; ring_nf; positivity
        · obtain ⟨q, rfl⟩ : ∃ q, b = 3 + q := ⟨b - 3, by omega⟩
          push_cast; ring_nf; positivity
        · push_cast; ring_nf; positivity
        · obtain ⟨v, rfl⟩ : ∃ v, s = 1 + v := ⟨s - 1, by omega⟩
          push_cast; ring_nf; positivity
        · obtain ⟨v, rfl⟩ : ∃ v, r = 1 + v := ⟨r - 1, by omega⟩
          push_cast; ring_nf; positivity
        · obtain ⟨v, rfl⟩ : ∃ v, s = 2 + v := ⟨s - 2, by omega⟩
          push_cast; ring_nf; positivity
      · obtain ⟨t, rfl⟩ : ∃ t, a = d + t := ⟨a - d, by omega⟩
        obtain ⟨u, rfl⟩ : ∃ u, r = t + u := ⟨r - t, by omega⟩
        obtain ⟨v, rfl⟩ : ∃ v, t = 1 + v := ⟨t - 1, by omega⟩
        obtain ⟨q, rfl⟩ : ∃ q, d = 1 + q := ⟨d - 1, by omega⟩
        obtain ⟨p, rfl⟩ : ∃ p, b = 1 + p := ⟨b - 1, by omega⟩
        push_cast; ring_nf; positivity
  3. Under the case m = a + b, the quadratic coefficient A_{m1} = 2ac + 2ad + 2bc - 2c - 2d - 4 is non-negative.

    By applying `b5_gap_A_m3` with the permuted arguments (c, d, a, b), the inequality follows directly after ring normalization (`ring_nf`) and linear arithmetic (`linarith`).

    lines 55–57

    uses b5_gap_A_m3

      have := b5_gap_A_m3 c d a b hc hd ha hb (by omega) (by omega) (by omega)
      ring_nf at this ⊢
      linarith
  4. Under the case m = b + d, the linear coefficient D_{m2} in (e - 1) is non-negative. automation

    Writing d = a + s and b = c + r and using the same five-case partition as for A_{m2}, shifting variables by their minimal values reveals that all coefficients in the expanded polynomial are non-negative, verified by `positivity`.

    lines 63–79

      obtain ⟨s, rfl⟩ : ∃ s, d = a + s := ⟨d - a, by omega⟩
      obtain ⟨r, rfl⟩ : ∃ r, b = c + r := ⟨b - c, by omega⟩
      rcases (show 2 ≤ a ∨ 2 ≤ c ∨ (a = 1 ∧ c = 1 ∧ 2 ≤ r) ∨ (a = 1 ∧ c = 1 ∧ 2 ≤ s) ∨
          (a = 1 ∧ c = 1 ∧ 1 ≤ r ∧ 1 ≤ s) by omega) with h | h | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h, h'⟩
      · obtain ⟨p, rfl⟩ : ∃ p, a = 2 + p := ⟨a - 2, by omega⟩
        obtain ⟨q, rfl⟩ : ∃ q, c = 1 + q := ⟨c - 1, by omega⟩
        push_cast; ring_nf; positivity
      · obtain ⟨p, rfl⟩ : ∃ p, a = 1 + p := ⟨a - 1, by omega⟩
        obtain ⟨q, rfl⟩ : ∃ q, c = 2 + q := ⟨c - 2, by omega⟩
        push_cast; ring_nf; positivity
      · obtain ⟨t, rfl⟩ : ∃ t, r = 2 + t := ⟨r - 2, by omega⟩
        push_cast; ring_nf; positivity
      · obtain ⟨t, rfl⟩ : ∃ t, s = 2 + t := ⟨s - 2, by omega⟩
        push_cast; ring_nf; positivity
      · obtain ⟨t, rfl⟩ : ∃ t, r = 1 + t := ⟨r - 1, by omega⟩
        obtain ⟨u, rfl⟩ : ∃ u, s = 1 + u := ⟨s - 1, by omega⟩
        push_cast; ring_nf; positivity
  5. Under the case m = c + d, the linear coefficient D_{m3} in (e - 1) is non-negative. automation

    Writing c = b + r and splitting into the cases a ≤ d (six subcases) and a > d, substituting non-negative slack variables produces polynomials with only non-negative coefficients in every branch, closed by `positivity`.

    lines 85–108

      obtain ⟨r, rfl⟩ : ∃ r, c = b + r := ⟨c - b, by omega⟩
      by_cases had : a ≤ d
      · obtain ⟨s, rfl⟩ : ∃ s, d = a + s := ⟨d - a, by omega⟩
        rcases (show 2 ≤ a ∨ (a = 1 ∧ 3 ≤ b) ∨ (a = 1 ∧ b = 2 ∧ s = 0) ∨ (a = 1 ∧ b = 2 ∧ 1 ≤ s) ∨
            (a = 1 ∧ b = 1 ∧ 1 ≤ r) ∨ (a = 1 ∧ b = 1 ∧ r = 0 ∧ 2 ≤ s) by omega) with
          h | ⟨rfl, h⟩ | ⟨rfl, rfl, rfl⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, rfl, h⟩
        · obtain ⟨p, rfl⟩ : ∃ p, a = 2 + p := ⟨a - 2, by omega⟩
          obtain ⟨q, rfl⟩ : ∃ q, b = 1 + q := ⟨b - 1, by omega⟩
          push_cast; ring_nf; positivity
        · obtain ⟨q, rfl⟩ : ∃ q, b = 3 + q := ⟨b - 3, by omega⟩
          push_cast; ring_nf; positivity
        · push_cast; ring_nf; positivity
        · obtain ⟨v, rfl⟩ : ∃ v, s = 1 + v := ⟨s - 1, by omega⟩
          push_cast; ring_nf; positivity
        · obtain ⟨v, rfl⟩ : ∃ v, r = 1 + v := ⟨r - 1, by omega⟩
          push_cast; ring_nf; positivity
        · obtain ⟨v, rfl⟩ : ∃ v, s = 2 + v := ⟨s - 2, by omega⟩
          push_cast; ring_nf; positivity
      · obtain ⟨t, rfl⟩ : ∃ t, a = d + t := ⟨a - d, by omega⟩
        obtain ⟨u, rfl⟩ : ∃ u, r = t + u := ⟨r - t, by omega⟩
        obtain ⟨v, rfl⟩ : ∃ v, t = 1 + v := ⟨t - 1, by omega⟩
        obtain ⟨q, rfl⟩ : ∃ q, d = 1 + q := ⟨d - 1, by omega⟩
        obtain ⟨p, rfl⟩ : ∃ p, b = 1 + p := ⟨b - 1, by omega⟩
        push_cast; ring_nf; positivity
  6. Under the case m = a + b, the linear coefficient D_{m1} in (e - 1) is non-negative.

    Applying `b5_gap_D_m3` to the swapped arguments (c, d, a, b) yields D_{m1} ≥ 0 after normalization with `ring_nf` and `linarith`.

    lines 113–115

    uses b5_gap_D_m3

      have := b5_gap_D_m3 c d a b hc hd ha hb (by omega) (by omega) (by omega)
      ring_nf at this ⊢
      linarith
  7. Under the case m = b + d, the constant term G_{m2} in (e - 1) is non-negative. automation

    Under the parametrization d = a + s, b = c + r and the five-case split, shifting variables by their minimum values yields a sum of monomials with positive coefficients in each branch, verified by `positivity`.

    lines 121–137

      obtain ⟨s, rfl⟩ : ∃ s, d = a + s := ⟨d - a, by omega⟩
      obtain ⟨r, rfl⟩ : ∃ r, b = c + r := ⟨b - c, by omega⟩
      rcases (show 2 ≤ a ∨ 2 ≤ c ∨ (a = 1 ∧ c = 1 ∧ 2 ≤ r) ∨ (a = 1 ∧ c = 1 ∧ 2 ≤ s) ∨
          (a = 1 ∧ c = 1 ∧ 1 ≤ r ∧ 1 ≤ s) by omega) with h | h | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h, h'⟩
      · obtain ⟨p, rfl⟩ : ∃ p, a = 2 + p := ⟨a - 2, by omega⟩
        obtain ⟨q, rfl⟩ : ∃ q, c = 1 + q := ⟨c - 1, by omega⟩
        push_cast; ring_nf; positivity
      · obtain ⟨p, rfl⟩ : ∃ p, a = 1 + p := ⟨a - 1, by omega⟩
        obtain ⟨q, rfl⟩ : ∃ q, c = 2 + q := ⟨c - 2, by omega⟩
        push_cast; ring_nf; positivity
      · obtain ⟨t, rfl⟩ : ∃ t, r = 2 + t := ⟨r - 2, by omega⟩
        push_cast; ring_nf; positivity
      · obtain ⟨t, rfl⟩ : ∃ t, s = 2 + t := ⟨s - 2, by omega⟩
        push_cast; ring_nf; positivity
      · obtain ⟨t, rfl⟩ : ∃ t, r = 1 + t := ⟨r - 1, by omega⟩
        obtain ⟨u, rfl⟩ : ∃ u, s = 1 + u := ⟨s - 1, by omega⟩
        push_cast; ring_nf; positivity
  8. Under the case m = c + d, the constant term G_{m3} in (e - 1) is non-negative. automation

    Setting c = b + r and analyzing the branches for a ≤ d (six subcases) and a > d, shifting variables by their lower bounds gives polynomials with positive coefficients in all branches, closed by `positivity`.

    lines 143–166

      obtain ⟨r, rfl⟩ : ∃ r, c = b + r := ⟨c - b, by omega⟩
      by_cases had : a ≤ d
      · obtain ⟨s, rfl⟩ : ∃ s, d = a + s := ⟨d - a, by omega⟩
        rcases (show 2 ≤ a ∨ (a = 1 ∧ 3 ≤ b) ∨ (a = 1 ∧ b = 2 ∧ s = 0) ∨ (a = 1 ∧ b = 2 ∧ 1 ≤ s) ∨
            (a = 1 ∧ b = 1 ∧ 1 ≤ r) ∨ (a = 1 ∧ b = 1 ∧ r = 0 ∧ 2 ≤ s) by omega) with
          h | ⟨rfl, h⟩ | ⟨rfl, rfl, rfl⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, rfl, h⟩
        · obtain ⟨p, rfl⟩ : ∃ p, a = 2 + p := ⟨a - 2, by omega⟩
          obtain ⟨q, rfl⟩ : ∃ q, b = 1 + q := ⟨b - 1, by omega⟩
          push_cast; ring_nf; positivity
        · obtain ⟨q, rfl⟩ : ∃ q, b = 3 + q := ⟨b - 3, by omega⟩
          push_cast; ring_nf; positivity
        · push_cast; ring_nf; positivity
        · obtain ⟨v, rfl⟩ : ∃ v, s = 1 + v := ⟨s - 1, by omega⟩
          push_cast; ring_nf; positivity
        · obtain ⟨v, rfl⟩ : ∃ v, r = 1 + v := ⟨r - 1, by omega⟩
          push_cast; ring_nf; positivity
        · obtain ⟨v, rfl⟩ : ∃ v, s = 2 + v := ⟨s - 2, by omega⟩
          push_cast; ring_nf; positivity
      · obtain ⟨t, rfl⟩ : ∃ t, a = d + t := ⟨a - d, by omega⟩
        obtain ⟨u, rfl⟩ : ∃ u, r = t + u := ⟨r - t, by omega⟩
        obtain ⟨v, rfl⟩ : ∃ v, t = 1 + v := ⟨t - 1, by omega⟩
        obtain ⟨q, rfl⟩ : ∃ q, d = 1 + q := ⟨d - 1, by omega⟩
        obtain ⟨p, rfl⟩ : ∃ p, b = 1 + p := ⟨b - 1, by omega⟩
        push_cast; ring_nf; positivity
  9. Under the case m = a + b, the constant term G_{m1} in (e - 1) is non-negative.

    Permuting the arguments as (c, d, a, b) in `b5_gap_G_m3` establishes G_{m1} ≥ 0 via `ring_nf` and `linarith`.

    lines 171–173

    uses b5_gap_G_m3

      have := b5_gap_G_m3 c d a b hc hd ha hb (by omega) (by omega) (by omega)
      ring_nf at this ⊢
      linarith
  10. When m = a + b, the difference n^2(e + m - 1)^2 - tr * (e + m)^2 identically equals G_{m1} + D_{m1}(e - 1) + A_{m1}(e - 1)^2. automation

    Expanding both sides into polynomials in a, b, c, d, e confirms that they are algebraically identical, verified by the `ring` tactic.

    line 180

      ring
  11. When m = b + d, the difference n^2(e + m - 1)^2 - tr * (e + m)^2 identically equals G_{m2} + D_{m2}(e - 1) + A_{m2}(e - 1)^2. automation

    An algebraic identity over ℝ in the variables a, b, c, d, e, verified by `ring`.

    line 186

          = (-2*a^2*b - 2*a^2*d - a^2 + 2*a*b^2*c + 2*a*b^2*d - 2*a*b^2 + 4*a*b*c*d + 4*a*b*d^2 - 2*a*b + 2*a*c*d^2 + 2*a*d^3 + 2*a*d^2 + 2*b^3*c + 4*b^2*c*d + 2*b^2*c - 4*b^2 - 2*b*c^2 + 2*b*c*d^2 - 8*b*d - 8*b - 2*c^2*d - c^2 - 2*c*d^2 - 2*c*d - 4*d^2 - 8*d - 4) + (-2*a^2 + 4*a*b*c + 4*a*b*d - 4*a*b + 4*a*c*d + 4*a*d^2 - 2*a + 4*b^2*c + 4*b*c*d - 8*b - 2*c^2 - 4*c*d - 2*c - 8*d - 8) * (e - 1) + (2*a*c + 2*a*d - 2*a + 2*b*c - 2*c - 4) * (e - 1) ^ 2 := by
  12. When m = c + d, the difference n^2(e + m - 1)^2 - tr * (e + m)^2 identically equals G_{m3} + D_{m3}(e - 1) + A_{m3}(e - 1)^2. automation

    An algebraic identity over ℝ in the variables a, b, c, d, e, verified by `ring`.

    line 194

      ring
  13. The point exclusion implies 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b + d, and the variables satisfy e - 1 ≥ 0 and ω > 0 in ℝ.

    Linear arithmetic (`omega`) deduces 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b + d from the hypothesis excluding the three points (1,1,1,1), (1,1,1,2), and (1,2,1,1). We cast the variables and hypotheses to ℝ, in particular noting that e ≥ 1 implies e - 1 ≥ 0 and ω = e + max(max(a+b, b+d), c+d) > 0.

    lines 201–216

    uses Or.inl, Or.inr

      have hx' : 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b + d := by omega
      have hxR : (2:ℝ) ≤ a ∨ (2:ℝ) ≤ c ∨ (4:ℝ) ≤ b + d := by
        rcases hx' with h | h | h
        · exact Or.inl (by exact_mod_cast h)
        · exact Or.inr (Or.inl (by exact_mod_cast h))
        · exact Or.inr (Or.inr (by exact_mod_cast h))
      have haR : (1:ℝ) ≤ a := by exact_mod_cast ha
      have hbR : (1:ℝ) ≤ b := by exact_mod_cast hb
      have hcR : (1:ℝ) ≤ c := by exact_mod_cast hc
      have hdR : (1:ℝ) ≤ d := by exact_mod_cast hd
      have heR : (0:ℝ) ≤ (e:ℝ) - 1 := by
        have : (1:ℝ) ≤ e := by exact_mod_cast he
        linarith
      have hw : (0:ℝ) < ((e + max (max (a + b) (b + d)) (c + d) : ℕ) : ℝ) := by
        have : 1 ≤ e + max (max (a + b) (b + d)) (c + d) := by omega
        exact_mod_cast this
  14. The target inequality tr ≤ n^2(1 - 1/ω)^2 is equivalent to tr * ω^2 ≤ n^2(ω - 1)^2.

    Rewriting 1 - 1/ω as (ω - 1)/ω with `field_simp`, distributing the square via `div_pow` and `mul_div_assoc'`, and clearing the strictly positive denominator ω^2 via `le_div_iff₀` reduces the goal to tr * ω^2 ≤ n^2(ω - 1)^2.

    lines 217–220

    uses div_pow, mul_div_assoc', le_div_iff₀

      rw [show (1:ℝ) - 1 / ((e + max (max (a + b) (b + d)) (c + d) : ℕ) : ℝ)
          = (((e + max (max (a + b) (b + d)) (c + d) : ℕ) : ℝ) - 1)
            / ((e + max (max (a + b) (b + d)) (c + d) : ℕ) : ℝ) by field_simp]
      rw [div_pow, mul_div_assoc', le_div_iff₀ (by positivity)]
  15. The maximum m = max(max(a+b, b+d), c+d) is attained by a + b, b + d, or c + d.

    Linear arithmetic on ℕ (`omega`) establishes that one of the three sums a + b, b + d, or c + d must be greater than or equal to the other two, providing a three-way case split.

    lines 221–224

      have hcases : (max (max (a + b) (b + d)) (c + d) = a + b ∧ b + d ≤ a + b ∧ c + d ≤ a + b) ∨
          (max (max (a + b) (b + d)) (c + d) = b + d ∧ a + b ≤ b + d ∧ c + d ≤ b + d) ∨
          (max (max (a + b) (b + d)) (c + d) = c + d ∧ a + b ≤ c + d ∧ b + d ≤ c + d) := by omega
      rcases hcases with ⟨hm, h1, h2⟩ | ⟨hm, h1, h2⟩ | ⟨hm, h1, h2⟩
  16. The inequality holds in Case 1, where m = a + b.

    Setting ω = e + a + b, the polynomial identity `b5_gap_identity_m1` writes n^2(ω - 1)^2 - tr * ω^2 as G_{m1} + D_{m1}(e - 1) + A_{m1}(e - 1)^2. The coefficients are non-negative by `b5_gap_G_m1`, `b5_gap_D_m1`, and `b5_gap_A_m1`. Combining these with e - 1 ≥ 0 and (e - 1)^2 ≥ 0 (via `sq_nonneg` and `mul_nonneg`), linear arithmetic (`linarith`) completes the proof.

    lines 225–234

    uses b5_gap_identity_m1, b5_gap_A_m1, b5_gap_D_m1, b5_gap_G_m1, mul_nonneg, sq_nonneg

      · rw [hm]; push_cast
        have h1R : (b:ℝ) + d ≤ a + b := by exact_mod_cast h1
        have h2R : (c:ℝ) + d ≤ a + b := by exact_mod_cast h2
        have hA := b5_gap_A_m1 a b c d ha hb hc hd h1 h2 hx'
        have hD := b5_gap_D_m1 a b c d ha hb hc hd h1 h2 hx'
        have hG := b5_gap_G_m1 a b c d ha hb hc hd h1 h2 hx'
        have key := b5_gap_identity_m1 a b c d e
        have := mul_nonneg hA (sq_nonneg ((e:ℝ) - 1))
        have := mul_nonneg hD heR
        linarith
  17. The inequality holds in Case 2, where m = b + d.

    Setting ω = e + b + d, identity `b5_gap_identity_m2` writes the difference as G_{m2} + D_{m2}(e - 1) + A_{m2}(e - 1)^2. The coefficients are non-negative by `b5_gap_G_m2`, `b5_gap_D_m2`, and `b5_gap_A_m2`. Multiplying by non-negative factors e - 1 and (e - 1)^2 via `mul_nonneg` and `sq_nonneg`, `linarith` closes the goal.

    lines 235–244

    uses b5_gap_identity_m2, b5_gap_A_m2, b5_gap_D_m2, b5_gap_G_m2, mul_nonneg, sq_nonneg

      · rw [hm]; push_cast
        have h1R : (a:ℝ) + b ≤ b + d := by exact_mod_cast h1
        have h2R : (c:ℝ) + d ≤ b + d := by exact_mod_cast h2
        have hA := b5_gap_A_m2 a b c d ha hb hc hd h1 h2 hx'
        have hD := b5_gap_D_m2 a b c d ha hb hc hd h1 h2 hx'
        have hG := b5_gap_G_m2 a b c d ha hb hc hd h1 h2 hx'
        have key := b5_gap_identity_m2 a b c d e
        have := mul_nonneg hA (sq_nonneg ((e:ℝ) - 1))
        have := mul_nonneg hD heR
        linarith
  18. The inequality holds in Case 3, where m = c + d.

    Setting ω = e + c + d, identity `b5_gap_identity_m3` writes the difference as G_{m3} + D_{m3}(e - 1) + A_{m3}(e - 1)^2. The coefficients are non-negative by `b5_gap_G_m3`, `b5_gap_D_m3`, and `b5_gap_A_m3`. Combining with e - 1 ≥ 0 and (e - 1)^2 ≥ 0 via `mul_nonneg` and `sq_nonneg`, `linarith` closes the final case.

    lines 245–254

    uses b5_gap_identity_m3, b5_gap_A_m3, b5_gap_D_m3, b5_gap_G_m3, mul_nonneg, sq_nonneg

      · rw [hm]; push_cast
        have h1R : (a:ℝ) + b ≤ c + d := by exact_mod_cast h1
        have h2R : (b:ℝ) + d ≤ c + d := by exact_mod_cast h2
        have hA := b5_gap_A_m3 a b c d ha hb hc hd h1 h2 hx'
        have hD := b5_gap_D_m3 a b c d ha hb hc hd h1 h2 hx'
        have hG := b5_gap_G_m3 a b c d ha hb hc hd h1 h2 hx'
        have key := b5_gap_identity_m3 a b c d e
        have := mul_nonneg hA (sq_nonneg ((e:ℝ) - 1))
        have := mul_nonneg hD heR
        linarith
b5_gap_A_m2
For positive integers a, b, c, d with a+b ≤ b+d, c+d ≤ b+d, and 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b+d, the quadratic coefficient 2ac + 2ad - 2a + 2bc - 2c - 4 is non-negative.
b5_gap_A_m3
For positive integers a, b, c, d with a+b ≤ c+d, b+d ≤ c+d, and 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b+d, the quadratic coefficient 2ac + 2ad - 2a + 2bc - 2b - 4 is non-negative.
b5_gap_A_m1
For positive integers a, b, c, d with b+d ≤ a+b, c+d ≤ a+b, and 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b+d, the quadratic coefficient 2ac + 2ad + 2bc - 2c - 2d - 4 is non-negative.
b5_gap_D_m2
Under the conditions of case m2, the linear coefficient D_{m2} in (e - 1) is non-negative.
b5_gap_D_m3
Under the conditions of case m3, the linear coefficient D_{m3} in (e - 1) is non-negative.
b5_gap_D_m1
Under the conditions of case m1, the linear coefficient D_{m1} in (e - 1) is non-negative.
b5_gap_G_m2
Under the conditions of case m2, the constant term G_{m2} in (e - 1) is non-negative.
b5_gap_G_m3
Under the conditions of case m3, the constant term G_{m3} in (e - 1) is non-negative.
b5_gap_G_m1
Under the conditions of case m1, the constant term G_{m1} in (e - 1) is non-negative.
b5_gap_identity_m1
Polynomial identity expanding n^2 (e + a + b - 1)^2 - tr * (e + a + b)^2 as G_{m1} + D_{m1} * (e - 1) + A_{m1} * (e - 1)^2.
b5_gap_identity_m2
Polynomial identity expanding n^2 (e + b + d - 1)^2 - tr * (e + b + d)^2 as G_{m2} + D_{m2} * (e - 1) + A_{m2} * (e - 1)^2.
b5_gap_identity_m3
Polynomial identity expanding n^2 (e + c + d - 1)^2 - tr * (e + c + d)^2 as G_{m3} + D_{m3} * (e - 1) + A_{m3} * (e - 1)^2.
Or.inl
From a proof of P, deduces P ∨ Q.
Or.inr
From a proof of Q, deduces P ∨ Q.
div_pow
In a division monoid, (a / b)^n = a^n / b^n.
mul_div_assoc'
In a division monoid, a * (b / c) = (a * b) / c.
le_div_iff₀
For c > 0 in a linearly ordered group with zero, a ≤ b / c is equivalent to a * c ≤ b.
mul_nonneg
The product of two non-negative elements in an ordered semiring is non-negative.
sq_nonneg
In an ordered semiring, the square of any element is non-negative.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

set_option maxHeartbeats 2000000 intheorem b5_gap_A_m2 (a b c d : ℕ) (ha : 1 ≤ a) (hb : 1 ≤ b) (hc : 1 ≤ c) (hd : 1 ≤ d)    (h1 : a + b ≤ b + d) (h2 : c + d ≤ b + d) (hx : 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b + d) :    (0 : ℝ) ≤ 2*(a:ℝ)*(c:ℝ) + 2*(a:ℝ)*(d:ℝ) - 2*(a:ℝ) + 2*(b:ℝ)*(c:ℝ) - 2*(c:ℝ) - 4 := by  obtain ⟨s, rfl⟩ : ∃ s, d = a + s := ⟨d - a, by omega⟩  obtain ⟨r, rfl⟩ : ∃ r, b = c + r := ⟨b - c, by omega⟩  rcases (show 2 ≤ a ∨ 2 ≤ c ∨ (a = 1 ∧ c = 1 ∧ 2 ≤ r) ∨ (a = 1 ∧ c = 1 ∧ 2 ≤ s) ∨      (a = 1 ∧ c = 1 ∧ 1 ≤ r ∧ 1 ≤ s) by omega) with h | h | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h, h'⟩  · obtain ⟨p, rfl⟩ : ∃ p, a = 2 + p := ⟨a - 2, by omega⟩    obtain ⟨q, rfl⟩ : ∃ q, c = 1 + q := ⟨c - 1, by omega⟩    push_cast; ring_nf; positivity  · obtain ⟨p, rfl⟩ : ∃ p, a = 1 + p := ⟨a - 1, by omega⟩    obtain ⟨q, rfl⟩ : ∃ q, c = 2 + q := ⟨c - 2, by omega⟩    push_cast; ring_nf; positivity  · obtain ⟨t, rfl⟩ : ∃ t, r = 2 + t := ⟨r - 2, by omega⟩    push_cast; ring_nf; positivity  · obtain ⟨t, rfl⟩ : ∃ t, s = 2 + t := ⟨s - 2, by omega⟩    push_cast; ring_nf; positivity  · obtain ⟨t, rfl⟩ : ∃ t, r = 1 + t := ⟨r - 1, by omega⟩    obtain ⟨u, rfl⟩ : ∃ u, s = 1 + u := ⟨s - 1, by omega⟩    push_cast; ring_nf; positivityset_option maxHeartbeats 2000000 intheorem b5_gap_A_m3 (a b c d : ℕ) (ha : 1 ≤ a) (hb : 1 ≤ b) (hc : 1 ≤ c) (hd : 1 ≤ d)    (h1 : a + b ≤ c + d) (h2 : b + d ≤ c + d) (hx : 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b + d) :    (0 : ℝ) ≤ 2*(a:ℝ)*(c:ℝ) + 2*(a:ℝ)*(d:ℝ) - 2*(a:ℝ) + 2*(b:ℝ)*(c:ℝ) - 2*(b:ℝ) - 4 := by  obtain ⟨r, rfl⟩ : ∃ r, c = b + r := ⟨c - b, by omega⟩  by_cases had : a ≤ d  · obtain ⟨s, rfl⟩ : ∃ s, d = a + s := ⟨d - a, by omega⟩    rcases (show 2 ≤ a ∨ (a = 1 ∧ 3 ≤ b) ∨ (a = 1 ∧ b = 2 ∧ s = 0) ∨ (a = 1 ∧ b = 2 ∧ 1 ≤ s) ∨        (a = 1 ∧ b = 1 ∧ 1 ≤ r) ∨ (a = 1 ∧ b = 1 ∧ r = 0 ∧ 2 ≤ s) by omega) with      h | ⟨rfl, h⟩ | ⟨rfl, rfl, rfl⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, rfl, h⟩    · obtain ⟨p, rfl⟩ : ∃ p, a = 2 + p := ⟨a - 2, by omega⟩      obtain ⟨q, rfl⟩ : ∃ q, b = 1 + q := ⟨b - 1, by omega⟩      push_cast; ring_nf; positivity    · obtain ⟨q, rfl⟩ : ∃ q, b = 3 + q := ⟨b - 3, by omega⟩      push_cast; ring_nf; positivity    · push_cast; ring_nf; positivity    · obtain ⟨v, rfl⟩ : ∃ v, s = 1 + v := ⟨s - 1, by omega⟩      push_cast; ring_nf; positivity    · obtain ⟨v, rfl⟩ : ∃ v, r = 1 + v := ⟨r - 1, by omega⟩      push_cast; ring_nf; positivity    · obtain ⟨v, rfl⟩ : ∃ v, s = 2 + v := ⟨s - 2, by omega⟩      push_cast; ring_nf; positivity  · obtain ⟨t, rfl⟩ : ∃ t, a = d + t := ⟨a - d, by omega⟩    obtain ⟨u, rfl⟩ : ∃ u, r = t + u := ⟨r - t, by omega⟩    obtain ⟨v, rfl⟩ : ∃ v, t = 1 + v := ⟨t - 1, by omega⟩    obtain ⟨q, rfl⟩ : ∃ q, d = 1 + q := ⟨d - 1, by omega⟩    obtain ⟨p, rfl⟩ : ∃ p, b = 1 + p := ⟨b - 1, by omega⟩    push_cast; ring_nf; positivitytheorem b5_gap_A_m1 (a b c d : ℕ) (ha : 1 ≤ a) (hb : 1 ≤ b) (hc : 1 ≤ c) (hd : 1 ≤ d)    (h1 : b + d ≤ a + b) (h2 : c + d ≤ a + b) (hx : 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b + d) :    (0 : ℝ) ≤ 2*(a:ℝ)*(c:ℝ) + 2*(a:ℝ)*(d:ℝ) + 2*(b:ℝ)*(c:ℝ) - 2*(c:ℝ) - 2*(d:ℝ) - 4 := by  have := b5_gap_A_m3 c d a b hc hd ha hb (by omega) (by omega) (by omega)  ring_nf at this ⊢  linarithset_option maxHeartbeats 2000000 intheorem b5_gap_D_m2 (a b c d : ℕ) (ha : 1 ≤ a) (hb : 1 ≤ b) (hc : 1 ≤ c) (hd : 1 ≤ d)    (h1 : a + b ≤ b + d) (h2 : c + d ≤ b + d) (hx : 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b + d) :    (0 : ℝ) ≤ -2*(a:ℝ)^2 + 4*(a:ℝ)*(b:ℝ)*(c:ℝ) + 4*(a:ℝ)*(b:ℝ)*(d:ℝ) - 4*(a:ℝ)*(b:ℝ) + 4*(a:ℝ)*(c:ℝ)*(d:ℝ) + 4*(a:ℝ)*(d:ℝ)^2 - 2*(a:ℝ) + 4*(b:ℝ)^2*(c:ℝ) + 4*(b:ℝ)*(c:ℝ)*(d:ℝ) - 8*(b:ℝ) - 2*(c:ℝ)^2 - 4*(c:ℝ)*(d:ℝ) - 2*(c:ℝ) - 8*(d:ℝ) - 8 := by  obtain ⟨s, rfl⟩ : ∃ s, d = a + s := ⟨d - a, by omega⟩  obtain ⟨r, rfl⟩ : ∃ r, b = c + r := ⟨b - c, by omega⟩  rcases (show 2 ≤ a ∨ 2 ≤ c ∨ (a = 1 ∧ c = 1 ∧ 2 ≤ r) ∨ (a = 1 ∧ c = 1 ∧ 2 ≤ s) ∨      (a = 1 ∧ c = 1 ∧ 1 ≤ r ∧ 1 ≤ s) by omega) with h | h | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h, h'⟩  · obtain ⟨p, rfl⟩ : ∃ p, a = 2 + p := ⟨a - 2, by omega⟩    obtain ⟨q, rfl⟩ : ∃ q, c = 1 + q := ⟨c - 1, by omega⟩    push_cast; ring_nf; positivity  · obtain ⟨p, rfl⟩ : ∃ p, a = 1 + p := ⟨a - 1, by omega⟩    obtain ⟨q, rfl⟩ : ∃ q, c = 2 + q := ⟨c - 2, by omega⟩    push_cast; ring_nf; positivity  · obtain ⟨t, rfl⟩ : ∃ t, r = 2 + t := ⟨r - 2, by omega⟩    push_cast; ring_nf; positivity  · obtain ⟨t, rfl⟩ : ∃ t, s = 2 + t := ⟨s - 2, by omega⟩    push_cast; ring_nf; positivity  · obtain ⟨t, rfl⟩ : ∃ t, r = 1 + t := ⟨r - 1, by omega⟩    obtain ⟨u, rfl⟩ : ∃ u, s = 1 + u := ⟨s - 1, by omega⟩    push_cast; ring_nf; positivityset_option maxHeartbeats 2000000 intheorem b5_gap_D_m3 (a b c d : ℕ) (ha : 1 ≤ a) (hb : 1 ≤ b) (hc : 1 ≤ c) (hd : 1 ≤ d)    (h1 : a + b ≤ c + d) (h2 : b + d ≤ c + d) (hx : 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b + d) :    (0 : ℝ) ≤ -2*(a:ℝ)^2 - 4*(a:ℝ)*(b:ℝ) + 4*(a:ℝ)*(c:ℝ)^2 + 8*(a:ℝ)*(c:ℝ)*(d:ℝ) + 4*(a:ℝ)*(d:ℝ)^2 - 2*(a:ℝ) - 2*(b:ℝ)^2 + 4*(b:ℝ)*(c:ℝ)^2 + 4*(b:ℝ)*(c:ℝ)*(d:ℝ) - 4*(b:ℝ)*(d:ℝ) - 2*(b:ℝ) - 8*(c:ℝ) - 8*(d:ℝ) - 8 := by  obtain ⟨r, rfl⟩ : ∃ r, c = b + r := ⟨c - b, by omega⟩  by_cases had : a ≤ d  · obtain ⟨s, rfl⟩ : ∃ s, d = a + s := ⟨d - a, by omega⟩    rcases (show 2 ≤ a ∨ (a = 1 ∧ 3 ≤ b) ∨ (a = 1 ∧ b = 2 ∧ s = 0) ∨ (a = 1 ∧ b = 2 ∧ 1 ≤ s) ∨        (a = 1 ∧ b = 1 ∧ 1 ≤ r) ∨ (a = 1 ∧ b = 1 ∧ r = 0 ∧ 2 ≤ s) by omega) with      h | ⟨rfl, h⟩ | ⟨rfl, rfl, rfl⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, rfl, h⟩    · obtain ⟨p, rfl⟩ : ∃ p, a = 2 + p := ⟨a - 2, by omega⟩      obtain ⟨q, rfl⟩ : ∃ q, b = 1 + q := ⟨b - 1, by omega⟩      push_cast; ring_nf; positivity    · obtain ⟨q, rfl⟩ : ∃ q, b = 3 + q := ⟨b - 3, by omega⟩      push_cast; ring_nf; positivity    · push_cast; ring_nf; positivity    · obtain ⟨v, rfl⟩ : ∃ v, s = 1 + v := ⟨s - 1, by omega⟩      push_cast; ring_nf; positivity    · obtain ⟨v, rfl⟩ : ∃ v, r = 1 + v := ⟨r - 1, by omega⟩      push_cast; ring_nf; positivity    · obtain ⟨v, rfl⟩ : ∃ v, s = 2 + v := ⟨s - 2, by omega⟩      push_cast; ring_nf; positivity  · obtain ⟨t, rfl⟩ : ∃ t, a = d + t := ⟨a - d, by omega⟩    obtain ⟨u, rfl⟩ : ∃ u, r = t + u := ⟨r - t, by omega⟩    obtain ⟨v, rfl⟩ : ∃ v, t = 1 + v := ⟨t - 1, by omega⟩    obtain ⟨q, rfl⟩ : ∃ q, d = 1 + q := ⟨d - 1, by omega⟩    obtain ⟨p, rfl⟩ : ∃ p, b = 1 + p := ⟨b - 1, by omega⟩    push_cast; ring_nf; positivitytheorem b5_gap_D_m1 (a b c d : ℕ) (ha : 1 ≤ a) (hb : 1 ≤ b) (hc : 1 ≤ c) (hd : 1 ≤ d)    (h1 : b + d ≤ a + b) (h2 : c + d ≤ a + b) (hx : 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b + d) :    (0 : ℝ) ≤ 4*(a:ℝ)^2*(c:ℝ) + 4*(a:ℝ)^2*(d:ℝ) + 8*(a:ℝ)*(b:ℝ)*(c:ℝ) + 4*(a:ℝ)*(b:ℝ)*(d:ℝ) - 8*(a:ℝ) + 4*(b:ℝ)^2*(c:ℝ) - 4*(b:ℝ)*(d:ℝ) - 8*(b:ℝ) - 2*(c:ℝ)^2 - 4*(c:ℝ)*(d:ℝ) - 2*(c:ℝ) - 2*(d:ℝ)^2 - 2*(d:ℝ) - 8 := by  have := b5_gap_D_m3 c d a b hc hd ha hb (by omega) (by omega) (by omega)  ring_nf at this ⊢  linarithset_option maxHeartbeats 2000000 intheorem b5_gap_G_m2 (a b c d : ℕ) (ha : 1 ≤ a) (hb : 1 ≤ b) (hc : 1 ≤ c) (hd : 1 ≤ d)    (h1 : a + b ≤ b + d) (h2 : c + d ≤ b + d) (hx : 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b + d) :    (0 : ℝ) ≤ -2*(a:ℝ)^2*(b:ℝ) - 2*(a:ℝ)^2*(d:ℝ) - (a:ℝ)^2 + 2*(a:ℝ)*(b:ℝ)^2*(c:ℝ) + 2*(a:ℝ)*(b:ℝ)^2*(d:ℝ) - 2*(a:ℝ)*(b:ℝ)^2 + 4*(a:ℝ)*(b:ℝ)*(c:ℝ)*(d:ℝ) + 4*(a:ℝ)*(b:ℝ)*(d:ℝ)^2 - 2*(a:ℝ)*(b:ℝ) + 2*(a:ℝ)*(c:ℝ)*(d:ℝ)^2 + 2*(a:ℝ)*(d:ℝ)^3 + 2*(a:ℝ)*(d:ℝ)^2 + 2*(b:ℝ)^3*(c:ℝ) + 4*(b:ℝ)^2*(c:ℝ)*(d:ℝ) + 2*(b:ℝ)^2*(c:ℝ) - 4*(b:ℝ)^2 - 2*(b:ℝ)*(c:ℝ)^2 + 2*(b:ℝ)*(c:ℝ)*(d:ℝ)^2 - 8*(b:ℝ)*(d:ℝ) - 8*(b:ℝ) - 2*(c:ℝ)^2*(d:ℝ) - (c:ℝ)^2 - 2*(c:ℝ)*(d:ℝ)^2 - 2*(c:ℝ)*(d:ℝ) - 4*(d:ℝ)^2 - 8*(d:ℝ) - 4 := by  obtain ⟨s, rfl⟩ : ∃ s, d = a + s := ⟨d - a, by omega⟩  obtain ⟨r, rfl⟩ : ∃ r, b = c + r := ⟨b - c, by omega⟩  rcases (show 2 ≤ a ∨ 2 ≤ c ∨ (a = 1 ∧ c = 1 ∧ 2 ≤ r) ∨ (a = 1 ∧ c = 1 ∧ 2 ≤ s) ∨      (a = 1 ∧ c = 1 ∧ 1 ≤ r ∧ 1 ≤ s) by omega) with h | h | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h, h'⟩  · obtain ⟨p, rfl⟩ : ∃ p, a = 2 + p := ⟨a - 2, by omega⟩    obtain ⟨q, rfl⟩ : ∃ q, c = 1 + q := ⟨c - 1, by omega⟩    push_cast; ring_nf; positivity  · obtain ⟨p, rfl⟩ : ∃ p, a = 1 + p := ⟨a - 1, by omega⟩    obtain ⟨q, rfl⟩ : ∃ q, c = 2 + q := ⟨c - 2, by omega⟩    push_cast; ring_nf; positivity  · obtain ⟨t, rfl⟩ : ∃ t, r = 2 + t := ⟨r - 2, by omega⟩    push_cast; ring_nf; positivity  · obtain ⟨t, rfl⟩ : ∃ t, s = 2 + t := ⟨s - 2, by omega⟩    push_cast; ring_nf; positivity  · obtain ⟨t, rfl⟩ : ∃ t, r = 1 + t := ⟨r - 1, by omega⟩    obtain ⟨u, rfl⟩ : ∃ u, s = 1 + u := ⟨s - 1, by omega⟩    push_cast; ring_nf; positivityset_option maxHeartbeats 2000000 intheorem b5_gap_G_m3 (a b c d : ℕ) (ha : 1 ≤ a) (hb : 1 ≤ b) (hc : 1 ≤ c) (hd : 1 ≤ d)    (h1 : a + b ≤ c + d) (h2 : b + d ≤ c + d) (hx : 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b + d) :    (0 : ℝ) ≤ -2*(a:ℝ)^2*(c:ℝ) - 2*(a:ℝ)^2*(d:ℝ) - (a:ℝ)^2 - 4*(a:ℝ)*(b:ℝ)*(c:ℝ) - 4*(a:ℝ)*(b:ℝ)*(d:ℝ) - 2*(a:ℝ)*(b:ℝ) + 2*(a:ℝ)*(c:ℝ)^3 + 6*(a:ℝ)*(c:ℝ)^2*(d:ℝ) + 2*(a:ℝ)*(c:ℝ)^2 + 6*(a:ℝ)*(c:ℝ)*(d:ℝ)^2 + 4*(a:ℝ)*(c:ℝ)*(d:ℝ) + 2*(a:ℝ)*(d:ℝ)^3 + 2*(a:ℝ)*(d:ℝ)^2 - 2*(b:ℝ)^2*(c:ℝ) - 2*(b:ℝ)^2*(d:ℝ) - (b:ℝ)^2 + 2*(b:ℝ)*(c:ℝ)^3 + 4*(b:ℝ)*(c:ℝ)^2*(d:ℝ) + 2*(b:ℝ)*(c:ℝ)^2 + 2*(b:ℝ)*(c:ℝ)*(d:ℝ)^2 - 2*(b:ℝ)*(d:ℝ)^2 - 2*(b:ℝ)*(d:ℝ) - 4*(c:ℝ)^2 - 8*(c:ℝ)*(d:ℝ) - 8*(c:ℝ) - 4*(d:ℝ)^2 - 8*(d:ℝ) - 4 := by  obtain ⟨r, rfl⟩ : ∃ r, c = b + r := ⟨c - b, by omega⟩  by_cases had : a ≤ d  · obtain ⟨s, rfl⟩ : ∃ s, d = a + s := ⟨d - a, by omega⟩    rcases (show 2 ≤ a ∨ (a = 1 ∧ 3 ≤ b) ∨ (a = 1 ∧ b = 2 ∧ s = 0) ∨ (a = 1 ∧ b = 2 ∧ 1 ≤ s) ∨        (a = 1 ∧ b = 1 ∧ 1 ≤ r) ∨ (a = 1 ∧ b = 1 ∧ r = 0 ∧ 2 ≤ s) by omega) with      h | ⟨rfl, h⟩ | ⟨rfl, rfl, rfl⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, h⟩ | ⟨rfl, rfl, rfl, h⟩    · obtain ⟨p, rfl⟩ : ∃ p, a = 2 + p := ⟨a - 2, by omega⟩      obtain ⟨q, rfl⟩ : ∃ q, b = 1 + q := ⟨b - 1, by omega⟩      push_cast; ring_nf; positivity    · obtain ⟨q, rfl⟩ : ∃ q, b = 3 + q := ⟨b - 3, by omega⟩      push_cast; ring_nf; positivity    · push_cast; ring_nf; positivity    · obtain ⟨v, rfl⟩ : ∃ v, s = 1 + v := ⟨s - 1, by omega⟩      push_cast; ring_nf; positivity    · obtain ⟨v, rfl⟩ : ∃ v, r = 1 + v := ⟨r - 1, by omega⟩      push_cast; ring_nf; positivity    · obtain ⟨v, rfl⟩ : ∃ v, s = 2 + v := ⟨s - 2, by omega⟩      push_cast; ring_nf; positivity  · obtain ⟨t, rfl⟩ : ∃ t, a = d + t := ⟨a - d, by omega⟩    obtain ⟨u, rfl⟩ : ∃ u, r = t + u := ⟨r - t, by omega⟩    obtain ⟨v, rfl⟩ : ∃ v, t = 1 + v := ⟨t - 1, by omega⟩    obtain ⟨q, rfl⟩ : ∃ q, d = 1 + q := ⟨d - 1, by omega⟩    obtain ⟨p, rfl⟩ : ∃ p, b = 1 + p := ⟨b - 1, by omega⟩    push_cast; ring_nf; positivitytheorem b5_gap_G_m1 (a b c d : ℕ) (ha : 1 ≤ a) (hb : 1 ≤ b) (hc : 1 ≤ c) (hd : 1 ≤ d)    (h1 : b + d ≤ a + b) (h2 : c + d ≤ a + b) (hx : 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b + d) :    (0 : ℝ) ≤ 2*(a:ℝ)^3*(c:ℝ) + 2*(a:ℝ)^3*(d:ℝ) + 6*(a:ℝ)^2*(b:ℝ)*(c:ℝ) + 4*(a:ℝ)^2*(b:ℝ)*(d:ℝ) + 2*(a:ℝ)^2*(c:ℝ) + 2*(a:ℝ)^2*(d:ℝ) - 4*(a:ℝ)^2 + 6*(a:ℝ)*(b:ℝ)^2*(c:ℝ) + 2*(a:ℝ)*(b:ℝ)^2*(d:ℝ) + 4*(a:ℝ)*(b:ℝ)*(c:ℝ) - 8*(a:ℝ)*(b:ℝ) - 2*(a:ℝ)*(c:ℝ)^2 - 4*(a:ℝ)*(c:ℝ)*(d:ℝ) - 2*(a:ℝ)*(d:ℝ)^2 - 8*(a:ℝ) + 2*(b:ℝ)^3*(c:ℝ) + 2*(b:ℝ)^2*(c:ℝ) - 2*(b:ℝ)^2*(d:ℝ) - 4*(b:ℝ)^2 - 2*(b:ℝ)*(c:ℝ)^2 - 4*(b:ℝ)*(c:ℝ)*(d:ℝ) - 2*(b:ℝ)*(d:ℝ)^2 - 2*(b:ℝ)*(d:ℝ) - 8*(b:ℝ) - (c:ℝ)^2 - 2*(c:ℝ)*(d:ℝ) - (d:ℝ)^2 - 4 := by  have := b5_gap_G_m3 c d a b hc hd ha hb (by omega) (by omega) (by omega)  ring_nf at this ⊢  linariththeorem b5_gap_identity_m1 (a b c d e : ℝ) :    (a + b + c + d + e) ^ 2 * (e + (a + b) - 1) ^ 2      - ((a - 1) ^ 2 + (b - 1) ^ 2 + (c - 1) ^ 2 + (d - 1) ^ 2 + (e - 1) ^ 2        + 2 * (a * b + c * d + b * d + e * (a + b + c + d))) * (e + (a + b)) ^ 2      = (2*a^3*c + 2*a^3*d + 6*a^2*b*c + 4*a^2*b*d + 2*a^2*c + 2*a^2*d - 4*a^2 + 6*a*b^2*c + 2*a*b^2*d + 4*a*b*c - 8*a*b - 2*a*c^2 - 4*a*c*d - 2*a*d^2 - 8*a + 2*b^3*c + 2*b^2*c - 2*b^2*d - 4*b^2 - 2*b*c^2 - 4*b*c*d - 2*b*d^2 - 2*b*d - 8*b - c^2 - 2*c*d - d^2 - 4) + (4*a^2*c + 4*a^2*d + 8*a*b*c + 4*a*b*d - 8*a + 4*b^2*c - 4*b*d - 8*b - 2*c^2 - 4*c*d - 2*c - 2*d^2 - 2*d - 8) * (e - 1) + (2*a*c + 2*a*d + 2*b*c - 2*c - 2*d - 4) * (e - 1) ^ 2 := by  ringtheorem b5_gap_identity_m2 (a b c d e : ℝ) :    (a + b + c + d + e) ^ 2 * (e + (b + d) - 1) ^ 2      - ((a - 1) ^ 2 + (b - 1) ^ 2 + (c - 1) ^ 2 + (d - 1) ^ 2 + (e - 1) ^ 2        + 2 * (a * b + c * d + b * d + e * (a + b + c + d))) * (e + (b + d)) ^ 2      = (-2*a^2*b - 2*a^2*d - a^2 + 2*a*b^2*c + 2*a*b^2*d - 2*a*b^2 + 4*a*b*c*d + 4*a*b*d^2 - 2*a*b + 2*a*c*d^2 + 2*a*d^3 + 2*a*d^2 + 2*b^3*c + 4*b^2*c*d + 2*b^2*c - 4*b^2 - 2*b*c^2 + 2*b*c*d^2 - 8*b*d - 8*b - 2*c^2*d - c^2 - 2*c*d^2 - 2*c*d - 4*d^2 - 8*d - 4) + (-2*a^2 + 4*a*b*c + 4*a*b*d - 4*a*b + 4*a*c*d + 4*a*d^2 - 2*a + 4*b^2*c + 4*b*c*d - 8*b - 2*c^2 - 4*c*d - 2*c - 8*d - 8) * (e - 1) + (2*a*c + 2*a*d - 2*a + 2*b*c - 2*c - 4) * (e - 1) ^ 2 := by  ringtheorem b5_gap_identity_m3 (a b c d e : ℝ) :    (a + b + c + d + e) ^ 2 * (e + (c + d) - 1) ^ 2      - ((a - 1) ^ 2 + (b - 1) ^ 2 + (c - 1) ^ 2 + (d - 1) ^ 2 + (e - 1) ^ 2        + 2 * (a * b + c * d + b * d + e * (a + b + c + d))) * (e + (c + d)) ^ 2      = (-2*a^2*c - 2*a^2*d - a^2 - 4*a*b*c - 4*a*b*d - 2*a*b + 2*a*c^3 + 6*a*c^2*d + 2*a*c^2 + 6*a*c*d^2 + 4*a*c*d + 2*a*d^3 + 2*a*d^2 - 2*b^2*c - 2*b^2*d - b^2 + 2*b*c^3 + 4*b*c^2*d + 2*b*c^2 + 2*b*c*d^2 - 2*b*d^2 - 2*b*d - 4*c^2 - 8*c*d - 8*c - 4*d^2 - 8*d - 4) + (-2*a^2 - 4*a*b + 4*a*c^2 + 8*a*c*d + 4*a*d^2 - 2*a - 2*b^2 + 4*b*c^2 + 4*b*c*d - 4*b*d - 2*b - 8*c - 8*d - 8) * (e - 1) + (2*a*c + 2*a*d - 2*a + 2*b*c - 2*b - 4) * (e - 1) ^ 2 := by  ringtheorem b5_gap_nonneg (a b c d e : ℕ) (ha : 1 ≤ a) (hb : 1 ≤ b) (hc : 1 ≤ c) (hd : 1 ≤ d) (he : 1 ≤ e)    (hx : ¬ (a = 1 ∧ c = 1 ∧ ((b = 1 ∧ d = 1) ∨ (b = 1 ∧ d = 2) ∨ (b = 2 ∧ d = 1)))) :    ((a : ℝ) - 1) ^ 2 + ((b : ℝ) - 1) ^ 2 + ((c : ℝ) - 1) ^ 2 + ((d : ℝ) - 1) ^ 2 + ((e : ℝ) - 1) ^ 2        + 2 * ((a : ℝ) * b + c * d + b * d + e * (a + b + c + d))      ≤ ((a : ℝ) + b + c + d + e) ^ 2 * (1 - 1 / ((e + max (max (a + b) (b + d)) (c + d) : ℕ) : ℝ)) ^ 2 := by  have hx' : 2 ≤ a ∨ 2 ≤ c ∨ 4 ≤ b + d := by omega  have hxR : (2:ℝ) ≤ a ∨ (2:ℝ) ≤ c ∨ (4:ℝ) ≤ b + d := by    rcases hx' with h | h | h    · exact Or.inl (by exact_mod_cast h)    · exact Or.inr (Or.inl (by exact_mod_cast h))    · exact Or.inr (Or.inr (by exact_mod_cast h))  have haR : (1:ℝ) ≤ a := by exact_mod_cast ha  have hbR : (1:ℝ) ≤ b := by exact_mod_cast hb  have hcR : (1:ℝ) ≤ c := by exact_mod_cast hc  have hdR : (1:ℝ) ≤ d := by exact_mod_cast hd  have heR : (0:ℝ) ≤ (e:ℝ) - 1 := by    have : (1:ℝ) ≤ e := by exact_mod_cast he    linarith  have hw : (0:ℝ) < ((e + max (max (a + b) (b + d)) (c + d) : ℕ) : ℝ) := by    have : 1 ≤ e + max (max (a + b) (b + d)) (c + d) := by omega    exact_mod_cast this  rw [show (1:ℝ) - 1 / ((e + max (max (a + b) (b + d)) (c + d) : ℕ) : ℝ)      = (((e + max (max (a + b) (b + d)) (c + d) : ℕ) : ℝ) - 1)        / ((e + max (max (a + b) (b + d)) (c + d) : ℕ) : ℝ) by field_simp]  rw [div_pow, mul_div_assoc', le_div_iff₀ (by positivity)]  have hcases : (max (max (a + b) (b + d)) (c + d) = a + b ∧ b + d ≤ a + b ∧ c + d ≤ a + b) ∨      (max (max (a + b) (b + d)) (c + d) = b + d ∧ a + b ≤ b + d ∧ c + d ≤ b + d) ∨      (max (max (a + b) (b + d)) (c + d) = c + d ∧ a + b ≤ c + d ∧ b + d ≤ c + d) := by omega  rcases hcases with ⟨hm, h1, h2⟩ | ⟨hm, h1, h2⟩ | ⟨hm, h1, h2⟩  · rw [hm]; push_cast    have h1R : (b:ℝ) + d ≤ a + b := by exact_mod_cast h1    have h2R : (c:ℝ) + d ≤ a + b := by exact_mod_cast h2    have hA := b5_gap_A_m1 a b c d ha hb hc hd h1 h2 hx'    have hD := b5_gap_D_m1 a b c d ha hb hc hd h1 h2 hx'    have hG := b5_gap_G_m1 a b c d ha hb hc hd h1 h2 hx'    have key := b5_gap_identity_m1 a b c d e    have := mul_nonneg hA (sq_nonneg ((e:ℝ) - 1))    have := mul_nonneg hD heR    linarith  · rw [hm]; push_cast    have h1R : (a:ℝ) + b ≤ b + d := by exact_mod_cast h1    have h2R : (c:ℝ) + d ≤ b + d := by exact_mod_cast h2    have hA := b5_gap_A_m2 a b c d ha hb hc hd h1 h2 hx'    have hD := b5_gap_D_m2 a b c d ha hb hc hd h1 h2 hx'    have hG := b5_gap_G_m2 a b c d ha hb hc hd h1 h2 hx'    have key := b5_gap_identity_m2 a b c d e    have := mul_nonneg hA (sq_nonneg ((e:ℝ) - 1))    have := mul_nonneg hD heR    linarith  · rw [hm]; push_cast    have h1R : (a:ℝ) + b ≤ c + d := by exact_mod_cast h1    have h2R : (b:ℝ) + d ≤ c + d := by exact_mod_cast h2    have hA := b5_gap_A_m3 a b c d ha hb hc hd h1 h2 hx'    have hD := b5_gap_D_m3 a b c d ha hb hc hd h1 h2 hx'    have hG := b5_gap_G_m3 a b c d ha hb hc hd h1 h2 hx'    have key := b5_gap_identity_m3 a b c d e    have := mul_nonneg hA (sq_nonneg ((e:ℝ) - 1))    have := mul_nonneg hD heR    linarith
See it in the graphDiscuss this resultChallenge it