author | paulson |
Thu, 26 Sep 1996 15:49:54 +0200 | |
changeset 2034 | 5079fdf938dd |
parent 1677 | 99044cda4ef3 |
child 2469 | b50b8c0eec01 |
permissions | -rw-r--r-- |
1461 | 1 |
(* Title: ZF/ex/integ.ML |
0 | 2 |
ID: $Id$ |
1461 | 3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
0 | 4 |
Copyright 1993 University of Cambridge |
5 |
||
1614 | 6 |
The integers as equivalence classes over nat*nat. |
0 | 7 |
|
8 |
Could also prove... |
|
9 |
"znegative(z) ==> $# zmagnitude(z) = $~ z" |
|
10 |
"~ znegative(z) ==> $# zmagnitude(z) = z" |
|
11 |
$< is a linear ordering |
|
12 |
$+ and $* are monotonic wrt $< |
|
13 |
*) |
|
14 |
||
7
268f93ab3bc4
Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents:
0
diff
changeset
|
15 |
open Integ; |
0 | 16 |
|
17 |
(*** Proving that intrel is an equivalence relation ***) |
|
18 |
||
19 |
(*By luck, requires no typing premises for y1, y2,y3*) |
|
20 |
val eqa::eqb::prems = goal Arith.thy |
|
21 |
"[| x1 #+ y2 = x2 #+ y1; x2 #+ y3 = x3 #+ y2; \ |
|
22 |
\ x1: nat; x2: nat; x3: nat |] ==> x1 #+ y3 = x3 #+ y1"; |
|
23 |
by (res_inst_tac [("k","x2")] add_left_cancel 1); |
|
438 | 24 |
by (resolve_tac prems 2); |
25 |
by (rtac (add_left_commute RS trans) 1 THEN typechk_tac prems); |
|
2034 | 26 |
by (stac eqb 1); |
438 | 27 |
by (rtac (add_left_commute RS trans) 1 THEN typechk_tac prems); |
2034 | 28 |
by (stac eqa 1); |
438 | 29 |
by (rtac (add_left_commute) 1 THEN typechk_tac prems); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
30 |
qed "integ_trans_lemma"; |
0 | 31 |
|
32 |
(** Natural deduction for intrel **) |
|
33 |
||
438 | 34 |
goalw Integ.thy [intrel_def] |
35 |
"<<x1,y1>,<x2,y2>>: intrel <-> \ |
|
36 |
\ x1: nat & y1: nat & x2: nat & y2: nat & x1#+y2 = x2#+y1"; |
|
37 |
by (fast_tac ZF_cs 1); |
|
760 | 38 |
qed "intrel_iff"; |
438 | 39 |
|
40 |
goalw Integ.thy [intrel_def] |
|
41 |
"!!x1 x2. [| x1#+y2 = x2#+y1; x1: nat; y1: nat; x2: nat; y2: nat |] ==> \ |
|
42 |
\ <<x1,y1>,<x2,y2>>: intrel"; |
|
0 | 43 |
by (fast_tac (ZF_cs addIs prems) 1); |
760 | 44 |
qed "intrelI"; |
0 | 45 |
|
46 |
(*intrelE is hard to derive because fast_tac tries hyp_subst_tac so soon*) |
|
47 |
goalw Integ.thy [intrel_def] |
|
48 |
"p: intrel --> (EX x1 y1 x2 y2. \ |
|
49 |
\ p = <<x1,y1>,<x2,y2>> & x1#+y2 = x2#+y1 & \ |
|
50 |
\ x1: nat & y1: nat & x2: nat & y2: nat)"; |
|
51 |
by (fast_tac ZF_cs 1); |
|
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
52 |
qed "intrelE_lemma"; |
0 | 53 |
|
54 |
val [major,minor] = goal Integ.thy |
|
55 |
"[| p: intrel; \ |
|
56 |
\ !!x1 y1 x2 y2. [| p = <<x1,y1>,<x2,y2>>; x1#+y2 = x2#+y1; \ |
|
57 |
\ x1: nat; y1: nat; x2: nat; y2: nat |] ==> Q |] \ |
|
58 |
\ ==> Q"; |
|
59 |
by (cut_facts_tac [major RS (intrelE_lemma RS mp)] 1); |
|
60 |
by (REPEAT (eresolve_tac [asm_rl,exE,conjE,minor] 1)); |
|
760 | 61 |
qed "intrelE"; |
0 | 62 |
|
63 |
val intrel_cs = ZF_cs addSIs [intrelI] addSEs [intrelE]; |
|
64 |
||
438 | 65 |
goalw Integ.thy [equiv_def, refl_def, sym_def, trans_def] |
66 |
"equiv(nat*nat, intrel)"; |
|
67 |
by (fast_tac (intrel_cs addSEs [sym, integ_trans_lemma]) 1); |
|
760 | 68 |
qed "equiv_intrel"; |
0 | 69 |
|
70 |
||
7
268f93ab3bc4
Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents:
0
diff
changeset
|
71 |
val intrel_ss = |
438 | 72 |
arith_ss addsimps [equiv_intrel RS eq_equiv_class_iff, intrel_iff, |
1461 | 73 |
add_0_right, add_succ_right] |
438 | 74 |
addcongs [conj_cong]; |
0 | 75 |
|
438 | 76 |
val eq_intrelD = equiv_intrel RSN (2,eq_equiv_class); |
0 | 77 |
|
78 |
(** znat: the injection from nat to integ **) |
|
79 |
||
438 | 80 |
goalw Integ.thy [integ_def,quotient_def,znat_def] |
81 |
"!!m. m : nat ==> $#m : integ"; |
|
82 |
by (fast_tac (ZF_cs addSIs [nat_0I]) 1); |
|
760 | 83 |
qed "znat_type"; |
0 | 84 |
|
438 | 85 |
goalw Integ.thy [znat_def] |
86 |
"!!m n. [| $#m = $#n; n: nat |] ==> m=n"; |
|
87 |
by (dtac eq_intrelD 1); |
|
88 |
by (typechk_tac [nat_0I, SigmaI]); |
|
89 |
by (asm_full_simp_tac intrel_ss 1); |
|
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
90 |
qed "znat_inject"; |
0 | 91 |
|
92 |
||
93 |
(**** zminus: unary negation on integ ****) |
|
94 |
||
95 |
goalw Integ.thy [congruent_def] |
|
1614 | 96 |
"congruent(intrel, %<x,y>. intrel``{<y,x>})"; |
0 | 97 |
by (safe_tac intrel_cs); |
438 | 98 |
by (asm_full_simp_tac (intrel_ss addsimps add_ac) 1); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
99 |
qed "zminus_congruent"; |
0 | 100 |
|
101 |
(*Resolve th against the corresponding facts for zminus*) |
|
102 |
val zminus_ize = RSLIST [equiv_intrel, zminus_congruent]; |
|
103 |
||
438 | 104 |
goalw Integ.thy [integ_def,zminus_def] |
105 |
"!!z. z : integ ==> $~z : integ"; |
|
106 |
by (typechk_tac [split_type, SigmaI, zminus_ize UN_equiv_class_type, |
|
1461 | 107 |
quotientI]); |
760 | 108 |
qed "zminus_type"; |
0 | 109 |
|
438 | 110 |
goalw Integ.thy [integ_def,zminus_def] |
111 |
"!!z w. [| $~z = $~w; z: integ; w: integ |] ==> z=w"; |
|
112 |
by (etac (zminus_ize UN_equiv_class_inject) 1); |
|
113 |
by (safe_tac intrel_cs); |
|
114 |
(*The setloop is only needed because assumptions are in the wrong order!*) |
|
115 |
by (asm_full_simp_tac (intrel_ss addsimps add_ac |
|
1461 | 116 |
setloop dtac eq_intrelD) 1); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
117 |
qed "zminus_inject"; |
0 | 118 |
|
438 | 119 |
goalw Integ.thy [zminus_def] |
120 |
"!!x y.[| x: nat; y: nat |] ==> $~ (intrel``{<x,y>}) = intrel `` {<y,x>}"; |
|
121 |
by (asm_simp_tac (ZF_ss addsimps [zminus_ize UN_equiv_class, SigmaI]) 1); |
|
760 | 122 |
qed "zminus"; |
0 | 123 |
|
124 |
goalw Integ.thy [integ_def] "!!z. z : integ ==> $~ ($~ z) = z"; |
|
125 |
by (REPEAT (eresolve_tac [quotientE,SigmaE,ssubst] 1)); |
|
7
268f93ab3bc4
Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents:
0
diff
changeset
|
126 |
by (asm_simp_tac (ZF_ss addsimps [zminus]) 1); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
127 |
qed "zminus_zminus"; |
0 | 128 |
|
129 |
goalw Integ.thy [integ_def, znat_def] "$~ ($#0) = $#0"; |
|
7
268f93ab3bc4
Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents:
0
diff
changeset
|
130 |
by (simp_tac (arith_ss addsimps [zminus]) 1); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
131 |
qed "zminus_0"; |
0 | 132 |
|
133 |
||
134 |
(**** znegative: the test for negative integers ****) |
|
135 |
||
1021 | 136 |
(*No natural number is negative!*) |
438 | 137 |
goalw Integ.thy [znegative_def, znat_def] "~ znegative($# n)"; |
1021 | 138 |
by (safe_tac intrel_cs); |
139 |
by (dres_inst_tac [("psi", "?lhs=?rhs")] asm_rl 1); |
|
140 |
by (dres_inst_tac [("psi", "?lhs<?rhs")] asm_rl 1); |
|
141 |
by (fast_tac (FOL_cs addss |
|
1461 | 142 |
(intrel_ss addsimps [add_le_self2 RS le_imp_not_lt])) 1); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
143 |
qed "not_znegative_znat"; |
0 | 144 |
|
29
4ec9b266ccd1
Modification of examples for the new operators, < and le.
lcp
parents:
16
diff
changeset
|
145 |
goalw Integ.thy [znegative_def, znat_def] |
4ec9b266ccd1
Modification of examples for the new operators, < and le.
lcp
parents:
16
diff
changeset
|
146 |
"!!n. n: nat ==> znegative($~ $# succ(n))"; |
4ec9b266ccd1
Modification of examples for the new operators, < and le.
lcp
parents:
16
diff
changeset
|
147 |
by (asm_simp_tac (intrel_ss addsimps [zminus]) 1); |
0 | 148 |
by (REPEAT |
29
4ec9b266ccd1
Modification of examples for the new operators, < and le.
lcp
parents:
16
diff
changeset
|
149 |
(ares_tac [refl, exI, conjI, nat_0_le, |
1461 | 150 |
refl RS intrelI RS imageI, consI1, nat_0I, nat_succI] 1)); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
151 |
qed "znegative_zminus_znat"; |
0 | 152 |
|
153 |
||
154 |
(**** zmagnitude: magnitide of an integer, as a natural number ****) |
|
155 |
||
156 |
goalw Integ.thy [congruent_def] |
|
1614 | 157 |
"congruent(intrel, %<x,y>. (y#-x) #+ (x#-y))"; |
0 | 158 |
by (safe_tac intrel_cs); |
7
268f93ab3bc4
Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents:
0
diff
changeset
|
159 |
by (ALLGOALS (asm_simp_tac intrel_ss)); |
0 | 160 |
by (etac rev_mp 1); |
438 | 161 |
by (res_inst_tac [("m","x1"),("n","y1")] diff_induct 1 THEN |
162 |
REPEAT (assume_tac 1)); |
|
1614 | 163 |
by (asm_simp_tac intrel_ss 3); |
438 | 164 |
by (asm_simp_tac (*this one's very sensitive to order of rewrites*) |
1614 | 165 |
(arith_ss0 addsimps [diff_add_inverse,diff_add_0,add_0_right]) 2); |
438 | 166 |
by (asm_simp_tac intrel_ss 1); |
0 | 167 |
by (rtac impI 1); |
168 |
by (etac subst 1); |
|
438 | 169 |
by (res_inst_tac [("m1","x")] (add_commute RS ssubst) 1 THEN |
170 |
REPEAT (assume_tac 1)); |
|
171 |
by (asm_simp_tac (arith_ss addsimps [diff_add_inverse, diff_add_0]) 1); |
|
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
172 |
qed "zmagnitude_congruent"; |
0 | 173 |
|
438 | 174 |
|
0 | 175 |
(*Resolve th against the corresponding facts for zmagnitude*) |
176 |
val zmagnitude_ize = RSLIST [equiv_intrel, zmagnitude_congruent]; |
|
177 |
||
438 | 178 |
goalw Integ.thy [integ_def,zmagnitude_def] |
179 |
"!!z. z : integ ==> zmagnitude(z) : nat"; |
|
180 |
by (typechk_tac [split_type, zmagnitude_ize UN_equiv_class_type, |
|
1461 | 181 |
add_type, diff_type]); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
182 |
qed "zmagnitude_type"; |
0 | 183 |
|
438 | 184 |
goalw Integ.thy [zmagnitude_def] |
185 |
"!!x y. [| x: nat; y: nat |] ==> \ |
|
186 |
\ zmagnitude (intrel``{<x,y>}) = (y #- x) #+ (x #- y)"; |
|
187 |
by (asm_simp_tac (ZF_ss addsimps [zmagnitude_ize UN_equiv_class, SigmaI]) 1); |
|
760 | 188 |
qed "zmagnitude"; |
0 | 189 |
|
29
4ec9b266ccd1
Modification of examples for the new operators, < and le.
lcp
parents:
16
diff
changeset
|
190 |
goalw Integ.thy [znat_def] |
4ec9b266ccd1
Modification of examples for the new operators, < and le.
lcp
parents:
16
diff
changeset
|
191 |
"!!n. n: nat ==> zmagnitude($# n) = n"; |
4ec9b266ccd1
Modification of examples for the new operators, < and le.
lcp
parents:
16
diff
changeset
|
192 |
by (asm_simp_tac (intrel_ss addsimps [zmagnitude]) 1); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
193 |
qed "zmagnitude_znat"; |
0 | 194 |
|
29
4ec9b266ccd1
Modification of examples for the new operators, < and le.
lcp
parents:
16
diff
changeset
|
195 |
goalw Integ.thy [znat_def] |
4ec9b266ccd1
Modification of examples for the new operators, < and le.
lcp
parents:
16
diff
changeset
|
196 |
"!!n. n: nat ==> zmagnitude($~ $# n) = n"; |
438 | 197 |
by (asm_simp_tac (intrel_ss addsimps [zmagnitude, zminus]) 1); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
198 |
qed "zmagnitude_zminus_znat"; |
0 | 199 |
|
200 |
||
201 |
(**** zadd: addition on integ ****) |
|
202 |
||
203 |
(** Congruence property for addition **) |
|
204 |
||
205 |
goalw Integ.thy [congruent2_def] |
|
1461 | 206 |
"congruent2(intrel, %z1 z2. \ |
1110
756aa2e81f6e
Changed some definitions and proofs to use pattern-matching.
lcp
parents:
1021
diff
changeset
|
207 |
\ let <x1,y1>=z1; <x2,y2>=z2 \ |
756aa2e81f6e
Changed some definitions and proofs to use pattern-matching.
lcp
parents:
1021
diff
changeset
|
208 |
\ in intrel``{<x1#+x2, y1#+y2>})"; |
0 | 209 |
(*Proof via congruent2_commuteI seems longer*) |
210 |
by (safe_tac intrel_cs); |
|
1110
756aa2e81f6e
Changed some definitions and proofs to use pattern-matching.
lcp
parents:
1021
diff
changeset
|
211 |
by (asm_simp_tac (intrel_ss addsimps [add_assoc, Let_def]) 1); |
438 | 212 |
(*The rest should be trivial, but rearranging terms is hard; |
213 |
add_ac does not help rewriting with the assumptions.*) |
|
214 |
by (res_inst_tac [("m1","x1a")] (add_left_commute RS ssubst) 1); |
|
215 |
by (res_inst_tac [("m1","x2a")] (add_left_commute RS ssubst) 3); |
|
0 | 216 |
by (typechk_tac [add_type]); |
7
268f93ab3bc4
Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents:
0
diff
changeset
|
217 |
by (asm_simp_tac (arith_ss addsimps [add_assoc RS sym]) 1); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
218 |
qed "zadd_congruent2"; |
0 | 219 |
|
220 |
(*Resolve th against the corresponding facts for zadd*) |
|
221 |
val zadd_ize = RSLIST [equiv_intrel, zadd_congruent2]; |
|
222 |
||
438 | 223 |
goalw Integ.thy [integ_def,zadd_def] |
224 |
"!!z w. [| z: integ; w: integ |] ==> z $+ w : integ"; |
|
1110
756aa2e81f6e
Changed some definitions and proofs to use pattern-matching.
lcp
parents:
1021
diff
changeset
|
225 |
by (rtac (zadd_ize UN_equiv_class_type2) 1); |
756aa2e81f6e
Changed some definitions and proofs to use pattern-matching.
lcp
parents:
1021
diff
changeset
|
226 |
by (simp_tac (ZF_ss addsimps [Let_def]) 3); |
756aa2e81f6e
Changed some definitions and proofs to use pattern-matching.
lcp
parents:
1021
diff
changeset
|
227 |
by (REPEAT (ares_tac [split_type, add_type, quotientI, SigmaI] 1)); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
228 |
qed "zadd_type"; |
0 | 229 |
|
438 | 230 |
goalw Integ.thy [zadd_def] |
1461 | 231 |
"!!x1 y1. [| x1: nat; y1: nat; x2: nat; y2: nat |] ==> \ |
232 |
\ (intrel``{<x1,y1>}) $+ (intrel``{<x2,y2>}) = \ |
|
233 |
\ intrel `` {<x1#+x2, y1#+y2>}"; |
|
438 | 234 |
by (asm_simp_tac (ZF_ss addsimps [zadd_ize UN_equiv_class2, SigmaI]) 1); |
1110
756aa2e81f6e
Changed some definitions and proofs to use pattern-matching.
lcp
parents:
1021
diff
changeset
|
235 |
by (simp_tac (ZF_ss addsimps [Let_def]) 1); |
760 | 236 |
qed "zadd"; |
0 | 237 |
|
238 |
goalw Integ.thy [integ_def,znat_def] "!!z. z : integ ==> $#0 $+ z = z"; |
|
438 | 239 |
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1)); |
7
268f93ab3bc4
Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents:
0
diff
changeset
|
240 |
by (asm_simp_tac (arith_ss addsimps [zadd]) 1); |
760 | 241 |
qed "zadd_0"; |
0 | 242 |
|
243 |
goalw Integ.thy [integ_def] |
|
244 |
"!!z w. [| z: integ; w: integ |] ==> $~ (z $+ w) = $~ z $+ $~ w"; |
|
438 | 245 |
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1)); |
7
268f93ab3bc4
Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents:
0
diff
changeset
|
246 |
by (asm_simp_tac (arith_ss addsimps [zminus,zadd]) 1); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
247 |
qed "zminus_zadd_distrib"; |
0 | 248 |
|
249 |
goalw Integ.thy [integ_def] |
|
250 |
"!!z w. [| z: integ; w: integ |] ==> z $+ w = w $+ z"; |
|
438 | 251 |
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1)); |
252 |
by (asm_simp_tac (intrel_ss addsimps (add_ac @ [zadd])) 1); |
|
760 | 253 |
qed "zadd_commute"; |
0 | 254 |
|
255 |
goalw Integ.thy [integ_def] |
|
256 |
"!!z1 z2 z3. [| z1: integ; z2: integ; z3: integ |] ==> \ |
|
257 |
\ (z1 $+ z2) $+ z3 = z1 $+ (z2 $+ z3)"; |
|
438 | 258 |
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1)); |
0 | 259 |
(*rewriting is much faster without intrel_iff, etc.*) |
438 | 260 |
by (asm_simp_tac (arith_ss addsimps [zadd, add_assoc]) 1); |
760 | 261 |
qed "zadd_assoc"; |
0 | 262 |
|
904
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
263 |
(*For AC rewriting*) |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
264 |
qed_goal "zadd_left_commute" Integ.thy |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
265 |
"!!z1 z2 z3. [| z1:integ; z2:integ; z3: integ |] ==> \ |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
266 |
\ z1$+(z2$+z3) = z2$+(z1$+z3)" |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
267 |
(fn _ => [asm_simp_tac (ZF_ss addsimps [zadd_assoc RS sym, zadd_commute]) 1]); |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
268 |
|
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
269 |
(*Integer addition is an AC operator*) |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
270 |
val zadd_ac = [zadd_assoc, zadd_commute, zadd_left_commute]; |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
271 |
|
438 | 272 |
goalw Integ.thy [znat_def] |
273 |
"!!m n. [| m: nat; n: nat |] ==> $# (m #+ n) = ($#m) $+ ($#n)"; |
|
274 |
by (asm_simp_tac (arith_ss addsimps [zadd]) 1); |
|
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
275 |
qed "znat_add"; |
0 | 276 |
|
277 |
goalw Integ.thy [integ_def,znat_def] "!!z. z : integ ==> z $+ ($~ z) = $#0"; |
|
438 | 278 |
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1)); |
279 |
by (asm_simp_tac (intrel_ss addsimps [zminus, zadd, add_commute]) 1); |
|
760 | 280 |
qed "zadd_zminus_inverse"; |
0 | 281 |
|
438 | 282 |
goal Integ.thy "!!z. z : integ ==> ($~ z) $+ z = $#0"; |
283 |
by (asm_simp_tac |
|
284 |
(ZF_ss addsimps [zadd_commute, zminus_type, zadd_zminus_inverse]) 1); |
|
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
285 |
qed "zadd_zminus_inverse2"; |
0 | 286 |
|
438 | 287 |
goal Integ.thy "!!z. z:integ ==> z $+ $#0 = z"; |
0 | 288 |
by (rtac (zadd_commute RS trans) 1); |
438 | 289 |
by (REPEAT (ares_tac [znat_type, nat_0I, zadd_0] 1)); |
760 | 290 |
qed "zadd_0_right"; |
0 | 291 |
|
292 |
||
293 |
(*Need properties of $- ??? Or use $- just as an abbreviation? |
|
294 |
[| m: nat; n: nat; m>=n |] ==> $# (m #- n) = ($#m) $- ($#n) |
|
295 |
*) |
|
296 |
||
297 |
(**** zmult: multiplication on integ ****) |
|
298 |
||
299 |
(** Congruence property for multiplication **) |
|
300 |
||
301 |
goal Integ.thy |
|
1461 | 302 |
"congruent2(intrel, %p1 p2. \ |
303 |
\ split(%x1 y1. split(%x2 y2. \ |
|
0 | 304 |
\ intrel``{<x1#*x2 #+ y1#*y2, x1#*y2 #+ y1#*x2>}, p2), p1))"; |
305 |
by (rtac (equiv_intrel RS congruent2_commuteI) 1); |
|
306 |
by (safe_tac intrel_cs); |
|
438 | 307 |
by (ALLGOALS (asm_simp_tac intrel_ss)); |
0 | 308 |
(*Proof that zmult is congruent in one argument*) |
438 | 309 |
by (asm_simp_tac |
310 |
(arith_ss addsimps (add_ac @ [add_mult_distrib_left RS sym])) 2); |
|
311 |
by (asm_simp_tac |
|
312 |
(arith_ss addsimps ([add_assoc RS sym, add_mult_distrib_left RS sym])) 2); |
|
0 | 313 |
(*Proof that zmult is commutative on representatives*) |
438 | 314 |
by (asm_simp_tac (arith_ss addsimps (mult_ac@add_ac)) 1); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
315 |
qed "zmult_congruent2"; |
0 | 316 |
|
438 | 317 |
|
0 | 318 |
(*Resolve th against the corresponding facts for zmult*) |
319 |
val zmult_ize = RSLIST [equiv_intrel, zmult_congruent2]; |
|
320 |
||
438 | 321 |
goalw Integ.thy [integ_def,zmult_def] |
322 |
"!!z w. [| z: integ; w: integ |] ==> z $* w : integ"; |
|
323 |
by (REPEAT (ares_tac [zmult_ize UN_equiv_class_type2, |
|
1461 | 324 |
split_type, add_type, mult_type, |
325 |
quotientI, SigmaI] 1)); |
|
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
326 |
qed "zmult_type"; |
0 | 327 |
|
438 | 328 |
goalw Integ.thy [zmult_def] |
1461 | 329 |
"!!x1 x2. [| x1: nat; y1: nat; x2: nat; y2: nat |] ==> \ |
330 |
\ (intrel``{<x1,y1>}) $* (intrel``{<x2,y2>}) = \ |
|
438 | 331 |
\ intrel `` {<x1#*x2 #+ y1#*y2, x1#*y2 #+ y1#*x2>}"; |
332 |
by (asm_simp_tac (ZF_ss addsimps [zmult_ize UN_equiv_class2, SigmaI]) 1); |
|
760 | 333 |
qed "zmult"; |
0 | 334 |
|
335 |
goalw Integ.thy [integ_def,znat_def] "!!z. z : integ ==> $#0 $* z = $#0"; |
|
438 | 336 |
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1)); |
7
268f93ab3bc4
Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents:
0
diff
changeset
|
337 |
by (asm_simp_tac (arith_ss addsimps [zmult]) 1); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
338 |
qed "zmult_0"; |
0 | 339 |
|
16
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
7
diff
changeset
|
340 |
goalw Integ.thy [integ_def,znat_def] |
0 | 341 |
"!!z. z : integ ==> $#1 $* z = z"; |
438 | 342 |
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1)); |
343 |
by (asm_simp_tac (arith_ss addsimps [zmult, add_0_right]) 1); |
|
760 | 344 |
qed "zmult_1"; |
0 | 345 |
|
346 |
goalw Integ.thy [integ_def] |
|
347 |
"!!z w. [| z: integ; w: integ |] ==> ($~ z) $* w = $~ (z $* w)"; |
|
438 | 348 |
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1)); |
349 |
by (asm_simp_tac (intrel_ss addsimps ([zminus, zmult] @ add_ac)) 1); |
|
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
350 |
qed "zmult_zminus"; |
0 | 351 |
|
352 |
goalw Integ.thy [integ_def] |
|
353 |
"!!z w. [| z: integ; w: integ |] ==> ($~ z) $* ($~ w) = (z $* w)"; |
|
438 | 354 |
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1)); |
355 |
by (asm_simp_tac (intrel_ss addsimps ([zminus, zmult] @ add_ac)) 1); |
|
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
356 |
qed "zmult_zminus_zminus"; |
0 | 357 |
|
358 |
goalw Integ.thy [integ_def] |
|
359 |
"!!z w. [| z: integ; w: integ |] ==> z $* w = w $* z"; |
|
438 | 360 |
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1)); |
361 |
by (asm_simp_tac (intrel_ss addsimps ([zmult] @ add_ac @ mult_ac)) 1); |
|
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
362 |
qed "zmult_commute"; |
0 | 363 |
|
364 |
goalw Integ.thy [integ_def] |
|
365 |
"!!z1 z2 z3. [| z1: integ; z2: integ; z3: integ |] ==> \ |
|
366 |
\ (z1 $* z2) $* z3 = z1 $* (z2 $* z3)"; |
|
438 | 367 |
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1)); |
368 |
by (asm_simp_tac |
|
369 |
(intrel_ss addsimps ([zmult, add_mult_distrib_left, |
|
1461 | 370 |
add_mult_distrib] @ add_ac @ mult_ac)) 1); |
782
200a16083201
added bind_thm for theorems defined by "standard ..."
clasohm
parents:
760
diff
changeset
|
371 |
qed "zmult_assoc"; |
0 | 372 |
|
904
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
373 |
(*For AC rewriting*) |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
374 |
qed_goal "zmult_left_commute" Integ.thy |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
375 |
"!!z1 z2 z3. [| z1:integ; z2:integ; z3: integ |] ==> \ |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
376 |
\ z1$*(z2$*z3) = z2$*(z1$*z3)" |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
377 |
(fn _ => [asm_simp_tac (ZF_ss addsimps [zmult_assoc RS sym, |
1461 | 378 |
zmult_commute]) 1]); |
904
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
379 |
|
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
380 |
(*Integer multiplication is an AC operator*) |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
381 |
val zmult_ac = [zmult_assoc, zmult_commute, zmult_left_commute]; |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
382 |
|
0 | 383 |
goalw Integ.thy [integ_def] |
384 |
"!!z1 z2 z3. [| z1: integ; z2: integ; w: integ |] ==> \ |
|
385 |
\ (z1 $+ z2) $* w = (z1 $* w) $+ (z2 $* w)"; |
|
438 | 386 |
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1)); |
1677
99044cda4ef3
repaired critical proofs depending on the order inside non-confluent SimpSets,
oheimb
parents:
1614
diff
changeset
|
387 |
by (asm_simp_tac (intrel_ss addsimps [zadd, zmult, add_mult_distrib]) 1); |
99044cda4ef3
repaired critical proofs depending on the order inside non-confluent SimpSets,
oheimb
parents:
1614
diff
changeset
|
388 |
by (asm_simp_tac (intrel_ss addsimps (add_ac @ mult_ac)) 1); |
760 | 389 |
qed "zadd_zmult_distrib"; |
0 | 390 |
|
391 |
val integ_typechecks = |
|
392 |
[znat_type, zminus_type, zmagnitude_type, zadd_type, zmult_type]; |
|
393 |
||
904
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
394 |
val zadd_simps = |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
395 |
[zadd_0, zadd_0_right, zadd_zminus_inverse, zadd_zminus_inverse2]; |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
396 |
|
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
397 |
val zminus_simps = [zminus_zminus, zminus_0]; |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
398 |
|
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
399 |
val zmult_simps = [zmult_0, zmult_1, zmult_zminus]; |
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
400 |
|
0 | 401 |
val integ_ss = |
904
5240dcd12adb
Proved zadd_left_commute and zmult_left_commute to define
lcp
parents:
804
diff
changeset
|
402 |
arith_ss addsimps (zadd_simps @ zminus_simps @ zmult_simps @ |
1461 | 403 |
[zmagnitude_znat, zmagnitude_zminus_znat] @ |
404 |
integ_typechecks); |