| author | blanchet | 
| Tue, 22 Jun 2010 13:17:59 +0200 | |
| changeset 37497 | 71fdbffe3275 | 
| parent 35440 | bdf8ad377877 | 
| child 38159 | e9b4835a54ee | 
| permissions | -rw-r--r-- | 
| 32479 | 1  | 
(* Author: Thomas M. Rasmussen  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
2  | 
Copyright 2000 University of Cambridge  | 
| 
9508
 
4d01dbf6ded7
Chinese Remainder Theorem, Wilsons Theorem, etc., by T M Masmussen
 
paulson 
parents:  
diff
changeset
 | 
3  | 
*)  | 
| 
 
4d01dbf6ded7
Chinese Remainder Theorem, Wilsons Theorem, etc., by T M Masmussen
 
paulson 
parents:  
diff
changeset
 | 
4  | 
|
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
5  | 
header {* Fermat's Little Theorem extended to Euler's Totient function *}
 | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
6  | 
|
| 27556 | 7  | 
theory EulerFermat  | 
8  | 
imports BijectionRel IntFact  | 
|
9  | 
begin  | 
|
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
10  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
11  | 
text {*
 | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
12  | 
Fermat's Little Theorem extended to Euler's Totient function. More  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
13  | 
abstract approach than Boyer-Moore (which seems necessary to achieve  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
14  | 
the extended version).  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
15  | 
*}  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
16  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
17  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
18  | 
subsection {* Definitions and lemmas *}
 | 
| 
9508
 
4d01dbf6ded7
Chinese Remainder Theorem, Wilsons Theorem, etc., by T M Masmussen
 
paulson 
parents:  
diff
changeset
 | 
19  | 
|
| 23755 | 20  | 
inductive_set  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
21  | 
RsetR :: "int => int set set"  | 
| 23755 | 22  | 
for m :: int  | 
23  | 
where  | 
|
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
24  | 
    empty [simp]: "{} \<in> RsetR m"
 | 
| 27556 | 25  | 
| insert: "A \<in> RsetR m ==> zgcd a m = 1 ==>  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
26  | 
\<forall>a'. a' \<in> A --> \<not> zcong a a' m ==> insert a A \<in> RsetR m"  | 
| 
9508
 
4d01dbf6ded7
Chinese Remainder Theorem, Wilsons Theorem, etc., by T M Masmussen
 
paulson 
parents:  
diff
changeset
 | 
27  | 
|
| 35440 | 28  | 
fun  | 
29  | 
BnorRset :: "int \<Rightarrow> int => int set"  | 
|
30  | 
where  | 
|
31  | 
"BnorRset a m =  | 
|
| 
11868
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
32  | 
(if 0 < a then  | 
| 35440 | 33  | 
let na = BnorRset (a - 1) m  | 
| 27556 | 34  | 
in (if zgcd a m = 1 then insert a na else na)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
35  | 
    else {})"
 | 
| 
9508
 
4d01dbf6ded7
Chinese Remainder Theorem, Wilsons Theorem, etc., by T M Masmussen
 
paulson 
parents:  
diff
changeset
 | 
36  | 
|
| 19670 | 37  | 
definition  | 
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19670 
diff
changeset
 | 
38  | 
norRRset :: "int => int set" where  | 
| 35440 | 39  | 
"norRRset m = BnorRset (m - 1) m"  | 
| 19670 | 40  | 
|
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19670 
diff
changeset
 | 
41  | 
definition  | 
| 
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19670 
diff
changeset
 | 
42  | 
noXRRset :: "int => int => int set" where  | 
| 19670 | 43  | 
"noXRRset m x = (\<lambda>a. a * x) ` norRRset m"  | 
44  | 
||
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19670 
diff
changeset
 | 
45  | 
definition  | 
| 
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19670 
diff
changeset
 | 
46  | 
phi :: "int => nat" where  | 
| 19670 | 47  | 
"phi m = card (norRRset m)"  | 
48  | 
||
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19670 
diff
changeset
 | 
49  | 
definition  | 
| 
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19670 
diff
changeset
 | 
50  | 
is_RRset :: "int set => int => bool" where  | 
| 19670 | 51  | 
"is_RRset A m = (A \<in> RsetR m \<and> card A = phi m)"  | 
52  | 
||
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19670 
diff
changeset
 | 
