-- Mathlib/Algebra/QuadraticDiscriminant.lean
theorem discrim_le_zero (h : ∀ x : K, 0 ≤ a * (x * x) + b * x + c) : discrim a b c ≤ 0

Proof state:
case inr.inl.inl
K : Type u_1
inst✝ : LinearOrderedField K
c : K
h : ∀ (x : K), 0 ≤ 0 * (x * x) + 0 * x + c
⊢ 0 * 0 - 4 * 0 * c ≤ 0

Tactic:
simp

Result:
no goals

Proof state:
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
⊢ b * b - 4 * a * c ≤ 0

Tactic:
obtain ha | rfl | ha : a < 0 ∨ a = 0 ∨ 0 < a := lt_trichotomy a 0

Result:
case inl
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : a < 0
⊢ b * b - 4 * a * c ≤ 0

case inr.inl
K : Type u_1
inst✝ : LinearOrderedField K
b c : K
h : ∀ (x : K), 0 ≤ 0 * (x * x) + b * x + c
⊢ b * b - 4 * 0 * c ≤ 0

case inr.inr
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : 0 < a
⊢ b * b - 4 * a * c ≤ 0

Proof state:
case h.e'_3
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : 0 < a
ha' : 0 ≤ 4 * a
⊢ b * b - 4 * a * c = -(4 * a * (a * (-b / (2 * a) * (-b / (2 * a))) + b * (-b / (2 * a)) + c))

Tactic:
field_simp

Result:
case h.e'_3
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : 0 < a
ha' : 0 ≤ 4 * a
⊢ (b * b - 4 * a * c) * (2 * a * (2 * a) * (2 * a)) =
    -(4 * a * (a * (b * b) * (2 * a) + -(b * b * (2 * a * (2 * a))) + c * (2 * a * (2 * a) * (2 * a))))

Proof state:
case inl
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : a < 0
this : Tendsto (fun x => (a * x + b) * x + c) atTop atBot
⊢ b * b - 4 * a * c ≤ 0

Tactic:
rcases (this.eventually (eventually_lt_atBot 0)).exists with ⟨x, hx⟩

Result:
case inl.intro
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : a < 0
this : Tendsto (fun x => (a * x + b) * x + c) atTop atBot
x : K
hx : (a * x + b) * x + c < 0
⊢ b * b - 4 * a * c ≤ 0

Proof state:
case inr.inr
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : 0 < a
⊢ b * b - 4 * a * c ≤ 0

Tactic:
have ha' : 0 ≤ 4 * a := mul_nonneg zero_le_four ha.le

Result:
case inr.inr
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : 0 < a
ha' : 0 ≤ 4 * a
⊢ b * b - 4 * a * c ≤ 0

Proof state:
case inl.intro
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : a < 0
this : Tendsto (fun x => (a * x + b) * x + c) atTop atBot
x : K
hx : (a * x + b) * x + c < 0
⊢ b * b - 4 * a * c ≤ 0

Tactic:
exact False.elim ((h x).not_lt <| by rwa [← mul_assoc, ← add_mul])

Result:
no goals

Proof state:
case inr.inr
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : 0 < a
ha' : 0 ≤ 4 * a
⊢ b * b - 4 * a * c ≤ 0

