Skip to content

Commit 970fa80

Browse files
committed
feat(Polynomial/Roots): add a theorem for computing roots (#32357)
The theorem `roots_eq_of_degree` shows that S is the set of roots of a degree d polynomial P if #S = d and P(x) = 0 for every x in S.
1 parent 6014a43 commit 970fa80

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Mathlib/Algebra/Polynomial/Roots.lean

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,20 @@ theorem card_roots_X_pow_sub_C {n : ℕ} (hn : 0 < n) (a : R) :
286286
card_roots (X_pow_sub_C_ne_zero hn a)
287287
_ = n := degree_X_pow_sub_C hn a
288288

289+
theorem roots_eq_of_degree_le_card_of_ne_zero {S : Finset R}
290+
(hS : ∀ x ∈ S, p.eval x = 0) (hcard : p.degree ≤ S.card) (hp : p ≠ 0) : p.roots = S.val := by
291+
refine (Multiset.eq_of_le_of_card_le ?_ ?_).symm
292+
· exact (Finset.val_le_iff_val_subset.mpr (fun x hx ↦ (p.mem_roots hp).mpr (hS x hx)))
293+
· simpa using (p.card_roots hp).trans hcard
294+
295+
theorem roots_eq_of_degree_le_card {S : Finset R}
296+
(hS : ∀ x ∈ S, p.eval x = 0) (hcard : S.card = p.degree) : p.roots = S.val :=
297+
roots_eq_of_degree_le_card_of_ne_zero hS (by lia) (by contrapose! hcard; simp [hcard])
298+
299+
theorem roots_eq_of_natDegree_le_card_of_ne_zero {S : Finset R}
300+
(hS : ∀ x ∈ S, p.eval x = 0) (hcard : p.natDegree ≤ S.card) (hp : p ≠ 0) : p.roots = S.val :=
301+
roots_eq_of_degree_le_card_of_ne_zero hS (degree_le_of_natDegree_le hcard) hp
302+
289303
section NthRoots
290304

291305
/-- `nthRoots n a` noncomputably returns the solutions to `x ^ n = a`. -/

0 commit comments

Comments
 (0)