53  | 
definition  | 
| 
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19670 
diff
changeset
 | 
54  | 
RRset2norRR :: "int set => int => int => int" where  | 
| 19670 | 55  | 
"RRset2norRR A m a =  | 
| 
11868
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
56  | 
(if 1 < m \<and> is_RRset A m \<and> a \<in> A then  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
57  | 
SOME b. zcong a b m \<and> b \<in> norRRset m  | 
| 
11868
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
58  | 
else 0)"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
59  | 
|
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19670 
diff
changeset
 | 
60  | 
definition  | 
| 
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19670 
diff
changeset
 | 
61  | 
zcongm :: "int => int => int => bool" where  | 
| 19670 | 62  | 
"zcongm m = (\<lambda>a b. zcong a b m)"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
63  | 
|
| 
11868
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
64  | 
lemma abs_eq_1_iff [iff]: "(abs z = (1::int)) = (z = 1 \<or> z = -1)"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
65  | 
  -- {* LCP: not sure why this lemma is needed now *}
 | 
| 18369 | 66  | 
by (auto simp add: abs_if)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
67  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
68  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
69  | 
text {* \medskip @{text norRRset} *}
 | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
70  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
71  | 
declare BnorRset.simps [simp del]  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
72  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
73  | 
lemma BnorRset_induct:  | 
| 18369 | 74  | 
  assumes "!!a m. P {} a m"
 | 
