Theorem: Polynomial.derivative_rootMultiplicity_of_root
File: Mathlib/Data/Polynomial/FieldDivision.lean

tactic: rcases eq_or_ne p 0 with (rfl | hp)
state_before: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
⊢ rootMultiplicity t (↑derivative p) = rootMultiplicity t p - 1

tactic: nth_rw 1 [← p.divByMonic_mul_pow_rootMultiplicity_eq t]
state_before: case inr
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
⊢ rootMultiplicity t (↑derivative p) = rootMultiplicity t p - 1

tactic: simp only [derivative_pow, derivative_mul, derivative_sub, derivative_X, derivative_C, sub_zero,
  mul_one]
state_before: case inr
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
⊢ rootMultiplicity t (↑derivative (p /ₘ (X - ↑C t) ^ rootMultiplicity t p * (X - ↑C t) ^ rootMultiplicity t p)) =
    rootMultiplicity t p - 1

tactic: set n := p.rootMultiplicity t - 1
state_before: case inr
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
⊢ rootMultiplicity t
      (↑derivative (p /ₘ (X - ↑C t) ^ rootMultiplicity t p) * (X - ↑C t) ^ rootMultiplicity t p +
        p /ₘ (X - ↑C t) ^ rootMultiplicity t p *
          (↑C ↑(rootMultiplicity t p) * (X - ↑C t) ^ (rootMultiplicity t p - 1))) =
    rootMultiplicity t p - 1

tactic: have hn : n + 1 = _ := tsub_add_cancel_of_le ((rootMultiplicity_pos hp).mpr hpt)
state_before: case inr
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
⊢ rootMultiplicity t
      (↑derivative (p /ₘ (X - ↑C t) ^ rootMultiplicity t p) * (X - ↑C t) ^ rootMultiplicity t p +
        p /ₘ (X - ↑C t) ^ rootMultiplicity t p * (↑C ↑(rootMultiplicity t p) * (X - ↑C t) ^ n)) =
    n

tactic: rw [← hn]
state_before: case inr
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
⊢ rootMultiplicity t
      (↑derivative (p /ₘ (X - ↑C t) ^ rootMultiplicity t p) * (X - ↑C t) ^ rootMultiplicity t p +
        p /ₘ (X - ↑C t) ^ rootMultiplicity t p * (↑C ↑(rootMultiplicity t p) * (X - ↑C t) ^ n)) =
    n

tactic: set q := p /ₘ (X - C t) ^ (n + 1) with _hq
state_before: case inr
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
⊢ rootMultiplicity t
      (↑derivative (p /ₘ (X - ↑C t) ^ (n + 1)) * (X - ↑C t) ^ (n + 1) +
        p /ₘ (X - ↑C t) ^ (n + 1) * (↑C ↑(n + 1) * (X - ↑C t) ^ n)) =
    n

tactic: convert_to rootMultiplicity t ((X - C t) ^ n * (derivative q * (X - C t) + q * C ↑(n + 1))) = n
state_before: case inr
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1)
_hq : q = p /ₘ (X - ↑C t) ^ (n + 1)
⊢ rootMultiplicity t (↑derivative q * (X - ↑C t) ^ (n + 1) + q * (↑C ↑(n + 1) * (X - ↑C t) ^ n)) = n

tactic: have h : eval t (derivative q * (X - C t) + q * C (R := R) ↑(n + 1)) ≠ 0 := by
  suffices eval t q * ↑(n + 1) ≠ 0 by simpa
  refine' mul_ne_zero _ (Nat.cast_ne_zero.mpr n.succ_ne_zero)
  convert eval_divByMonic_pow_rootMultiplicity_ne_zero t hp
state_before: case inr
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1)
_hq : q = p /ₘ (X - ↑C t) ^ (n + 1)
⊢ rootMultiplicity t ((X - ↑C t) ^ n * (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1))) = n

tactic: rw [rootMultiplicity_mul, rootMultiplicity_X_sub_C_pow, rootMultiplicity_eq_zero h, add_zero]
state_before: case inr
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1)
_hq : q = p /ₘ (X - ↑C t) ^ (n + 1)
h : eval t (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1)) ≠ 0
⊢ rootMultiplicity t ((X - ↑C t) ^ n * (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1))) = n

