| author | nipkow |
| Sat, 14 Jun 2025 11:45:56 +0200 | |
| changeset 82704 | e0fb46018187 |
| parent 81438 | 95c9af7483b1 |
| permissions | -rw-r--r-- |
| 35849 | 1 |
(* Title: HOL/Algebra/IntRing.thy |
2 |
Author: Stephan Hohe, TU Muenchen |
|
|
41433
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
3 |
Author: Clemens Ballarin |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
4 |
*) |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
5 |
|
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
6 |
theory IntRing |
|
68399
0b71d08528f0
resolution of name clashes in Algebra
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
7 |
imports "HOL-Computational_Algebra.Primes" QuotRing Lattice |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
8 |
begin |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
9 |
|
| 61382 | 10 |
section \<open>The Ring of Integers\<close> |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
11 |
|
| 69597 | 12 |
subsection \<open>Some properties of \<^typ>\<open>int\<close>\<close> |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
13 |
|
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
14 |
lemma dvds_eq_abseq: |
| 55991 | 15 |
fixes k :: int |
| 61945 | 16 |
shows "l dvd k \<and> k dvd l \<longleftrightarrow> \<bar>l\<bar> = \<bar>k\<bar>" |
| 68561 | 17 |
by (metis dvd_if_abs_eq lcm.commute lcm_proj1_iff_int) |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
18 |
|
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
19 |
|
| 63167 | 20 |
subsection \<open>\<open>\<Z>\<close>: The Set of Integers as Algebraic Structure\<close> |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
21 |
|
|
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
69597
diff
changeset
|
22 |
abbreviation int_ring :: "int ring" (\<open>\<Z>\<close>) |
|
69064
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
nipkow
parents:
68561
diff
changeset
|
23 |
where "int_ring \<equiv> \<lparr>carrier = UNIV, mult = (*), one = 1, zero = 0, add = (+)\<rparr>" |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
24 |
|
| 55991 | 25 |
lemma int_Zcarr [intro!, simp]: "k \<in> carrier \<Z>" |
|
41433
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
26 |
by simp |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
27 |
|
| 55991 | 28 |
lemma int_is_cring: "cring \<Z>" |
| 68561 | 29 |
proof (rule cringI) |
30 |
show "abelian_group \<Z>" |
|
31 |
by (rule abelian_groupI) (auto intro: left_minus) |
|
32 |
show "Group.comm_monoid \<Z>" |
|
33 |
by (simp add: Group.monoid.intro monoid.monoid_comm_monoidI) |
|
34 |
qed (auto simp: distrib_right) |
|
| 35849 | 35 |
|
36 |
||
| 61382 | 37 |
subsection \<open>Interpretations\<close> |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
38 |
|
| 61382 | 39 |
text \<open>Since definitions of derived operations are global, their |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
40 |
interpretation needs to be done as early as possible --- that is, |
| 61382 | 41 |
with as few assumptions as possible.\<close> |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
42 |
|
|
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
29948
diff
changeset
|
43 |
interpretation int: monoid \<Z> |
|
61566
c3d6e570ccef
Keyword 'rewrites' identifies rewrite morphisms.
ballarin
parents:
61382
diff
changeset
|
44 |
rewrites "carrier \<Z> = UNIV" |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
45 |
and "mult \<Z> x y = x * y" |
|
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
46 |
and "one \<Z> = 1" |
|
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
47 |
and "pow \<Z> x n = x^n" |
|
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
48 |
proof - |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
67399
diff
changeset
|
49 |
\<comment> \<open>Specification\<close> |
| 61169 | 50 |
show "monoid \<Z>" by standard auto |
|
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
29948
diff
changeset
|
51 |
then interpret int: monoid \<Z> . |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
52 |
|
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
67399
diff
changeset
|
53 |
\<comment> \<open>Carrier\<close> |
|
41433
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
54 |
show "carrier \<Z> = UNIV" by simp |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
55 |
|
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
67399
diff
changeset
|
56 |
\<comment> \<open>Operations\<close> |
| 81438 | 57 |
show "mult \<Z> x y = x * y" for x y by simp |
| 55991 | 58 |
show "one \<Z> = 1" by simp |
|
41433
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
59 |
show "pow \<Z> x n = x^n" by (induct n) simp_all |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
60 |
qed |
|
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
61 |
|
|
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
29948
diff
changeset
|
62 |
interpretation int: comm_monoid \<Z> |
| 64272 | 63 |
rewrites "finprod \<Z> f A = prod f A" |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
64 |
proof - |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
67399
diff
changeset
|
65 |
\<comment> \<open>Specification\<close> |
| 61169 | 66 |
show "comm_monoid \<Z>" by standard auto |
|
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
29948
diff
changeset
|
67 |
then interpret int: comm_monoid \<Z> . |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
68 |
|
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
67399
diff
changeset
|
69 |
\<comment> \<open>Operations\<close> |
| 64272 | 70 |
show "finprod \<Z> f A = prod f A" |
| 81438 | 71 |
by (induct A rule: infinite_finite_induct) auto |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
72 |
qed |
|
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
73 |
|
|
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
29948
diff
changeset
|
74 |
interpretation int: abelian_monoid \<Z> |
|
61566
c3d6e570ccef
Keyword 'rewrites' identifies rewrite morphisms.
ballarin
parents:
61382
diff
changeset
|
75 |
rewrites int_carrier_eq: "carrier \<Z> = UNIV" |
|
41433
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
76 |
and int_zero_eq: "zero \<Z> = 0" |
|
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
77 |
and int_add_eq: "add \<Z> x y = x + y" |
| 64267 | 78 |
and int_finsum_eq: "finsum \<Z> f A = sum f A" |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
79 |
proof - |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
67399
diff
changeset
|
80 |
\<comment> \<open>Specification\<close> |
| 61169 | 81 |
show "abelian_monoid \<Z>" by standard auto |
|
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
29948
diff
changeset
|
82 |
then interpret int: abelian_monoid \<Z> . |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
83 |
|
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
67399
diff
changeset
|
84 |
\<comment> \<open>Carrier\<close> |
|
41433
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
85 |
show "carrier \<Z> = UNIV" by simp |
|
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
86 |
|
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
67399
diff
changeset
|
87 |
\<comment> \<open>Operations\<close> |
| 81438 | 88 |
show "add \<Z> x y = x + y" for x y by simp |
89 |
show zero: "zero \<Z> = 0" by simp |
|
| 64267 | 90 |
show "finsum \<Z> f A = sum f A" |
| 81438 | 91 |
by (induct A rule: infinite_finite_induct) auto |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
92 |
qed |
|
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
93 |
|
|
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
29948
diff
changeset
|
94 |
interpretation int: abelian_group \<Z> |
|
41433
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
95 |
(* The equations from the interpretation of abelian_monoid need to be repeated. |
|
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
96 |
Since the morphisms through which the abelian structures are interpreted are |
|
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
97 |
not the identity, the equations of these interpretations are not inherited. *) |
|
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
98 |
(* FIXME *) |
|
61566
c3d6e570ccef
Keyword 'rewrites' identifies rewrite morphisms.
ballarin
parents:
61382
diff
changeset
|
99 |
rewrites "carrier \<Z> = UNIV" |
|
41433
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
100 |
and "zero \<Z> = 0" |
|
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
101 |
and "add \<Z> x y = x + y" |
| 64267 | 102 |
and "finsum \<Z> f A = sum f A" |
|
41433
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
103 |
and int_a_inv_eq: "a_inv \<Z> x = - x" |
|
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
104 |
and int_a_minus_eq: "a_minus \<Z> x y = x - y" |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
105 |
proof - |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
67399
diff
changeset
|
106 |
\<comment> \<open>Specification\<close> |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
107 |
show "abelian_group \<Z>" |
|
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
108 |
proof (rule abelian_groupI) |
| 55991 | 109 |
fix x |
110 |
assume "x \<in> carrier \<Z>" |
|
111 |
then show "\<exists>y \<in> carrier \<Z>. y \<oplus>\<^bsub>\<Z>\<^esub> x = \<zero>\<^bsub>\<Z>\<^esub>" |
|
|
41433
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
112 |
by simp arith |
|
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
113 |
qed auto |
|
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
29948
diff
changeset
|
114 |
then interpret int: abelian_group \<Z> . |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
67399
diff
changeset
|
115 |
\<comment> \<open>Operations\<close> |
| 81438 | 116 |
have add: "add \<Z> x y = x + y" for x y by simp |
|
41433
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
117 |
have zero: "zero \<Z> = 0" by simp |
| 81438 | 118 |
show a_inv: "a_inv \<Z> x = - x" for x |
119 |
proof - |
|
| 55991 | 120 |
have "add \<Z> (- x) x = zero \<Z>" |
121 |
by (simp add: add zero) |
|
| 81438 | 122 |
then show ?thesis |
| 55991 | 123 |
by (simp add: int.minus_equality) |
| 81438 | 124 |
qed |
| 55991 | 125 |
show "a_minus \<Z> x y = x - y" |
126 |
by (simp add: int.minus_eq add a_inv) |
|
|
41433
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
127 |
qed (simp add: int_carrier_eq int_zero_eq int_add_eq int_finsum_eq)+ |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
128 |
|
|
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
29948
diff
changeset
|
129 |
interpretation int: "domain" \<Z> |
|
61566
c3d6e570ccef
Keyword 'rewrites' identifies rewrite morphisms.
ballarin
parents:
61382
diff
changeset
|
130 |
rewrites "carrier \<Z> = UNIV" |
|
41433
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
131 |
and "zero \<Z> = 0" |
|
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
132 |
and "add \<Z> x y = x + y" |
| 64267 | 133 |
and "finsum \<Z> f A = sum f A" |
|
41433
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
134 |
and "a_inv \<Z> x = - x" |
|
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
135 |
and "a_minus \<Z> x y = x - y" |
|
1b8ff770f02c
Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents:
35849
diff
changeset
|
136 |
proof - |
| 55991 | 137 |
show "domain \<Z>" |
138 |
by unfold_locales (auto simp: distrib_right distrib_left) |
|
139 |
qed (simp add: int_carrier_eq int_zero_eq int_add_eq int_finsum_eq int_a_inv_eq int_a_minus_eq)+ |
|
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
140 |
|
|
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
141 |
|
| 69597 | 142 |
text \<open>Removal of occurrences of \<^term>\<open>UNIV\<close> in interpretation result |
| 61382 | 143 |
--- experimental.\<close> |
|
24131
1099f6c73649
Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents:
23957
diff
changeset
|
144 |
|
|
1099f6c73649
Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents:
23957
diff
changeset
|
145 |
lemma UNIV: |
| 55991 | 146 |
"x \<in> UNIV \<longleftrightarrow> True" |
147 |
"A \<subseteq> UNIV \<longleftrightarrow> True" |
|
148 |
"(\<forall>x \<in> UNIV. P x) \<longleftrightarrow> (\<forall>x. P x)" |
|
| 67091 | 149 |
"(\<exists>x \<in> UNIV. P x) \<longleftrightarrow> (\<exists>x. P x)" |
| 55991 | 150 |
"(True \<longrightarrow> Q) \<longleftrightarrow> Q" |
151 |
"(True \<Longrightarrow> PROP R) \<equiv> PROP R" |
|
|
24131
1099f6c73649
Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents:
23957
diff
changeset
|
152 |
by simp_all |
|
1099f6c73649
Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents:
23957
diff
changeset
|
153 |
|
|
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
29948
diff
changeset
|
154 |
interpretation int (* FIXME [unfolded UNIV] *) : |
| 67399 | 155 |
partial_order "\<lparr>carrier = UNIV::int set, eq = (=), le = (\<le>)\<rparr>" |
156 |
rewrites "carrier \<lparr>carrier = UNIV::int set, eq = (=), le = (\<le>)\<rparr> = UNIV" |
|
157 |
and "le \<lparr>carrier = UNIV::int set, eq = (=), le = (\<le>)\<rparr> x y = (x \<le> y)" |
|
158 |
and "lless \<lparr>carrier = UNIV::int set, eq = (=), le = (\<le>)\<rparr> x y = (x < y)" |
|
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
159 |
proof - |
| 67399 | 160 |
show "partial_order \<lparr>carrier = UNIV::int set, eq = (=), le = (\<le>)\<rparr>" |
| 61169 | 161 |
by standard simp_all |
| 67399 | 162 |
show "carrier \<lparr>carrier = UNIV::int set, eq = (=), le = (\<le>)\<rparr> = UNIV" |
|
24131
1099f6c73649
Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents:
23957
diff
changeset
|
163 |
by simp |
| 67399 | 164 |
show "le \<lparr>carrier = UNIV::int set, eq = (=), le = (\<le>)\<rparr> x y = (x \<le> y)" |
|
24131
1099f6c73649
Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents:
23957
diff
changeset
|
165 |
by simp |
| 67399 | 166 |
show "lless \<lparr>carrier = UNIV::int set, eq = (=), le = (\<le>)\<rparr> x y = (x < y)" |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
167 |
by (simp add: lless_def) auto |
|
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
168 |
qed |
|
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
169 |
|
|
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
29948
diff
changeset
|
170 |
interpretation int (* FIXME [unfolded UNIV] *) : |
| 67399 | 171 |
lattice "\<lparr>carrier = UNIV::int set, eq = (=), le = (\<le>)\<rparr>" |
172 |
rewrites "join \<lparr>carrier = UNIV::int set, eq = (=), le = (\<le>)\<rparr> x y = max x y" |
|
173 |
and "meet \<lparr>carrier = UNIV::int set, eq = (=), le = (\<le>)\<rparr> x y = min x y" |
|
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
174 |
proof - |
| 67399 | 175 |
let ?Z = "\<lparr>carrier = UNIV::int set, eq = (=), le = (\<le>)\<rparr>" |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
176 |
show "lattice ?Z" |
|
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
177 |
apply unfold_locales |
| 68561 | 178 |
apply (simp_all add: least_def Upper_def greatest_def Lower_def) |
179 |
apply arith+ |
|
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
180 |
done |
|
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
29948
diff
changeset
|
181 |
then interpret int: lattice "?Z" . |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
182 |
show "join ?Z x y = max x y" |
| 68561 | 183 |
by (metis int.le_iff_meet iso_tuple_UNIV_I join_comm linear max.absorb_iff2 max_def) |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
184 |
show "meet ?Z x y = min x y" |
| 68561 | 185 |
using int.meet_le int.meet_left int.meet_right by auto |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
186 |
qed |
|
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
187 |
|
|
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
29948
diff
changeset
|
188 |
interpretation int (* [unfolded UNIV] *) : |
| 67399 | 189 |
total_order "\<lparr>carrier = UNIV::int set, eq = (=), le = (\<le>)\<rparr>" |
| 61169 | 190 |
by standard clarsimp |
|
23957
54fab60ddc97
Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents:
22063
diff
changeset
|
191 |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
192 |
|
| 63167 | 193 |
subsection \<open>Generated Ideals of \<open>\<Z>\<close>\<close> |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
194 |
|
| 55991 | 195 |
lemma int_Idl: "Idl\<^bsub>\<Z>\<^esub> {a} = {x * a | x. True}"
|
| 68561 | 196 |
by (simp_all add: cgenideal_def int.cgenideal_eq_genideal[symmetric]) |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
197 |
|
| 55991 | 198 |
lemma multiples_principalideal: "principalideal {x * a | x. True } \<Z>"
|
199 |
by (metis UNIV_I int.cgenideal_eq_genideal int.cgenideal_is_principalideal int_Idl) |
|
| 29700 | 200 |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
201 |
lemma prime_primeideal: |
|
68399
0b71d08528f0
resolution of name clashes in Algebra
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
202 |
assumes prime: "Factorial_Ring.prime p" |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
203 |
shows "primeideal (Idl\<^bsub>\<Z>\<^esub> {p}) \<Z>"
|
| 68561 | 204 |
proof (rule primeidealI) |
205 |
show "ideal (Idl\<^bsub>\<Z>\<^esub> {p}) \<Z>"
|
|
206 |
by (rule int.genideal_ideal, simp) |
|
207 |
show "cring \<Z>" |
|
208 |
by (rule int_is_cring) |
|
209 |
have False if "UNIV = {v::int. \<exists>x. v = x * p}"
|
|
210 |
proof - |
|
211 |
from that |
|
212 |
obtain i where "1 = i * p" |
|
213 |
by (blast intro: elim: ) |
|
214 |
then show False |
|
215 |
using prime by (auto simp add: abs_mult zmult_eq_1_iff) |
|
216 |
qed |
|
217 |
then show "carrier \<Z> \<noteq> Idl\<^bsub>\<Z>\<^esub> {p}"
|
|
218 |
by (auto simp add: int.cgenideal_eq_genideal[symmetric] cgenideal_def) |
|
219 |
have "p dvd a \<or> p dvd b" if "a * b = x * p" for a b x |
|
220 |
by (simp add: prime prime_dvd_multD that) |
|
221 |
then show "\<And>a b. \<lbrakk>a \<in> carrier \<Z>; b \<in> carrier \<Z>; a \<otimes>\<^bsub>\<Z>\<^esub> b \<in> Idl\<^bsub>\<Z>\<^esub> {p}\<rbrakk>
|
|
222 |
\<Longrightarrow> a \<in> Idl\<^bsub>\<Z>\<^esub> {p} \<or> b \<in> Idl\<^bsub>\<Z>\<^esub> {p}"
|
|
223 |
by (auto simp add: int.cgenideal_eq_genideal[symmetric] cgenideal_def dvd_def mult.commute) |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
224 |
qed |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
225 |
|
| 61382 | 226 |
subsection \<open>Ideals and Divisibility\<close> |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
227 |
|
| 55991 | 228 |
lemma int_Idl_subset_ideal: "Idl\<^bsub>\<Z>\<^esub> {k} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {l} = (k \<in> Idl\<^bsub>\<Z>\<^esub> {l})"
|
229 |
by (rule int.Idl_subset_ideal') simp_all |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
230 |
|
| 55991 | 231 |
lemma Idl_subset_eq_dvd: "Idl\<^bsub>\<Z>\<^esub> {k} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {l} \<longleftrightarrow> l dvd k"
|
| 68561 | 232 |
by (subst int_Idl_subset_ideal) (auto simp: dvd_def int_Idl) |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
233 |
|
| 55991 | 234 |
lemma dvds_eq_Idl: "l dvd k \<and> k dvd l \<longleftrightarrow> Idl\<^bsub>\<Z>\<^esub> {k} = Idl\<^bsub>\<Z>\<^esub> {l}"
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
235 |
proof - |
| 55991 | 236 |
have a: "l dvd k \<longleftrightarrow> (Idl\<^bsub>\<Z>\<^esub> {k} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {l})"
|
237 |
by (rule Idl_subset_eq_dvd[symmetric]) |
|
238 |
have b: "k dvd l \<longleftrightarrow> (Idl\<^bsub>\<Z>\<^esub> {l} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {k})"
|
|
239 |
by (rule Idl_subset_eq_dvd[symmetric]) |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
240 |
|
| 55991 | 241 |
have "l dvd k \<and> k dvd l \<longleftrightarrow> Idl\<^bsub>\<Z>\<^esub> {k} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {l} \<and> Idl\<^bsub>\<Z>\<^esub> {l} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {k}"
|
242 |
by (subst a, subst b, simp) |
|
243 |
also have "Idl\<^bsub>\<Z>\<^esub> {k} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {l} \<and> Idl\<^bsub>\<Z>\<^esub> {l} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {k} \<longleftrightarrow> Idl\<^bsub>\<Z>\<^esub> {k} = Idl\<^bsub>\<Z>\<^esub> {l}"
|
|
244 |
by blast |
|
245 |
finally show ?thesis . |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
246 |
qed |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
247 |
|
| 61945 | 248 |
lemma Idl_eq_abs: "Idl\<^bsub>\<Z>\<^esub> {k} = Idl\<^bsub>\<Z>\<^esub> {l} \<longleftrightarrow> \<bar>l\<bar> = \<bar>k\<bar>"
|
| 55991 | 249 |
apply (subst dvds_eq_abseq[symmetric]) |
250 |
apply (rule dvds_eq_Idl[symmetric]) |
|
251 |
done |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
252 |
|
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
253 |
|
| 61382 | 254 |
subsection \<open>Ideals and the Modulus\<close> |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
255 |
|
| 55991 | 256 |
definition ZMod :: "int \<Rightarrow> int \<Rightarrow> int set" |
|
35848
5443079512ea
slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents:
35416
diff
changeset
|
257 |
where "ZMod k r = (Idl\<^bsub>\<Z>\<^esub> {k}) +>\<^bsub>\<Z>\<^esub> r"
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
258 |
|
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
259 |
lemmas ZMod_defs = |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
260 |
ZMod_def genideal_def |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
261 |
|
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
262 |
lemma rcos_zfact: |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
263 |
assumes kIl: "k \<in> ZMod l r" |
| 55991 | 264 |
shows "\<exists>x. k = x * l + r" |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
265 |
proof - |
| 55991 | 266 |
from kIl[unfolded ZMod_def] have "\<exists>xl\<in>Idl\<^bsub>\<Z>\<^esub> {l}. k = xl + r"
|
267 |
by (simp add: a_r_coset_defs) |
|
268 |
then obtain xl where xl: "xl \<in> Idl\<^bsub>\<Z>\<^esub> {l}" and k: "k = xl + r"
|
|
269 |
by auto |
|
270 |
from xl obtain x where "xl = x * l" |
|
271 |
by (auto simp: int_Idl) |
|
272 |
with k have "k = x * l + r" |
|
273 |
by simp |
|
274 |
then show "\<exists>x. k = x * l + r" .. |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
275 |
qed |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
276 |
|
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
277 |
lemma ZMod_imp_zmod: |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
278 |
assumes zmods: "ZMod m a = ZMod m b" |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
279 |
shows "a mod m = b mod m" |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
280 |
proof - |
| 55991 | 281 |
interpret ideal "Idl\<^bsub>\<Z>\<^esub> {m}" \<Z>
|
282 |
by (rule int.genideal_ideal) fast |
|
283 |
from zmods have "b \<in> ZMod m a" |
|
284 |
unfolding ZMod_def by (simp add: a_repr_independenceD) |
|
285 |
then have "\<exists>x. b = x * m + a" |
|
286 |
by (rule rcos_zfact) |
|
287 |
then obtain x where "b = x * m + a" |
|
288 |
by fast |
|
289 |
then have "b mod m = (x * m + a) mod m" |
|
290 |
by simp |
|
291 |
also have "\<dots> = ((x * m) mod m) + (a mod m)" |
|
292 |
by (simp add: mod_add_eq) |
|
293 |
also have "\<dots> = a mod m" |
|
294 |
by simp |
|
295 |
finally have "b mod m = a mod m" . |
|
296 |
then show "a mod m = b mod m" .. |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
297 |
qed |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
298 |
|
| 55991 | 299 |
lemma ZMod_mod: "ZMod m a = ZMod m (a mod m)" |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
300 |
proof - |
| 55991 | 301 |
interpret ideal "Idl\<^bsub>\<Z>\<^esub> {m}" \<Z>
|
302 |
by (rule int.genideal_ideal) fast |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
303 |
show ?thesis |
| 55991 | 304 |
unfolding ZMod_def |
305 |
apply (rule a_repr_independence'[symmetric]) |
|
306 |
apply (simp add: int_Idl a_r_coset_defs) |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
307 |
proof - |
| 55991 | 308 |
have "a = m * (a div m) + (a mod m)" |
| 64246 | 309 |
by (simp add: mult_div_mod_eq [symmetric]) |
| 55991 | 310 |
then have "a = (a div m) * m + (a mod m)" |
311 |
by simp |
|
312 |
then show "\<exists>h. (\<exists>x. h = x * m) \<and> a = h + a mod m" |
|
313 |
by fast |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
314 |
qed simp |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
315 |
qed |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
316 |
|
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
317 |
lemma zmod_imp_ZMod: |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
318 |
assumes modeq: "a mod m = b mod m" |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
319 |
shows "ZMod m a = ZMod m b" |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
320 |
proof - |
| 55991 | 321 |
have "ZMod m a = ZMod m (a mod m)" |
322 |
by (rule ZMod_mod) |
|
323 |
also have "\<dots> = ZMod m (b mod m)" |
|
324 |
by (simp add: modeq[symmetric]) |
|
325 |
also have "\<dots> = ZMod m b" |
|
326 |
by (rule ZMod_mod[symmetric]) |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
327 |
finally show ?thesis . |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
328 |
qed |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
329 |
|
| 55991 | 330 |
corollary ZMod_eq_mod: "ZMod m a = ZMod m b \<longleftrightarrow> a mod m = b mod m" |
331 |
apply (rule iffI) |
|
332 |
apply (erule ZMod_imp_zmod) |
|
333 |
apply (erule zmod_imp_ZMod) |
|
334 |
done |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
335 |
|
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
336 |
|
| 61382 | 337 |
subsection \<open>Factorization\<close> |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
338 |
|
| 55991 | 339 |
definition ZFact :: "int \<Rightarrow> int set ring" |
|
35848
5443079512ea
slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents:
35416
diff
changeset
|
340 |
where "ZFact k = \<Z> Quot (Idl\<^bsub>\<Z>\<^esub> {k})"
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
341 |
|
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
342 |
lemmas ZFact_defs = ZFact_def FactRing_def |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
343 |
|
| 55991 | 344 |
lemma ZFact_is_cring: "cring (ZFact k)" |
| 68561 | 345 |
by (simp add: ZFact_def ideal.quotient_is_cring int.cring_axioms int.genideal_ideal) |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
346 |
|
| 55991 | 347 |
lemma ZFact_zero: "carrier (ZFact 0) = (\<Union>a. {{a}})"
|
| 68561 | 348 |
by (simp add: ZFact_defs A_RCOSETS_defs r_coset_def int.genideal_zero) |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
349 |
|
| 55991 | 350 |
lemma ZFact_one: "carrier (ZFact 1) = {UNIV}"
|
| 68561 | 351 |
unfolding ZFact_defs A_RCOSETS_defs r_coset_def ring_record_simps int.genideal_one |
352 |
proof |
|
353 |
have "\<And>a b::int. \<exists>x. b = x + a" |
|
354 |
by presburger |
|
355 |
then show "(\<Union>a::int. {\<Union>h. {h + a}}) \<subseteq> {UNIV}"
|
|
356 |
by force |
|
357 |
then show "{UNIV} \<subseteq> (\<Union>a::int. {\<Union>h. {h + a}})"
|
|
358 |
by (metis (no_types, lifting) UNIV_I UN_I singletonD singletonI subset_iff) |
|
359 |
qed |
|
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
360 |
|
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
361 |
lemma ZFact_prime_is_domain: |
|
68399
0b71d08528f0
resolution of name clashes in Algebra
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
362 |
assumes pprime: "Factorial_Ring.prime p" |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
363 |
shows "domain (ZFact p)" |
| 68561 | 364 |
by (simp add: ZFact_def pprime prime_primeideal primeideal.quotient_is_domain) |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
365 |
|
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff
changeset
|
366 |
end |