Theorem: Polynomial.degree_add_divByMonic
File: Mathlib/Data/Polynomial/Div.lean

tactic: nontriviality R
state_before: R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : CommRing R
p q : R[X]
hq : Monic q
h : degree q ≤ degree p
⊢ degree q + degree (p /ₘ q) = degree p

tactic: have hdiv0 : p /ₘ q ≠ 0 := by rwa [Ne.def, divByMonic_eq_zero_iff hq, not_lt]
state_before: R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : CommRing R
p q : R[X]
hq : Monic q
h : degree q ≤ degree p
✝ : Nontrivial R
⊢ degree q + degree (p /ₘ q) = degree p

tactic: have hlc : leadingCoeff q * leadingCoeff (p /ₘ q) ≠ 0 := by
  rwa [Monic.def.1 hq, one_mul, Ne.def, leadingCoeff_eq_zero]
state_before: R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : CommRing R
p q : R[X]
hq : Monic q
h : degree q ≤ degree p
✝ : Nontrivial R
hdiv0 : p /ₘ q ≠ 0
⊢ degree q + degree (p /ₘ q) = degree p

tactic: have hmod : degree (p %ₘ q) < degree (q * (p /ₘ q)) :=
  calc
    degree (p %ₘ q) < degree q := degree_modByMonic_lt _ hq
    _ ≤ _ := by
      rw [degree_mul' hlc, degree_eq_natDegree hq.ne_zero, degree_eq_natDegree hdiv0, ←
          Nat.cast_add, Nat.cast_withBot, Nat.cast_withBot, WithBot.coe_le_coe]
      exact Nat.le_add_right _ _
state_before: R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : CommRing R
p q : R[X]
hq : Monic q
h : degree q ≤ degree p
✝ : Nontrivial R
hdiv0 : p /ₘ q ≠ 0
hlc : leadingCoeff q * leadingCoeff (p /ₘ q) ≠ 0
⊢ degree q + degree (p /ₘ q) = degree p

tactic: calc
  degree q + degree (p /ₘ q) = degree (q * (p /ₘ q)) := Eq.symm (degree_mul' hlc)
  _ = degree (p %ₘ q + q * (p /ₘ q)) := (degree_add_eq_right_of_degree_lt hmod).symm
  _ = _ := congr_arg _ (modByMonic_add_div _ hq)
state_before: R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : CommRing R
p q : R[X]
hq : Monic q
h : degree q ≤ degree p
✝ : Nontrivial R
hdiv0 : p /ₘ q ≠ 0
hlc : leadingCoeff q * leadingCoeff (p /ₘ q) ≠ 0
hmod : degree (p %ₘ q) < degree (q * (p /ₘ q))
⊢ degree q + degree (p /ₘ q) = degree p

tactic: rwa [Ne.def, divByMonic_eq_zero_iff hq, not_lt]
state_before: R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : CommRing R
p q : R[X]
hq : Monic q
h : degree q ≤ degree p
✝ : Nontrivial R
⊢ p /ₘ q ≠ 0

tactic: rwa [Monic.def.1 hq, one_mul, Ne.def, leadingCoeff_eq_zero]
state_before: R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : CommRing R
p q : R[X]
hq : Monic q
h : degree q ≤ degree p
✝ : Nontrivial R
hdiv0 : p /ₘ q ≠ 0
⊢ leadingCoeff q * leadingCoeff (p /ₘ q) ≠ 0

tactic: rw [degree_mul' hlc, degree_eq_natDegree hq.ne_zero, degree_eq_natDegree hdiv0, ←
    Nat.cast_add, Nat.cast_withBot, Nat.cast_withBot, WithBot.coe_le_coe]
state_before: R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : CommRing R
p q : R[X]
hq : Monic q
h : degree q ≤ degree p
✝ : Nontrivial R
hdiv0 : p /ₘ q ≠ 0
hlc : leadingCoeff q * leadingCoeff (p /ₘ q) ≠ 0
⊢ degree q ≤ degree (q * (p /ₘ q))

tactic: exact Nat.le_add_right _ _
state_before: R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : CommRing R
p q : R[X]
hq : Monic q
h : degree q ≤ degree p
✝ : Nontrivial R
hdiv0 : p /ₘ q ≠ 0
hlc : leadingCoeff q * leadingCoeff (p /ₘ q) ≠ 0
⊢ natDegree q ≤ natDegree q + natDegree (p /ₘ q)