@@ -373,6 +373,24 @@ section integral_domain
373
373
374
374
variables {ζ : R}
375
375
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
+
376
394
lemma neg_one (p : ℕ) [char_p R p] (hp : p ≠ 2 ) : is_primitive_root (-1 : R) 2 :=
377
395
mk_of_lt (-1 : R) dec_trivial (by simp only [one_pow, neg_square]) $
378
396
begin
@@ -562,43 +580,50 @@ end
562
580
563
581
/-- The cardinality of the multiset `nth_roots ↑n (1 : R)` is `n`
564
582
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 :=
567
585
begin
586
+ cases nat.eq_zero_or_pos n with hzero hpos,
587
+ { simp only [hzero, multiset.card_zero, nth_roots_zero] },
568
588
rw eq_iff_le_not_lt,
569
- split,
570
- { exact card_nth_roots n 1 },
589
+ use card_nth_roots n 1 ,
571
590
{ rw [not_lt],
572
591
have hcard : fintype.card {x // x ∈ nth_roots n (1 : R)}
573
592
≤ (nth_roots n (1 : R)).attach.card := multiset.card_le_of_le (multiset.erase_dup_le _),
574
593
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,
576
597
exact hcard }
577
598
end
578
599
579
600
/-- The multiset `nth_roots ↑n (1 : R)` has no repeated elements
580
601
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 :=
582
603
begin
604
+ cases nat.eq_zero_or_pos n with hzero hpos,
605
+ { simp only [hzero, multiset.nodup_zero, nth_roots_zero] },
583
606
apply (@multiset.erase_dup_eq_self R _ _).1 ,
584
607
rw eq_iff_le_not_lt,
585
608
split,
586
- { exact multiset.erase_dup_le (nth_roots ↑ n (1 : R)) },
609
+ { exact multiset.erase_dup_le (nth_roots n (1 : R)) },
587
610
{ by_contra ha,
588
611
replace ha := multiset.card_lt_of_lt ha,
589
612
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),
593
616
rw [← finset.card_mk, ← fintype.card_of_subtype fs _],
594
617
intro x,
595
618
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),
597
622
card_roots_of_unity h] at ha,
598
623
exact nat.lt_asymm ha ha }
599
624
end
600
625
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) :
602
627
(nth_roots_finset n R).card = n :=
603
628
by rw [nth_roots_finset, ← multiset.to_finset_eq (nth_roots_nodup h), card_mk, h.card_nth_roots]
604
629
650
675
651
676
/-- `nth_roots n` as a `finset` is equal to the union of `primitive_roots i R` for `i ∣ n`
652
677
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) :
654
679
nth_roots_finset n R = (nat.divisors ↑n).bind (λ i, (primitive_roots i R)) :=
655
680
begin
656
681
symmetry,
@@ -668,7 +693,7 @@ begin
668
693
rw [hd, pow_mul, ha.pow_eq_one, one_pow] },
669
694
{ apply le_of_eq,
670
695
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]
672
697
{ occs := occurrences.pos [1 ] },
673
698
simp only [finset.mem_filter, finset.mem_range, nat.mem_divisors],
674
699
rintro k ⟨H, hk⟩,
@@ -681,6 +706,13 @@ begin
681
706
exact disjoint (pnat.pos_of_div_pos hi) (pnat.pos_of_div_pos hj) hdiff } }
682
707
end
683
708
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
+
684
716
end integral_domain
685
717
686
718
end is_primitive_root
0 commit comments