| 35440 | 75  | 
and "!!a m :: int. 0 < a ==> P (BnorRset (a - 1) m) (a - 1) m  | 
76  | 
==> P (BnorRset a m) a m"  | 
|
77  | 
shows "P (BnorRset u v) u v"  | 
|
| 18369 | 78  | 
apply (rule BnorRset.induct)  | 
| 35440 | 79  | 
apply (case_tac "0 < a")  | 
80  | 
apply (rule_tac assms)  | 
|
| 18369 | 81  | 
apply simp_all  | 
| 35440 | 82  | 
apply (simp_all add: BnorRset.simps assms)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
83  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
84  | 
|
| 35440 | 85  | 
lemma Bnor_mem_zle [rule_format]: "b \<in> BnorRset a m \<longrightarrow> b \<le> a"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
86  | 
apply (induct a m rule: BnorRset_induct)  | 
| 18369 | 87  | 
apply simp  | 
88  | 
apply (subst BnorRset.simps)  | 
|
| 13833 | 89  | 
apply (unfold Let_def, auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
90  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
91  | 
|
| 35440 | 92  | 
lemma Bnor_mem_zle_swap: "a < b ==> b \<notin> BnorRset a m"  | 
| 18369 | 93  | 
by (auto dest: Bnor_mem_zle)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
94  | 
|
| 35440 | 95  | 
lemma Bnor_mem_zg [rule_format]: "b \<in> BnorRset a m --> 0 < b"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
96  | 
apply (induct a m rule: BnorRset_induct)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
97  | 
prefer 2  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
98  | 
apply (subst BnorRset.simps)  | 
| 13833 | 99  | 
apply (unfold Let_def, auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
100  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
101  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
102  | 
lemma Bnor_mem_if [rule_format]:  | 
| 35440 | 103  | 
"zgcd b m = 1 --> 0 < b --> b \<le> a --> b \<in> BnorRset a m"  | 
| 13833 | 104  | 
apply (induct a m rule: BnorRset.induct, auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
105  | 
apply (subst BnorRset.simps)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
106  | 
defer  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
107  | 
apply (subst BnorRset.simps)  | 
| 13833 | 108  | 
apply (unfold Let_def, auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
109  | 
done  | 
| 
9508
 
4d01dbf6ded7
Chinese Remainder Theorem, Wilsons Theorem, etc., by T M Masmussen
 
paulson 
parents:  
diff
changeset
 | 
110  | 
|
| 35440 | 111  | 
lemma Bnor_in_RsetR [rule_format]: "a < m --> BnorRset a m \<in> RsetR m"  | 
| 13833 | 112  | 
apply (induct a m rule: BnorRset_induct, simp)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
113  | 
apply (subst BnorRset.simps)  | 
| 13833 | 114  | 
apply (unfold Let_def, auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
115  | 
apply (rule RsetR.insert)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
116  | 
apply (rule_tac [3] allI)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
117  | 
apply (rule_tac [3] impI)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
118  | 
apply (rule_tac [3] zcong_not)  | 
| 
11868
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
119  | 
apply (subgoal_tac [6] "a' \<le> a - 1")  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
120  | 
apply (rule_tac [7] Bnor_mem_zle)  | 
| 13833 | 121  | 
apply (rule_tac [5] Bnor_mem_zg, auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
122  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
123  | 
|
| 35440 | 124  | 
lemma Bnor_fin: "finite (BnorRset a m)"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
125  | 
apply (induct a m rule: BnorRset_induct)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
126  | 
prefer 2  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
127  | 
apply (subst BnorRset.simps)  | 
| 13833 | 128  | 
apply (unfold Let_def, auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
129  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
130  | 
|
| 13524 | 131  | 
lemma norR_mem_unique_aux: "a \<le> b - 1 ==> a < (b::int)"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
132  | 
apply auto  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
133  | 
done  | 
| 
9508
 
4d01dbf6ded7
Chinese Remainder Theorem, Wilsons Theorem, etc., by T M Masmussen
 
paulson 
parents:  
diff
changeset
 | 
134  | 
|
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
135  | 
lemma norR_mem_unique:  | 
| 
11868
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
136  | 
"1 < m ==>  | 
| 27556 | 137  | 
zgcd a m = 1 ==> \<exists>!b. [a = b] (mod m) \<and> b \<in> norRRset m"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
138  | 
apply (unfold norRRset_def)  | 
| 13833 | 139  | 
apply (cut_tac a = a and m = m in zcong_zless_unique, auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
140  | 
apply (rule_tac [2] m = m in zcong_zless_imp_eq)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
141  | 
apply (auto intro: Bnor_mem_zle Bnor_mem_zg zcong_trans  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32479 
diff
changeset
 | 
142  | 
order_less_imp_le norR_mem_unique_aux simp add: zcong_sym)  | 
| 
14174
 
f3cafd2929d5
Methods rule_tac etc support static (Isar) contexts.
 
ballarin 
parents: 
13833 
diff
changeset
 | 
143  | 
apply (rule_tac x = b in exI, safe)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
144  | 
apply (rule Bnor_mem_if)  | 
| 
11868
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
145  | 
apply (case_tac [2] "b = 0")  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
146  | 
apply (auto intro: order_less_le [THEN iffD2])  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
147  | 
prefer 2  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
148  | 
apply (simp only: zcong_def)  | 
| 27556 | 149  | 
apply (subgoal_tac "zgcd a m = m")  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
150  | 
prefer 2  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
151  | 
apply (subst zdvd_iff_zgcd [symmetric])  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
152  | 
apply (rule_tac [4] zgcd_zcong_zgcd)  | 
| 30042 | 153  | 
apply (simp_all add: zcong_sym)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
154  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
155  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
156  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
157  | 
text {* \medskip @{term noXRRset} *}
 | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
158  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
159  | 
lemma RRset_gcd [rule_format]:  | 
| 27556 | 160  | 
"is_RRset A m ==> a \<in> A --> zgcd a m = 1"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
161  | 
apply (unfold is_RRset_def)  | 
| 27556 | 162  | 
apply (rule RsetR.induct [where P="%A. a \<in> A --> zgcd a m = 1"], auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
163  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
164  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
165  | 
lemma RsetR_zmult_mono:  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
166  | 
"A \<in> RsetR m ==>  | 
| 27556 | 167  | 
0 < m ==> zgcd x m = 1 ==> (\<lambda>a. a * x) ` A \<in> RsetR m"  | 
| 13833 | 168  | 
apply (erule RsetR.induct, simp_all)  | 
169  | 
apply (rule RsetR.insert, auto)  | 
|
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
170  | 
apply (blast intro: zgcd_zgcd_zmult)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
171  | 
apply (simp add: zcong_cancel)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
172  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
173  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
174  | 
lemma card_nor_eq_noX:  | 
| 
11868
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
175  | 
"0 < m ==>  | 
| 27556 | 176  | 
zgcd x m = 1 ==> card (noXRRset m x) = card (norRRset m)"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
177  | 
apply (unfold norRRset_def noXRRset_def)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
178  | 
apply (rule card_image)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
179  | 
apply (auto simp add: inj_on_def Bnor_fin)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
180  | 
apply (simp add: BnorRset.simps)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
181  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
182  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
183  | 
lemma noX_is_RRset:  | 
| 27556 | 184  | 
"0 < m ==> zgcd x m = 1 ==> is_RRset (noXRRset m x) m"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
185  | 
apply (unfold is_RRset_def phi_def)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
186  | 
apply (auto simp add: card_nor_eq_noX)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
187  | 
apply (unfold noXRRset_def norRRset_def)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
188  | 
apply (rule RsetR_zmult_mono)  | 
| 13833 | 189  | 
apply (rule Bnor_in_RsetR, simp_all)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
190  | 
done  | 
| 
9508
 
4d01dbf6ded7
Chinese Remainder Theorem, Wilsons Theorem, etc., by T M Masmussen
 
paulson 
parents:  
diff
changeset
 | 
191  | 
|
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
192  | 
lemma aux_some:  | 
| 
11868
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
193  | 
"1 < m ==> is_RRset A m ==> a \<in> A  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
194  | 
==> zcong a (SOME b. [a = b] (mod m) \<and> b \<in> norRRset m) m \<and>  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
195  | 
(SOME b. [a = b] (mod m) \<and> b \<in> norRRset m) \<in> norRRset m"  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
196  | 
apply (rule norR_mem_unique [THEN ex1_implies_ex, THEN someI_ex])  | 
| 13833 | 197  | 
apply (rule_tac [2] RRset_gcd, simp_all)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
198  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
199  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
200  | 
lemma RRset2norRR_correct:  | 
| 
11868
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
201  | 
"1 < m ==> is_RRset A m ==> a \<in> A ==>  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
202  | 
[a = RRset2norRR A m a] (mod m) \<and> RRset2norRR A m a \<in> norRRset m"  | 
| 13833 | 203  | 
apply (unfold RRset2norRR_def, simp)  | 
204  | 
apply (rule aux_some, simp_all)  | 
|
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
205  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
206  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
207  | 
lemmas RRset2norRR_correct1 =  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
208  | 
RRset2norRR_correct [THEN conjunct1, standard]  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
209  | 
lemmas RRset2norRR_correct2 =  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
210  | 
RRset2norRR_correct [THEN conjunct2, standard]  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
211  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
212  | 
lemma RsetR_fin: "A \<in> RsetR m ==> finite A"  | 
| 18369 | 213  | 
by (induct set: RsetR) auto  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
214  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
215  | 
lemma RRset_zcong_eq [rule_format]:  | 
| 
11868
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
216  | 
"1 < m ==>  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
217  | 
is_RRset A m ==> [a = b] (mod m) ==> a \<in> A --> b \<in> A --> a = b"  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
218  | 
apply (unfold is_RRset_def)  | 
| 
26793
 
e36a92ff543e
Instantiated some rules to avoid problems with HO unification.
 
berghofe 
parents: 
23755 
diff
changeset
 | 
219  | 
apply (rule RsetR.induct [where P="%A. a \<in> A --> b \<in> A --> a = b"])  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
220  | 
apply (auto simp add: zcong_sym)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
221  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
222  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
223  | 
lemma aux:  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
224  | 
"P (SOME a. P a) ==> Q (SOME a. Q a) ==>  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
225  | 
(SOME a. P a) = (SOME a. Q a) ==> \<exists>a. P a \<and> Q a"  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
226  | 
apply auto  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
227  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
228  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
229  | 
lemma RRset2norRR_inj:  | 
| 
11868
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
230  | 
"1 < m ==> is_RRset A m ==> inj_on (RRset2norRR A m) A"  | 
| 13833 | 231  | 
apply (unfold RRset2norRR_def inj_on_def, auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
232  | 
apply (subgoal_tac "\<exists>b. ([x = b] (mod m) \<and> b \<in> norRRset m) \<and>  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
233  | 
([y = b] (mod m) \<and> b \<in> norRRset m)")  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
234  | 
apply (rule_tac [2] aux)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
235  | 
apply (rule_tac [3] aux_some)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
236  | 
apply (rule_tac [2] aux_some)  | 
| 13833 | 237  | 
apply (rule RRset_zcong_eq, auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
238  | 
apply (rule_tac b = b in zcong_trans)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
239  | 
apply (simp_all add: zcong_sym)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
240  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
241  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
242  | 
lemma RRset2norRR_eq_norR:  | 
| 
11868
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
243  | 
"1 < m ==> is_RRset A m ==> RRset2norRR A m ` A = norRRset m"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
244  | 
apply (rule card_seteq)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
245  | 
prefer 3  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
246  | 
apply (subst card_image)  | 
| 15402 | 247  | 
apply (rule_tac RRset2norRR_inj, auto)  | 
248  | 
apply (rule_tac [3] RRset2norRR_correct2, auto)  | 
|
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
249  | 
apply (unfold is_RRset_def phi_def norRRset_def)  | 
| 15402 | 250  | 
apply (auto simp add: Bnor_fin)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
251  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
252  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
253  | 
|
| 13524 | 254  | 
lemma Bnor_prod_power_aux: "a \<notin> A ==> inj f ==> f a \<notin> f ` A"  | 
| 13833 | 255  | 
by (unfold inj_on_def, auto)  | 
| 
9508
 
4d01dbf6ded7
Chinese Remainder Theorem, Wilsons Theorem, etc., by T M Masmussen
 
paulson 
parents:  
diff
changeset
 | 
256  | 
|
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
257  | 
lemma Bnor_prod_power [rule_format]:  | 
| 35440 | 258  | 
"x \<noteq> 0 ==> a < m --> \<Prod>((\<lambda>a. a * x) ` BnorRset a m) =  | 
259  | 
\<Prod>(BnorRset a m) * x^card (BnorRset a m)"  | 
|
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
260  | 
apply (induct a m rule: BnorRset_induct)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
261  | 
prefer 2  | 
| 15481 | 262  | 
   apply (simplesubst BnorRset.simps)  --{*multiple redexes*}
 | 
| 13833 | 263  | 
apply (unfold Let_def, auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
264  | 
apply (simp add: Bnor_fin Bnor_mem_zle_swap)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
265  | 
apply (subst setprod_insert)  | 
| 13524 | 266  | 
apply (rule_tac [2] Bnor_prod_power_aux)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
267  | 
apply (unfold inj_on_def)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
268  | 
apply (simp_all add: zmult_ac Bnor_fin finite_imageI  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
269  | 
Bnor_mem_zle_swap)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
270  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
271  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
272  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
273  | 
subsection {* Fermat *}
 | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
274  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
275  | 
lemma bijzcong_zcong_prod:  | 
| 15392 | 276  | 
"(A, B) \<in> bijR (zcongm m) ==> [\<Prod>A = \<Prod>B] (mod m)"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
277  | 
apply (unfold zcongm_def)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
278  | 
apply (erule bijR.induct)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
279  | 
apply (subgoal_tac [2] "a \<notin> A \<and> b \<notin> B \<and> finite A \<and> finite B")  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
280  | 
apply (auto intro: fin_bijRl fin_bijRr zcong_zmult)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
281  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
282  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
283  | 
lemma Bnor_prod_zgcd [rule_format]:  | 
| 35440 | 284  | 
"a < m --> zgcd (\<Prod>(BnorRset a m)) m = 1"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
285  | 
apply (induct a m rule: BnorRset_induct)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
286  | 
prefer 2  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
287  | 
apply (subst BnorRset.simps)  | 
| 13833 | 288  | 
apply (unfold Let_def, auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
289  | 
apply (simp add: Bnor_fin Bnor_mem_zle_swap)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
290  | 
apply (blast intro: zgcd_zgcd_zmult)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
291  | 
done  | 
| 
9508
 
4d01dbf6ded7
Chinese Remainder Theorem, Wilsons Theorem, etc., by T M Masmussen
 
paulson 
parents:  
diff
changeset
 | 
292  | 
|
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
293  | 
theorem Euler_Fermat:  | 
| 27556 | 294  | 
"0 < m ==> zgcd x m = 1 ==> [x^(phi m) = 1] (mod m)"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
295  | 
apply (unfold norRRset_def phi_def)  | 
| 
11868
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
296  | 
apply (case_tac "x = 0")  | 
| 
 
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
 
paulson 
parents: 
11704 
diff
changeset
 | 
297  | 
apply (case_tac [2] "m = 1")  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
298  | 
apply (rule_tac [3] iffD1)  | 
| 35440 | 299  | 
apply (rule_tac [3] k = "\<Prod>(BnorRset (m - 1) m)"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
300  | 
in zcong_cancel2)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
301  | 
prefer 5  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
302  | 
apply (subst Bnor_prod_power [symmetric])  | 
| 13833 | 303  | 
apply (rule_tac [7] Bnor_prod_zgcd, simp_all)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
304  | 
apply (rule bijzcong_zcong_prod)  | 
| 35440 | 305  | 
apply (fold norRRset_def, fold noXRRset_def)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
306  | 
apply (subst RRset2norRR_eq_norR [symmetric])  | 
| 13833 | 307  | 
apply (rule_tac [3] inj_func_bijR, auto)  | 
| 13187 | 308  | 
apply (unfold zcongm_def)  | 
309  | 
apply (rule_tac [2] RRset2norRR_correct1)  | 
|
310  | 
apply (rule_tac [5] RRset2norRR_inj)  | 
|
311  | 
apply (auto intro: order_less_le [THEN iffD2]  | 
|
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32479 
diff
changeset
 | 
312  | 
simp add: noX_is_RRset)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
313  | 
apply (unfold noXRRset_def norRRset_def)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
314  | 
apply (rule finite_imageI)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
315  | 
apply (rule Bnor_fin)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
316  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
317  | 
|
| 
16733
 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 
nipkow 
parents: 
16663 
diff
changeset
 | 
318  | 
lemma Bnor_prime:  | 
| 35440 | 319  | 
"\<lbrakk> zprime p; a < p \<rbrakk> \<Longrightarrow> card (BnorRset a p) = nat a"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
320  | 
apply (induct a p rule: BnorRset.induct)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
321  | 
apply (subst BnorRset.simps)  | 
| 
16733
 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 
nipkow 
parents: 
16663 
diff
changeset
 | 
322  | 
apply (unfold Let_def, auto simp add:zless_zprime_imp_zrelprime)  | 
| 35440 | 323  | 
apply (subgoal_tac "finite (BnorRset (a - 1) m)")  | 
324  | 
apply (subgoal_tac "a ~: BnorRset (a - 1) m")  | 
|
| 13833 | 325  | 
apply (auto simp add: card_insert_disjoint Suc_nat_eq_nat_zadd1)  | 
326  | 
apply (frule Bnor_mem_zle, arith)  | 
|
327  | 
apply (frule Bnor_fin)  | 
|
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
328  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
329  | 
|
| 16663 | 330  | 
lemma phi_prime: "zprime p ==> phi p = nat (p - 1)"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
331  | 
apply (unfold phi_def norRRset_def)  | 
| 13833 | 332  | 
apply (rule Bnor_prime, auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
333  | 
done  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
334  | 
|
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
335  | 
theorem Little_Fermat:  | 
| 16663 | 336  | 
"zprime p ==> \<not> p dvd x ==> [x^(nat (p - 1)) = 1] (mod p)"  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
337  | 
apply (subst phi_prime [symmetric])  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
338  | 
apply (rule_tac [2] Euler_Fermat)  | 
| 
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
339  | 
apply (erule_tac [3] zprime_imp_zrelprime)  | 
| 13833 | 340  | 
apply (unfold zprime_def, auto)  | 
| 
11049
 
7eef34adb852
HOL-NumberTheory: converted to new-style format and proper document setup;
 
wenzelm 
parents: 
10834 
diff
changeset
 | 
341  | 
done  | 
| 
9508
 
4d01dbf6ded7
Chinese Remainder Theorem, Wilsons Theorem, etc., by T M Masmussen
 
paulson 
parents:  
diff
changeset
 | 
342  | 
|
| 
 
4d01dbf6ded7
Chinese Remainder Theorem, Wilsons Theorem, etc., by T M Masmussen
 
paulson 
parents:  
diff
changeset
 | 
343  | 
end  |