tactic: refine' mul_ne_zero (pow_ne_zero n <| X_sub_C_ne_zero t) _
state_before: case inr
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1)
_hq : q = p /ₘ (X - ↑C t) ^ (n + 1)
h : eval t (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1)) ≠ 0
⊢ (X - ↑C t) ^ n * (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1)) ≠ 0

tactic: contrapose! h
state_before: case inr
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1)
_hq : q = p /ₘ (X - ↑C t) ^ (n + 1)
h : eval t (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1)) ≠ 0
⊢ ↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1) ≠ 0

tactic: rw [h, eval_zero]
state_before: case inr
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1)
_hq : q = p /ₘ (X - ↑C t) ^ (n + 1)
h :
  ↑derivative (p /ₘ (X - ↑C t) ^ (n + 1)) * (X - ↑C t) +
      p /ₘ (X - ↑C t) ^ (n + 1) * ↑C ↑(rootMultiplicity t p - 1 + 1) =
    0
⊢ eval t
      (↑derivative (p /ₘ (X - ↑C t) ^ (n + 1)) * (X - ↑C t) +
        p /ₘ (X - ↑C t) ^ (n + 1) * ↑C ↑(rootMultiplicity t p - 1 + 1)) =
    0

tactic: simp
state_before: case inl
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
t : R
hpt : IsRoot 0 t
⊢ rootMultiplicity t (↑derivative 0) = rootMultiplicity t 0 - 1

tactic: congr
state_before: case h.e'_2
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1)
_hq : q = p /ₘ (X - ↑C t) ^ (n + 1)
⊢ rootMultiplicity t (↑derivative q * (X - ↑C t) ^ (n + 1) + q * (↑C ↑(n + 1) * (X - ↑C t) ^ n)) =
    rootMultiplicity t ((X - ↑C t) ^ n * (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1)))

tactic: rw [mul_add, mul_left_comm <| (X - C t) ^ n, ← pow_succ']
state_before: case h.e'_2.e_p
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1)
_hq : q = p /ₘ (X - ↑C t) ^ (n + 1)
⊢ ↑derivative q * (X - ↑C t) ^ (n + 1) + q * (↑C ↑(n + 1) * (X - ↑C t) ^ n) =
    (X - ↑C t) ^ n * (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1))

tactic: congr 1
state_before: case h.e'_2.e_p
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1)
_hq : q = p /ₘ (X - ↑C t) ^ (n + 1)
⊢ ↑derivative q * (X - ↑C t) ^ (n + 1) + q * (↑C ↑(n + 1) * (X - ↑C t) ^ n) =
    ↑derivative q * (X - ↑C t) ^ (n + 1) + (X - ↑C t) ^ n * (q * ↑C ↑(n + 1))

tactic: rw [mul_left_comm <| (X - C t) ^ n, mul_comm <| (X - C t) ^ n]
state_before: case h.e'_2.e_p.e_a
R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1)
_hq : q = p /ₘ (X - ↑C t) ^ (n + 1)
⊢ q * (↑C ↑(n + 1) * (X - ↑C t) ^ n) = (X - ↑C t) ^ n * (q * ↑C ↑(n + 1))

tactic: suffices eval t q * ↑(n + 1) ≠ 0 by simpa
state_before: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1)
_hq : q = p /ₘ (X - ↑C t) ^ (n + 1)
⊢ eval t (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1)) ≠ 0

tactic: refine' mul_ne_zero _ (Nat.cast_ne_zero.mpr n.succ_ne_zero)
state_before: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1)
_hq : q = p /ₘ (X - ↑C t) ^ (n + 1)
⊢ eval t q * ↑(n + 1) ≠ 0

tactic: convert eval_divByMonic_pow_rootMultiplicity_ne_zero t hp
state_before: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1)
_hq : q = p /ₘ (X - ↑C t) ^ (n + 1)
⊢ eval t q ≠ 0

tactic: simpa
state_before: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n✝ : ℕ
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : CharZero R
p : R[X]
t : R
hpt : IsRoot p t
hp : p ≠ 0
n : ℕ := rootMultiplicity t p - 1
hn : n + 1 = rootMultiplicity t p
q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1)
_hq : q = p /ₘ (X - ↑C t) ^ (n + 1)
this : eval t q * ↑(n + 1) ≠ 0
⊢ eval t (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1)) ≠ 0