Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit e88a5bb

Browse files
feat(*): assorted prereqs for cyclotomic polynomials (#4887)
This is hopefully my last preparatory PR for cyclotomic polynomials. It was in [4869](#4869) . Co-authored-by: Johan Commelin <johan@commelin.net>
1 parent b37d4a3 commit e88a5bb

File tree

3 files changed

+54
-22
lines changed

3 files changed

+54
-22
lines changed

src/data/polynomial/ring_division.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,12 @@ else by rw [← with_bot.coe_le_coe, ← degree_X_pow_sub_C (nat.pos_of_ne_zero
406406
exact card_roots (X_pow_sub_C_ne_zero (nat.pos_of_ne_zero hn) a)
407407

408408
/-- The multiset `nth_roots ↑n (1 : R)` as a finset. -/
409-
def nth_roots_finset (n : ℕ+) (R : Type*) [integral_domain R] : finset R :=
409+
def nth_roots_finset (n : ℕ) (R : Type*) [integral_domain R] : finset R :=
410410
multiset.to_finset (nth_roots n (1 : R))
411411

412-
@[simp] lemma mem_nth_roots_finset {n : ℕ+} {x : R} :
412+
@[simp] lemma mem_nth_roots_finset {n : ℕ} (h : 0 < n) {x : R} :
413413
x ∈ nth_roots_finset n R ↔ x ^ (n : ℕ) = 1 :=
414-
by rw [nth_roots_finset, mem_to_finset, mem_nth_roots n.pos]
414+
by rw [nth_roots_finset, mem_to_finset, mem_nth_roots h]
415415

416416
end nth_roots
417417

src/number_theory/divisors.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,14 @@ lemma prod_divisors_prime_pow {α : Type*} [comm_monoid α] {k p : ℕ} {f : ℕ
359359
@sum_divisors_prime_pow (additive α) _ _ _ _ h
360360

361361
@[simp]
362-
lemma filter_dvd_eq_divisors (n : ℕ+) :
363-
finset.filter (λ (x : ℕ), x ∣ n) (finset.range (n : ℕ).succ) = (n : ℕ).divisors :=
362+
lemma filter_dvd_eq_divisors {n : ℕ} (h : n ≠ 0) :
363+
finset.filter (λ (x : ℕ), x ∣ n) (finset.range (n : ℕ).succ) = (n : ℕ).divisors :=
364364
begin
365365
apply finset.ext,
366-
simp only [mem_divisors, mem_filter, mem_range, and_true,
367-
and_iff_right_iff_imp, ne.def, pnat.ne_zero, not_false_iff],
366+
simp only [h, mem_filter, and_true, and_iff_right_iff_imp, cast_id, mem_range, ne.def,
367+
not_false_iff, mem_divisors],
368368
intros a ha,
369-
exact nat.lt_succ_of_le (nat.divisor_le (nat.mem_divisors.2 (and.intro ha (pnat.ne_zero n))))
369+
exact nat.lt_succ_of_le (nat.divisor_le (nat.mem_divisors.2 ⟨ha, h⟩))
370370
end
371371

372372
end nat

src/ring_theory/roots_of_unity.lean

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,24 @@ section integral_domain
373373

374374
variables {ζ : R}
375375

376+
@[simp] lemma primitive_roots_zero : primitive_roots 0 R = ∅ :=
377+
begin
378+
rw [← finset.val_eq_zero, ← multiset.subset_zero, ← nth_roots_zero (1 : R), primitive_roots],
379+
simp only [finset.not_mem_empty, forall_const, forall_prop_of_false, multiset.to_finset_zero,
380+
finset.filter_true_of_mem, finset.empty_val, not_false_iff,
381+
multiset.zero_subset, nth_roots_zero]
382+
end
383+
384+
@[simp] lemma primitive_root_one : primitive_roots 1 R = {(1 : R)} :=
385+
begin
386+
apply finset.eq_singleton_iff_unique_mem.2,
387+
split,
388+
{ simp only [is_primitive_root.one_right_iff, mem_primitive_roots zero_lt_one] },
389+
{ intros x hx,
390+
rw [mem_primitive_roots zero_lt_one, is_primitive_root.one_right_iff] at hx,
391+
exact hx }
392+
end
393+
376394
lemma neg_one (p : ℕ) [char_p R p] (hp : p ≠ 2) : is_primitive_root (-1 : R) 2 :=
377395
mk_of_lt (-1 : R) dec_trivial (by simp only [one_pow, neg_square]) $
378396
begin
@@ -562,43 +580,50 @@ end
562580

563581
/-- The cardinality of the multiset `nth_roots ↑n (1 : R)` is `n`
564582
if there is a primitive root of unity in `R`. -/
565-
lemma card_nth_roots {ζ : R} {n : ℕ+} (h : is_primitive_root ζ n) :
566-
(nth_roots n (1 : R)).card = n :=
583+
lemma card_nth_roots {ζ : R} {n : ℕ} (h : is_primitive_root ζ n) :
584+
(nth_roots n (1 : R)).card = n :=
567585
begin
586+
cases nat.eq_zero_or_pos n with hzero hpos,
587+
{ simp only [hzero, multiset.card_zero, nth_roots_zero] },
568588
rw eq_iff_le_not_lt,
569-
split,
570-
{ exact card_nth_roots n 1 },
589+
use card_nth_roots n 1,
571590
{ rw [not_lt],
572591
have hcard : fintype.card {x // x ∈ nth_roots n (1 : R)}
573592
≤ (nth_roots n (1 : R)).attach.card := multiset.card_le_of_le (multiset.erase_dup_le _),
574593
rw multiset.card_attach at hcard,
575-
rw [← fintype.card_congr (roots_of_unity_equiv_nth_roots R n), card_roots_of_unity h] at hcard,
594+
rw ← pnat.to_pnat'_coe hpos at hcard h ⊢,
595+
set m := nat.to_pnat' n,
596+
rw [← fintype.card_congr (roots_of_unity_equiv_nth_roots R m), card_roots_of_unity h] at hcard,
576597
exact hcard }
577598
end
578599

579600
/-- The multiset `nth_roots ↑n (1 : R)` has no repeated elements
580601
if there is a primitive root of unity in `R`. -/
581-
lemma nth_roots_nodup {ζ : R} {n : ℕ+} (h : is_primitive_root ζ n) : (nth_roots n (1 : R)).nodup :=
602+
lemma nth_roots_nodup {ζ : R} {n : ℕ} (h : is_primitive_root ζ n) : (nth_roots n (1 : R)).nodup :=
582603
begin
604+
cases nat.eq_zero_or_pos n with hzero hpos,
605+
{ simp only [hzero, multiset.nodup_zero, nth_roots_zero] },
583606
apply (@multiset.erase_dup_eq_self R _ _).1,
584607
rw eq_iff_le_not_lt,
585608
split,
586-
{ exact multiset.erase_dup_le (nth_roots n (1 : R)) },
609+
{ exact multiset.erase_dup_le (nth_roots n (1 : R)) },
587610
{ by_contra ha,
588611
replace ha := multiset.card_lt_of_lt ha,
589612
rw card_nth_roots h at ha,
590-
have hrw : (nth_roots n (1 : R)).erase_dup.card =
591-
fintype.card {x // x ∈ (nth_roots n (1 : R))},
592-
{ set fs := (⟨(nth_roots n (1 : R)).erase_dup, multiset.nodup_erase_dup _⟩ : finset R),
613+
have hrw : (nth_roots n (1 : R)).erase_dup.card =
614+
fintype.card {x // x ∈ (nth_roots n (1 : R))},
615+
{ set fs := (⟨(nth_roots n (1 : R)).erase_dup, multiset.nodup_erase_dup _⟩ : finset R),
593616
rw [← finset.card_mk, ← fintype.card_of_subtype fs _],
594617
intro x,
595618
simp only [multiset.mem_erase_dup, finset.mem_mk] },
596-
rw [hrw, ← fintype.card_congr (roots_of_unity_equiv_nth_roots R n),
619+
rw ← pnat.to_pnat'_coe hpos at h hrw ha,
620+
set m := nat.to_pnat' n,
621+
rw [hrw, ← fintype.card_congr (roots_of_unity_equiv_nth_roots R m),
597622
card_roots_of_unity h] at ha,
598623
exact nat.lt_asymm ha ha }
599624
end
600625

601-
@[simp] lemma card_nth_roots_finset {ζ : R} {n : ℕ+} (h : is_primitive_root ζ n) :
626+
@[simp] lemma card_nth_roots_finset {ζ : R} {n : ℕ} (h : is_primitive_root ζ n) :
602627
(nth_roots_finset n R).card = n :=
603628
by rw [nth_roots_finset, ← multiset.to_finset_eq (nth_roots_nodup h), card_mk, h.card_nth_roots]
604629

@@ -650,7 +675,7 @@ end
650675

651676
/-- `nth_roots n` as a `finset` is equal to the union of `primitive_roots i R` for `i ∣ n`
652677
if there is a primitive root of unity in `R`. -/
653-
lemma nth_roots_one_eq_bind_primitive_roots {ζ : R} {n : ℕ+} (h : is_primitive_root ζ n) :
678+
lemma nth_roots_one_eq_bind_primitive_roots' {ζ : R} {n : ℕ+} (h : is_primitive_root ζ n) :
654679
nth_roots_finset n R = (nat.divisors ↑n).bind (λ i, (primitive_roots i R)) :=
655680
begin
656681
symmetry,
@@ -668,7 +693,7 @@ begin
668693
rw [hd, pow_mul, ha.pow_eq_one, one_pow] },
669694
{ apply le_of_eq,
670695
rw [h.card_nth_roots_finset, finset.card_bind],
671-
{ rw [← nat.sum_totient n, nat.filter_dvd_eq_divisors n, sum_congr rfl]
696+
{ rw [← nat.sum_totient n, nat.filter_dvd_eq_divisors (pnat.ne_zero n), sum_congr rfl]
672697
{ occs := occurrences.pos [1] },
673698
simp only [finset.mem_filter, finset.mem_range, nat.mem_divisors],
674699
rintro k ⟨H, hk⟩,
@@ -681,6 +706,13 @@ begin
681706
exact disjoint (pnat.pos_of_div_pos hi) (pnat.pos_of_div_pos hj) hdiff } }
682707
end
683708

709+
/-- `nth_roots n` as a `finset` is equal to the union of `primitive_roots i R` for `i ∣ n`
710+
if there is a primitive root of unity in `R`. -/
711+
lemma nth_roots_one_eq_bind_primitive_roots {ζ : R} {n : ℕ} (hpos : 0 < n)
712+
(h : is_primitive_root ζ n) :
713+
nth_roots_finset n R = (nat.divisors n).bind (λ i, (primitive_roots i R)) :=
714+
@nth_roots_one_eq_bind_primitive_roots' _ _ _ ⟨n, hpos⟩ h
715+
684716
end integral_domain
685717

686718
end is_primitive_root

0 commit comments

Comments
 (0)