Tactic:
convert neg_nonpos.2 (mul_nonneg ha' (h (-b / (2 * a)))) using 1

Result:
case h.e'_3
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : 0 < a
ha' : 0 ≤ 4 * a
⊢ b * b - 4 * a * c = -(4 * a * (a * (-b / (2 * a) * (-b / (2 * a))) + b * (-b / (2 * a)) + c))

Proof state:
case inr.inl.inr
K : Type u_1
inst✝ : LinearOrderedField K
b c : K
h : ∀ (x : K), 0 ≤ 0 * (x * x) + b * x + c
hb : b ≠ 0
this : 0 ≤ 0 * ((-c - 1) / b * ((-c - 1) / b)) + (-c - 1) + c
⊢ b * b - 4 * 0 * c ≤ 0

Tactic:
linarith

Result:
no goals

Proof state:
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : a < 0
this : Tendsto (fun x => (a * x + b) * x + c) atTop atBot
x : K
hx : (a * x + b) * x + c < 0
⊢ a * (x * x) + b * x + c < 0

Tactic:
rwa [← mul_assoc, ← add_mul]

Result:
no goals

Proof state:
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
⊢ discrim a b c ≤ 0

Tactic:
rw [discrim, sq]

Result:
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
⊢ b * b - 4 * a * c ≤ 0

Proof state:
case inl
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : a < 0
⊢ b * b - 4 * a * c ≤ 0

Tactic:
have : Tendsto (fun x => (a * x + b) * x + c) atTop atBot :=
  tendsto_atBot_add_const_right _ c <|
    (tendsto_atBot_add_const_right _ b (tendsto_id.const_mul_atTop_of_neg ha)).atBot_mul_atTop₀
      tendsto_id

Result:
case inl
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : a < 0
this : Tendsto (fun x => (a * x + b) * x + c) atTop atBot
⊢ b * b - 4 * a * c ≤ 0

Proof state:
case inr.inl.inr
K : Type u_1
inst✝ : LinearOrderedField K
b c : K
h : ∀ (x : K), 0 ≤ 0 * (x * x) + b * x + c
hb : b ≠ 0
⊢ b * b - 4 * 0 * c ≤ 0

Tactic:
have := h ((-c - 1) / b)

Result:
case inr.inl.inr
K : Type u_1
inst✝ : LinearOrderedField K
b c : K
h : ∀ (x : K), 0 ≤ 0 * (x * x) + b * x + c
hb : b ≠ 0
this : 0 ≤ 0 * ((-c - 1) / b * ((-c - 1) / b)) + b * ((-c - 1) / b) + c
⊢ b * b - 4 * 0 * c ≤ 0

Proof state:
case inr.inl
K : Type u_1
inst✝ : LinearOrderedField K
b c : K
h : ∀ (x : K), 0 ≤ 0 * (x * x) + b * x + c
⊢ b * b - 4 * 0 * c ≤ 0

Tactic:
rcases eq_or_ne b 0 with (rfl | hb)

Result:
case inr.inl.inl
K : Type u_1
inst✝ : LinearOrderedField K
c : K
h : ∀ (x : K), 0 ≤ 0 * (x * x) + 0 * x + c
⊢ 0 * 0 - 4 * 0 * c ≤ 0

case inr.inl.inr
K : Type u_1
inst✝ : LinearOrderedField K
b c : K
h : ∀ (x : K), 0 ≤ 0 * (x * x) + b * x + c
hb : b ≠ 0
⊢ b * b - 4 * 0 * c ≤ 0

Proof state:
case h.e'_3
K : Type u_1
inst✝ : LinearOrderedField K
a b c : K
h : ∀ (x : K), 0 ≤ a * (x * x) + b * x + c
ha : 0 < a
ha' : 0 ≤ 4 * a
⊢ (b * b - 4 * a * c) * (2 * a * (2 * a) * (2 * a)) =
    -(4 * a * (a * (b * b) * (2 * a) + -(b * b * (2 * a * (2 * a))) + c * (2 * a * (2 * a) * (2 * a))))

Tactic:
ring

Result:
no goals

Proof state:
case inr.inl.inr
K : Type u_1
inst✝ : LinearOrderedField K
b c : K
h : ∀ (x : K), 0 ≤ 0 * (x * x) + b * x + c
hb : b ≠ 0
this : 0 ≤ 0 * ((-c - 1) / b * ((-c - 1) / b)) + b * ((-c - 1) / b) + c
⊢ b * b - 4 * 0 * c ≤ 0

Tactic:
rw [mul_div_cancel₀ _ hb] at this

Result:
case inr.inl.inr
K : Type u_1
inst✝ : LinearOrderedField K
b c : K
h : ∀ (x : K), 0 ≤ 0 * (x * x) + b * x + c
hb : b ≠ 0
this : 0 ≤ 0 * ((-c - 1) / b * ((-c - 1) / b)) + (-c - 1) + c
⊢ b * b - 4 * 0 * c ≤ 0