Skip to content

Commit bfed280

Browse files
urkudRaggedR
authored andcommitted
chore(Algebra/Polynomial): golf (leanprover-community#39208)
Use existing lemmas instead of reinventing the wheel.
1 parent 72dec69 commit bfed280

2 files changed

Lines changed: 5 additions & 18 deletions

File tree

Mathlib/Algebra/Polynomial/AlgebraMap.lean

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -630,28 +630,12 @@ section Ring
630630
variable [Ring R]
631631

632632
/-- The evaluation map is not generally multiplicative when the coefficient ring is noncommutative,
633-
but nevertheless any polynomial of the form `p * (X - monomial 0 r)` is sent to zero
634-
when evaluated at `r`.
633+
but nevertheless any polynomial of the form `p * (X - C r)` is sent to zero when evaluated at `r`.
635634
636635
This is the key step in our proof of the Cayley-Hamilton theorem.
637636
-/
638637
theorem eval_mul_X_sub_C {p : R[X]} (r : R) : (p * (X - C r)).eval r = 0 := by
639-
simp only [eval, eval₂_eq_sum, RingHom.id_apply]
640-
have bound :=
641-
calc
642-
(p * (X - C r)).natDegree ≤ p.natDegree + (X - C r).natDegree := natDegree_mul_le
643-
_ ≤ p.natDegree + 1 := by grw [natDegree_X_sub_C_le]
644-
_ < p.natDegree + 2 := lt_add_one _
645-
rw [sum_over_range' _ _ (p.natDegree + 2) bound]
646-
swap
647-
· simp
648-
rw [sum_range_succ']
649-
conv_lhs =>
650-
congr
651-
arg 2
652-
simp [coeff_mul_X_sub_C, sub_mul, mul_assoc, ← pow_succ']
653-
rw [sum_range_sub']
654-
simp
638+
rw [mul_sub, eval_sub, eval_mul_X, eval_mul_C_of_commute] <;> simp
655639

656640
theorem not_isUnit_X_sub_C [Nontrivial R] (r : R) : ¬IsUnit (X - C r) :=
657641
fun ⟨⟨_, g, _hfg, hgf⟩, rfl⟩ => zero_ne_one' R <| by rw [← eval_mul_X_sub_C, hgf, eval_one]

Mathlib/Algebra/Polynomial/Eval/Defs.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ theorem eval_mul_X_pow {k : ℕ} : (p * X ^ k).eval x = p.eval x * x ^ k := by
325325
| zero => simp
326326
| succ k ih => simp [pow_succ, ← mul_assoc, ih]
327327

328+
theorem eval_mul_C_of_commute (h : Commute a x) : (p * C a).eval x = p.eval x * a := by
329+
rw [eval, eval₂_mul_C'] <;> simp [h]
330+
328331
/-- Polynomial evaluation commutes with `List.sum`. -/
329332
theorem eval_listSum (l : List R[X]) (x : R) : eval x l.sum = (l.map (eval x)).sum :=
330333
eval₂_list_sum ..

0 commit comments

Comments
 (0)