Skip to content

Commit 3aa8562

Browse files
Xmask19ocfnash
andcommitted
feat: add TendstoCofinite lemma for polynomial functions (#40807)
Add `Polynomial.tendstoCofinite_of_natDegree_ne_zero`, which states that a non-constant (univariate) polynomial over a domain has finite fibres. Co-authored-by: Bhavik Mehta Co-authored-by: Oliver Nash <7734364+ocfnash@users.noreply.github.com>
1 parent 40b6a8f commit 3aa8562

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

Mathlib/Algebra/Polynomial/Degree/Defs.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ theorem Monic.leadingCoeff {p : R[X]} (hp : p.Monic) : leadingCoeff p = 1 :=
7373
theorem Monic.coeff_natDegree {p : R[X]} (hp : p.Monic) : p.coeff p.natDegree = 1 :=
7474
hp
7575

76-
@[simp]
76+
@[simp, grind =]
7777
theorem degree_zero : degree (0 : R[X]) = ⊥ :=
7878
rfl
7979

80-
@[simp]
80+
@[simp, grind =]
8181
theorem natDegree_zero : natDegree (0 : R[X]) = 0 :=
8282
rfl
8383

@@ -161,18 +161,18 @@ theorem degree_C_lt : degree (C a) < 1 :=
161161

162162
theorem degree_one_le : degree (1 : R[X]) ≤ (0 : WithBot ℕ) := by rw [← C_1]; exact degree_C_le
163163

164-
@[simp]
164+
@[simp, grind =]
165165
theorem natDegree_C (a : R) : natDegree (C a) = 0 := by
166166
by_cases ha : a = 0
167167
· have : C a = 0 := by rw [ha, C_0]
168168
rw [natDegree, degree_eq_bot.2 this, WithBot.unbotD_bot]
169169
· rw [natDegree, degree_C ha, WithBot.unbotD_zero]
170170

171-
@[simp]
171+
@[simp, grind =]
172172
theorem natDegree_one : natDegree (1 : R[X]) = 0 :=
173173
natDegree_C 1
174174

175-
@[simp]
175+
@[simp, grind =]
176176
theorem natDegree_natCast (n : ℕ) : natDegree (n : R[X]) = 0 := by
177177
simp only [← C_eq_natCast, natDegree_C]
178178

Mathlib/Algebra/Polynomial/Roots.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public import Mathlib.Data.Set.Finite.Lemmas
1212
public import Mathlib.RingTheory.Coprime.Lemmas
1313
public import Mathlib.RingTheory.Localization.FractionRing
1414
public import Mathlib.SetTheory.Cardinal.Order
15+
public import Mathlib.Order.Filter.TendstoCofinite
1516

1617
/-!
1718
# Theory of univariate polynomials
@@ -157,6 +158,15 @@ theorem eq_of_infinite_eval_eq (p q : R[X]) (h : Set.Infinite { x | eval x p = e
157158
apply eq_zero_of_infinite_isRoot
158159
simpa only [IsRoot, eval_sub, sub_eq_zero]
159160

161+
/-- Non-constant polynomials have finite fibres, provided the coefficients are a domain. -/
162+
lemma tendstoCofinite_of_natDegree_ne_zero {R : Type} [CommRing R] [IsDomain R] (p : R[X])
163+
(hp : p.natDegree ≠ 0) : Filter.TendstoCofinite p.eval := by
164+
rw [Filter.tendstoCofinite_iff_finite_preimage_singleton]
165+
intro x
166+
by_contra! hx
167+
obtain ⟨rfl⟩ : p = C x := p.eq_of_infinite_eval_eq (C x) (by simpa)
168+
simp at hp
169+
160170
theorem roots_mul {p q : R[X]} (hpq : p * q ≠ 0) : (p * q).roots = p.roots + q.roots := by
161171
classical
162172
exact Multiset.ext.mpr fun r => by

Mathlib/RingTheory/PowerBasis.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ theorem mem_span_pow {x y : S} {d : ℕ} (hd : d ≠ 0) :
115115
· rintro ⟨f, h, hy⟩
116116
refine ⟨f, ?_, hy⟩
117117
by_cases hf : f = 0
118-
· simp only [hf, natDegree_zero, degree_zero] at h ⊢
118+
· simp only [hf, natDegree_zero, Polynomial.degree_zero] at h ⊢
119119
first | exact lt_of_le_of_ne (Nat.zero_le d) hd.symm | exact WithBot.bot_lt_coe d
120120
simpa [degree_eq_natDegree hf] using h
121121

0 commit comments

Comments
 (0)