author | paulson |
Fri, 30 Aug 2002 16:42:45 +0200 | |
changeset 13550 | 5a176b8dda84 |
parent 11778 | 37efbe093d3c |
child 13735 | 7de9342aca7a |
permissions | -rw-r--r-- |
7998 | 1 |
(* |
2 |
Abstract class ring (commutative, with 1) |
|
3 |
$Id$ |
|
4 |
Author: Clemens Ballarin, started 9 December 1996 |
|
5 |
*) |
|
6 |
||
11778 | 7 |
val a_assoc = thm "plus_ac0.assoc"; |
8 |
val l_zero = thm "plus_ac0.zero"; |
|
9 |
val a_comm = thm "plus_ac0.commute"; |
|
10 |
||
7998 | 11 |
section "Rings"; |
12 |
||
13 |
fun make_left_commute assoc commute s = |
|
14 |
[rtac (commute RS trans) 1, rtac (assoc RS trans) 1, |
|
15 |
rtac (commute RS arg_cong) 1]; |
|
16 |
||
17 |
(* addition *) |
|
18 |
||
19 |
qed_goal "a_lcomm" Ring.thy "!!a::'a::ring. a+(b+c) = b+(a+c)" |
|
20 |
(make_left_commute a_assoc a_comm); |
|
21 |
||
22 |
val a_ac = [a_assoc, a_comm, a_lcomm]; |
|
23 |
||
11093 | 24 |
Goal "!!a::'a::ring. a + 0 = a"; |
9390
e6b96d953965
renamed // to / (which is what we want anyway) to avoid clash with the new
paulson
parents:
8707
diff
changeset
|
25 |
by (rtac (a_comm RS trans) 1); |
e6b96d953965
renamed // to / (which is what we want anyway) to avoid clash with the new
paulson
parents:
8707
diff
changeset
|
26 |
by (rtac l_zero 1); |
e6b96d953965
renamed // to / (which is what we want anyway) to avoid clash with the new
paulson
parents:
8707
diff
changeset
|
27 |
qed "r_zero"; |
7998 | 28 |
|
11093 | 29 |
Goal "!!a::'a::ring. a + (-a) = 0"; |
9390
e6b96d953965
renamed // to / (which is what we want anyway) to avoid clash with the new
paulson
parents:
8707
diff
changeset
|
30 |
by (rtac (a_comm RS trans) 1); |
e6b96d953965
renamed // to / (which is what we want anyway) to avoid clash with the new
paulson
parents:
8707
diff
changeset
|
31 |
by (rtac l_neg 1); |
e6b96d953965
renamed // to / (which is what we want anyway) to avoid clash with the new
paulson
parents:
8707
diff
changeset
|
32 |
qed "r_neg"; |
7998 | 33 |
|
34 |
Goal "!! a::'a::ring. a + b = a + c ==> b = c"; |
|
35 |
by (rtac box_equals 1); |
|
36 |
by (rtac l_zero 2); |
|
37 |
by (rtac l_zero 2); |
|
38 |
by (res_inst_tac [("a1", "a")] (l_neg RS subst) 1); |
|
39 |
by (asm_simp_tac (simpset() addsimps [a_assoc]) 1); |
|
40 |
qed "a_lcancel"; |
|
41 |
||
42 |
Goal "!! a::'a::ring. b + a = c + a ==> b = c"; |
|
43 |
by (rtac a_lcancel 1); |
|
44 |
by (asm_simp_tac (simpset() addsimps a_ac) 1); |
|
45 |
qed "a_rcancel"; |
|
46 |
||
47 |
Goal "!! a::'a::ring. (a + b = a + c) = (b = c)"; |
|
48 |
by (auto_tac (claset() addSDs [a_lcancel], simpset())); |
|
49 |
qed "a_lcancel_eq"; |
|
50 |
||
51 |
Goal "!! a::'a::ring. (b + a = c + a) = (b = c)"; |
|
52 |
by (simp_tac (simpset() addsimps [a_lcancel_eq, a_comm]) 1); |
|
53 |
qed "a_rcancel_eq"; |
|
54 |
||
55 |
Addsimps [a_lcancel_eq, a_rcancel_eq]; |
|
56 |
||
57 |
Goal "!!a::'a::ring. -(-a) = a"; |
|
58 |
by (rtac a_lcancel 1); |
|
59 |
by (rtac (r_neg RS trans) 1); |
|
60 |
by (rtac (l_neg RS sym) 1); |
|
61 |
qed "minus_minus"; |
|
62 |
||
11093 | 63 |
Goal "- 0 = (0::'a::ring)"; |
7998 | 64 |
by (rtac a_lcancel 1); |
65 |
by (rtac (r_neg RS trans) 1); |
|
66 |
by (rtac (l_zero RS sym) 1); |
|
67 |
qed "minus0"; |
|
68 |
||
69 |
Goal "!!a::'a::ring. -(a + b) = (-a) + (-b)"; |
|
70 |
by (res_inst_tac [("a", "a+b")] a_lcancel 1); |
|
71 |
by (simp_tac (simpset() addsimps ([r_neg, l_neg, l_zero]@a_ac)) 1); |
|
72 |
qed "minus_add"; |
|
73 |
||
74 |
(* multiplication *) |
|
75 |
||
76 |
qed_goal "m_lcomm" Ring.thy "!!a::'a::ring. a*(b*c) = b*(a*c)" |
|
77 |
(make_left_commute m_assoc m_comm); |
|
78 |
||
79 |
val m_ac = [m_assoc, m_comm, m_lcomm]; |
|
80 |
||
9390
e6b96d953965
renamed // to / (which is what we want anyway) to avoid clash with the new
paulson
parents:
8707
diff
changeset
|
81 |
Goal "!!a::'a::ring. a * <1> = a"; |
e6b96d953965
renamed // to / (which is what we want anyway) to avoid clash with the new
paulson
parents:
8707
diff
changeset
|
82 |
by (rtac (m_comm RS trans) 1); |
e6b96d953965
renamed // to / (which is what we want anyway) to avoid clash with the new
paulson
parents:
8707
diff
changeset
|
83 |
by (rtac l_one 1); |
e6b96d953965
renamed // to / (which is what we want anyway) to avoid clash with the new
paulson
parents:
8707
diff
changeset
|
84 |
qed "r_one"; |
7998 | 85 |
|
86 |
(* distributive and derived *) |
|
87 |
||
88 |
Goal "!!a::'a::ring. a * (b + c) = a * b + a * c"; |
|
89 |
by (rtac (m_comm RS trans) 1); |
|
90 |
by (rtac (l_distr RS trans) 1); |
|
91 |
by (simp_tac (simpset() addsimps [m_comm]) 1); |
|
92 |
qed "r_distr"; |
|
93 |
||
94 |
val m_distr = m_ac @ [l_distr, r_distr]; |
|
95 |
||
96 |
(* the following two proofs can be found in |
|
97 |
Jacobson, Basic Algebra I, pp. 88-89 *) |
|
98 |
||
11093 | 99 |
Goal "!!a::'a::ring. 0 * a = 0"; |
7998 | 100 |
by (rtac a_lcancel 1); |
101 |
by (rtac (l_distr RS sym RS trans) 1); |
|
102 |
by (simp_tac (simpset() addsimps [r_zero]) 1); |
|
103 |
qed "l_null"; |
|
104 |
||
11093 | 105 |
Goal "!!a::'a::ring. a * 0 = 0"; |
9390
e6b96d953965
renamed // to / (which is what we want anyway) to avoid clash with the new
paulson
parents:
8707
diff
changeset
|
106 |
by (rtac (m_comm RS trans) 1); |
e6b96d953965
renamed // to / (which is what we want anyway) to avoid clash with the new
paulson
parents:
8707
diff
changeset
|
107 |
by (rtac l_null 1); |
e6b96d953965
renamed // to / (which is what we want anyway) to avoid clash with the new
paulson
parents:
8707
diff
changeset
|
108 |
qed "r_null"; |
7998 | 109 |
|
110 |
Goal "!!a::'a::ring. (-a) * b = - (a * b)"; |
|
111 |
by (rtac a_lcancel 1); |
|
112 |
by (rtac (r_neg RS sym RSN (2, trans)) 1); |
|
113 |
by (rtac (l_distr RS sym RS trans) 1); |
|
114 |
by (simp_tac (simpset() addsimps [l_null, r_neg]) 1); |
|
115 |
qed "l_minus"; |
|
116 |
||
117 |
Goal "!!a::'a::ring. a * (-b) = - (a * b)"; |
|
118 |
by (rtac a_lcancel 1); |
|
119 |
by (rtac (r_neg RS sym RSN (2, trans)) 1); |
|
120 |
by (rtac (r_distr RS sym RS trans) 1); |
|
121 |
by (simp_tac (simpset() addsimps [r_null, r_neg]) 1); |
|
122 |
qed "r_minus"; |
|
123 |
||
124 |
val m_minus = [l_minus, r_minus]; |
|
125 |
||
126 |
Addsimps [l_zero, r_zero, l_neg, r_neg, minus_minus, minus0, |
|
11093 | 127 |
l_one, r_one, l_null, r_null]; |
7998 | 128 |
|
129 |
(* further rules *) |
|
130 |
||
11093 | 131 |
Goal "!!a::'a::ring. -a = 0 ==> a = 0"; |
7998 | 132 |
by (res_inst_tac [("t", "a")] (minus_minus RS subst) 1); |
133 |
by (Asm_simp_tac 1); |
|
134 |
qed "uminus_monom"; |
|
135 |
||
11093 | 136 |
Goal "!!a::'a::ring. a ~= 0 ==> -a ~= 0"; |
10198 | 137 |
by (blast_tac (claset() addIs [uminus_monom]) 1); |
7998 | 138 |
qed "uminus_monom_neq"; |
139 |
||
11093 | 140 |
Goal "!!a::'a::ring. a * b ~= 0 ==> a ~= 0"; |
10198 | 141 |
by Auto_tac; |
7998 | 142 |
qed "l_nullD"; |
143 |
||
11093 | 144 |
Goal "!!a::'a::ring. a * b ~= 0 ==> b ~= 0"; |
10198 | 145 |
by Auto_tac; |
7998 | 146 |
qed "r_nullD"; |
147 |
||
11093 | 148 |
(* reflection between a = b and a -- b = 0 *) |
7998 | 149 |
|
11093 | 150 |
Goal "!!a::'a::ring. a = b ==> a + (-b) = 0"; |
7998 | 151 |
by (Asm_simp_tac 1); |
152 |
qed "eq_imp_diff_zero"; |
|
153 |
||
11093 | 154 |
Goal "!!a::'a::ring. a + (-b) = 0 ==> a = b"; |
7998 | 155 |
by (res_inst_tac [("a", "-b")] a_rcancel 1); |
156 |
by (Asm_simp_tac 1); |
|
157 |
qed "diff_zero_imp_eq"; |
|
158 |
||
159 |
(* this could be a rewrite rule, but won't terminate |
|
160 |
==> make it a simproc? |
|
11093 | 161 |
Goal "!!a::'a::ring. (a = b) = (a -- b = 0)"; |
7998 | 162 |
*) |
163 |
||
164 |
(* Power *) |
|
165 |
||
166 |
Goal "!!a::'a::ring. a ^ 0 = <1>"; |
|
167 |
by (simp_tac (simpset() addsimps [power_ax]) 1); |
|
168 |
qed "power_0"; |
|
169 |
||
170 |
Goal "!!a::'a::ring. a ^ Suc n = a ^ n * a"; |
|
171 |
by (simp_tac (simpset() addsimps [power_ax]) 1); |
|
172 |
qed "power_Suc"; |
|
173 |
||
174 |
Addsimps [power_0, power_Suc]; |
|
175 |
||
176 |
Goal "<1> ^ n = (<1>::'a::ring)"; |
|
8707 | 177 |
by (induct_tac "n" 1); |
178 |
by Auto_tac; |
|
7998 | 179 |
qed "power_one"; |
180 |
||
11093 | 181 |
Goal "!!n. n ~= 0 ==> 0 ^ n = (0::'a::ring)"; |
7998 | 182 |
by (etac rev_mp 1); |
8707 | 183 |
by (induct_tac "n" 1); |
184 |
by Auto_tac; |
|
7998 | 185 |
qed "power_zero"; |
186 |
||
187 |
Addsimps [power_zero, power_one]; |
|
188 |
||
189 |
Goal "!! a::'a::ring. a ^ m * a ^ n = a ^ (m + n)"; |
|
8707 | 190 |
by (induct_tac "m" 1); |
7998 | 191 |
by (Simp_tac 1); |
192 |
by (asm_simp_tac (simpset() addsimps m_ac) 1); |
|
193 |
qed "power_mult"; |
|
194 |
||
195 |
(* Divisibility *) |
|
196 |
section "Divisibility"; |
|
197 |
||
11093 | 198 |
Goalw [dvd_def] "!! a::'a::ring. a dvd 0"; |
199 |
by (res_inst_tac [("x", "0")] exI 1); |
|
7998 | 200 |
by (Simp_tac 1); |
201 |
qed "dvd_zero_right"; |
|
202 |
||
11093 | 203 |
Goalw [dvd_def] "!! a::'a::ring. 0 dvd a ==> a = 0"; |
7998 | 204 |
by Auto_tac; |
205 |
qed "dvd_zero_left"; |
|
206 |
||
207 |
Goalw [dvd_def] "!! a::'a::ring. a dvd a"; |
|
208 |
by (res_inst_tac [("x", "<1>")] exI 1); |
|
209 |
by (Simp_tac 1); |
|
210 |
qed "dvd_refl_ring"; |
|
211 |
||
212 |
Goalw [dvd_def] "!! a::'a::ring. [| a dvd b; b dvd c |] ==> a dvd c"; |
|
213 |
by (Step_tac 1); |
|
214 |
by (res_inst_tac [("x", "k * ka")] exI 1); |
|
215 |
by (simp_tac (simpset() addsimps m_ac) 1); |
|
216 |
qed "dvd_trans_ring"; |
|
217 |
||
218 |
Addsimps [dvd_zero_right, dvd_refl_ring]; |
|
219 |
||
220 |
Goalw [dvd_def] |
|
221 |
"!!a::'a::ring. [| a dvd <1>; b dvd <1> |] ==> a * b dvd <1>"; |
|
222 |
by (Clarify_tac 1); |
|
223 |
by (res_inst_tac [("x", "k * ka")] exI 1); |
|
224 |
by (asm_full_simp_tac (simpset() addsimps m_ac) 1); |
|
225 |
qed "unit_mult"; |
|
226 |
||
227 |
Goal "!!a::'a::ring. a dvd <1> ==> a^n dvd <1>"; |
|
228 |
by (induct_tac "n" 1); |
|
229 |
by (Simp_tac 1); |
|
230 |
by (asm_simp_tac (simpset() addsimps [unit_mult]) 1); |
|
231 |
qed "unit_power"; |
|
232 |
||
233 |
Goalw [dvd_def] |
|
10789
260fa2c67e3e
Changed priority of dvd from 70 to 50 as befits a relation.
nipkow
parents:
10448
diff
changeset
|
234 |
"!! a::'a::ring. [| a dvd b; a dvd c |] ==> a dvd b + c"; |
7998 | 235 |
by (Clarify_tac 1); |
236 |
by (res_inst_tac [("x", "k + ka")] exI 1); |
|
237 |
by (simp_tac (simpset() addsimps [r_distr]) 1); |
|
238 |
qed "dvd_add_right"; |
|
239 |
||
240 |
Goalw [dvd_def] |
|
10789
260fa2c67e3e
Changed priority of dvd from 70 to 50 as befits a relation.
nipkow
parents:
10448
diff
changeset
|
241 |
"!! a::'a::ring. a dvd b ==> a dvd -b"; |
7998 | 242 |
by (Clarify_tac 1); |
243 |
by (res_inst_tac [("x", "-k")] exI 1); |
|
244 |
by (simp_tac (simpset() addsimps [r_minus]) 1); |
|
245 |
qed "dvd_uminus_right"; |
|
246 |
||
247 |
Goalw [dvd_def] |
|
10789
260fa2c67e3e
Changed priority of dvd from 70 to 50 as befits a relation.
nipkow
parents:
10448
diff
changeset
|
248 |
"!! a::'a::ring. a dvd b ==> a dvd c*b"; |
7998 | 249 |
by (Clarify_tac 1); |
250 |
by (res_inst_tac [("x", "c * k")] exI 1); |
|
251 |
by (simp_tac (simpset() addsimps m_ac) 1); |
|
252 |
qed "dvd_l_mult_right"; |
|
253 |
||
254 |
Goalw [dvd_def] |
|
10789
260fa2c67e3e
Changed priority of dvd from 70 to 50 as befits a relation.
nipkow
parents:
10448
diff
changeset
|
255 |
"!! a::'a::ring. a dvd b ==> a dvd b*c"; |
7998 | 256 |
by (Clarify_tac 1); |
257 |
by (res_inst_tac [("x", "k * c")] exI 1); |
|
258 |
by (simp_tac (simpset() addsimps m_ac) 1); |
|
259 |
qed "dvd_r_mult_right"; |
|
260 |
||
261 |
Addsimps [dvd_add_right, dvd_uminus_right, dvd_l_mult_right, dvd_r_mult_right]; |
|
262 |
||
263 |
(* Inverse of multiplication *) |
|
264 |
||
265 |
section "inverse"; |
|
266 |
||
267 |
Goal "!! a::'a::ring. [| a * x = <1>; a * y = <1> |] ==> x = y"; |
|
268 |
by (res_inst_tac [("a", "(a*y)*x"), ("b", "y*(a*x)")] box_equals 1); |
|
269 |
by (simp_tac (simpset() addsimps m_ac) 1); |
|
270 |
by Auto_tac; |
|
271 |
qed "inverse_unique"; |
|
272 |
||
10448 | 273 |
Goal "!! a::'a::ring. a dvd <1> ==> a * inverse a = <1>"; |
274 |
by (asm_full_simp_tac (simpset () addsimps [inverse_ax, dvd_def]) 1); |
|
7998 | 275 |
by (Clarify_tac 1); |
9970 | 276 |
by (rtac someI 1); |
7998 | 277 |
by (rtac sym 1); |
278 |
by (assume_tac 1); |
|
279 |
qed "r_inverse_ring"; |
|
280 |
||
281 |
Goal "!! a::'a::ring. a dvd <1> ==> inverse a * a= <1>"; |
|
282 |
by (asm_simp_tac (simpset() addsimps r_inverse_ring::m_ac) 1); |
|
283 |
qed "l_inverse_ring"; |
|
284 |
||
285 |
(* Integral domain *) |
|
286 |
||
287 |
section "Integral domains"; |
|
288 |
||
11093 | 289 |
Goal "0 ~= (<1>::'a::domain)"; |
290 |
by (rtac not_sym 1); |
|
291 |
by (rtac one_not_zero 1); |
|
292 |
qed "zero_not_one"; |
|
293 |
||
294 |
Goal "!! a::'a::domain. a dvd <1> ==> a ~= 0"; |
|
295 |
by (auto_tac (claset() addDs [dvd_zero_left], |
|
296 |
simpset() addsimps [one_not_zero] )); |
|
297 |
qed "unit_imp_nonzero"; |
|
298 |
||
299 |
Goal "[| a * b = 0; a ~= 0 |] ==> (b::'a::domain) = 0"; |
|
7998 | 300 |
by (dtac integral 1); |
301 |
by (Fast_tac 1); |
|
302 |
qed "r_integral"; |
|
303 |
||
11093 | 304 |
Goal "[| a * b = 0; b ~= 0 |] ==> (a::'a::domain) = 0"; |
7998 | 305 |
by (dtac integral 1); |
306 |
by (Fast_tac 1); |
|
307 |
qed "l_integral"; |
|
308 |
||
11093 | 309 |
Goal "!! a::'a::domain. [| a ~= 0; b ~= 0 |] ==> a * b ~= 0"; |
10230 | 310 |
by (blast_tac (claset() addIs [l_integral]) 1); |
7998 | 311 |
qed "not_integral"; |
312 |
||
11093 | 313 |
Addsimps [not_integral, one_not_zero, zero_not_one]; |
7998 | 314 |
|
11093 | 315 |
Goal "!! a::'a::domain. [| a * x = x; x ~= 0 |] ==> a = <1>"; |
7998 | 316 |
by (res_inst_tac [("a", "- <1>")] a_lcancel 1); |
317 |
by (Simp_tac 1); |
|
318 |
by (rtac l_integral 1); |
|
319 |
by (assume_tac 2); |
|
320 |
by (asm_simp_tac (simpset() addsimps [l_distr, l_minus]) 1); |
|
321 |
qed "l_one_integral"; |
|
322 |
||
11093 | 323 |
Goal "!! a::'a::domain. [| x * a = x; x ~= 0 |] ==> a = <1>"; |
7998 | 324 |
by (res_inst_tac [("a", "- <1>")] a_rcancel 1); |
325 |
by (Simp_tac 1); |
|
326 |
by (rtac r_integral 1); |
|
327 |
by (assume_tac 2); |
|
328 |
by (asm_simp_tac (simpset() addsimps [r_distr, r_minus]) 1); |
|
329 |
qed "r_one_integral"; |
|
330 |
||
331 |
(* cancellation laws for multiplication *) |
|
332 |
||
11093 | 333 |
Goal "!! a::'a::domain. [| a ~= 0; a * b = a * c |] ==> b = c"; |
7998 | 334 |
by (rtac diff_zero_imp_eq 1); |
335 |
by (dtac eq_imp_diff_zero 1); |
|
336 |
by (full_simp_tac (simpset() addsimps [r_minus RS sym, r_distr RS sym]) 1); |
|
337 |
by (fast_tac (claset() addIs [l_integral]) 1); |
|
338 |
qed "m_lcancel"; |
|
339 |
||
11093 | 340 |
Goal "!! a::'a::domain. [| a ~= 0; b * a = c * a |] ==> b = c"; |
7998 | 341 |
by (rtac m_lcancel 1); |
342 |
by (assume_tac 1); |
|
343 |
by (asm_full_simp_tac (simpset() addsimps m_ac) 1); |
|
344 |
qed "m_rcancel"; |
|
345 |
||
11093 | 346 |
Goal "!! a::'a::domain. a ~= 0 ==> (a * b = a * c) = (b = c)"; |
7998 | 347 |
by (auto_tac (claset() addDs [m_lcancel], simpset())); |
348 |
qed "m_lcancel_eq"; |
|
349 |
||
11093 | 350 |
Goal "!! a::'a::domain. a ~= 0 ==> (b * a = c * a) = (b = c)"; |
7998 | 351 |
by (asm_simp_tac (simpset() addsimps [m_lcancel_eq, m_comm]) 1); |
352 |
qed "m_rcancel_eq"; |
|
353 |
||
354 |
Addsimps [m_lcancel_eq, m_rcancel_eq]; |
|
355 |
||
356 |
(* Fields *) |
|
357 |
||
358 |
section "Fields"; |
|
359 |
||
11093 | 360 |
Goal "!! a::'a::field. (a dvd <1>) = (a ~= 0)"; |
361 |
by (auto_tac (claset() addDs [field_ax, dvd_zero_left], |
|
362 |
simpset() addsimps [field_one_not_zero])); |
|
7998 | 363 |
qed "field_unit"; |
364 |
||
365 |
Addsimps [field_unit]; |
|
366 |
||
11093 | 367 |
Goal "!! a::'a::field. a ~= 0 ==> a * inverse a = <1>"; |
7998 | 368 |
by (asm_full_simp_tac (simpset() addsimps [r_inverse_ring]) 1); |
369 |
qed "r_inverse"; |
|
370 |
||
11093 | 371 |
Goal "!! a::'a::field. a ~= 0 ==> inverse a * a= <1>"; |
7998 | 372 |
by (asm_full_simp_tac (simpset() addsimps [l_inverse_ring]) 1); |
373 |
qed "l_inverse"; |
|
374 |
||
375 |
Addsimps [l_inverse, r_inverse]; |
|
376 |
||
11093 | 377 |
(* fields are integral domains *) |
7998 | 378 |
|
11093 | 379 |
Goal "!! a::'a::field. a * b = 0 ==> a = 0 | b = 0"; |
7998 | 380 |
by (Step_tac 1); |
381 |
by (res_inst_tac [("a", "(a*b)*inverse b")] box_equals 1); |
|
382 |
by (rtac refl 3); |
|
383 |
by (simp_tac (simpset() addsimps m_ac) 2); |
|
384 |
by Auto_tac; |
|
385 |
qed "field_integral"; |
|
386 |
||
11093 | 387 |
(* fields are factorial domains *) |
388 |
||
7998 | 389 |
Goalw [prime_def, irred_def] "!! a::'a::field. irred a ==> prime a"; |
390 |
by (blast_tac (claset() addIs [field_ax]) 1); |
|
391 |
qed "field_fact_prime"; |