author | oheimb |
Tue, 04 Nov 1997 20:50:35 +0100 | |
changeset 4135 | 4830f1f5f6ea |
parent 4089 | 96fba19bcbe2 |
child 4158 | 47c7490c74fe |
permissions | -rw-r--r-- |
1465 | 1 |
(* Title: HOL/Arith.ML |
923 | 2 |
ID: $Id$ |
1465 | 3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
923 | 4 |
Copyright 1993 University of Cambridge |
5 |
||
6 |
Proofs about elementary arithmetic: addition, multiplication, etc. |
|
3234 | 7 |
Some from the Hoare example from Norbert Galm |
923 | 8 |
*) |
9 |
||
10 |
(*** Basic rewrite rules for the arithmetic operators ***) |
|
11 |
||
2099 | 12 |
goalw Arith.thy [pred_def] "pred 0 = 0"; |
3457 | 13 |
by (Simp_tac 1); |
2099 | 14 |
qed "pred_0"; |
15 |
||
16 |
goalw Arith.thy [pred_def] "pred(Suc n) = n"; |
|
3457 | 17 |
by (Simp_tac 1); |
2099 | 18 |
qed "pred_Suc"; |
19 |
||
2682
13cdbf95ed92
minor changes due to new primrec definitions for +,-,*
pusch
parents:
2498
diff
changeset
|
20 |
Addsimps [pred_0,pred_Suc]; |
1301 | 21 |
|
22 |
(** pred **) |
|
23 |
||
24 |
val prems = goal Arith.thy "n ~= 0 ==> Suc(pred n) = n"; |
|
1552 | 25 |
by (res_inst_tac [("n","n")] natE 1); |
26 |
by (cut_facts_tac prems 1); |
|
27 |
by (ALLGOALS Asm_full_simp_tac); |
|
1301 | 28 |
qed "Suc_pred"; |
29 |
Addsimps [Suc_pred]; |
|
923 | 30 |
|
3484
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
31 |
goal Arith.thy "pred(n) <= (n::nat)"; |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
32 |
by (res_inst_tac [("n","n")] natE 1); |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
33 |
by (ALLGOALS Asm_simp_tac); |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
34 |
qed "pred_le"; |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
35 |
AddIffs [pred_le]; |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
36 |
|
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
37 |
goalw Arith.thy [pred_def] "m<=n --> pred(m) <= pred(n)"; |
4089 | 38 |
by(simp_tac (simpset() addsplits [expand_nat_case]) 1); |
3484
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
39 |
qed_spec_mp "pred_le_mono"; |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
40 |
|
3896
ee8ebb74ec00
Various new lemmas. Improved conversion of equations to rewrite rules:
nipkow
parents:
3842
diff
changeset
|
41 |
goal Arith.thy "!!n. n ~= 0 ==> pred n < n"; |
ee8ebb74ec00
Various new lemmas. Improved conversion of equations to rewrite rules:
nipkow
parents:
3842
diff
changeset
|
42 |
by(exhaust_tac "n" 1); |
ee8ebb74ec00
Various new lemmas. Improved conversion of equations to rewrite rules:
nipkow
parents:
3842
diff
changeset
|
43 |
by(ALLGOALS Asm_full_simp_tac); |
ee8ebb74ec00
Various new lemmas. Improved conversion of equations to rewrite rules:
nipkow
parents:
3842
diff
changeset
|
44 |
qed "pred_less"; |
ee8ebb74ec00
Various new lemmas. Improved conversion of equations to rewrite rules:
nipkow
parents:
3842
diff
changeset
|
45 |
Addsimps [pred_less]; |
ee8ebb74ec00
Various new lemmas. Improved conversion of equations to rewrite rules:
nipkow
parents:
3842
diff
changeset
|
46 |
|
923 | 47 |
(** Difference **) |
48 |
||
2682
13cdbf95ed92
minor changes due to new primrec definitions for +,-,*
pusch
parents:
2498
diff
changeset
|
49 |
qed_goalw "diff_0_eq_0" Arith.thy [pred_def] |
923 | 50 |
"0 - n = 0" |
3339 | 51 |
(fn _ => [induct_tac "n" 1, ALLGOALS Asm_simp_tac]); |
923 | 52 |
|
53 |
(*Must simplify BEFORE the induction!! (Else we get a critical pair) |
|
54 |
Suc(m) - Suc(n) rewrites to pred(Suc(m) - n) *) |
|
2682
13cdbf95ed92
minor changes due to new primrec definitions for +,-,*
pusch
parents:
2498
diff
changeset
|
55 |
qed_goalw "diff_Suc_Suc" Arith.thy [pred_def] |
923 | 56 |
"Suc(m) - Suc(n) = m - n" |
57 |
(fn _ => |
|
3339 | 58 |
[Simp_tac 1, induct_tac "n" 1, ALLGOALS Asm_simp_tac]); |
923 | 59 |
|
2682
13cdbf95ed92
minor changes due to new primrec definitions for +,-,*
pusch
parents:
2498
diff
changeset
|
60 |
Addsimps [diff_0_eq_0, diff_Suc_Suc]; |
923 | 61 |
|
62 |
||
63 |
(**** Inductive properties of the operators ****) |
|
64 |
||
65 |
(*** Addition ***) |
|
66 |
||
67 |
qed_goal "add_0_right" Arith.thy "m + 0 = m" |
|
3339 | 68 |
(fn _ => [induct_tac "m" 1, ALLGOALS Asm_simp_tac]); |
923 | 69 |
|
70 |
qed_goal "add_Suc_right" Arith.thy "m + Suc(n) = Suc(m+n)" |
|
3339 | 71 |
(fn _ => [induct_tac "m" 1, ALLGOALS Asm_simp_tac]); |
923 | 72 |
|
1264
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
73 |
Addsimps [add_0_right,add_Suc_right]; |
923 | 74 |
|
75 |
(*Associative law for addition*) |
|
76 |
qed_goal "add_assoc" Arith.thy "(m + n) + k = m + ((n + k)::nat)" |
|
3339 | 77 |
(fn _ => [induct_tac "m" 1, ALLGOALS Asm_simp_tac]); |
923 | 78 |
|
79 |
(*Commutative law for addition*) |
|
80 |
qed_goal "add_commute" Arith.thy "m + n = n + (m::nat)" |
|
3339 | 81 |
(fn _ => [induct_tac "m" 1, ALLGOALS Asm_simp_tac]); |
923 | 82 |
|
83 |
qed_goal "add_left_commute" Arith.thy "x+(y+z)=y+((x+z)::nat)" |
|
84 |
(fn _ => [rtac (add_commute RS trans) 1, rtac (add_assoc RS trans) 1, |
|
85 |
rtac (add_commute RS arg_cong) 1]); |
|
86 |
||
87 |
(*Addition is an AC-operator*) |
|
88 |
val add_ac = [add_assoc, add_commute, add_left_commute]; |
|
89 |
||
90 |
goal Arith.thy "!!k::nat. (k + m = k + n) = (m=n)"; |
|
3339 | 91 |
by (induct_tac "k" 1); |
1264
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
92 |
by (Simp_tac 1); |
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
93 |
by (Asm_simp_tac 1); |
923 | 94 |
qed "add_left_cancel"; |
95 |
||
96 |
goal Arith.thy "!!k::nat. (m + k = n + k) = (m=n)"; |
|
3339 | 97 |
by (induct_tac "k" 1); |
1264
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
98 |
by (Simp_tac 1); |
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
99 |
by (Asm_simp_tac 1); |
923 | 100 |
qed "add_right_cancel"; |
101 |
||
102 |
goal Arith.thy "!!k::nat. (k + m <= k + n) = (m<=n)"; |
|
3339 | 103 |
by (induct_tac "k" 1); |
1264
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
104 |
by (Simp_tac 1); |
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
105 |
by (Asm_simp_tac 1); |
923 | 106 |
qed "add_left_cancel_le"; |
107 |
||
108 |
goal Arith.thy "!!k::nat. (k + m < k + n) = (m<n)"; |
|
3339 | 109 |
by (induct_tac "k" 1); |
1264
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
110 |
by (Simp_tac 1); |
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
111 |
by (Asm_simp_tac 1); |
923 | 112 |
qed "add_left_cancel_less"; |
113 |
||
1327
6c29cfab679c
added new arithmetic lemmas and the functions take and drop.
nipkow
parents:
1301
diff
changeset
|
114 |
Addsimps [add_left_cancel, add_right_cancel, |
6c29cfab679c
added new arithmetic lemmas and the functions take and drop.
nipkow
parents:
1301
diff
changeset
|
115 |
add_left_cancel_le, add_left_cancel_less]; |
6c29cfab679c
added new arithmetic lemmas and the functions take and drop.
nipkow
parents:
1301
diff
changeset
|
116 |
|
3339 | 117 |
(** Reasoning about m+0=0, etc. **) |
118 |
||
1327
6c29cfab679c
added new arithmetic lemmas and the functions take and drop.
nipkow
parents:
1301
diff
changeset
|
119 |
goal Arith.thy "(m+n = 0) = (m=0 & n=0)"; |
3339 | 120 |
by (induct_tac "m" 1); |
1327
6c29cfab679c
added new arithmetic lemmas and the functions take and drop.
nipkow
parents:
1301
diff
changeset
|
121 |
by (ALLGOALS Asm_simp_tac); |
6c29cfab679c
added new arithmetic lemmas and the functions take and drop.
nipkow
parents:
1301
diff
changeset
|
122 |
qed "add_is_0"; |
6c29cfab679c
added new arithmetic lemmas and the functions take and drop.
nipkow
parents:
1301
diff
changeset
|
123 |
Addsimps [add_is_0]; |
6c29cfab679c
added new arithmetic lemmas and the functions take and drop.
nipkow
parents:
1301
diff
changeset
|
124 |
|
3293 | 125 |
goal Arith.thy "(pred (m+n) = 0) = (m=0 & pred n = 0 | pred m = 0 & n=0)"; |
3339 | 126 |
by (induct_tac "m" 1); |
4089 | 127 |
by (ALLGOALS (fast_tac (claset() addss (simpset())))); |
3293 | 128 |
qed "pred_add_is_0"; |
129 |
Addsimps [pred_add_is_0]; |
|
130 |
||
1327
6c29cfab679c
added new arithmetic lemmas and the functions take and drop.
nipkow
parents:
1301
diff
changeset
|
131 |
goal Arith.thy "!!n. n ~= 0 ==> m + pred n = pred(m+n)"; |
3339 | 132 |
by (induct_tac "m" 1); |
1327
6c29cfab679c
added new arithmetic lemmas and the functions take and drop.
nipkow
parents:
1301
diff
changeset
|
133 |
by (ALLGOALS Asm_simp_tac); |
6c29cfab679c
added new arithmetic lemmas and the functions take and drop.
nipkow
parents:
1301
diff
changeset
|
134 |
qed "add_pred"; |
6c29cfab679c
added new arithmetic lemmas and the functions take and drop.
nipkow
parents:
1301
diff
changeset
|
135 |
Addsimps [add_pred]; |
6c29cfab679c
added new arithmetic lemmas and the functions take and drop.
nipkow
parents:
1301
diff
changeset
|
136 |
|
1626 | 137 |
|
923 | 138 |
(**** Additional theorems about "less than" ****) |
139 |
||
3339 | 140 |
goal Arith.thy "i<j --> (EX k. j = Suc(i+k))"; |
141 |
by (induct_tac "j" 1); |
|
1909 | 142 |
by (Simp_tac 1); |
4089 | 143 |
by (blast_tac (claset() addSEs [less_SucE] |
3339 | 144 |
addSIs [add_0_right RS sym, add_Suc_right RS sym]) 1); |
1909 | 145 |
val lemma = result(); |
146 |
||
3339 | 147 |
(* [| i<j; !!x. j = Suc(i+x) ==> Q |] ==> Q *) |
148 |
bind_thm ("less_natE", lemma RS mp RS exE); |
|
149 |
||
923 | 150 |
goal Arith.thy "!!m. m<n --> (? k. n=Suc(m+k))"; |
3339 | 151 |
by (induct_tac "n" 1); |
4089 | 152 |
by (ALLGOALS (simp_tac (simpset() addsimps [less_Suc_eq]))); |
153 |
by (blast_tac (claset() addSEs [less_SucE] |
|
3339 | 154 |
addSIs [add_0_right RS sym, add_Suc_right RS sym]) 1); |
1485
240cc98b94a7
Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents:
1475
diff
changeset
|
155 |
qed_spec_mp "less_eq_Suc_add"; |
923 | 156 |
|
157 |
goal Arith.thy "n <= ((m + n)::nat)"; |
|
3339 | 158 |
by (induct_tac "m" 1); |
1264
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
159 |
by (ALLGOALS Simp_tac); |
923 | 160 |
by (etac le_trans 1); |
161 |
by (rtac (lessI RS less_imp_le) 1); |
|
162 |
qed "le_add2"; |
|
163 |
||
164 |
goal Arith.thy "n <= ((n + m)::nat)"; |
|
4089 | 165 |
by (simp_tac (simpset() addsimps add_ac) 1); |
923 | 166 |
by (rtac le_add2 1); |
167 |
qed "le_add1"; |
|
168 |
||
169 |
bind_thm ("less_add_Suc1", (lessI RS (le_add1 RS le_less_trans))); |
|
170 |
bind_thm ("less_add_Suc2", (lessI RS (le_add2 RS le_less_trans))); |
|
171 |
||
172 |
(*"i <= j ==> i <= j+m"*) |
|
173 |
bind_thm ("trans_le_add1", le_add1 RSN (2,le_trans)); |
|
174 |
||
175 |
(*"i <= j ==> i <= m+j"*) |
|
176 |
bind_thm ("trans_le_add2", le_add2 RSN (2,le_trans)); |
|
177 |
||
178 |
(*"i < j ==> i < j+m"*) |
|
179 |
bind_thm ("trans_less_add1", le_add1 RSN (2,less_le_trans)); |
|
180 |
||
181 |
(*"i < j ==> i < m+j"*) |
|
182 |
bind_thm ("trans_less_add2", le_add2 RSN (2,less_le_trans)); |
|
183 |
||
1152 | 184 |
goal Arith.thy "!!i. i+j < (k::nat) ==> i<k"; |
1552 | 185 |
by (etac rev_mp 1); |
3339 | 186 |
by (induct_tac "j" 1); |
1264
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
187 |
by (ALLGOALS Asm_simp_tac); |
4089 | 188 |
by (blast_tac (claset() addDs [Suc_lessD]) 1); |
1152 | 189 |
qed "add_lessD1"; |
190 |
||
3234 | 191 |
goal Arith.thy "!!i::nat. ~ (i+j < i)"; |
3457 | 192 |
by (rtac notI 1); |
193 |
by (etac (add_lessD1 RS less_irrefl) 1); |
|
3234 | 194 |
qed "not_add_less1"; |
195 |
||
196 |
goal Arith.thy "!!i::nat. ~ (j+i < i)"; |
|
4089 | 197 |
by (simp_tac (simpset() addsimps [add_commute, not_add_less1]) 1); |
3234 | 198 |
qed "not_add_less2"; |
199 |
AddIffs [not_add_less1, not_add_less2]; |
|
200 |
||
923 | 201 |
goal Arith.thy "!!k::nat. m <= n ==> m <= n+k"; |
1552 | 202 |
by (etac le_trans 1); |
203 |
by (rtac le_add1 1); |
|
923 | 204 |
qed "le_imp_add_le"; |
205 |
||
206 |
goal Arith.thy "!!k::nat. m < n ==> m < n+k"; |
|
1552 | 207 |
by (etac less_le_trans 1); |
208 |
by (rtac le_add1 1); |
|
923 | 209 |
qed "less_imp_add_less"; |
210 |
||
211 |
goal Arith.thy "m+k<=n --> m<=(n::nat)"; |
|
3339 | 212 |
by (induct_tac "k" 1); |
1264
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
213 |
by (ALLGOALS Asm_simp_tac); |
4089 | 214 |
by (blast_tac (claset() addDs [Suc_leD]) 1); |
1485
240cc98b94a7
Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents:
1475
diff
changeset
|
215 |
qed_spec_mp "add_leD1"; |
923 | 216 |
|
2498 | 217 |
goal Arith.thy "!!n::nat. m+k<=n ==> k<=n"; |
4089 | 218 |
by (full_simp_tac (simpset() addsimps [add_commute]) 1); |
2498 | 219 |
by (etac add_leD1 1); |
220 |
qed_spec_mp "add_leD2"; |
|
221 |
||
222 |
goal Arith.thy "!!n::nat. m+k<=n ==> m<=n & k<=n"; |
|
4089 | 223 |
by (blast_tac (claset() addDs [add_leD1, add_leD2]) 1); |
2498 | 224 |
bind_thm ("add_leE", result() RS conjE); |
225 |
||
923 | 226 |
goal Arith.thy "!!k l::nat. [| k<l; m+l = k+n |] ==> m<n"; |
4089 | 227 |
by (safe_tac (claset() addSDs [less_eq_Suc_add])); |
923 | 228 |
by (asm_full_simp_tac |
4089 | 229 |
(simpset() delsimps [add_Suc_right] |
1264
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
230 |
addsimps ([add_Suc_right RS sym, add_left_cancel] @add_ac)) 1); |
1552 | 231 |
by (etac subst 1); |
4089 | 232 |
by (simp_tac (simpset() addsimps [less_add_Suc1]) 1); |
923 | 233 |
qed "less_add_eq_less"; |
234 |
||
235 |
||
1713 | 236 |
(*** Monotonicity of Addition ***) |
923 | 237 |
|
238 |
(*strict, in 1st argument*) |
|
239 |
goal Arith.thy "!!i j k::nat. i < j ==> i + k < j + k"; |
|
3339 | 240 |
by (induct_tac "k" 1); |
1264
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
241 |
by (ALLGOALS Asm_simp_tac); |
923 | 242 |
qed "add_less_mono1"; |
243 |
||
244 |
(*strict, in both arguments*) |
|
245 |
goal Arith.thy "!!i j k::nat. [|i < j; k < l|] ==> i + k < j + l"; |
|
246 |
by (rtac (add_less_mono1 RS less_trans) 1); |
|
1198 | 247 |
by (REPEAT (assume_tac 1)); |
3339 | 248 |
by (induct_tac "j" 1); |
1264
3eb91524b938
added local simpsets; removed IOA from 'make test'
clasohm
parents:
1198
diff
changeset
|
249 |
by (ALLGOALS Asm_simp_tac); |
923 | 250 |
qed "add_less_mono"; |
251 |
||
252 |
(*A [clumsy] way of lifting < monotonicity to <= monotonicity *) |
|
253 |
val [lt_mono,le] = goal Arith.thy |
|
1465 | 254 |
"[| !!i j::nat. i<j ==> f(i) < f(j); \ |
255 |
\ i <= j \ |
|
923 | 256 |
\ |] ==> f(i) <= (f(j)::nat)"; |
257 |
by (cut_facts_tac [le] 1); |
|
4089 | 258 |
by (asm_full_simp_tac (simpset() addsimps [le_eq_less_or_eq]) 1); |
259 |
by (blast_tac (claset() addSIs [lt_mono]) 1); |
|
923 | 260 |
qed "less_mono_imp_le_mono"; |
261 |
||
262 |
(*non-strict, in 1st argument*) |
|
263 |
goal Arith.thy "!!i j k::nat. i<=j ==> i + k <= j + k"; |
|
3842 | 264 |
by (res_inst_tac [("f", "%j. j+k")] less_mono_imp_le_mono 1); |
1552 | 265 |
by (etac add_less_mono1 1); |
923 | 266 |
by (assume_tac 1); |
267 |
qed "add_le_mono1"; |
|
268 |
||
269 |
(*non-strict, in both arguments*) |
|
270 |
goal Arith.thy "!!k l::nat. [|i<=j; k<=l |] ==> i + k <= j + l"; |
|
271 |
by (etac (add_le_mono1 RS le_trans) 1); |
|
4089 | 272 |
by (simp_tac (simpset() addsimps [add_commute]) 1); |
923 | 273 |
(*j moves to the end because it is free while k, l are bound*) |
1552 | 274 |
by (etac add_le_mono1 1); |
923 | 275 |
qed "add_le_mono"; |
1713 | 276 |
|
3234 | 277 |
|
278 |
(*** Multiplication ***) |
|
279 |
||
280 |
(*right annihilation in product*) |
|
281 |
qed_goal "mult_0_right" Arith.thy "m * 0 = 0" |
|
3339 | 282 |
(fn _ => [induct_tac "m" 1, ALLGOALS Asm_simp_tac]); |
3234 | 283 |
|
3293 | 284 |
(*right successor law for multiplication*) |
3234 | 285 |
qed_goal "mult_Suc_right" Arith.thy "m * Suc(n) = m + (m * n)" |
3339 | 286 |
(fn _ => [induct_tac "m" 1, |
4089 | 287 |
ALLGOALS(asm_simp_tac (simpset() addsimps add_ac))]); |
3234 | 288 |
|
3293 | 289 |
Addsimps [mult_0_right, mult_Suc_right]; |
3234 | 290 |
|
291 |
goal Arith.thy "1 * n = n"; |
|
292 |
by (Asm_simp_tac 1); |
|
293 |
qed "mult_1"; |
|
294 |
||
295 |
goal Arith.thy "n * 1 = n"; |
|
296 |
by (Asm_simp_tac 1); |
|
297 |
qed "mult_1_right"; |
|
298 |
||
299 |
(*Commutative law for multiplication*) |
|
300 |
qed_goal "mult_commute" Arith.thy "m * n = n * (m::nat)" |
|
3339 | 301 |
(fn _ => [induct_tac "m" 1, ALLGOALS Asm_simp_tac]); |
3234 | 302 |
|
303 |
(*addition distributes over multiplication*) |
|
304 |
qed_goal "add_mult_distrib" Arith.thy "(m + n)*k = (m*k) + ((n*k)::nat)" |
|
3339 | 305 |
(fn _ => [induct_tac "m" 1, |
4089 | 306 |
ALLGOALS(asm_simp_tac (simpset() addsimps add_ac))]); |
3234 | 307 |
|
308 |
qed_goal "add_mult_distrib2" Arith.thy "k*(m + n) = (k*m) + ((k*n)::nat)" |
|
3339 | 309 |
(fn _ => [induct_tac "m" 1, |
4089 | 310 |
ALLGOALS(asm_simp_tac (simpset() addsimps add_ac))]); |
3234 | 311 |
|
312 |
(*Associative law for multiplication*) |
|
313 |
qed_goal "mult_assoc" Arith.thy "(m * n) * k = m * ((n * k)::nat)" |
|
3339 | 314 |
(fn _ => [induct_tac "m" 1, |
4089 | 315 |
ALLGOALS (asm_simp_tac (simpset() addsimps [add_mult_distrib]))]); |
3234 | 316 |
|
317 |
qed_goal "mult_left_commute" Arith.thy "x*(y*z) = y*((x*z)::nat)" |
|
318 |
(fn _ => [rtac trans 1, rtac mult_commute 1, rtac trans 1, |
|
319 |
rtac mult_assoc 1, rtac (mult_commute RS arg_cong) 1]); |
|
320 |
||
321 |
val mult_ac = [mult_assoc,mult_commute,mult_left_commute]; |
|
322 |
||
3293 | 323 |
goal Arith.thy "(m*n = 0) = (m=0 | n=0)"; |
3339 | 324 |
by (induct_tac "m" 1); |
325 |
by (induct_tac "n" 2); |
|
3293 | 326 |
by (ALLGOALS Asm_simp_tac); |
327 |
qed "mult_is_0"; |
|
328 |
Addsimps [mult_is_0]; |
|
329 |
||
3234 | 330 |
|
331 |
(*** Difference ***) |
|
332 |
||
333 |
qed_goal "pred_Suc_diff" Arith.thy "pred(Suc m - n) = m - n" |
|
3339 | 334 |
(fn _ => [induct_tac "n" 1, ALLGOALS Asm_simp_tac]); |
3234 | 335 |
Addsimps [pred_Suc_diff]; |
336 |
||
337 |
qed_goal "diff_self_eq_0" Arith.thy "m - m = 0" |
|
3339 | 338 |
(fn _ => [induct_tac "m" 1, ALLGOALS Asm_simp_tac]); |
3234 | 339 |
Addsimps [diff_self_eq_0]; |
340 |
||
341 |
(*Addition is the inverse of subtraction: if n<=m then n+(m-n) = m. *) |
|
3381
2bac33ec2b0d
New theorems le_add_diff_inverse, le_add_diff_inverse2
paulson
parents:
3366
diff
changeset
|
342 |
goal Arith.thy "~ m<n --> n+(m-n) = (m::nat)"; |
3234 | 343 |
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); |
3352 | 344 |
by (ALLGOALS Asm_simp_tac); |
3381
2bac33ec2b0d
New theorems le_add_diff_inverse, le_add_diff_inverse2
paulson
parents:
3366
diff
changeset
|
345 |
qed_spec_mp "add_diff_inverse"; |
2bac33ec2b0d
New theorems le_add_diff_inverse, le_add_diff_inverse2
paulson
parents:
3366
diff
changeset
|
346 |
|
2bac33ec2b0d
New theorems le_add_diff_inverse, le_add_diff_inverse2
paulson
parents:
3366
diff
changeset
|
347 |
goal Arith.thy "!!m. n<=m ==> n+(m-n) = (m::nat)"; |
4089 | 348 |
by (asm_simp_tac (simpset() addsimps [add_diff_inverse, not_less_iff_le]) 1); |
3381
2bac33ec2b0d
New theorems le_add_diff_inverse, le_add_diff_inverse2
paulson
parents:
3366
diff
changeset
|
349 |
qed "le_add_diff_inverse"; |
3234 | 350 |
|
3381
2bac33ec2b0d
New theorems le_add_diff_inverse, le_add_diff_inverse2
paulson
parents:
3366
diff
changeset
|
351 |
goal Arith.thy "!!m. n<=m ==> (m-n)+n = (m::nat)"; |
4089 | 352 |
by (asm_simp_tac (simpset() addsimps [le_add_diff_inverse, add_commute]) 1); |
3381
2bac33ec2b0d
New theorems le_add_diff_inverse, le_add_diff_inverse2
paulson
parents:
3366
diff
changeset
|
353 |
qed "le_add_diff_inverse2"; |
2bac33ec2b0d
New theorems le_add_diff_inverse, le_add_diff_inverse2
paulson
parents:
3366
diff
changeset
|
354 |
|
2bac33ec2b0d
New theorems le_add_diff_inverse, le_add_diff_inverse2
paulson
parents:
3366
diff
changeset
|
355 |
Addsimps [le_add_diff_inverse, le_add_diff_inverse2]; |
3234 | 356 |
Delsimps [diff_Suc]; |
357 |
||
358 |
||
359 |
(*** More results about difference ***) |
|
360 |
||
3352 | 361 |
val [prem] = goal Arith.thy "n < Suc(m) ==> Suc(m)-n = Suc(m-n)"; |
362 |
by (rtac (prem RS rev_mp) 1); |
|
363 |
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); |
|
364 |
by (ALLGOALS Asm_simp_tac); |
|
365 |
qed "Suc_diff_n"; |
|
366 |
||
3234 | 367 |
goal Arith.thy "m - n < Suc(m)"; |
368 |
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); |
|
369 |
by (etac less_SucE 3); |
|
4089 | 370 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [less_Suc_eq]))); |
3234 | 371 |
qed "diff_less_Suc"; |
372 |
||
373 |
goal Arith.thy "!!m::nat. m - n <= m"; |
|
374 |
by (res_inst_tac [("m","m"), ("n","n")] diff_induct 1); |
|
375 |
by (ALLGOALS Asm_simp_tac); |
|
376 |
qed "diff_le_self"; |
|
3903
1b29151a1009
New simprule diff_le_self, requiring a new proof of diff_diff_cancel
paulson
parents:
3896
diff
changeset
|
377 |
Addsimps [diff_le_self]; |
3234 | 378 |
|
3352 | 379 |
goal Arith.thy "!!i::nat. i-j-k = i - (j+k)"; |
380 |
by (res_inst_tac [("m","i"),("n","j")] diff_induct 1); |
|
381 |
by (ALLGOALS Asm_simp_tac); |
|
382 |
qed "diff_diff_left"; |
|
383 |
||
3396 | 384 |
(*This and the next few suggested by Florian Kammueller*) |
3352 | 385 |
goal Arith.thy "!!i::nat. i-j-k = i-k-j"; |
4089 | 386 |
by (simp_tac (simpset() addsimps [diff_diff_left, add_commute]) 1); |
3352 | 387 |
qed "diff_commute"; |
388 |
||
389 |
goal Arith.thy "!!i j k:: nat. k<=j --> j<=i --> i - (j - k) = i - j + k"; |
|
390 |
by (res_inst_tac [("m","i"),("n","j")] diff_induct 1); |
|
391 |
by (ALLGOALS Asm_simp_tac); |
|
392 |
by (asm_simp_tac |
|
4089 | 393 |
(simpset() addsimps [Suc_diff_n, le_imp_less_Suc, le_Suc_eq]) 1); |
3352 | 394 |
qed_spec_mp "diff_diff_right"; |
395 |
||
396 |
goal Arith.thy "!!i j k:: nat. k<=j --> (i + j) - k = i + (j - k)"; |
|
397 |
by (res_inst_tac [("m","j"),("n","k")] diff_induct 1); |
|
398 |
by (ALLGOALS Asm_simp_tac); |
|
399 |
qed_spec_mp "diff_add_assoc"; |
|
400 |
||
3234 | 401 |
goal Arith.thy "!!n::nat. (n+m) - n = m"; |
3339 | 402 |
by (induct_tac "n" 1); |
3234 | 403 |
by (ALLGOALS Asm_simp_tac); |
404 |
qed "diff_add_inverse"; |
|
405 |
Addsimps [diff_add_inverse]; |
|
406 |
||
407 |
goal Arith.thy "!!n::nat.(m+n) - n = m"; |
|
4089 | 408 |
by (simp_tac (simpset() addsimps [diff_add_assoc]) 1); |
3234 | 409 |
qed "diff_add_inverse2"; |
410 |
Addsimps [diff_add_inverse2]; |
|
411 |
||
3366 | 412 |
goal Arith.thy "!!i j k::nat. i<=j ==> (j-i=k) = (j=k+i)"; |
3724 | 413 |
by Safe_tac; |
3381
2bac33ec2b0d
New theorems le_add_diff_inverse, le_add_diff_inverse2
paulson
parents:
3366
diff
changeset
|
414 |
by (ALLGOALS Asm_simp_tac); |
3366 | 415 |
qed "le_imp_diff_is_add"; |
416 |
||
3234 | 417 |
val [prem] = goal Arith.thy "m < Suc(n) ==> m-n = 0"; |
418 |
by (rtac (prem RS rev_mp) 1); |
|
419 |
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); |
|
4089 | 420 |
by (asm_simp_tac (simpset() addsimps [less_Suc_eq]) 1); |
3352 | 421 |
by (ALLGOALS Asm_simp_tac); |
3234 | 422 |
qed "less_imp_diff_is_0"; |
423 |
||
424 |
val prems = goal Arith.thy "m-n = 0 --> n-m = 0 --> m=n"; |
|
425 |
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); |
|
426 |
by (REPEAT(Simp_tac 1 THEN TRY(atac 1))); |
|
427 |
qed_spec_mp "diffs0_imp_equal"; |
|
428 |
||
429 |
val [prem] = goal Arith.thy "m<n ==> 0<n-m"; |
|
430 |
by (rtac (prem RS rev_mp) 1); |
|
431 |
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); |
|
3352 | 432 |
by (ALLGOALS Asm_simp_tac); |
3234 | 433 |
qed "less_imp_diff_positive"; |
434 |
||
435 |
goal Arith.thy "Suc(m)-n = (if m<n then 0 else Suc(m-n))"; |
|
4089 | 436 |
by (simp_tac (simpset() addsimps [less_imp_diff_is_0, not_less_eq, Suc_diff_n] |
3919 | 437 |
addsplits [expand_if]) 1); |
3234 | 438 |
qed "if_Suc_diff_n"; |
439 |
||
440 |
goal Arith.thy "P(k) --> (!n. P(Suc(n))--> P(n)) --> P(k-i)"; |
|
441 |
by (res_inst_tac [("m","k"),("n","i")] diff_induct 1); |
|
3718 | 442 |
by (ALLGOALS (Clarify_tac THEN' Simp_tac THEN' TRY o Blast_tac)); |
3234 | 443 |
qed "zero_induct_lemma"; |
444 |
||
445 |
val prems = goal Arith.thy "[| P(k); !!n. P(Suc(n)) ==> P(n) |] ==> P(0)"; |
|
446 |
by (rtac (diff_self_eq_0 RS subst) 1); |
|
447 |
by (rtac (zero_induct_lemma RS mp RS mp) 1); |
|
448 |
by (REPEAT (ares_tac ([impI,allI]@prems) 1)); |
|
449 |
qed "zero_induct"; |
|
450 |
||
451 |
goal Arith.thy "!!k::nat. (k+m) - (k+n) = m - n"; |
|
3339 | 452 |
by (induct_tac "k" 1); |
3234 | 453 |
by (ALLGOALS Asm_simp_tac); |
454 |
qed "diff_cancel"; |
|
455 |
Addsimps [diff_cancel]; |
|
456 |
||
457 |
goal Arith.thy "!!m::nat. (m+k) - (n+k) = m - n"; |
|
458 |
val add_commute_k = read_instantiate [("n","k")] add_commute; |
|
4089 | 459 |
by (asm_simp_tac (simpset() addsimps ([add_commute_k])) 1); |
3234 | 460 |
qed "diff_cancel2"; |
461 |
Addsimps [diff_cancel2]; |
|
462 |
||
463 |
(*From Clemens Ballarin*) |
|
464 |
goal Arith.thy "!!n::nat. [| k<=n; n<=m |] ==> (m-k) - (n-k) = m-n"; |
|
465 |
by (subgoal_tac "k<=n --> n<=m --> (m-k) - (n-k) = m-n" 1); |
|
466 |
by (Asm_full_simp_tac 1); |
|
3339 | 467 |
by (induct_tac "k" 1); |
3234 | 468 |
by (Simp_tac 1); |
469 |
(* Induction step *) |
|
470 |
by (subgoal_tac "Suc na <= m --> n <= m --> Suc na <= n --> \ |
|
471 |
\ Suc (m - Suc na) - Suc (n - Suc na) = m-n" 1); |
|
472 |
by (Asm_full_simp_tac 1); |
|
4089 | 473 |
by (blast_tac (claset() addIs [le_trans]) 1); |
474 |
by (auto_tac (claset() addIs [Suc_leD], simpset() delsimps [diff_Suc_Suc])); |
|
475 |
by (asm_full_simp_tac (simpset() delsimps [Suc_less_eq] |
|
3234 | 476 |
addsimps [Suc_diff_n RS sym, le_eq_less_Suc]) 1); |
477 |
qed "diff_right_cancel"; |
|
478 |
||
479 |
goal Arith.thy "!!n::nat. n - (n+m) = 0"; |
|
3339 | 480 |
by (induct_tac "n" 1); |
3234 | 481 |
by (ALLGOALS Asm_simp_tac); |
482 |
qed "diff_add_0"; |
|
483 |
Addsimps [diff_add_0]; |
|
484 |
||
485 |
(** Difference distributes over multiplication **) |
|
486 |
||
487 |
goal Arith.thy "!!m::nat. (m - n) * k = (m * k) - (n * k)"; |
|
488 |
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); |
|
489 |
by (ALLGOALS Asm_simp_tac); |
|
490 |
qed "diff_mult_distrib" ; |
|
491 |
||
492 |
goal Arith.thy "!!m::nat. k * (m - n) = (k * m) - (k * n)"; |
|
493 |
val mult_commute_k = read_instantiate [("m","k")] mult_commute; |
|
4089 | 494 |
by (simp_tac (simpset() addsimps [diff_mult_distrib, mult_commute_k]) 1); |
3234 | 495 |
qed "diff_mult_distrib2" ; |
496 |
(*NOT added as rewrites, since sometimes they are used from right-to-left*) |
|
497 |
||
498 |
||
1713 | 499 |
(*** Monotonicity of Multiplication ***) |
500 |
||
501 |
goal Arith.thy "!!i::nat. i<=j ==> i*k<=j*k"; |
|
3339 | 502 |
by (induct_tac "k" 1); |
4089 | 503 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [add_le_mono]))); |
1713 | 504 |
qed "mult_le_mono1"; |
505 |
||
506 |
(*<=monotonicity, BOTH arguments*) |
|
507 |
goal Arith.thy "!!i::nat. [| i<=j; k<=l |] ==> i*k<=j*l"; |
|
2007 | 508 |
by (etac (mult_le_mono1 RS le_trans) 1); |
1713 | 509 |
by (rtac le_trans 1); |
2007 | 510 |
by (stac mult_commute 2); |
511 |
by (etac mult_le_mono1 2); |
|
4089 | 512 |
by (simp_tac (simpset() addsimps [mult_commute]) 1); |
1713 | 513 |
qed "mult_le_mono"; |
514 |
||
515 |
(*strict, in 1st argument; proof is by induction on k>0*) |
|
516 |
goal Arith.thy "!!i::nat. [| i<j; 0<k |] ==> k*i < k*j"; |
|
3339 | 517 |
by (eres_inst_tac [("i","0")] less_natE 1); |
1713 | 518 |
by (Asm_simp_tac 1); |
3339 | 519 |
by (induct_tac "x" 1); |
4089 | 520 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [add_less_mono]))); |
1713 | 521 |
qed "mult_less_mono2"; |
522 |
||
3234 | 523 |
goal Arith.thy "!!i::nat. [| i<j; 0<k |] ==> i*k < j*k"; |
3457 | 524 |
by (dtac mult_less_mono2 1); |
4089 | 525 |
by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [mult_commute]))); |
3234 | 526 |
qed "mult_less_mono1"; |
527 |
||
1713 | 528 |
goal Arith.thy "(0 < m*n) = (0<m & 0<n)"; |
3339 | 529 |
by (induct_tac "m" 1); |
530 |
by (induct_tac "n" 2); |
|
1713 | 531 |
by (ALLGOALS Asm_simp_tac); |
532 |
qed "zero_less_mult_iff"; |
|
533 |
||
1795 | 534 |
goal Arith.thy "(m*n = 1) = (m=1 & n=1)"; |
3339 | 535 |
by (induct_tac "m" 1); |
1795 | 536 |
by (Simp_tac 1); |
3339 | 537 |
by (induct_tac "n" 1); |
1795 | 538 |
by (Simp_tac 1); |
4089 | 539 |
by (fast_tac (claset() addss simpset()) 1); |
1795 | 540 |
qed "mult_eq_1_iff"; |
541 |
||
3234 | 542 |
goal Arith.thy "!!k. 0<k ==> (m*k < n*k) = (m<n)"; |
4089 | 543 |
by (safe_tac (claset() addSIs [mult_less_mono1])); |
3234 | 544 |
by (cut_facts_tac [less_linear] 1); |
4089 | 545 |
by (blast_tac (claset() addDs [mult_less_mono1] addEs [less_asym]) 1); |
3234 | 546 |
qed "mult_less_cancel2"; |
547 |
||
548 |
goal Arith.thy "!!k. 0<k ==> (k*m < k*n) = (m<n)"; |
|
3457 | 549 |
by (dtac mult_less_cancel2 1); |
4089 | 550 |
by (asm_full_simp_tac (simpset() addsimps [mult_commute]) 1); |
3234 | 551 |
qed "mult_less_cancel1"; |
552 |
Addsimps [mult_less_cancel1, mult_less_cancel2]; |
|
553 |
||
554 |
goal Arith.thy "!!k. 0<k ==> (m*k = n*k) = (m=n)"; |
|
555 |
by (cut_facts_tac [less_linear] 1); |
|
3724 | 556 |
by Safe_tac; |
3457 | 557 |
by (assume_tac 2); |
3234 | 558 |
by (ALLGOALS (dtac mult_less_mono1 THEN' assume_tac)); |
559 |
by (ALLGOALS Asm_full_simp_tac); |
|
560 |
qed "mult_cancel2"; |
|
561 |
||
562 |
goal Arith.thy "!!k. 0<k ==> (k*m = k*n) = (m=n)"; |
|
3457 | 563 |
by (dtac mult_cancel2 1); |
4089 | 564 |
by (asm_full_simp_tac (simpset() addsimps [mult_commute]) 1); |
3234 | 565 |
qed "mult_cancel1"; |
566 |
Addsimps [mult_cancel1, mult_cancel2]; |
|
567 |
||
568 |
||
1795 | 569 |
(** Lemma for gcd **) |
570 |
||
571 |
goal Arith.thy "!!m n. m = m*n ==> n=1 | m=0"; |
|
572 |
by (dtac sym 1); |
|
573 |
by (rtac disjCI 1); |
|
574 |
by (rtac nat_less_cases 1 THEN assume_tac 2); |
|
4089 | 575 |
by (fast_tac (claset() addSEs [less_SucE] addss simpset()) 1); |
576 |
by (best_tac (claset() addDs [mult_less_mono2] |
|
577 |
addss (simpset() addsimps [zero_less_eq RS sym])) 1); |
|
1795 | 578 |
qed "mult_eq_self_implies_10"; |
579 |
||
580 |
||
3234 | 581 |
(*** Subtraction laws -- from Clemens Ballarin ***) |
582 |
||
583 |
goal Arith.thy "!! a b c::nat. [| a < b; c <= a |] ==> a-c < b-c"; |
|
584 |
by (subgoal_tac "c+(a-c) < c+(b-c)" 1); |
|
3381
2bac33ec2b0d
New theorems le_add_diff_inverse, le_add_diff_inverse2
paulson
parents:
3366
diff
changeset
|
585 |
by (Full_simp_tac 1); |
3234 | 586 |
by (subgoal_tac "c <= b" 1); |
4089 | 587 |
by (blast_tac (claset() addIs [less_imp_le, le_trans]) 2); |
3381
2bac33ec2b0d
New theorems le_add_diff_inverse, le_add_diff_inverse2
paulson
parents:
3366
diff
changeset
|
588 |
by (Asm_simp_tac 1); |
3234 | 589 |
qed "diff_less_mono"; |
590 |
||
591 |
goal Arith.thy "!! a b c::nat. a+b < c ==> a < c-b"; |
|
3457 | 592 |
by (dtac diff_less_mono 1); |
593 |
by (rtac le_add2 1); |
|
3234 | 594 |
by (Asm_full_simp_tac 1); |
595 |
qed "add_less_imp_less_diff"; |
|
596 |
||
597 |
goal Arith.thy "!! n. n <= m ==> Suc m - n = Suc (m - n)"; |
|
3457 | 598 |
by (rtac Suc_diff_n 1); |
4089 | 599 |
by (asm_full_simp_tac (simpset() addsimps [le_eq_less_Suc]) 1); |
3234 | 600 |
qed "Suc_diff_le"; |
601 |
||
602 |
goal Arith.thy "!! n. Suc i <= n ==> Suc (n - Suc i) = n - i"; |
|
603 |
by (asm_full_simp_tac |
|
4089 | 604 |
(simpset() addsimps [Suc_diff_n RS sym, le_eq_less_Suc]) 1); |
3234 | 605 |
qed "Suc_diff_Suc"; |
606 |
||
607 |
goal Arith.thy "!! i::nat. i <= n ==> n - (n - i) = i"; |
|
3903
1b29151a1009
New simprule diff_le_self, requiring a new proof of diff_diff_cancel
paulson
parents:
3896
diff
changeset
|
608 |
by (etac rev_mp 1); |
1b29151a1009
New simprule diff_le_self, requiring a new proof of diff_diff_cancel
paulson
parents:
3896
diff
changeset
|
609 |
by (res_inst_tac [("m","n"),("n","i")] diff_induct 1); |
4089 | 610 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [Suc_diff_le]))); |
3234 | 611 |
qed "diff_diff_cancel"; |
3381
2bac33ec2b0d
New theorems le_add_diff_inverse, le_add_diff_inverse2
paulson
parents:
3366
diff
changeset
|
612 |
Addsimps [diff_diff_cancel]; |
3234 | 613 |
|
614 |
goal Arith.thy "!!k::nat. k <= n ==> m <= n + m - k"; |
|
3457 | 615 |
by (etac rev_mp 1); |
3234 | 616 |
by (res_inst_tac [("m", "k"), ("n", "n")] diff_induct 1); |
617 |
by (Simp_tac 1); |
|
4089 | 618 |
by (simp_tac (simpset() addsimps [less_add_Suc2, less_imp_le]) 1); |
3234 | 619 |
by (Simp_tac 1); |
620 |
qed "le_add_diff"; |
|
621 |
||
622 |
||
3484
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
623 |
(** (Anti)Monotonicity of subtraction -- by Stefan Merz **) |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
624 |
|
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
625 |
(* Monotonicity of subtraction in first argument *) |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
626 |
goal Arith.thy "!!n::nat. m<=n --> (m-l) <= (n-l)"; |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
627 |
by (induct_tac "n" 1); |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
628 |
by (Simp_tac 1); |
4089 | 629 |
by (simp_tac (simpset() addsimps [le_Suc_eq]) 1); |
3484
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
630 |
by (rtac impI 1); |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
631 |
by (etac impE 1); |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
632 |
by (atac 1); |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
633 |
by (etac le_trans 1); |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
634 |
by (res_inst_tac [("m1","n")] (pred_Suc_diff RS subst) 1); |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
635 |
by (rtac pred_le 1); |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
636 |
qed_spec_mp "diff_le_mono"; |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
637 |
|
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
638 |
goal Arith.thy "!!n::nat. m<=n ==> (l-n) <= (l-m)"; |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
639 |
by (induct_tac "l" 1); |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
640 |
by (Simp_tac 1); |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
641 |
by (case_tac "n <= l" 1); |
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
642 |
by (subgoal_tac "m <= l" 1); |
4089 | 643 |
by (asm_simp_tac (simpset() addsimps [Suc_diff_le]) 1); |
644 |
by (fast_tac (claset() addEs [le_trans]) 1); |
|
3484
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
645 |
by (dtac not_leE 1); |
4089 | 646 |
by (asm_simp_tac (simpset() addsimps [if_Suc_diff_n]) 1); |
3484
1e93eb09ebb9
Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents:
3457
diff
changeset
|
647 |
qed_spec_mp "diff_le_mono2"; |