Skip to content

Commit 21bf164

Browse files
committed
refactor(Algebra/Polynomial/Factors): rename Factors to Splits (#31878)
This PR renames `Factors` to `Splits`. There is still plenty of work to be done in cleaning up `Splits.lean`, but that can wait for follow-up PRs. The first commit is a direct find & replace, and the rest are manual fixes. Co-authored-by: tb65536 <thomas.l.browning@gmail.com>
1 parent 588a751 commit 21bf164

File tree

10 files changed

+110
-128
lines changed

10 files changed

+110
-128
lines changed

Mathlib/Algebra/Polynomial/Factors.lean

Lines changed: 73 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@ public import Mathlib.Algebra.Polynomial.FieldDivision
1010
/-!
1111
# Split polynomials
1212
13-
A polynomial `f : R[X]` factors if it is a product of constant and monic linear polynomials.
13+
A polynomial `f : R[X]` splits if it is a product of constant and monic linear polynomials.
1414
1515
## Main definitions
1616
17-
* `Polynomial.Factors f`: A predicate on a polynomial `f` saying that `f` is a product of
17+
* `Polynomial.Splits f`: A predicate on a polynomial `f` saying that `f` is a product of
1818
constant and monic linear polynomials.
1919
20-
## TODO
21-
22-
- Redefine `Splits` in terms of `Factors` and then deprecate `Splits`.
23-
2420
-/
2521

2622
@[expose] public section
@@ -33,67 +29,67 @@ section Semiring
3329

3430
variable [Semiring R]
3531

36-
/-- A polynomial `Factors` if it is a product of constant and monic linear polynomials.
32+
/-- A polynomial `Splits` if it is a product of constant and monic linear polynomials.
3733
This will eventually replace `Polynomial.Splits`. -/
38-
def Factors (f : R[X]) : Prop := f ∈ Submonoid.closure ({C a | a : R} ∪ {X + C a | a : R})
34+
def Splits (f : R[X]) : Prop := f ∈ Submonoid.closure ({C a | a : R} ∪ {X + C a | a : R})
3935

4036
@[simp, aesop safe apply]
41-
protected theorem Factors.C (a : R) : Factors (C a) :=
37+
protected theorem Splits.C (a : R) : Splits (C a) :=
4238
Submonoid.mem_closure_of_mem (Set.mem_union_left _ ⟨a, rfl⟩)
4339

4440
@[simp, aesop safe apply]
45-
protected theorem Factors.zero : Factors (0 : R[X]) := by
46-
simpa using Factors.C (0 : R)
41+
protected theorem Splits.zero : Splits (0 : R[X]) := by
42+
simpa using Splits.C (0 : R)
4743

4844
@[simp, aesop safe apply]
49-
protected theorem Factors.one : Factors (1 : R[X]) :=
50-
Factors.C (1 : R)
45+
protected theorem Splits.one : Splits (1 : R[X]) :=
46+
Splits.C (1 : R)
5147

5248
@[simp, aesop safe apply]
53-
theorem Factors.X_add_C (a : R) : Factors (X + C a) :=
49+
theorem Splits.X_add_C (a : R) : Splits (X + C a) :=
5450
Submonoid.mem_closure_of_mem (Set.mem_union_right _ ⟨a, rfl⟩)
5551

5652
@[simp, aesop safe apply]
57-
protected theorem Factors.X : Factors (X : R[X]) := by
58-
simpa using Factors.X_add_C (0 : R)
53+
protected theorem Splits.X : Splits (X : R[X]) := by
54+
simpa using Splits.X_add_C (0 : R)
5955

6056
@[simp, aesop safe apply]
61-
protected theorem Factors.mul {f g : R[X]} (hf : Factors f) (hg : Factors g) :
62-
Factors (f * g) :=
57+
protected theorem Splits.mul {f g : R[X]} (hf : Splits f) (hg : Splits g) :
58+
Splits (f * g) :=
6359
mul_mem hf hg
6460

65-
protected theorem Factors.C_mul {f : R[X]} (hf : Factors f) (a : R) : Factors (C a * f) :=
66-
(Factors.C a).mul hf
61+
protected theorem Splits.C_mul {f : R[X]} (hf : Splits f) (a : R) : Splits (C a * f) :=
62+
(Splits.C a).mul hf
6763

6864
@[simp, aesop safe apply]
69-
theorem Factors.listProd {l : List R[X]} (h : ∀ f ∈ l, Factors f) : Factors l.prod :=
65+
theorem Splits.listProd {l : List R[X]} (h : ∀ f ∈ l, Splits f) : Splits l.prod :=
7066
list_prod_mem h
7167

7268
@[simp, aesop safe apply]
73-
protected theorem Factors.pow {f : R[X]} (hf : Factors f) (n : ℕ) : Factors (f ^ n) :=
69+
protected theorem Splits.pow {f : R[X]} (hf : Splits f) (n : ℕ) : Splits (f ^ n) :=
7470
pow_mem hf n
7571

76-
theorem Factors.X_pow (n : ℕ) : Factors (X ^ n : R[X]) :=
77-
Factors.X.pow n
72+
theorem Splits.X_pow (n : ℕ) : Splits (X ^ n : R[X]) :=
73+
Splits.X.pow n
7874

79-
theorem Factors.C_mul_X_pow (a : R) (n : ℕ) : Factors (C a * X ^ n) :=
80-
(Factors.X_pow n).C_mul a
75+
theorem Splits.C_mul_X_pow (a : R) (n : ℕ) : Splits (C a * X ^ n) :=
76+
(Splits.X_pow n).C_mul a
8177

8278
@[simp, aesop safe apply]
83-
theorem Factors.monomial (n : ℕ) (a : R) : Factors (monomial n a) := by
79+
theorem Splits.monomial (n : ℕ) (a : R) : Splits (monomial n a) := by
8480
simp [← C_mul_X_pow_eq_monomial]
8581

86-
protected theorem Factors.map {f : R[X]} (hf : Factors f) {S : Type*} [Semiring S] (i : R →+* S) :
87-
Factors (map i f) := by
82+
protected theorem Splits.map {f : R[X]} (hf : Splits f) {S : Type*} [Semiring S] (i : R →+* S) :
83+
Splits (map i f) := by
8884
induction hf using Submonoid.closure_induction <;> aesop
8985

90-
theorem factors_of_natDegree_eq_zero {f : R[X]} (hf : natDegree f = 0) :
91-
Factors f :=
86+
theorem splits_of_natDegree_eq_zero {f : R[X]} (hf : natDegree f = 0) :
87+
Splits f :=
9288
(natDegree_eq_zero.mp hf).choose_spec ▸ by aesop
9389

94-
theorem factors_of_degree_le_zero {f : R[X]} (hf : degree f ≤ 0) :
95-
Factors f :=
96-
factors_of_natDegree_eq_zero (natDegree_eq_zero_iff_degree_le_zero.mpr hf)
90+
theorem splits_of_degree_le_zero {f : R[X]} (hf : degree f ≤ 0) :
91+
Splits f :=
92+
splits_of_natDegree_eq_zero (natDegree_eq_zero_iff_degree_le_zero.mpr hf)
9793

9894
end Semiring
9995

@@ -102,21 +98,21 @@ section CommSemiring
10298
variable [CommSemiring R]
10399

104100
@[simp, aesop safe apply]
105-
theorem Factors.multisetProd {m : Multiset R[X]} (hm : ∀ f ∈ m, Factors f) : Factors m.prod :=
101+
theorem Splits.multisetProd {m : Multiset R[X]} (hm : ∀ f ∈ m, Splits f) : Splits m.prod :=
106102
multiset_prod_mem _ hm
107103

108104
@[simp, aesop safe apply]
109-
protected theorem Factors.prod {ι : Type*} {f : ι → R[X]} {s : Finset ι}
110-
(h : ∀ i ∈ s, Factors (f i)) : Factors (∏ i ∈ s, f i) :=
105+
protected theorem Splits.prod {ι : Type*} {f : ι → R[X]} {s : Finset ι}
106+
(h : ∀ i ∈ s, Splits (f i)) : Splits (∏ i ∈ s, f i) :=
111107
prod_mem h
112108

113-
/-- See `factors_iff_exists_multiset` for the version with subtraction. -/
114-
theorem factors_iff_exists_multiset' {f : R[X]} :
115-
Factors f ↔ ∃ m : Multiset R, f = C f.leadingCoeff * (m.map (X + C ·)).prod := by
109+
/-- See `splits_iff_exists_multiset` for the version with subtraction. -/
110+
theorem splits_iff_exists_multiset' {f : R[X]} :
111+
Splits f ↔ ∃ m : Multiset R, f = C f.leadingCoeff * (m.map (X + C ·)).prod := by
116112
refine ⟨fun hf ↦ ?_, ?_⟩
117113
· let S : Submonoid R[X] := MonoidHom.mrange C
118114
have hS : S = {C a | a : R} := MonoidHom.coe_mrange C
119-
rw [Factors, Submonoid.closure_union, ← hS, Submonoid.closure_eq, Submonoid.mem_sup] at hf
115+
rw [Splits, Submonoid.closure_union, ← hS, Submonoid.closure_eq, Submonoid.mem_sup] at hf
120116
obtain ⟨-, ⟨a, rfl⟩, g, hg, rfl⟩ := hf
121117
obtain ⟨mg, hmg, rfl⟩ := Submonoid.exists_multiset_of_mem_closure hg
122118
choose! j hj using hmg
@@ -127,12 +123,12 @@ theorem factors_iff_exists_multiset' {f : R[X]} :
127123
apply monic_multiset_prod_of_monic
128124
simp [monic_X_add_C]
129125
· rintro ⟨m, hm⟩
130-
exact hm ▸ (Factors.C _).mul (.multisetProd (by simp [Factors.X_add_C]))
126+
exact hm ▸ (Splits.C _).mul (.multisetProd (by simp [Splits.X_add_C]))
131127

132-
theorem Factors.natDegree_le_one_of_irreducible {f : R[X]} (hf : Factors f)
128+
theorem Splits.natDegree_le_one_of_irreducible {f : R[X]} (hf : Splits f)
133129
(h : Irreducible f) : natDegree f ≤ 1 := by
134130
nontriviality R
135-
obtain ⟨m, hm⟩ := factors_iff_exists_multiset'.mp hf
131+
obtain ⟨m, hm⟩ := splits_iff_exists_multiset'.mp hf
136132
rcases m.empty_or_exists_mem with rfl | ⟨a, ha⟩
137133
· rw [hm]
138134
simp
@@ -152,16 +148,16 @@ section Ring
152148
variable [Ring R]
153149

154150
@[simp, aesop safe apply]
155-
theorem Factors.X_sub_C (a : R) : Factors (X - C a) := by
156-
simpa using Factors.X_add_C (-a)
151+
theorem Splits.X_sub_C (a : R) : Splits (X - C a) := by
152+
simpa using Splits.X_add_C (-a)
157153

158154
@[aesop safe apply]
159-
protected theorem Factors.neg {f : R[X]} (hf : Factors f) : Factors (-f) := by
155+
protected theorem Splits.neg {f : R[X]} (hf : Splits f) : Splits (-f) := by
160156
rw [← neg_one_mul, ← C_1, ← C_neg]
161157
exact hf.C_mul (-1)
162158

163159
@[simp]
164-
theorem factors_neg_iff {f : R[X]} : Factors (-f) ↔ Factors f :=
160+
theorem splits_neg_iff {f : R[X]} : Splits (-f) ↔ Splits f :=
165161
fun hf ↦ neg_neg f ▸ hf.neg, .neg⟩
166162

167163
end Ring
@@ -170,14 +166,14 @@ section CommRing
170166

171167
variable [CommRing R] {f g : R[X]}
172168

173-
theorem factors_iff_exists_multiset :
174-
Factors f ↔ ∃ m : Multiset R, f = C f.leadingCoeff * (m.map (X - C ·)).prod := by
175-
refine factors_iff_exists_multiset'.trans ⟨?_, ?_⟩ <;>
169+
theorem splits_iff_exists_multiset :
170+
Splits f ↔ ∃ m : Multiset R, f = C f.leadingCoeff * (m.map (X - C ·)).prod := by
171+
refine splits_iff_exists_multiset'.trans ⟨?_, ?_⟩ <;>
176172
rintro ⟨m, hm⟩ <;> exact ⟨m.map (- ·), by simpa⟩
177173

178-
theorem Factors.exists_eval_eq_zero (hf : Factors f) (hf0 : degree f ≠ 0) :
174+
theorem Splits.exists_eval_eq_zero (hf : Splits f) (hf0 : degree f ≠ 0) :
179175
∃ a, eval a f = 0 := by
180-
obtain ⟨m, hm⟩ := factors_iff_exists_multiset.mp hf
176+
obtain ⟨m, hm⟩ := splits_iff_exists_multiset.mp hf
181177
by_cases hf₀ : f.leadingCoeff = 0
182178
· simp [leadingCoeff_eq_zero.mp hf₀]
183179
obtain rfl | ⟨a, ha⟩ := m.empty_or_exists_mem
@@ -188,27 +184,27 @@ theorem Factors.exists_eval_eq_zero (hf : Factors f) (hf0 : degree f ≠ 0) :
188184

189185
variable [IsDomain R]
190186

191-
theorem Factors.eq_prod_roots (hf : Factors f) :
187+
theorem Splits.eq_prod_roots (hf : Splits f) :
192188
f = C f.leadingCoeff * (f.roots.map (X - C ·)).prod := by
193189
by_cases hf0 : f.leadingCoeff = 0
194190
· simp [leadingCoeff_eq_zero.mp hf0]
195-
· obtain ⟨m, hm⟩ := factors_iff_exists_multiset.mp hf
191+
· obtain ⟨m, hm⟩ := splits_iff_exists_multiset.mp hf
196192
suffices hf : f.roots = m by rwa [hf]
197193
rw [hm, roots_C_mul _ hf0, roots_multiset_prod_X_sub_C]
198194

199-
theorem Factors.natDegree_eq_card_roots (hf : Factors f) :
195+
theorem Splits.natDegree_eq_card_roots (hf : Splits f) :
200196
f.natDegree = f.roots.card := by
201197
by_cases hf0 : f.leadingCoeff = 0
202198
· simp [leadingCoeff_eq_zero.mp hf0]
203199
· conv_lhs => rw [hf.eq_prod_roots, natDegree_C_mul hf0, natDegree_multiset_prod_X_sub_C_eq_card]
204200

205-
theorem Factors.roots_ne_zero (hf : Factors f) (hf0 : natDegree f ≠ 0) :
201+
theorem Splits.roots_ne_zero (hf : Splits f) (hf0 : natDegree f ≠ 0) :
206202
f.roots ≠ 0 := by
207203
obtain ⟨a, ha⟩ := hf.exists_eval_eq_zero (degree_ne_of_natDegree_ne hf0)
208204
exact mt (· ▸ (mem_roots (by aesop)).mpr ha) (Multiset.notMem_zero a)
209205

210-
theorem factors_X_sub_C_mul_iff {a : R} : Factors ((X - C a) * f) ↔ Factors f := by
211-
refine ⟨fun hf ↦ ?_, ((Factors.X_sub_C _).mul ·)⟩
206+
theorem splits_X_sub_C_mul_iff {a : R} : Splits ((X - C a) * f) ↔ Splits f := by
207+
refine ⟨fun hf ↦ ?_, ((Splits.X_sub_C _).mul ·)⟩
212208
by_cases hf₀ : f = 0
213209
· aesop
214210
have := hf.eq_prod_roots
@@ -218,17 +214,17 @@ theorem factors_X_sub_C_mul_iff {a : R} : Factors ((X - C a) * f) ↔ Factors f
218214
rw [mul_left_cancel₀ (X_sub_C_ne_zero _) this]
219215
aesop
220216

221-
theorem factors_mul_iff (hf₀ : f ≠ 0) (hg₀ : g ≠ 0) :
222-
Factors (f * g) ↔ Factors f ∧ Factors g := by
217+
theorem splits_mul_iff (hf₀ : f ≠ 0) (hg₀ : g ≠ 0) :
218+
Splits (f * g) ↔ Splits f ∧ Splits g := by
223219
refine ⟨fun h ↦ ?_, and_imp.mpr .mul⟩
224220
generalize hp : f * g = p at *
225221
generalize hn : p.natDegree = n
226222
induction n generalizing p f g with
227223
| zero =>
228224
rw [← hp, natDegree_mul hf₀ hg₀, Nat.add_eq_zero_iff] at hn
229-
exact ⟨factors_of_natDegree_eq_zero hn.1, factors_of_natDegree_eq_zero hn.2
225+
exact ⟨splits_of_natDegree_eq_zero hn.1, splits_of_natDegree_eq_zero hn.2
230226
| succ n ih =>
231-
obtain ⟨a, ha⟩ := Factors.exists_eval_eq_zero h (degree_ne_of_natDegree_ne <| hn ▸ by aesop)
227+
obtain ⟨a, ha⟩ := Splits.exists_eval_eq_zero h (degree_ne_of_natDegree_ne <| hn ▸ by aesop)
232228
have := dvd_iff_isRoot.mpr ha
233229
rw [← hp, (prime_X_sub_C a).dvd_mul] at this
234230
wlog hf : X - C a ∣ f with hf2
@@ -237,15 +233,15 @@ theorem factors_mul_iff (hf₀ : f ≠ 0) (hg₀ : g ≠ 0) :
237233
obtain ⟨f, rfl⟩ := hf
238234
rw [mul_assoc] at hp; subst hp
239235
rw [natDegree_mul (by aesop) (by aesop), natDegree_X_sub_C, add_comm, Nat.succ_inj] at hn
240-
have := ih (by aesop) hg₀ (f * g) rfl (factors_X_sub_C_mul_iff.mp h) hn
236+
have := ih (by aesop) hg₀ (f * g) rfl (splits_X_sub_C_mul_iff.mp h) hn
241237
aesop
242238

243-
theorem Factors.of_dvd (hg : Factors g) (hg₀ : g ≠ 0) (hfg : f ∣ g) : Factors f := by
239+
theorem Splits.of_dvd (hg : Splits g) (hg₀ : g ≠ 0) (hfg : f ∣ g) : Splits f := by
244240
obtain ⟨g, rfl⟩ := hfg
245-
exact ((factors_mul_iff (by aesop) (by aesop)).mp hg).1
241+
exact ((splits_mul_iff (by aesop) (by aesop)).mp hg).1
246242

247243
-- Todo: Remove or fix name once `Splits` is gone.
248-
theorem Factors.splits (hf : Factors f) :
244+
theorem Splits.splits (hf : Splits f) :
249245
f = 0 ∨ ∀ {g : R[X]}, Irreducible g → g ∣ f → degree g ≤ 1 :=
250246
or_iff_not_imp_left.mpr fun hf0 _ hg hgf ↦ degree_le_of_natDegree_le <|
251247
(hf.of_dvd hf0 hgf).natDegree_le_one_of_irreducible hg
@@ -256,20 +252,20 @@ section DivisionSemiring
256252

257253
variable [DivisionSemiring R]
258254

259-
theorem Factors.of_natDegree_le_one {f : R[X]} (hf : natDegree f ≤ 1) : Factors f := by
255+
theorem Splits.of_natDegree_le_one {f : R[X]} (hf : natDegree f ≤ 1) : Splits f := by
260256
obtain ⟨a, b, rfl⟩ := exists_eq_X_add_C_of_natDegree_le_one hf
261257
by_cases ha : a = 0
262258
· aesop
263259
· rw [← mul_inv_cancel_left₀ ha b, C_mul, ← mul_add]
264260
exact (X_add_C (a⁻¹ * b)).C_mul a
265261

266-
theorem Factors.of_natDegree_eq_one {f : R[X]} (hf : natDegree f = 1) : Factors f :=
262+
theorem Splits.of_natDegree_eq_one {f : R[X]} (hf : natDegree f = 1) : Splits f :=
267263
of_natDegree_le_one hf.le
268264

269-
theorem Factors.of_degree_le_one {f : R[X]} (hf : degree f ≤ 1) : Factors f :=
265+
theorem Splits.of_degree_le_one {f : R[X]} (hf : degree f ≤ 1) : Splits f :=
270266
of_natDegree_le_one (natDegree_le_of_degree_le hf)
271267

272-
theorem Factors.of_degree_eq_one {f : R[X]} (hf : degree f = 1) : Factors f :=
268+
theorem Splits.of_degree_eq_one {f : R[X]} (hf : degree f = 1) : Splits f :=
273269
of_degree_le_one hf.le
274270

275271
end DivisionSemiring
@@ -279,9 +275,9 @@ section Field
279275
variable [Field R]
280276

281277
open UniqueFactorizationMonoid in
282-
-- Todo: Remove or fix name once `Splits` is gone.
283-
theorem factors_iff_splits {f : R[X]} :
284-
Factors f ↔ f = 0 ∨ ∀ {g : R[X]}, Irreducible g → g ∣ f → degree g = 1 := by
278+
-- Todo: Remove or fix name.
279+
theorem splits_iff_splits {f : R[X]} :
280+
Splits f ↔ f = 0 ∨ ∀ {g : R[X]}, Irreducible g → g ∣ f → degree g = 1 := by
285281
refine ⟨fun hf ↦ hf.splits.imp_right (forall₃_imp fun g hg hgf ↦
286282
(le_antisymm · (Nat.WithBot.one_le_iff_zero_lt.mpr hg.degree_pos))), ?_⟩
287283
rintro (rfl | hf)
@@ -291,9 +287,9 @@ theorem factors_iff_splits {f : R[X]} :
291287
· simp [hf0]
292288
obtain ⟨u, hu⟩ := factors_prod hf0
293289
rw [← hu]
294-
refine (Factors.multisetProd fun g hg ↦ ?_).mul
295-
(factors_of_natDegree_eq_zero (natDegree_eq_zero_of_isUnit u.isUnit))
296-
exact Factors.of_degree_eq_one (hf (irreducible_of_factor g hg) (dvd_of_mem_factors hg))
290+
refine (Splits.multisetProd fun g hg ↦ ?_).mul
291+
(splits_of_natDegree_eq_zero (natDegree_eq_zero_of_isUnit u.isUnit))
292+
exact Splits.of_degree_eq_one (hf (irreducible_of_factor g hg) (dvd_of_mem_factors hg))
297293

298294
end Field
299295

0 commit comments

Comments
 (0)