@@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
4
4
Authors: Michael Stoll
5
5
-/
6
6
import Mathlib.Algebra.CharP.Basic
7
- import Mathlib.Algebra.EuclideanDomain.Instances
8
7
import Mathlib.Data.Fintype.Units
9
8
10
9
#align_import number_theory.legendre_symbol.mul_character from "leanprover-community/mathlib" @"f0c8bf9245297a541f468be517f1bde6195105e9"
@@ -37,8 +36,6 @@ multiplicative character
37
36
-/
38
37
39
38
40
- section DefinitionAndGroup
41
-
42
39
/-!
43
40
### Definitions related to multiplicative characters
44
41
@@ -54,15 +51,13 @@ have a natural structure as a commutative group.
54
51
-/
55
52
56
53
57
- universe u v
58
-
59
54
section Defi
60
55
61
56
-- The domain of our multiplicative characters
62
- variable (R : Type u ) [CommMonoid R]
57
+ variable (R : Type * ) [CommMonoid R]
63
58
64
59
-- The target
65
- variable (R' : Type v ) [CommMonoidWithZero R']
60
+ variable (R' : Type * ) [CommMonoidWithZero R']
66
61
67
62
/-- Define a structure for multiplicative characters.
68
63
A multiplicative character from a commutative monoid `R` to a commutative monoid with zero `R'`
@@ -87,20 +82,17 @@ attribute [simp] MulCharClass.map_nonunit
87
82
88
83
end Defi
89
84
90
- section Group
91
-
92
85
namespace MulChar
93
86
87
+ section Group
88
+
94
89
-- The domain of our multiplicative characters
95
- variable {R : Type u } [CommMonoid R]
90
+ variable {R : Type * } [CommMonoid R]
96
91
97
92
-- The target
98
- variable {R' : Type v} [CommMonoidWithZero R']
99
-
100
- section trivial
101
-
102
- variable (R R')
93
+ variable {R' : Type *} [CommMonoidWithZero R']
103
94
95
+ variable (R R') in
104
96
/-- The trivial multiplicative character. It takes the value `0` on non-units and
105
97
the value `1` on units. -/
106
98
@[simps]
@@ -117,8 +109,6 @@ noncomputable def trivial : MulChar R R' where
117
109
split_ifs <;> tauto
118
110
#align mul_char.trivial MulChar.trivial
119
111
120
- end trivial
121
-
122
112
@[simp]
123
113
theorem coe_mk (f : R →* R') (hf) : (MulChar.mk f hf : R → R') = f :=
124
114
rfl
@@ -251,7 +241,7 @@ protected theorem map_one (χ : MulChar R R') : χ (1 : R) = 1 :=
251
241
#align mul_char.map_one MulChar.map_one
252
242
253
243
/-- If the domain has a zero (and is nontrivial), then `χ 0 = 0`. -/
254
- protected theorem map_zero {R : Type u } [CommMonoidWithZero R] [Nontrivial R] (χ : MulChar R R') :
244
+ protected theorem map_zero {R : Type * } [CommMonoidWithZero R] [Nontrivial R] (χ : MulChar R R') :
255
245
χ (0 : R) = 0 := by rw [map_nonunit χ not_isUnit_zero]
256
246
#align mul_char.map_zero MulChar.map_zero
257
247
@@ -266,7 +256,7 @@ def toMonoidWithZeroHom {R : Type*} [CommMonoidWithZero R] [Nontrivial R] (χ :
266
256
map_mul' := χ.map_mul'
267
257
268
258
/-- If the domain is a ring `R`, then `χ (ringChar R) = 0`. -/
269
- theorem map_ringChar {R : Type u } [CommRing R] [Nontrivial R] (χ : MulChar R R') :
259
+ theorem map_ringChar {R : Type * } [CommRing R] [Nontrivial R] (χ : MulChar R R') :
270
260
χ (ringChar R) = 0 := by rw [ringChar.Nat.cast_ringChar, χ.map_zero]
271
261
#align mul_char.map_ring_char MulChar.map_ringChar
272
262
@@ -334,23 +324,20 @@ theorem inv_apply_eq_inv (χ : MulChar R R') (a : R) : χ⁻¹ a = Ring.inverse
334
324
335
325
/-- The inverse of a multiplicative character `χ`, applied to `a`, is the inverse of `χ a`.
336
326
Variant when the target is a field -/
337
- theorem inv_apply_eq_inv' {R' : Type v } [Field R'] (χ : MulChar R R') (a : R) : χ⁻¹ a = (χ a)⁻¹ :=
327
+ theorem inv_apply_eq_inv' {R' : Type * } [Field R'] (χ : MulChar R R') (a : R) : χ⁻¹ a = (χ a)⁻¹ :=
338
328
(inv_apply_eq_inv χ a).trans <| Ring.inverse_eq_inv (χ a)
339
329
#align mul_char.inv_apply_eq_inv' MulChar.inv_apply_eq_inv'
340
330
341
331
/-- When the domain has a zero, then the inverse of a multiplicative character `χ`,
342
332
applied to `a`, is `χ` applied to the inverse of `a`. -/
343
- theorem inv_apply {R : Type u } [CommMonoidWithZero R] (χ : MulChar R R') (a : R) :
333
+ theorem inv_apply {R : Type * } [CommMonoidWithZero R] (χ : MulChar R R') (a : R) :
344
334
χ⁻¹ a = χ (Ring.inverse a) := by
345
335
by_cases ha : IsUnit a
346
336
· rw [inv_apply_eq_inv]
347
337
have h := IsUnit.map χ ha
348
338
apply_fun (χ a * ·) using IsUnit.mul_right_injective h
349
339
dsimp only
350
- -- Porting note: was
351
- -- rw [Ring.mul_inverse_cancel _ h, ← map_mul, Ring.mul_inverse_cancel _ ha, MulChar.map_one]
352
- erw [Ring.mul_inverse_cancel _ h, ← map_mul, Ring.mul_inverse_cancel _ ha]
353
- exact (MulChar.map_one χ).symm
340
+ rw [Ring.mul_inverse_cancel _ h, ← map_mul, Ring.mul_inverse_cancel _ ha, map_one]
354
341
· revert ha
355
342
nontriviality R
356
343
intro ha
@@ -360,7 +347,7 @@ theorem inv_apply {R : Type u} [CommMonoidWithZero R] (χ : MulChar R R') (a : R
360
347
361
348
/-- When the domain has a zero, then the inverse of a multiplicative character `χ`,
362
349
applied to `a`, is `χ` applied to the inverse of `a`. -/
363
- theorem inv_apply' {R : Type u } [Field R] (χ : MulChar R R') (a : R) : χ⁻¹ a = χ a⁻¹ :=
350
+ theorem inv_apply' {R : Type * } [Field R] (χ : MulChar R R') (a : R) : χ⁻¹ a = χ a⁻¹ :=
364
351
(inv_apply χ a).trans <| congr_arg _ (Ring.inverse_eq_inv a)
365
352
#align mul_char.inv_apply' MulChar.inv_apply'
366
353
@@ -369,9 +356,7 @@ theorem inv_apply' {R : Type u} [Field R] (χ : MulChar R R') (a : R) : χ⁻¹
369
356
theorem inv_mul (χ : MulChar R R') : χ⁻¹ * χ = 1 := by
370
357
ext x
371
358
rw [coeToFun_mul, Pi.mul_apply, inv_apply_eq_inv]
372
- -- Porting note: was
373
- -- simp only [Ring.inverse_mul_cancel _ (IsUnit.map _ x.isUnit)]
374
- erw [Ring.inverse_mul_cancel _ (IsUnit.map χ x.isUnit)]
359
+ simp only [Ring.inverse_mul_cancel _ (IsUnit.map χ x.isUnit)]
375
360
rw [one_apply_coe]
376
361
#align mul_char.inv_mul MulChar.inv_mul
377
362
@@ -407,11 +392,27 @@ theorem pow_apply' (χ : MulChar R R') {n : ℕ} (hn : n ≠ 0) (a : R) : (χ ^
407
392
· rw [map_nonunit (χ ^ n) ha, map_nonunit χ ha, zero_pow hn]
408
393
#align mul_char.pow_apply' MulChar.pow_apply'
409
394
410
- end MulChar
395
+ lemma equivToUnitHom_mul_apply (χ₁ χ₂ : MulChar R R') (a : Rˣ) :
396
+ equivToUnitHom (χ₁ * χ₂) a = equivToUnitHom χ₁ a * equivToUnitHom χ₂ a := by
397
+ apply_fun ((↑) : R'ˣ → R') using Units.ext
398
+ push_cast
399
+ simp_rw [coe_equivToUnitHom]
400
+ rfl
401
+
402
+ /-- The equivalence between multiplicative characters and homomorphisms of unit groups
403
+ as a multiplicative equivalence. -/
404
+ noncomputable
405
+ def mulEquivToUnitHom : MulChar R R' ≃* (Rˣ →* R'ˣ) :=
406
+ { equivToUnitHom with
407
+ map_mul' := by
408
+ intro χ ψ
409
+ ext
410
+ simp only [Equiv.toFun_as_coe, coe_equivToUnitHom, coeToFun_mul, Pi.mul_apply,
411
+ MonoidHom.mul_apply, Units.val_mul]
412
+ }
411
413
412
414
end Group
413
415
414
- end DefinitionAndGroup
415
416
416
417
/-!
417
418
### Properties of multiplicative characters
@@ -425,13 +426,9 @@ We now (mostly) assume that the target is a commutative ring.
425
426
426
427
section Properties
427
428
428
- namespace MulChar
429
-
430
- universe u v w
431
-
432
429
section nontrivial
433
430
434
- variable {R : Type u } [CommMonoid R] {R' : Type v } [CommMonoidWithZero R']
431
+ variable {R : Type * } [CommMonoid R] {R' : Type * } [CommMonoidWithZero R']
435
432
436
433
/-- A multiplicative character is *nontrivial* if it takes a value `≠ 1` on a unit. -/
437
434
def IsNontrivial (χ : MulChar R R') : Prop :=
@@ -447,7 +444,7 @@ end nontrivial
447
444
448
445
section quadratic_and_comp
449
446
450
- variable {R : Type u } [CommMonoid R] {R' : Type v } [CommRing R'] {R'' : Type w } [CommRing R'']
447
+ variable {R : Type * } [CommMonoid R] {R' : Type * } [CommRing R'] {R'' : Type * } [CommRing R'']
451
448
452
449
/-- A multiplicative character is *quadratic* if it takes only the values `0`, `1`, `-1`. -/
453
450
def IsQuadratic (χ : MulChar R R') : Prop :=
@@ -532,17 +529,46 @@ theorem IsQuadratic.pow_odd {χ : MulChar R R'} (hχ : χ.IsQuadratic) {n : ℕ}
532
529
533
530
end quadratic_and_comp
534
531
532
+ end Properties
533
+
534
+ /-!
535
+ ### Multiplicative characters with finite domain
536
+ -/
537
+
538
+ section Finite
539
+
540
+ variable {M : Type *} [CommMonoid M] [Fintype M] [DecidableEq M]
541
+ variable {R : Type *} [CommMonoidWithZero R]
542
+
543
+ /-- A multiplicative character on a finite commutative monoid has finite (= positive) order. -/
544
+ lemma orderOf_pos (χ : MulChar M R) : 0 < orderOf χ := by
545
+ let e := MulChar.mulEquivToUnitHom (R := M) (R' := R)
546
+ rw [← MulEquiv.orderOf_eq e χ]
547
+ have : orderOf (e χ) ∣ Fintype.card Mˣ := by
548
+ refine orderOf_dvd_of_pow_eq_one ?_
549
+ ext1 x
550
+ simp only [MonoidHom.pow_apply, ← map_pow (e χ), pow_card_eq_one, map_one, MonoidHom.one_apply]
551
+ exact Nat.pos_of_ne_zero <| ne_zero_of_dvd_ne_zero Fintype.card_ne_zero this
552
+
553
+ /-- If `χ` is a multiplicative character on a finite commutative monoid `M`, then `χ ^ #Mˣ = 1`. -/
554
+ protected
555
+ lemma pow_card_eq_one (χ : MulChar M R) : χ ^ (Fintype.card Mˣ) = 1 := by
556
+ ext1
557
+ rw [pow_apply_coe, ← map_pow, one_apply_coe, ← Units.val_pow_eq_pow_val, pow_card_eq_one,
558
+ Units.val_eq_one.mpr rfl, map_one]
559
+
560
+ end Finite
561
+
535
562
section sum
536
563
537
- variable {R : Type u } [CommMonoid R] [Fintype R] {R' : Type v } [CommRing R']
564
+ variable {R : Type * } [CommMonoid R] [Fintype R] {R' : Type * } [CommRing R']
538
565
539
566
/-- The sum over all values of a nontrivial multiplicative character on a finite ring is zero
540
567
(when the target is a domain). -/
541
568
theorem IsNontrivial.sum_eq_zero [IsDomain R'] {χ : MulChar R R'}
542
569
(hχ : χ.IsNontrivial) : ∑ a, χ a = 0 := by
543
570
rcases hχ with ⟨b, hb⟩
544
571
refine eq_zero_of_mul_eq_self_left hb ?_
545
- -- POrting note: `map_mul` isn't applied
546
572
simp only [Finset.mul_sum, ← map_mul]
547
573
exact Fintype.sum_bijective _ (Units.mulLeft_bijective b) _ _ fun x => rfl
548
574
#align mul_char.is_nontrivial.sum_eq_zero MulChar.IsNontrivial.sum_eq_zero
@@ -568,6 +594,18 @@ theorem sum_one_eq_card_units [DecidableEq R] :
568
594
569
595
end sum
570
596
571
- end MulChar
597
+ /-!
598
+ ### Multiplicative characters on rings
599
+ -/
572
600
573
- end Properties
601
+ section Ring
602
+
603
+ variable {R R' : Type *} [CommRing R] [CommMonoidWithZero R']
604
+
605
+ /-- If `χ` is of odd order, then `χ(-1) = 1` -/
606
+ lemma val_neg_one_eq_one_of_odd_order {χ : MulChar R R'} {n : ℕ} (hn : Odd n) (hχ : χ ^ n = 1 ) :
607
+ χ (-1 ) = 1 := by
608
+ rw [← hn.neg_one_pow, map_pow, ← χ.pow_apply' (Nat.ne_of_odd_add hn), hχ]
609
+ exact MulChar.one_apply_coe (-1 )
610
+
611
+ end Ring
0 commit comments