equal
deleted
inserted
replaced
207 defines "R \<equiv> residue_ring p" |
207 defines "R \<equiv> residue_ring p" |
208 |
208 |
209 sublocale residues_prime < residues p |
209 sublocale residues_prime < residues p |
210 apply (unfold R_def residues_def) |
210 apply (unfold R_def residues_def) |
211 using p_prime apply auto |
211 using p_prime apply auto |
212 apply (metis (full_types) int_1 of_nat_less_iff prime_gt_1_nat) |
212 apply (metis (full_types) of_nat_1 of_nat_less_iff prime_gt_1_nat) |
213 done |
213 done |
214 |
214 |
215 context residues_prime |
215 context residues_prime |
216 begin |
216 begin |
217 |
217 |
219 apply (rule cring.field_intro2) |
219 apply (rule cring.field_intro2) |
220 apply (rule cring) |
220 apply (rule cring) |
221 apply (auto simp add: res_carrier_eq res_one_eq res_zero_eq res_units_eq) |
221 apply (auto simp add: res_carrier_eq res_one_eq res_zero_eq res_units_eq) |
222 apply (rule classical) |
222 apply (rule classical) |
223 apply (erule notE) |
223 apply (erule notE) |
224 apply (subst gcd_commute_int) |
224 apply (subst gcd.commute) |
225 apply (rule prime_imp_coprime_int) |
225 apply (rule prime_imp_coprime_int) |
226 apply (rule p_prime) |
226 apply (rule p_prime) |
227 apply (rule notI) |
227 apply (rule notI) |
228 apply (frule zdvd_imp_le) |
228 apply (frule zdvd_imp_le) |
229 apply auto |
229 apply auto |
230 done |
230 done |
231 |
231 |
232 lemma res_prime_units_eq: "Units R = {1..p - 1}" |
232 lemma res_prime_units_eq: "Units R = {1..p - 1}" |
233 apply (subst res_units_eq) |
233 apply (subst res_units_eq) |
234 apply auto |
234 apply auto |
235 apply (subst gcd_commute_int) |
235 apply (subst gcd.commute) |
236 apply (auto simp add: p_prime prime_imp_coprime_int zdvd_not_zless) |
236 apply (auto simp add: p_prime prime_imp_coprime_int zdvd_not_zless) |
237 done |
237 done |
238 |
238 |
239 end |
239 end |
240 |
240 |
254 lemma phi_def_nat: "phi m = card {x. 0 < x \<and> x < nat m \<and> gcd x (nat m) = 1}" |
254 lemma phi_def_nat: "phi m = card {x. 0 < x \<and> x < nat m \<and> gcd x (nat m) = 1}" |
255 apply (simp add: phi_def) |
255 apply (simp add: phi_def) |
256 apply (rule bij_betw_same_card [of nat]) |
256 apply (rule bij_betw_same_card [of nat]) |
257 apply (auto simp add: inj_on_def bij_betw_def image_def) |
257 apply (auto simp add: inj_on_def bij_betw_def image_def) |
258 apply (metis dual_order.irrefl dual_order.strict_trans leI nat_1 transfer_nat_int_gcd(1)) |
258 apply (metis dual_order.irrefl dual_order.strict_trans leI nat_1 transfer_nat_int_gcd(1)) |
259 apply (metis One_nat_def int_0 int_1 int_less_0_conv int_nat_eq nat_int |
259 apply (metis One_nat_def of_nat_0 of_nat_1 of_nat_less_0_iff int_nat_eq nat_int |
260 transfer_int_nat_gcd(1) zless_int) |
260 transfer_int_nat_gcd(1) of_nat_less_iff) |
261 done |
261 done |
262 |
262 |
263 lemma prime_phi: |
263 lemma prime_phi: |
264 assumes "2 \<le> p" "phi p = p - 1" |
264 assumes "2 \<le> p" "phi p = p - 1" |
265 shows "prime p" |
265 shows "prime p" |
368 |
368 |
369 lemma fermat_theorem_nat: |
369 lemma fermat_theorem_nat: |
370 assumes "prime p" and "\<not> p dvd a" |
370 assumes "prime p" and "\<not> p dvd a" |
371 shows "[a ^ (p - 1) = 1] (mod p)" |
371 shows "[a ^ (p - 1) = 1] (mod p)" |
372 using fermat_theorem [of p a] assms |
372 using fermat_theorem [of p a] assms |
373 by (metis int_1 of_nat_power transfer_int_nat_cong zdvd_int) |
373 by (metis of_nat_1 of_nat_power transfer_int_nat_cong zdvd_int) |
374 |
374 |
375 |
375 |
376 subsection \<open>Wilson's theorem\<close> |
376 subsection \<open>Wilson's theorem\<close> |
377 |
377 |
378 lemma (in field) inv_pair_lemma: "x \<in> Units R \<Longrightarrow> y \<in> Units R \<Longrightarrow> |
378 lemma (in field) inv_pair_lemma: "x \<in> Units R \<Longrightarrow> y \<in> Units R \<Longrightarrow> |