Theorem: Polynomial.comp_eq_zero_iff
File: Mathlib/Data/Polynomial/RingDivision.lean

tactic: constructor
state_before: R : Type u
S : Type v
T : Type w
a b : R
n : ℕ
inst✝¹ : CommRing R
inst✝ : IsDomain R
p q : R[X]
⊢ comp p q = 0 ↔ p = 0 ∨ eval (coeff q 0) p = 0 ∧ q = ↑C (coeff q 0)

tactic: intro h
state_before: case mp
R : Type u
S : Type v
T : Type w
a b : R
n : ℕ
inst✝¹ : CommRing R
inst✝ : IsDomain R
p q : R[X]
⊢ comp p q = 0 → p = 0 ∨ eval (coeff q 0) p = 0 ∧ q = ↑C (coeff q 0)

tactic: have key : p.natDegree = 0 ∨ q.natDegree = 0 := by
  rw [← mul_eq_zero, ← natDegree_comp, h, natDegree_zero]
state_before: case mp
R : Type u
S : Type v
T : Type w
a b : R
n : ℕ
inst✝¹ : CommRing R
inst✝ : IsDomain R
p q : R[X]
h : comp p q = 0
⊢ p = 0 ∨ eval (coeff q 0) p = 0 ∧ q = ↑C (coeff q 0)

tactic: replace key := Or.imp eq_C_of_natDegree_eq_zero eq_C_of_natDegree_eq_zero key
state_before: case mp
R : Type u
S : Type v
T : Type w
a b : R
n : ℕ
inst✝¹ : CommRing R
inst✝ : IsDomain R
p q : R[X]
h : comp p q = 0
key : natDegree p = 0 ∨ natDegree q = 0
⊢ p = 0 ∨ eval (coeff q 0) p = 0 ∧ q = ↑C (coeff q 0)

tactic: cases' key with key key
state_before: case mp
R : Type u
S : Type v
T : Type w
a b : R
n : ℕ
inst✝¹ : CommRing R
inst✝ : IsDomain R
p q : R[X]
h : comp p q = 0
key : p = ↑C (coeff p 0) ∨ q = ↑C (coeff q 0)
⊢ p = 0 ∨ eval (coeff q 0) p = 0 ∧ q = ↑C (coeff q 0)

tactic: rw [← mul_eq_zero, ← natDegree_comp, h, natDegree_zero]
state_before: R : Type u
S : Type v
T : Type w
a b : R
n : ℕ
inst✝¹ : CommRing R
inst✝ : IsDomain R
p q : R[X]
h : comp p q = 0
⊢ natDegree p = 0 ∨ natDegree q = 0

tactic: rw [key, C_comp] at h
state_before: case mp.inl
R : Type u
S : Type v
T : Type w
a b : R
n : ℕ
inst✝¹ : CommRing R
inst✝ : IsDomain R
p q : R[X]
h : comp p q = 0
key : p = ↑C (coeff p 0)
⊢ p = 0 ∨ eval (coeff q 0) p = 0 ∧ q = ↑C (coeff q 0)

tactic: exact Or.inl (key.trans h)
state_before: case mp.inl
R : Type u
S : Type v
T : Type w
a b : R
n : ℕ
inst✝¹ : CommRing R
inst✝ : IsDomain R
p q : R[X]
h : ↑C (coeff p 0) = 0
key : p = ↑C (coeff p 0)
⊢ p = 0 ∨ eval (coeff q 0) p = 0 ∧ q = ↑C (coeff q 0)

tactic: rw [key, comp_C, C_eq_zero] at h
state_before: case mp.inr
R : Type u
S : Type v
T : Type w
a b : R
n : ℕ
inst✝¹ : CommRing R
inst✝ : IsDomain R
p q : R[X]
h : comp p q = 0
key : q = ↑C (coeff q 0)
⊢ p = 0 ∨ eval (coeff q 0) p = 0 ∧ q = ↑C (coeff q 0)

tactic: exact Or.inr ⟨h, key⟩
state_before: case mp.inr
R : Type u
S : Type v
T : Type w
a b : R
n : ℕ
inst✝¹ : CommRing R
inst✝ : IsDomain R
p q : R[X]
h : eval (coeff q 0) p = 0
key : q = ↑C (coeff q 0)
⊢ p = 0 ∨ eval (coeff q 0) p = 0 ∧ q = ↑C (coeff q 0)

tactic: exact fun h =>
  Or.rec (fun h => by rw [h, zero_comp]) (fun h => by rw [h.2, comp_C, h.1, C_0]) h
state_before: case mpr
R : Type u
S : Type v
T : Type w
a b : R
n : ℕ
inst✝¹ : CommRing R
inst✝ : IsDomain R
p q : R[X]
⊢ p = 0 ∨ eval (coeff q 0) p = 0 ∧ q = ↑C (coeff q 0) → comp p q = 0

tactic: rw [h, zero_comp]
state_before: R : Type u
S : Type v
T : Type w
a b : R
n : ℕ
inst✝¹ : CommRing R
inst✝ : IsDomain R
p q : R[X]
h✝ : p = 0 ∨ eval (coeff q 0) p = 0 ∧ q = ↑C (coeff q 0)
h : p = 0
⊢ comp p q = 0

tactic: rw [h.2, comp_C, h.1, C_0]
state_before: R : Type u
S : Type v
T : Type w
a b : R
n : ℕ
inst✝¹ : CommRing R
inst✝ : IsDomain R
p q : R[X]
h✝ : p = 0 ∨ eval (coeff q 0) p = 0 ∧ q = ↑C (coeff q 0)
h : eval (coeff q 0) p = 0 ∧ q = ↑C (coeff q 0)
⊢ comp p q = 0