@@ -261,6 +261,9 @@ section comm_monoid
261
261
262
262
variables {ζ : M} (h : is_primitive_root ζ k)
263
263
264
+ @[nontriviality] lemma of_subsingleton [subsingleton M] (x : M) : is_primitive_root x 1 :=
265
+ ⟨subsingleton.elim _ _, λ _ _, one_dvd _⟩
266
+
264
267
lemma pow_eq_one_iff_dvd (l : ℕ) : ζ ^ l = 1 ↔ k ∣ l :=
265
268
⟨h.dvd_of_pow_eq_one l,
266
269
by { rintro ⟨i, rfl⟩, simp only [pow_mul, h.pow_eq_one, one_pow, pnat.mul_coe] }⟩
@@ -338,8 +341,44 @@ begin
338
341
rw [← pow_mul', ← mul_assoc, ← hb, pow_mul, h.pow_eq_one, one_pow]
339
342
end
340
343
344
+ protected lemma order_of (ζ : M) : is_primitive_root ζ (order_of ζ) :=
345
+ ⟨pow_order_of_eq_one ζ, λ l, order_of_dvd_of_pow_eq_one⟩
346
+
347
+ lemma unique {ζ : M} (hk : is_primitive_root ζ k) (hl : is_primitive_root ζ l) : k = l :=
348
+ begin
349
+ wlog hkl : k ≤ l,
350
+ rcases hkl.eq_or_lt with rfl | hkl,
351
+ { refl },
352
+ rcases k.eq_zero_or_pos with rfl | hk',
353
+ { exact (zero_dvd_iff.mp $ hk.dvd_of_pow_eq_one l hl.pow_eq_one).symm },
354
+ exact absurd hk.pow_eq_one (hl.pow_ne_one_of_pos_of_lt hk' hkl)
355
+ end
356
+
357
+ lemma eq_order_of : k = order_of ζ := h.unique (is_primitive_root.order_of ζ)
358
+
359
+ protected lemma iff (hk : 0 < k) :
360
+ is_primitive_root ζ k ↔ ζ ^ k = 1 ∧ ∀ l : ℕ, 0 < l → l < k → ζ ^ l ≠ 1 :=
361
+ begin
362
+ refine ⟨λ h, ⟨h.pow_eq_one, λ l hl' hl, _⟩, λ ⟨hζ, hl⟩, is_primitive_root.mk_of_lt ζ hk hζ hl⟩,
363
+ rw h.eq_order_of at hl,
364
+ exact pow_ne_one_of_lt_order_of' hl'.ne' hl,
365
+ end
366
+
367
+ protected lemma not_iff : ¬ is_primitive_root ζ k ↔ order_of ζ ≠ k :=
368
+ ⟨λ h hk, h $ hk ▸ is_primitive_root.order_of ζ,
369
+ λ h hk, h.symm $ hk.unique $ is_primitive_root.order_of ζ⟩
370
+
341
371
end comm_monoid
342
372
373
+ section comm_monoid_with_zero
374
+
375
+ variables {M₀ : Type *} [comm_monoid_with_zero M₀]
376
+
377
+ lemma zero [nontrivial M₀] : is_primitive_root (0 : M₀) 0 :=
378
+ ⟨pow_zero 0 , λ l hl, by simpa [zero_pow_eq, show ∀ p, ¬p → false ↔ p, from @not_not] using hl⟩
379
+
380
+ end comm_monoid_with_zero
381
+
343
382
section comm_group
344
383
345
384
variables {ζ : G}
440
479
441
480
end comm_group_with_zero
442
481
482
+ section comm_semiring
483
+
484
+ variables [comm_semiring R] [comm_semiring S] {f : R →+* S} {ζ : R}
485
+
486
+ open function
487
+
488
+ lemma map_of_injective (hf : injective f) (h : is_primitive_root ζ k) : is_primitive_root (f ζ) k :=
489
+ { pow_eq_one := by rw [←f.map_pow, h.pow_eq_one, f.map_one],
490
+ dvd_of_pow_eq_one := begin
491
+ rw h.eq_order_of,
492
+ intros l hl,
493
+ rw [←f.map_pow, ←f.map_one] at hl,
494
+ exact order_of_dvd_of_pow_eq_one (hf hl)
495
+ end }
496
+
497
+ lemma of_map_of_injective (hf : injective f) (h : is_primitive_root (f ζ) k) :
498
+ is_primitive_root ζ k :=
499
+ { pow_eq_one := by { apply_fun f, rw [f.map_pow, f.map_one, h.pow_eq_one] },
500
+ dvd_of_pow_eq_one := begin
501
+ rw h.eq_order_of,
502
+ intros l hl,
503
+ apply_fun f at hl,
504
+ rw [f.map_pow, f.map_one] at hl,
505
+ exact order_of_dvd_of_pow_eq_one hl
506
+ end }
507
+
508
+ lemma map_iff_of_injective (hf : injective f) : is_primitive_root (f ζ) k ↔ is_primitive_root ζ k :=
509
+ ⟨λ h, h.of_map_of_injective hf, λ h, h.map_of_injective hf⟩
510
+
511
+ end comm_semiring
512
+
443
513
section is_domain
444
514
445
515
variables {ζ : R}
0 commit comments