@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
4
4
Authors: Michael Stoll
5
5
-/
6
6
import tactic.basic
7
- import field_theory.finite.basic
7
+ import number_theory.legendre_symbol.auxiliary
8
8
import data.int.range
9
9
10
10
/-!
@@ -18,165 +18,6 @@ some basic statements about it.
18
18
quadratic character
19
19
-/
20
20
21
- /-!
22
- ### Some general results, mostly on finite fields
23
-
24
- We collect some results here that are not specific to quadratic characters
25
- but are needed below. They will be moved to appropriate places eventually.
26
- -/
27
-
28
- section general
29
-
30
- /-- A natural number is odd iff it has residue `1` or `3` mod `4`-/
31
- lemma nat.odd_mod_four_iff {n : ℕ} : n % 2 = 1 ↔ n % 4 = 1 ∨ n % 4 = 3 :=
32
- begin
33
- split,
34
- { have help : ∀ (m : ℕ), 0 ≤ m → m < 4 → m % 2 = 1 → m = 1 ∨ m = 3 := dec_trivial,
35
- intro hn,
36
- rw [← nat.mod_mod_of_dvd n (by norm_num : 2 ∣ 4 )] at hn,
37
- exact help (n % 4 ) zero_le' (nat.mod_lt n (by norm_num)) hn, },
38
- { intro h,
39
- cases h with h h,
40
- { exact nat.odd_of_mod_four_eq_one h, },
41
- { exact nat.odd_of_mod_four_eq_three h }, },
42
- end
43
-
44
- /-- If `ring_char R = 2`, where `R` is a finite reduced commutative ring,
45
- then every `a : R` is a square. -/
46
- lemma is_square_of_char_two' {R : Type *} [fintype R] [comm_ring R] [is_reduced R] [char_p R 2 ]
47
- (a : R) : is_square a :=
48
- exists_imp_exists (λ b h, pow_two b ▸ eq.symm h) $
49
- ((fintype.bijective_iff_injective_and_card _).mpr ⟨frobenius_inj R 2 , rfl⟩).surjective a
50
-
51
- namespace finite_field
52
-
53
- variables {F : Type *} [field F] [fintype F]
54
-
55
- /-- In a finite field of characteristic `2`, all elements are squares. -/
56
- lemma is_square_of_char_two (hF : ring_char F = 2 ) (a : F) : is_square a :=
57
- begin
58
- haveI hF' : char_p F 2 := ring_char.of_eq hF,
59
- exact is_square_of_char_two' a,
60
- end
61
-
62
- /-- The finite field `F` has even cardinality iff it has characteristic `2`. -/
63
- lemma even_card_iff_char_two : ring_char F = 2 ↔ fintype.card F % 2 = 0 :=
64
- begin
65
- rcases finite_field.card F (ring_char F) with ⟨n, hp, h⟩,
66
- rw [h, nat.pow_mod],
67
- split,
68
- { intro hF,
69
- rw hF,
70
- simp only [nat.bit0_mod_two, zero_pow', ne.def, pnat.ne_zero, not_false_iff, nat.zero_mod], },
71
- { rw [← nat.even_iff, nat.even_pow],
72
- rintros ⟨hev, hnz⟩,
73
- rw [nat.even_iff, nat.mod_mod] at hev,
74
- cases (nat.prime.eq_two_or_odd hp) with h₁ h₁,
75
- { exact h₁, },
76
- { exact false.rec (ring_char F = 2 ) (one_ne_zero ((eq.symm h₁).trans hev)), }, },
77
- end
78
-
79
- lemma even_card_of_char_two (hF : ring_char F = 2 ) : fintype.card F % 2 = 0 :=
80
- even_card_iff_char_two.mp hF
81
-
82
- lemma odd_card_of_char_ne_two (hF : ring_char F ≠ 2 ) : fintype.card F % 2 = 1 :=
83
- nat.mod_two_ne_zero.mp (mt even_card_iff_char_two.mpr hF)
84
-
85
- /-- Characteristic `≠ 2` implies that `-1 ≠ 1`. -/
86
- lemma neg_one_ne_one_of_char_ne_two (hF : ring_char F ≠ 2 ) : (-1 : F) ≠ 1 :=
87
- begin
88
- have hc := char_p.char_is_prime F (ring_char F),
89
- haveI hF' : fact (2 < ring_char F) := ⟨ lt_of_le_of_ne (nat.prime.two_le hc) (ne.symm hF) ⟩,
90
- exact char_p.neg_one_ne_one _ (ring_char F),
91
- end
92
-
93
- /-- Characteristic `≠ 2` implies that `-a ≠ a` when `a ≠ 0`. -/
94
- lemma neg_ne_self_of_char_ne_two (hF : ring_char F ≠ 2 ) {a : F} (ha : a ≠ 0 ) : a ≠ -a :=
95
- begin
96
- intro hf,
97
- apply (neg_one_ne_one_of_char_ne_two hF).symm,
98
- rw [eq_neg_iff_add_eq_zero, ←two_mul, mul_one],
99
- rw [eq_neg_iff_add_eq_zero, ←two_mul, mul_eq_zero] at hf,
100
- exact hf.resolve_right ha,
101
- end
102
-
103
- /-- If `F` has odd characteristic, then for nonzero `a : F`, we have that `a ^ (#F / 2) = ±1`. -/
104
- lemma pow_dichotomy (hF : ring_char F ≠ 2 ) {a : F} (ha : a ≠ 0 ) :
105
- a^(fintype.card F / 2 ) = 1 ∨ a^(fintype.card F / 2 ) = -1 :=
106
- begin
107
- have h₁ := finite_field.pow_card_sub_one_eq_one a ha,
108
- set q := fintype.card F with hq,
109
- have hq : q % 2 = 1 := finite_field.odd_card_of_char_ne_two hF,
110
- have h₂ := nat.two_mul_odd_div_two hq,
111
- rw [← h₂, mul_comm, pow_mul, pow_two] at h₁,
112
- exact mul_self_eq_one_iff.mp h₁,
113
- end
114
-
115
- /-- A unit `a` of a finite field `F` of odd characteristic is a square
116
- if and only if `a ^ (#F / 2) = 1`. -/
117
- lemma unit_is_square_iff (hF : ring_char F ≠ 2 ) (a : Fˣ) :
118
- is_square a ↔ a ^ (fintype.card F / 2 ) = 1 :=
119
- begin
120
- classical,
121
- obtain ⟨g, hg⟩ := is_cyclic.exists_generator Fˣ,
122
- obtain ⟨n, hn⟩ : a ∈ submonoid.powers g, { rw mem_powers_iff_mem_zpowers, apply hg },
123
- have hodd := nat.two_mul_odd_div_two (finite_field.odd_card_of_char_ne_two hF),
124
- split,
125
- { rintro ⟨y, rfl⟩,
126
- rw [← pow_two, ← pow_mul, hodd],
127
- apply_fun (@coe Fˣ F _),
128
- { push_cast,
129
- exact finite_field.pow_card_sub_one_eq_one (y : F) (units.ne_zero y), },
130
- { exact units.ext, }, },
131
- { subst a, assume h,
132
- have key : 2 * (fintype.card F / 2 ) ∣ n * (fintype.card F / 2 ),
133
- { rw [← pow_mul] at h,
134
- rw [hodd, ← fintype.card_units, ← order_of_eq_card_of_forall_mem_zpowers hg],
135
- apply order_of_dvd_of_pow_eq_one h },
136
- have : 0 < fintype.card F / 2 := nat.div_pos fintype.one_lt_card (by norm_num),
137
- obtain ⟨m, rfl⟩ := nat.dvd_of_mul_dvd_mul_right this key,
138
- refine ⟨g ^ m, _⟩,
139
- rw [mul_comm, pow_mul, pow_two], },
140
- end
141
-
142
- /-- A non-zero `a : F` is a square if and only if `a ^ (#F / 2) = 1`. -/
143
- lemma is_square_iff (hF : ring_char F ≠ 2 ) {a : F} (ha : a ≠ 0 ) :
144
- is_square a ↔ a ^ (fintype.card F / 2 ) = 1 :=
145
- begin
146
- apply (iff_congr _ (by simp [units.ext_iff])).mp
147
- (finite_field.unit_is_square_iff hF (units.mk0 a ha)),
148
- simp only [is_square, units.ext_iff, units.coe_mk0, units.coe_mul],
149
- split, { rintro ⟨y, hy⟩, exact ⟨y, hy⟩ },
150
- { rintro ⟨y, rfl⟩,
151
- have hy : y ≠ 0 , { rintro rfl, simpa [zero_pow] using ha, },
152
- refine ⟨units.mk0 y hy, _⟩, simp, }
153
- end
154
-
155
- /-- In a finite field of odd characteristic, not every element is a square. -/
156
- lemma exists_nonsquare (hF : ring_char F ≠ 2 ) : ∃ (a : F), ¬ is_square a :=
157
- begin
158
- -- idea: the squaring map on `F` is not injetive, hence not surjective
159
- let sq : F → F := λ x, x^2 ,
160
- have h : ¬ function.injective sq,
161
- { simp only [function.injective, not_forall, exists_prop],
162
- use [-1 , 1 ],
163
- split,
164
- { simp only [sq, one_pow, neg_one_sq], },
165
- { exact finite_field.neg_one_ne_one_of_char_ne_two hF, }, },
166
- have h₁ := mt (fintype.injective_iff_surjective.mpr) h, -- sq not surjective
167
- push_neg at h₁,
168
- cases h₁ with a h₁,
169
- use a,
170
- simp only [is_square, sq, not_exists, ne.def] at h₁ ⊢,
171
- intros b hb,
172
- rw ← pow_two at hb,
173
- exact (h₁ b hb.symm),
174
- end
175
-
176
- end finite_field
177
-
178
- end general
179
-
180
21
namespace char
181
22
182
23
/-!
0 commit comments