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

tactic: rw [← modByMonic_add_div p hq, h, zero_add]
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 : p %ₘ q = 0
⊢ q ∣ p

tactic: exact dvd_mul_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 : p %ₘ q = 0
⊢ q ∣ q * (p /ₘ q)

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 : q ∣ p
⊢ p %ₘ q = 0

tactic: obtain ⟨r, hr⟩ := exists_eq_mul_right_of_dvd h
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 : q ∣ p
✝ : Nontrivial R
⊢ p %ₘ q = 0

tactic: by_contra hpq0
state_before: case intro
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 : q ∣ p
✝ : Nontrivial R
r : R[X]
hr : p = q * r
⊢ p %ₘ q = 0

tactic: have hmod : p %ₘ q = q * (r - p /ₘ q) := by rw [modByMonic_eq_sub_mul_div _ hq, mul_sub, ← hr]
state_before: case intro
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 : q ∣ p
✝ : Nontrivial R
r : R[X]
hr : p = q * r
hpq0 : ¬p %ₘ q = 0
⊢ False

tactic: have : degree (q * (r - p /ₘ q)) < degree q := hmod ▸ degree_modByMonic_lt _ hq
state_before: case intro
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 : q ∣ p
✝ : Nontrivial R
r : R[X]
hr : p = q * r
hpq0 : ¬p %ₘ q = 0
hmod : p %ₘ q = q * (r - p /ₘ q)
⊢ False

tactic: have hrpq0 : leadingCoeff (r - p /ₘ q) ≠ 0 := fun h =>
  hpq0 <|
    leadingCoeff_eq_zero.1
      (by rw [hmod, leadingCoeff_eq_zero.1 h, MulZeroClass.mul_zero, leadingCoeff_zero])
state_before: case intro
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 : q ∣ p
✝ : Nontrivial R
r : R[X]
hr : p = q * r
hpq0 : ¬p %ₘ q = 0
hmod : p %ₘ q = q * (r - p /ₘ q)
this : degree (q * (r - p /ₘ q)) < degree q
⊢ False

tactic: have hlc : leadingCoeff q * leadingCoeff (r - p /ₘ q) ≠ 0 := by rwa [Monic.def.1 hq, one_mul]
state_before: case intro
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 : q ∣ p
✝ : Nontrivial R
r : R[X]
hr : p = q * r
hpq0 : ¬p %ₘ q = 0
hmod : p %ₘ q = q * (r - p /ₘ q)
this : degree (q * (r - p /ₘ q)) < degree q
hrpq0 : leadingCoeff (r - p /ₘ q) ≠ 0
⊢ False

tactic: rw [degree_mul' hlc, degree_eq_natDegree hq.ne_zero,
  degree_eq_natDegree (mt leadingCoeff_eq_zero.2 hrpq0)] at this
state_before: case intro
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 : q ∣ p
✝ : Nontrivial R
r : R[X]
hr : p = q * r
hpq0 : ¬p %ₘ q = 0
hmod : p %ₘ q = q * (r - p /ₘ q)
this : degree (q * (r - p /ₘ q)) < degree q
hrpq0 : leadingCoeff (r - p /ₘ q) ≠ 0
hlc : leadingCoeff q * leadingCoeff (r - p /ₘ q) ≠ 0
⊢ False

tactic: exact not_lt_of_ge (Nat.le_add_right _ _) (WithBot.some_lt_some.1 this)
state_before: case intro
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 : q ∣ p
✝ : Nontrivial R
r : R[X]
hr : p = q * r
hpq0 : ¬p %ₘ q = 0
hmod : p %ₘ q = q * (r - p /ₘ q)
this : ↑(natDegree q) + ↑(natDegree (r - p /ₘ q)) < ↑(natDegree q)
hrpq0 : leadingCoeff (r - p /ₘ q) ≠ 0
hlc : leadingCoeff q * leadingCoeff (r - p /ₘ q) ≠ 0
⊢ False

tactic: rw [modByMonic_eq_sub_mul_div _ hq, mul_sub, ← hr]
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 : q ∣ p
✝ : Nontrivial R
r : R[X]
hr : p = q * r
hpq0 : ¬p %ₘ q = 0
⊢ p %ₘ q = q * (r - p /ₘ q)

tactic: rw [hmod, leadingCoeff_eq_zero.1 h, MulZeroClass.mul_zero, leadingCoeff_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✝ : q ∣ p
✝ : Nontrivial R
r : R[X]
hr : p = q * r
hpq0 : ¬p %ₘ q = 0
hmod : p %ₘ q = q * (r - p /ₘ q)
this : degree (q * (r - p /ₘ q)) < degree q
h : leadingCoeff (r - p /ₘ q) = 0
⊢ leadingCoeff (p %ₘ q) = 0

tactic: rwa [Monic.def.1 hq, one_mul]
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 : q ∣ p
✝ : Nontrivial R
r : R[X]
hr : p = q * r
hpq0 : ¬p %ₘ q = 0
hmod : p %ₘ q = q * (r - p /ₘ q)
this : degree (q * (r - p /ₘ q)) < degree q
hrpq0 : leadingCoeff (r - p /ₘ q) ≠ 0
⊢ leadingCoeff q * leadingCoeff (r - p /ₘ q) ≠ 0