author | paulson |
Sat, 29 Jun 2002 22:46:56 +0200 | |
changeset 13260 | ea36a40c004f |
parent 13094 | 643fce75f6cd |
child 13438 | 527811f00c56 |
permissions | -rw-r--r-- |
2441 | 1 |
(* Title: HOL/Nat.ML |
923 | 2 |
ID: $Id$ |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
3 |
Author: Lawrence C Paulson and Tobias Nipkow |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
4 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
5 |
Proofs about natural numbers and elementary arithmetic: addition, |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
6 |
multiplication, etc. Some from the Hoare example from Norbert Galm. |
923 | 7 |
*) |
8 |
||
5188
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
9 |
(** conversion rules for nat_rec **) |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
10 |
|
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
11 |
val [nat_rec_0, nat_rec_Suc] = nat.recs; |
9108 | 12 |
bind_thm ("nat_rec_0", nat_rec_0); |
13 |
bind_thm ("nat_rec_Suc", nat_rec_Suc); |
|
5188
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
14 |
|
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
15 |
(*These 2 rules ease the use of primitive recursion. NOTE USE OF == *) |
5316 | 16 |
val prems = Goal |
5188
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
17 |
"[| !!n. f(n) == nat_rec c h n |] ==> f(0) = c"; |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
18 |
by (simp_tac (simpset() addsimps prems) 1); |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
19 |
qed "def_nat_rec_0"; |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
20 |
|
5316 | 21 |
val prems = Goal |
5188
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
22 |
"[| !!n. f(n) == nat_rec c h n |] ==> f(Suc(n)) = h n (f n)"; |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
23 |
by (simp_tac (simpset() addsimps prems) 1); |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
24 |
qed "def_nat_rec_Suc"; |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
25 |
|
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
26 |
val [nat_case_0, nat_case_Suc] = nat.cases; |
9108 | 27 |
bind_thm ("nat_case_0", nat_case_0); |
28 |
bind_thm ("nat_case_Suc", nat_case_Suc); |
|
5188
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
29 |
|
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
30 |
Goal "n ~= 0 ==> EX m. n = Suc m"; |
8442
96023903c2df
case_tac now subsumes both boolean and datatype cases;
wenzelm
parents:
8423
diff
changeset
|
31 |
by (case_tac "n" 1); |
5188
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
32 |
by (REPEAT (Blast_tac 1)); |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
33 |
qed "not0_implies_Suc"; |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
34 |
|
8942
6aad5381ba83
added type constraint ::nat because 0 is now overloaded
paulson
parents:
8442
diff
changeset
|
35 |
Goal "!!n::nat. m<n ==> n ~= 0"; |
8442
96023903c2df
case_tac now subsumes both boolean and datatype cases;
wenzelm
parents:
8423
diff
changeset
|
36 |
by (case_tac "n" 1); |
5188
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
37 |
by (ALLGOALS Asm_full_simp_tac); |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
38 |
qed "gr_implies_not0"; |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
39 |
|
8942
6aad5381ba83
added type constraint ::nat because 0 is now overloaded
paulson
parents:
8442
diff
changeset
|
40 |
Goal "!!n::nat. (n ~= 0) = (0 < n)"; |
8442
96023903c2df
case_tac now subsumes both boolean and datatype cases;
wenzelm
parents:
8423
diff
changeset
|
41 |
by (case_tac "n" 1); |
7089 | 42 |
by Auto_tac; |
5188
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
43 |
qed "neq0_conv"; |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
44 |
AddIffs [neq0_conv]; |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
45 |
|
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
46 |
(*This theorem is useful with blast_tac: (n=0 ==> False) ==> 0<n *) |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
47 |
bind_thm ("gr0I", [neq0_conv, notI] MRS iffD1); |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
48 |
|
8115 | 49 |
Goal "(0<n) = (EX m. n = Suc m)"; |
12486 | 50 |
by (fast_tac (claset() addIs [not0_implies_Suc]) 1); |
8115 | 51 |
qed "gr0_conv_Suc"; |
52 |
||
8942
6aad5381ba83
added type constraint ::nat because 0 is now overloaded
paulson
parents:
8442
diff
changeset
|
53 |
Goal "!!n::nat. (~(0 < n)) = (n=0)"; |
5188
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
54 |
by (rtac iffI 1); |
10173 | 55 |
by (rtac ccontr 1); |
5188
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
56 |
by (ALLGOALS Asm_full_simp_tac); |
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
57 |
qed "not_gr0"; |
6109 | 58 |
AddIffs [not_gr0]; |
5188
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
59 |
|
8260 | 60 |
Goal "(Suc n <= m') --> (? m. m' = Suc m)"; |
61 |
by (induct_tac "m'" 1); |
|
62 |
by Auto_tac; |
|
63 |
qed_spec_mp "Suc_le_D"; |
|
64 |
||
6805 | 65 |
(*Useful in certain inductive arguments*) |
66 |
Goal "(m < Suc n) = (m=0 | (EX j. m = Suc j & j < n))"; |
|
8442
96023903c2df
case_tac now subsumes both boolean and datatype cases;
wenzelm
parents:
8423
diff
changeset
|
67 |
by (case_tac "m" 1); |
6805 | 68 |
by Auto_tac; |
69 |
qed "less_Suc_eq_0_disj"; |
|
70 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11464
diff
changeset
|
71 |
val prems = Goal "[| P 0; P(Suc 0); !!k. P k ==> P (Suc (Suc k)) |] ==> P n"; |
9870 | 72 |
by (rtac nat_less_induct 1); |
8442
96023903c2df
case_tac now subsumes both boolean and datatype cases;
wenzelm
parents:
8423
diff
changeset
|
73 |
by (case_tac "n" 1); |
96023903c2df
case_tac now subsumes both boolean and datatype cases;
wenzelm
parents:
8423
diff
changeset
|
74 |
by (case_tac "nat" 2); |
7089 | 75 |
by (ALLGOALS (blast_tac (claset() addIs prems@[less_trans]))); |
7058 | 76 |
qed "nat_induct2"; |
5188
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
5069
diff
changeset
|
77 |
|
10850
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
78 |
(** LEAST theorems for type "nat" by specialization **) |
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
79 |
|
11139
b092ad5cd510
moved wellorder_LeastI,wellorder_Least_le,wellorder_not_less_Least
oheimb
parents:
10850
diff
changeset
|
80 |
bind_thm("LeastI", wellorder_LeastI); |
b092ad5cd510
moved wellorder_LeastI,wellorder_Least_le,wellorder_not_less_Least
oheimb
parents:
10850
diff
changeset
|
81 |
bind_thm("Least_le", wellorder_Least_le); |
b092ad5cd510
moved wellorder_LeastI,wellorder_Least_le,wellorder_not_less_Least
oheimb
parents:
10850
diff
changeset
|
82 |
bind_thm("not_less_Least", wellorder_not_less_Least); |
10850
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
83 |
|
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
84 |
Goal "[| P n; ~ P 0 |] ==> (LEAST n. P n) = Suc (LEAST m. P(Suc m))"; |
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
85 |
by (case_tac "n" 1); |
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
86 |
by Auto_tac; |
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
87 |
by (ftac LeastI 1); |
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
88 |
by (dres_inst_tac [("P","%x. P (Suc x)")] LeastI 1); |
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
89 |
by (subgoal_tac "(LEAST x. P x) <= Suc (LEAST x. P (Suc x))" 1); |
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
90 |
by (etac Least_le 2); |
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
91 |
by (case_tac "LEAST x. P x" 1); |
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
92 |
by Auto_tac; |
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
93 |
by (dres_inst_tac [("P","%x. P (Suc x)")] Least_le 1); |
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
94 |
by (blast_tac (claset() addIs [order_antisym]) 1); |
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
95 |
qed "Least_Suc"; |
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
96 |
|
11337 | 97 |
Goal "[|P n; Q m; ~P 0; !k. P (Suc k) = Q k|] ==> Least P = Suc (Least Q)"; |
98 |
by (eatac (Least_Suc RS ssubst) 1 1); |
|
99 |
by (Asm_simp_tac 1); |
|
100 |
qed "Least_Suc2"; |
|
101 |
||
10850
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
102 |
|
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
103 |
(** min and max **) |
e1a793957a8f
generalizing the LEAST theorems from "nat" to linear
paulson
parents:
10710
diff
changeset
|
104 |
|
8942
6aad5381ba83
added type constraint ::nat because 0 is now overloaded
paulson
parents:
8442
diff
changeset
|
105 |
Goal "min 0 n = (0::nat)"; |
3023 | 106 |
by (rtac min_leastL 1); |
5983 | 107 |
by (Simp_tac 1); |
2608 | 108 |
qed "min_0L"; |
1301 | 109 |
|
8942
6aad5381ba83
added type constraint ::nat because 0 is now overloaded
paulson
parents:
8442
diff
changeset
|
110 |
Goal "min n 0 = (0::nat)"; |
3023 | 111 |
by (rtac min_leastR 1); |
5983 | 112 |
by (Simp_tac 1); |
2608 | 113 |
qed "min_0R"; |
923 | 114 |
|
11139
b092ad5cd510
moved wellorder_LeastI,wellorder_Least_le,wellorder_not_less_Least
oheimb
parents:
10850
diff
changeset
|
115 |
Goal "min (Suc m) (Suc n) = Suc (min m n)"; |
b092ad5cd510
moved wellorder_LeastI,wellorder_Least_le,wellorder_not_less_Least
oheimb
parents:
10850
diff
changeset
|
116 |
by (simp_tac (simpset() addsimps [min_of_mono]) 1); |
2608 | 117 |
qed "min_Suc_Suc"; |
1660 | 118 |
|
2608 | 119 |
Addsimps [min_0L,min_0R,min_Suc_Suc]; |
6433 | 120 |
|
11139
b092ad5cd510
moved wellorder_LeastI,wellorder_Least_le,wellorder_not_less_Least
oheimb
parents:
10850
diff
changeset
|
121 |
Goal "max 0 n = (n::nat)"; |
b092ad5cd510
moved wellorder_LeastI,wellorder_Least_le,wellorder_not_less_Least
oheimb
parents:
10850
diff
changeset
|
122 |
by (rtac max_leastL 1); |
6433 | 123 |
by (Simp_tac 1); |
124 |
qed "max_0L"; |
|
125 |
||
11139
b092ad5cd510
moved wellorder_LeastI,wellorder_Least_le,wellorder_not_less_Least
oheimb
parents:
10850
diff
changeset
|
126 |
Goal "max n 0 = (n::nat)"; |
b092ad5cd510
moved wellorder_LeastI,wellorder_Least_le,wellorder_not_less_Least
oheimb
parents:
10850
diff
changeset
|
127 |
by (rtac max_leastR 1); |
6433 | 128 |
by (Simp_tac 1); |
129 |
qed "max_0R"; |
|
130 |
||
11139
b092ad5cd510
moved wellorder_LeastI,wellorder_Least_le,wellorder_not_less_Least
oheimb
parents:
10850
diff
changeset
|
131 |
Goal "max (Suc m) (Suc n) = Suc(max m n)"; |
b092ad5cd510
moved wellorder_LeastI,wellorder_Least_le,wellorder_not_less_Least
oheimb
parents:
10850
diff
changeset
|
132 |
by (simp_tac (simpset() addsimps [max_of_mono]) 1); |
6433 | 133 |
qed "max_Suc_Suc"; |
134 |
||
135 |
Addsimps [max_0L,max_0R,max_Suc_Suc]; |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
136 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
137 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
138 |
(*** Basic rewrite rules for the arithmetic operators ***) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
139 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
140 |
(** Difference **) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
141 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
142 |
Goal "0 - n = (0::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
143 |
by (induct_tac "n" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
144 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
145 |
qed "diff_0_eq_0"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
146 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
147 |
(*Must simplify BEFORE the induction! (Else we get a critical pair) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
148 |
Suc(m) - Suc(n) rewrites to pred(Suc(m) - n) *) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
149 |
Goal "Suc(m) - Suc(n) = m - n"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
150 |
by (Simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
151 |
by (induct_tac "n" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
152 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
153 |
qed "diff_Suc_Suc"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
154 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
155 |
Addsimps [diff_0_eq_0, diff_Suc_Suc]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
156 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
157 |
(* Could be (and is, below) generalized in various ways; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
158 |
However, none of the generalizations are currently in the simpset, |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
159 |
and I dread to think what happens if I put them in *) |
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11464
diff
changeset
|
160 |
Goal "0 < n ==> Suc(n - Suc 0) = n"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
161 |
by (asm_simp_tac (simpset() addsplits [nat.split]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
162 |
qed "Suc_pred"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
163 |
Addsimps [Suc_pred]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
164 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
165 |
Delsimps [diff_Suc]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
166 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
167 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
168 |
(**** Inductive properties of the operators ****) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
169 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
170 |
(*** Addition ***) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
171 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
172 |
Goal "m + 0 = (m::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
173 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
174 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
175 |
qed "add_0_right"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
176 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
177 |
Goal "m + Suc(n) = Suc(m+n)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
178 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
179 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
180 |
qed "add_Suc_right"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
181 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
182 |
Addsimps [add_0_right,add_Suc_right]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
183 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
184 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
185 |
(*Associative law for addition*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
186 |
Goal "(m + n) + k = m + ((n + k)::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
187 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
188 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
189 |
qed "add_assoc"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
190 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
191 |
(*Commutative law for addition*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
192 |
Goal "m + n = n + (m::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
193 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
194 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
195 |
qed "add_commute"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
196 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
197 |
Goal "x+(y+z)=y+((x+z)::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
198 |
by (rtac (add_commute RS trans) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
199 |
by (rtac (add_assoc RS trans) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
200 |
by (rtac (add_commute RS arg_cong) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
201 |
qed "add_left_commute"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
202 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
203 |
(*Addition is an AC-operator*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
204 |
bind_thms ("add_ac", [add_assoc, add_commute, add_left_commute]); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
205 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
206 |
Goal "(k + m = k + n) = (m=(n::nat))"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
207 |
by (induct_tac "k" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
208 |
by (Simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
209 |
by (Asm_simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
210 |
qed "add_left_cancel"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
211 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
212 |
Goal "(m + k = n + k) = (m=(n::nat))"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
213 |
by (induct_tac "k" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
214 |
by (Simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
215 |
by (Asm_simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
216 |
qed "add_right_cancel"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
217 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
218 |
Goal "(k + m <= k + n) = (m<=(n::nat))"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
219 |
by (induct_tac "k" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
220 |
by (Simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
221 |
by (Asm_simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
222 |
qed "add_left_cancel_le"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
223 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
224 |
Goal "(k + m < k + n) = (m<(n::nat))"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
225 |
by (induct_tac "k" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
226 |
by (Simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
227 |
by (Asm_simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
228 |
qed "add_left_cancel_less"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
229 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
230 |
Addsimps [add_left_cancel, add_right_cancel, |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
231 |
add_left_cancel_le, add_left_cancel_less]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
232 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
233 |
(** Reasoning about m+0=0, etc. **) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
234 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
235 |
Goal "!!m::nat. (m+n = 0) = (m=0 & n=0)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
236 |
by (case_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
237 |
by (Auto_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
238 |
qed "add_is_0"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
239 |
AddIffs [add_is_0]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
240 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11464
diff
changeset
|
241 |
Goal "(m+n= Suc 0) = (m= Suc 0 & n=0 | m=0 & n= Suc 0)"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
242 |
by (case_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
243 |
by (Auto_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
244 |
qed "add_is_1"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
245 |
|
11868
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents:
11701
diff
changeset
|
246 |
Goal "(Suc 0 = m+n) = (m = Suc 0 & n=0 | m=0 & n = Suc 0)"; |
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents:
11701
diff
changeset
|
247 |
by (rtac ([eq_commute, add_is_1] MRS trans) 1); |
11464 | 248 |
qed "one_is_add"; |
249 |
||
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
250 |
Goal "!!m::nat. (0<m+n) = (0<m | 0<n)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
251 |
by (simp_tac (simpset() delsimps [neq0_conv] addsimps [neq0_conv RS sym]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
252 |
qed "add_gr_0"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
253 |
AddIffs [add_gr_0]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
254 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
255 |
Goal "!!m::nat. m + n = m ==> n = 0"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
256 |
by (dtac (add_0_right RS ssubst) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
257 |
by (asm_full_simp_tac (simpset() addsimps [add_assoc] |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
258 |
delsimps [add_0_right]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
259 |
qed "add_eq_self_zero"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
260 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
261 |
(**** Additional theorems about "less than" ****) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
262 |
|
10558 | 263 |
(*Deleted less_natE; instead use less_imp_Suc_add RS exE*) |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
264 |
Goal "m<n --> (EX k. n=Suc(m+k))"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
265 |
by (induct_tac "n" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
266 |
by (ALLGOALS (simp_tac (simpset() addsimps [order_le_less]))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
267 |
by (blast_tac (claset() addSEs [less_SucE] |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
268 |
addSIs [add_0_right RS sym, add_Suc_right RS sym]) 1); |
10558 | 269 |
qed_spec_mp "less_imp_Suc_add"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
270 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
271 |
Goal "n <= ((m + n)::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
272 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
273 |
by (ALLGOALS Simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
274 |
by (etac le_SucI 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
275 |
qed "le_add2"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
276 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
277 |
Goal "n <= ((n + m)::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
278 |
by (simp_tac (simpset() addsimps add_ac) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
279 |
by (rtac le_add2 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
280 |
qed "le_add1"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
281 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
282 |
bind_thm ("less_add_Suc1", (lessI RS (le_add1 RS le_less_trans))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
283 |
bind_thm ("less_add_Suc2", (lessI RS (le_add2 RS le_less_trans))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
284 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
285 |
Goal "(m<n) = (EX k. n=Suc(m+k))"; |
10558 | 286 |
by (blast_tac (claset() addSIs [less_add_Suc1, less_imp_Suc_add]) 1); |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
287 |
qed "less_iff_Suc_add"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
288 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
289 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
290 |
(*"i <= j ==> i <= j+m"*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
291 |
bind_thm ("trans_le_add1", le_add1 RSN (2,le_trans)); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
292 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
293 |
(*"i <= j ==> i <= m+j"*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
294 |
bind_thm ("trans_le_add2", le_add2 RSN (2,le_trans)); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
295 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
296 |
(*"i < j ==> i < j+m"*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
297 |
bind_thm ("trans_less_add1", le_add1 RSN (2,less_le_trans)); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
298 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
299 |
(*"i < j ==> i < m+j"*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
300 |
bind_thm ("trans_less_add2", le_add2 RSN (2,less_le_trans)); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
301 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
302 |
Goal "i+j < (k::nat) --> i<k"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
303 |
by (induct_tac "j" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
304 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
305 |
by (blast_tac (claset() addDs [Suc_lessD]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
306 |
qed_spec_mp "add_lessD1"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
307 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
308 |
Goal "~ (i+j < (i::nat))"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
309 |
by (rtac notI 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
310 |
by (etac (add_lessD1 RS less_irrefl) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
311 |
qed "not_add_less1"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
312 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
313 |
Goal "~ (j+i < (i::nat))"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
314 |
by (simp_tac (simpset() addsimps [add_commute, not_add_less1]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
315 |
qed "not_add_less2"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
316 |
AddIffs [not_add_less1, not_add_less2]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
317 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
318 |
Goal "m+k<=n --> m<=(n::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
319 |
by (induct_tac "k" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
320 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps le_simps))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
321 |
qed_spec_mp "add_leD1"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
322 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
323 |
Goal "m+k<=n ==> k<=(n::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
324 |
by (full_simp_tac (simpset() addsimps [add_commute]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
325 |
by (etac add_leD1 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
326 |
qed_spec_mp "add_leD2"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
327 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
328 |
Goal "m+k<=n ==> m<=n & k<=(n::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
329 |
by (blast_tac (claset() addDs [add_leD1, add_leD2]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
330 |
bind_thm ("add_leE", result() RS conjE); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
331 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
332 |
(*needs !!k for add_ac to work*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
333 |
Goal "!!k:: nat. [| k<l; m+l = k+n |] ==> m<n"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
334 |
by (force_tac (claset(), |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
335 |
simpset() delsimps [add_Suc_right] |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
336 |
addsimps [less_iff_Suc_add, |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
337 |
add_Suc_right RS sym] @ add_ac) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
338 |
qed "less_add_eq_less"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
339 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
340 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
341 |
(*** Monotonicity of Addition ***) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
342 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
343 |
(*strict, in 1st argument*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
344 |
Goal "i < j ==> i + k < j + (k::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
345 |
by (induct_tac "k" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
346 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
347 |
qed "add_less_mono1"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
348 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
349 |
(*strict, in both arguments*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
350 |
Goal "[|i < j; k < l|] ==> i + k < j + (l::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
351 |
by (rtac (add_less_mono1 RS less_trans) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
352 |
by (REPEAT (assume_tac 1)); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
353 |
by (induct_tac "j" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
354 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
355 |
qed "add_less_mono"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
356 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
357 |
(*A [clumsy] way of lifting < monotonicity to <= monotonicity *) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
358 |
val [lt_mono,le] = Goal |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
359 |
"[| !!i j::nat. i<j ==> f(i) < f(j); \ |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
360 |
\ i <= j \ |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
361 |
\ |] ==> f(i) <= (f(j)::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
362 |
by (cut_facts_tac [le] 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
363 |
by (asm_full_simp_tac (simpset() addsimps [order_le_less]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
364 |
by (blast_tac (claset() addSIs [lt_mono]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
365 |
qed "less_mono_imp_le_mono"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
366 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
367 |
(*non-strict, in 1st argument*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
368 |
Goal "i<=j ==> i + k <= j + (k::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
369 |
by (res_inst_tac [("f", "%j. j+k")] less_mono_imp_le_mono 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
370 |
by (etac add_less_mono1 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
371 |
by (assume_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
372 |
qed "add_le_mono1"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
373 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
374 |
(*non-strict, in both arguments*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
375 |
Goal "[|i<=j; k<=l |] ==> i + k <= j + (l::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
376 |
by (etac (add_le_mono1 RS le_trans) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
377 |
by (simp_tac (simpset() addsimps [add_commute]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
378 |
qed "add_le_mono"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
379 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
380 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
381 |
(*** Multiplication ***) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
382 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
383 |
(*right annihilation in product*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
384 |
Goal "!!m::nat. m * 0 = 0"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
385 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
386 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
387 |
qed "mult_0_right"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
388 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
389 |
(*right successor law for multiplication*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
390 |
Goal "m * Suc(n) = m + (m * n)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
391 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
392 |
by (ALLGOALS(asm_simp_tac (simpset() addsimps add_ac))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
393 |
qed "mult_Suc_right"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
394 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
395 |
Addsimps [mult_0_right, mult_Suc_right]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
396 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11464
diff
changeset
|
397 |
Goal "(1::nat) * n = n"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
398 |
by (Asm_simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
399 |
qed "mult_1"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
400 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11464
diff
changeset
|
401 |
Goal "n * (1::nat) = n"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
402 |
by (Asm_simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
403 |
qed "mult_1_right"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
404 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
405 |
(*Commutative law for multiplication*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
406 |
Goal "m * n = n * (m::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
407 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
408 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
409 |
qed "mult_commute"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
410 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
411 |
(*addition distributes over multiplication*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
412 |
Goal "(m + n)*k = (m*k) + ((n*k)::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
413 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
414 |
by (ALLGOALS(asm_simp_tac (simpset() addsimps add_ac))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
415 |
qed "add_mult_distrib"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
416 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
417 |
Goal "k*(m + n) = (k*m) + ((k*n)::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
418 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
419 |
by (ALLGOALS(asm_simp_tac (simpset() addsimps add_ac))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
420 |
qed "add_mult_distrib2"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
421 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
422 |
(*Associative law for multiplication*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
423 |
Goal "(m * n) * k = m * ((n * k)::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
424 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
425 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [add_mult_distrib]))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
426 |
qed "mult_assoc"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
427 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
428 |
Goal "x*(y*z) = y*((x*z)::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
429 |
by (rtac trans 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
430 |
by (rtac mult_commute 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
431 |
by (rtac trans 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
432 |
by (rtac mult_assoc 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
433 |
by (rtac (mult_commute RS arg_cong) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
434 |
qed "mult_left_commute"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
435 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
436 |
bind_thms ("mult_ac", [mult_assoc,mult_commute,mult_left_commute]); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
437 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
438 |
Goal "!!m::nat. (m*n = 0) = (m=0 | n=0)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
439 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
440 |
by (induct_tac "n" 2); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
441 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
442 |
qed "mult_is_0"; |
10710
0c8d58332658
tidying, removing obsolete lemmas about 0=... and 1=...
paulson
parents:
10558
diff
changeset
|
443 |
Addsimps [mult_is_0]; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
444 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
445 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
446 |
(*** Difference ***) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
447 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
448 |
Goal "!!m::nat. m - m = 0"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
449 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
450 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
451 |
qed "diff_self_eq_0"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
452 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
453 |
Addsimps [diff_self_eq_0]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
454 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
455 |
(*Addition is the inverse of subtraction: if n<=m then n+(m-n) = m. *) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
456 |
Goal "~ m<n --> n+(m-n) = (m::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
457 |
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
458 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
459 |
qed_spec_mp "add_diff_inverse"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
460 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
461 |
Goal "n<=m ==> n+(m-n) = (m::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
462 |
by (asm_simp_tac (simpset() addsimps [add_diff_inverse, not_less_iff_le]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
463 |
qed "le_add_diff_inverse"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
464 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
465 |
Goal "n<=m ==> (m-n)+n = (m::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
466 |
by (asm_simp_tac (simpset() addsimps [le_add_diff_inverse, add_commute]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
467 |
qed "le_add_diff_inverse2"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
468 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
469 |
Addsimps [le_add_diff_inverse, le_add_diff_inverse2]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
470 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
471 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
472 |
(*** More results about difference ***) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
473 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
474 |
Goal "n <= m ==> Suc(m)-n = Suc(m-n)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
475 |
by (etac rev_mp 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
476 |
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
477 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
478 |
qed "Suc_diff_le"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
479 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
480 |
Goal "m - n < Suc(m)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
481 |
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
482 |
by (etac less_SucE 3); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
483 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [less_Suc_eq]))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
484 |
qed "diff_less_Suc"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
485 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
486 |
Goal "m - n <= (m::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
487 |
by (res_inst_tac [("m","m"), ("n","n")] diff_induct 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
488 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [le_SucI]))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
489 |
qed "diff_le_self"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
490 |
Addsimps [diff_le_self]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
491 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
492 |
(* j<k ==> j-n < k *) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
493 |
bind_thm ("less_imp_diff_less", diff_le_self RS le_less_trans); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
494 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
495 |
Goal "!!i::nat. i-j-k = i - (j+k)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
496 |
by (res_inst_tac [("m","i"),("n","j")] diff_induct 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
497 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
498 |
qed "diff_diff_left"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
499 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
500 |
Goal "(Suc m - n) - Suc k = m - n - k"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
501 |
by (simp_tac (simpset() addsimps [diff_diff_left]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
502 |
qed "Suc_diff_diff"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
503 |
Addsimps [Suc_diff_diff]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
504 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
505 |
Goal "0<n ==> n - Suc i < n"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
506 |
by (case_tac "n" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
507 |
by Safe_tac; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
508 |
by (asm_simp_tac (simpset() addsimps le_simps) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
509 |
qed "diff_Suc_less"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
510 |
Addsimps [diff_Suc_less]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
511 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
512 |
(*This and the next few suggested by Florian Kammueller*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
513 |
Goal "!!i::nat. i-j-k = i-k-j"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
514 |
by (simp_tac (simpset() addsimps [diff_diff_left, add_commute]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
515 |
qed "diff_commute"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
516 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
517 |
Goal "k <= (j::nat) --> (i + j) - k = i + (j - k)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
518 |
by (res_inst_tac [("m","j"),("n","k")] diff_induct 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
519 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
520 |
qed_spec_mp "diff_add_assoc"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
521 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
522 |
Goal "k <= (j::nat) --> (j + i) - k = (j - k) + i"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
523 |
by (asm_simp_tac (simpset() addsimps [add_commute, diff_add_assoc]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
524 |
qed_spec_mp "diff_add_assoc2"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
525 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
526 |
Goal "(n+m) - n = (m::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
527 |
by (induct_tac "n" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
528 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
529 |
qed "diff_add_inverse"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
530 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
531 |
Goal "(m+n) - n = (m::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
532 |
by (simp_tac (simpset() addsimps [diff_add_assoc]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
533 |
qed "diff_add_inverse2"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
534 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
535 |
Goal "i <= (j::nat) ==> (j-i=k) = (j=k+i)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
536 |
by Safe_tac; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
537 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [diff_add_inverse2]))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
538 |
qed "le_imp_diff_is_add"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
539 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
540 |
Goal "!!m::nat. (m-n = 0) = (m <= n)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
541 |
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
542 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
543 |
qed "diff_is_0_eq"; |
13094 | 544 |
Addsimps [diff_is_0_eq, diff_is_0_eq RS iffD2]; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
545 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
546 |
Goal "!!m::nat. (0<n-m) = (m<n)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
547 |
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
548 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
549 |
qed "zero_less_diff"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
550 |
Addsimps [zero_less_diff]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
551 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
552 |
Goal "i < j ==> EX k::nat. 0<k & i+k = j"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
553 |
by (res_inst_tac [("x","j - i")] exI 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
554 |
by (asm_simp_tac (simpset() addsimps [add_diff_inverse, less_not_sym]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
555 |
qed "less_imp_add_positive"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
556 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
557 |
Goal "P(k) --> (ALL n. P(Suc(n))--> P(n)) --> P(k-i)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
558 |
by (res_inst_tac [("m","k"),("n","i")] diff_induct 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
559 |
by (ALLGOALS (Clarify_tac THEN' Simp_tac THEN' TRY o Blast_tac)); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
560 |
qed "zero_induct_lemma"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
561 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
562 |
val prems = Goal "[| P(k); !!n. P(Suc(n)) ==> P(n) |] ==> P(0)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
563 |
by (rtac (diff_self_eq_0 RS subst) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
564 |
by (rtac (zero_induct_lemma RS mp RS mp) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
565 |
by (REPEAT (ares_tac ([impI,allI]@prems) 1)); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
566 |
qed "zero_induct"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
567 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
568 |
Goal "(k+m) - (k+n) = m - (n::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
569 |
by (induct_tac "k" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
570 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
571 |
qed "diff_cancel"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
572 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
573 |
Goal "(m+k) - (n+k) = m - (n::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
574 |
by (asm_simp_tac |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
575 |
(simpset() addsimps [diff_cancel, inst "n" "k" add_commute]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
576 |
qed "diff_cancel2"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
577 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
578 |
Goal "n - (n+m) = (0::nat)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
579 |
by (induct_tac "n" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
580 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
581 |
qed "diff_add_0"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
582 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
583 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
584 |
(** Difference distributes over multiplication **) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
585 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
586 |
Goal "!!m::nat. (m - n) * k = (m * k) - (n * k)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
587 |
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
588 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [diff_cancel]))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
589 |
qed "diff_mult_distrib" ; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
590 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
591 |
Goal "!!m::nat. k * (m - n) = (k * m) - (k * n)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
592 |
val mult_commute_k = read_instantiate [("m","k")] mult_commute; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
593 |
by (simp_tac (simpset() addsimps [diff_mult_distrib, mult_commute_k]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
594 |
qed "diff_mult_distrib2" ; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
595 |
(*NOT added as rewrites, since sometimes they are used from right-to-left*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
596 |
|
10450 | 597 |
bind_thms ("nat_distrib", |
598 |
[add_mult_distrib, add_mult_distrib2, diff_mult_distrib, diff_mult_distrib2]); |
|
599 |
||
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
600 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
601 |
(*** Monotonicity of Multiplication ***) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
602 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
603 |
Goal "i <= (j::nat) ==> i*k<=j*k"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
604 |
by (induct_tac "k" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
605 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [add_le_mono]))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
606 |
qed "mult_le_mono1"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
607 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
608 |
Goal "i <= (j::nat) ==> k*i <= k*j"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
609 |
by (dtac mult_le_mono1 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
610 |
by (asm_simp_tac (simpset() addsimps [mult_commute]) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
611 |
qed "mult_le_mono2"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
612 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
613 |
(* <= monotonicity, BOTH arguments*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
614 |
Goal "[| i <= (j::nat); k <= l |] ==> i*k <= j*l"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
615 |
by (etac (mult_le_mono1 RS le_trans) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
616 |
by (etac mult_le_mono2 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
617 |
qed "mult_le_mono"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
618 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
619 |
(*strict, in 1st argument; proof is by induction on k>0*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
620 |
Goal "!!i::nat. [| i<j; 0<k |] ==> k*i < k*j"; |
10558 | 621 |
by (eres_inst_tac [("m1","0")] (less_imp_Suc_add RS exE) 1); |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
622 |
by (Asm_simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
623 |
by (induct_tac "x" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
624 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [add_less_mono]))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
625 |
qed "mult_less_mono2"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
626 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
627 |
Goal "!!i::nat. [| i<j; 0<k |] ==> i*k < j*k"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
628 |
by (dtac mult_less_mono2 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
629 |
by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [mult_commute]))); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
630 |
qed "mult_less_mono1"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
631 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
632 |
Goal "!!m::nat. (0 < m*n) = (0<m & 0<n)"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
633 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
634 |
by (case_tac "n" 2); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
635 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
636 |
qed "zero_less_mult_iff"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
637 |
Addsimps [zero_less_mult_iff]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
638 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11464
diff
changeset
|
639 |
Goal "(Suc 0 <= m*n) = (1<=m & 1<=n)"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
640 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
641 |
by (case_tac "n" 2); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
642 |
by (ALLGOALS Asm_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
643 |
qed "one_le_mult_iff"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
644 |
Addsimps [one_le_mult_iff]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
645 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11464
diff
changeset
|
646 |
Goal "(m*n = Suc 0) = (m=1 & n=1)"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
647 |
by (induct_tac "m" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
648 |
by (Simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
649 |
by (induct_tac "n" 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
650 |
by (Simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
651 |
by (fast_tac (claset() addss simpset()) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
652 |
qed "mult_eq_1_iff"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
653 |
Addsimps [mult_eq_1_iff]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
654 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11464
diff
changeset
|
655 |
Goal "(Suc 0 = m*n) = (m=1 & n=1)"; |
12486 | 656 |
by (rtac (mult_eq_1_iff RSN (2,trans)) 1); |
11464 | 657 |
by (fast_tac (claset() addss simpset()) 1); |
658 |
qed "one_eq_mult_iff"; |
|
659 |
Addsimps [one_eq_mult_iff]; |
|
660 |
||
9637
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
661 |
Goal "!!m::nat. (m*k < n*k) = (0<k & m<n)"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
662 |
by (safe_tac (claset() addSIs [mult_less_mono1])); |
9637
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
663 |
by (case_tac "k" 1); |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
664 |
by Auto_tac; |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
665 |
by (full_simp_tac (simpset() delsimps [le_0_eq] |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
666 |
addsimps [linorder_not_le RS sym]) 1); |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
667 |
by (blast_tac (claset() addIs [mult_le_mono1]) 1); |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
668 |
qed "mult_less_cancel2"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
669 |
|
9637
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
670 |
Goal "!!m::nat. (k*m < k*n) = (0<k & m<n)"; |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
671 |
by (simp_tac (simpset() addsimps [mult_less_cancel2, |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
672 |
inst "m" "k" mult_commute]) 1); |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
673 |
qed "mult_less_cancel1"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
674 |
Addsimps [mult_less_cancel1, mult_less_cancel2]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
675 |
|
9637
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
676 |
Goal "!!m::nat. (m*k <= n*k) = (0<k --> m<=n)"; |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
677 |
by (simp_tac (simpset() addsimps [linorder_not_less RS sym]) 1); |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
678 |
by Auto_tac; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
679 |
qed "mult_le_cancel2"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
680 |
|
9637
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
681 |
Goal "!!m::nat. (k*m <= k*n) = (0<k --> m<=n)"; |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
682 |
by (simp_tac (simpset() addsimps [linorder_not_less RS sym]) 1); |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
683 |
by Auto_tac; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
684 |
qed "mult_le_cancel1"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
685 |
Addsimps [mult_le_cancel1, mult_le_cancel2]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
686 |
|
9637
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
687 |
Goal "(m*k = n*k) = (m=n | (k = (0::nat)))"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
688 |
by (cut_facts_tac [less_linear] 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
689 |
by Safe_tac; |
9637
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
690 |
by Auto_tac; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
691 |
by (ALLGOALS (dtac mult_less_mono1 THEN' assume_tac)); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
692 |
by (ALLGOALS Asm_full_simp_tac); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
693 |
qed "mult_cancel2"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
694 |
|
9637
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
695 |
Goal "(k*m = k*n) = (m=n | (k = (0::nat)))"; |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
696 |
by (simp_tac (simpset() addsimps [mult_cancel2, inst "m" "k" mult_commute]) 1); |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
697 |
qed "mult_cancel1"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
698 |
Addsimps [mult_cancel1, mult_cancel2]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
699 |
|
9637
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
700 |
Goal "(Suc k * m < Suc k * n) = (m < n)"; |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
701 |
by (stac mult_less_cancel1 1); |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
702 |
by (Simp_tac 1); |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
703 |
qed "Suc_mult_less_cancel1"; |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
704 |
|
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
705 |
Goal "(Suc k * m <= Suc k * n) = (m <= n)"; |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
706 |
by (stac mult_le_cancel1 1); |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
707 |
by (Simp_tac 1); |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
708 |
qed "Suc_mult_le_cancel1"; |
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
709 |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
710 |
Goal "(Suc k * m = Suc k * n) = (m = n)"; |
9637
47d39a31eb2f
better rules for cancellation of common factors across comparisons
paulson
parents:
9436
diff
changeset
|
711 |
by (stac mult_cancel1 1); |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
712 |
by (Simp_tac 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
713 |
qed "Suc_mult_cancel1"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
714 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
715 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
716 |
(*Lemma for gcd*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
717 |
Goal "!!m::nat. m = m*n ==> n=1 | m=0"; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
718 |
by (dtac sym 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
719 |
by (rtac disjCI 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
720 |
by (rtac nat_less_cases 1 THEN assume_tac 2); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
721 |
by (fast_tac (claset() addSEs [less_SucE] addss simpset()) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
722 |
by (best_tac (claset() addDs [mult_less_mono2] addss simpset()) 1); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
9108
diff
changeset
|
723 |
qed "mult_eq_self_implies_10"; |