author | huffman |
Mon, 11 Jun 2007 01:22:29 +0200 | |
changeset 23304 | 83f3b6dc58b5 |
parent 23263 | 0c227412b285 |
child 23365 | f31794033ae1 |
permissions | -rw-r--r-- |
23164 | 1 |
(* Title: HOL/IntArith.thy |
2 |
ID: $Id$ |
|
3 |
Authors: Larry Paulson and Tobias Nipkow |
|
4 |
*) |
|
5 |
||
6 |
header {* Integer arithmetic *} |
|
7 |
||
8 |
theory IntArith |
|
9 |
imports Numeral Wellfounded_Relations |
|
23263 | 10 |
uses |
11 |
"~~/src/Provers/Arith/assoc_fold.ML" |
|
12 |
"~~/src/Provers/Arith/cancel_numerals.ML" |
|
13 |
"~~/src/Provers/Arith/combine_numerals.ML" |
|
14 |
("int_arith1.ML") |
|
23164 | 15 |
begin |
16 |
||
17 |
text{*Duplicate: can't understand why it's necessary*} |
|
18 |
declare numeral_0_eq_0 [simp] |
|
19 |
||
20 |
||
21 |
subsection{*Inequality Reasoning for the Arithmetic Simproc*} |
|
22 |
||
23 |
lemma add_numeral_0: "Numeral0 + a = (a::'a::number_ring)" |
|
24 |
by simp |
|
25 |
||
26 |
lemma add_numeral_0_right: "a + Numeral0 = (a::'a::number_ring)" |
|
27 |
by simp |
|
28 |
||
29 |
lemma mult_numeral_1: "Numeral1 * a = (a::'a::number_ring)" |
|
30 |
by simp |
|
31 |
||
32 |
lemma mult_numeral_1_right: "a * Numeral1 = (a::'a::number_ring)" |
|
33 |
by simp |
|
34 |
||
35 |
lemma divide_numeral_1: "a / Numeral1 = (a::'a::{number_ring,field})" |
|
36 |
by simp |
|
37 |
||
38 |
lemma inverse_numeral_1: |
|
39 |
"inverse Numeral1 = (Numeral1::'a::{number_ring,field})" |
|
40 |
by simp |
|
41 |
||
42 |
text{*Theorem lists for the cancellation simprocs. The use of binary numerals |
|
43 |
for 0 and 1 reduces the number of special cases.*} |
|
44 |
||
45 |
lemmas add_0s = add_numeral_0 add_numeral_0_right |
|
46 |
lemmas mult_1s = mult_numeral_1 mult_numeral_1_right |
|
47 |
mult_minus1 mult_minus1_right |
|
48 |
||
49 |
||
50 |
subsection{*Special Arithmetic Rules for Abstract 0 and 1*} |
|
51 |
||
52 |
text{*Arithmetic computations are defined for binary literals, which leaves 0 |
|
53 |
and 1 as special cases. Addition already has rules for 0, but not 1. |
|
54 |
Multiplication and unary minus already have rules for both 0 and 1.*} |
|
55 |
||
56 |
||
57 |
lemma binop_eq: "[|f x y = g x y; x = x'; y = y'|] ==> f x' y' = g x' y'" |
|
58 |
by simp |
|
59 |
||
60 |
||
61 |
lemmas add_number_of_eq = number_of_add [symmetric] |
|
62 |
||
63 |
text{*Allow 1 on either or both sides*} |
|
64 |
lemma one_add_one_is_two: "1 + 1 = (2::'a::number_ring)" |
|
65 |
by (simp del: numeral_1_eq_1 add: numeral_1_eq_1 [symmetric] add_number_of_eq) |
|
66 |
||
67 |
lemmas add_special = |
|
68 |
one_add_one_is_two |
|
69 |
binop_eq [of "op +", OF add_number_of_eq numeral_1_eq_1 refl, standard] |
|
70 |
binop_eq [of "op +", OF add_number_of_eq refl numeral_1_eq_1, standard] |
|
71 |
||
72 |
text{*Allow 1 on either or both sides (1-1 already simplifies to 0)*} |
|
73 |
lemmas diff_special = |
|
74 |
binop_eq [of "op -", OF diff_number_of_eq numeral_1_eq_1 refl, standard] |
|
75 |
binop_eq [of "op -", OF diff_number_of_eq refl numeral_1_eq_1, standard] |
|
76 |
||
77 |
text{*Allow 0 or 1 on either side with a binary numeral on the other*} |
|
78 |
lemmas eq_special = |
|
79 |
binop_eq [of "op =", OF eq_number_of_eq numeral_0_eq_0 refl, standard] |
|
80 |
binop_eq [of "op =", OF eq_number_of_eq numeral_1_eq_1 refl, standard] |
|
81 |
binop_eq [of "op =", OF eq_number_of_eq refl numeral_0_eq_0, standard] |
|
82 |
binop_eq [of "op =", OF eq_number_of_eq refl numeral_1_eq_1, standard] |
|
83 |
||
84 |
text{*Allow 0 or 1 on either side with a binary numeral on the other*} |
|
85 |
lemmas less_special = |
|
86 |
binop_eq [of "op <", OF less_number_of_eq_neg numeral_0_eq_0 refl, standard] |
|
87 |
binop_eq [of "op <", OF less_number_of_eq_neg numeral_1_eq_1 refl, standard] |
|
88 |
binop_eq [of "op <", OF less_number_of_eq_neg refl numeral_0_eq_0, standard] |
|
89 |
binop_eq [of "op <", OF less_number_of_eq_neg refl numeral_1_eq_1, standard] |
|
90 |
||
91 |
text{*Allow 0 or 1 on either side with a binary numeral on the other*} |
|
92 |
lemmas le_special = |
|
93 |
binop_eq [of "op \<le>", OF le_number_of_eq numeral_0_eq_0 refl, standard] |
|
94 |
binop_eq [of "op \<le>", OF le_number_of_eq numeral_1_eq_1 refl, standard] |
|
95 |
binop_eq [of "op \<le>", OF le_number_of_eq refl numeral_0_eq_0, standard] |
|
96 |
binop_eq [of "op \<le>", OF le_number_of_eq refl numeral_1_eq_1, standard] |
|
97 |
||
98 |
lemmas arith_special[simp] = |
|
99 |
add_special diff_special eq_special less_special le_special |
|
100 |
||
101 |
||
102 |
lemma min_max_01: "min (0::int) 1 = 0 & min (1::int) 0 = 0 & |
|
103 |
max (0::int) 1 = 1 & max (1::int) 0 = 1" |
|
104 |
by(simp add:min_def max_def) |
|
105 |
||
106 |
lemmas min_max_special[simp] = |
|
107 |
min_max_01 |
|
108 |
max_def[of "0::int" "number_of v", standard, simp] |
|
109 |
min_def[of "0::int" "number_of v", standard, simp] |
|
110 |
max_def[of "number_of u" "0::int", standard, simp] |
|
111 |
min_def[of "number_of u" "0::int", standard, simp] |
|
112 |
max_def[of "1::int" "number_of v", standard, simp] |
|
113 |
min_def[of "1::int" "number_of v", standard, simp] |
|
114 |
max_def[of "number_of u" "1::int", standard, simp] |
|
115 |
min_def[of "number_of u" "1::int", standard, simp] |
|
116 |
||
117 |
use "int_arith1.ML" |
|
118 |
setup int_arith_setup |
|
119 |
||
120 |
||
121 |
subsection{*Lemmas About Small Numerals*} |
|
122 |
||
123 |
lemma of_int_m1 [simp]: "of_int -1 = (-1 :: 'a :: number_ring)" |
|
124 |
proof - |
|
125 |
have "(of_int -1 :: 'a) = of_int (- 1)" by simp |
|
126 |
also have "... = - of_int 1" by (simp only: of_int_minus) |
|
127 |
also have "... = -1" by simp |
|
128 |
finally show ?thesis . |
|
129 |
qed |
|
130 |
||
131 |
lemma abs_minus_one [simp]: "abs (-1) = (1::'a::{ordered_idom,number_ring})" |
|
132 |
by (simp add: abs_if) |
|
133 |
||
134 |
lemma abs_power_minus_one [simp]: |
|
135 |
"abs(-1 ^ n) = (1::'a::{ordered_idom,number_ring,recpower})" |
|
136 |
by (simp add: power_abs) |
|
137 |
||
138 |
lemma of_int_number_of_eq: |
|
139 |
"of_int (number_of v) = (number_of v :: 'a :: number_ring)" |
|
140 |
by (simp add: number_of_eq) |
|
141 |
||
142 |
text{*Lemmas for specialist use, NOT as default simprules*} |
|
143 |
lemma mult_2: "2 * z = (z+z::'a::number_ring)" |
|
144 |
proof - |
|
145 |
have "2*z = (1 + 1)*z" by simp |
|
146 |
also have "... = z+z" by (simp add: left_distrib) |
|
147 |
finally show ?thesis . |
|
148 |
qed |
|
149 |
||
150 |
lemma mult_2_right: "z * 2 = (z+z::'a::number_ring)" |
|
151 |
by (subst mult_commute, rule mult_2) |
|
152 |
||
153 |
||
154 |
subsection{*More Inequality Reasoning*} |
|
155 |
||
156 |
lemma zless_add1_eq: "(w < z + (1::int)) = (w<z | w=z)" |
|
157 |
by arith |
|
158 |
||
159 |
lemma add1_zle_eq: "(w + (1::int) \<le> z) = (w<z)" |
|
160 |
by arith |
|
161 |
||
162 |
lemma zle_diff1_eq [simp]: "(w \<le> z - (1::int)) = (w<z)" |
|
163 |
by arith |
|
164 |
||
165 |
lemma zle_add1_eq_le [simp]: "(w < z + (1::int)) = (w\<le>z)" |
|
166 |
by arith |
|
167 |
||
168 |
lemma int_one_le_iff_zero_less: "((1::int) \<le> z) = (0 < z)" |
|
169 |
by arith |
|
170 |
||
171 |
||
172 |
subsection{*The Functions @{term nat} and @{term int}*} |
|
173 |
||
174 |
text{*Simplify the terms @{term "int 0"}, @{term "int(Suc 0)"} and |
|
175 |
@{term "w + - z"}*} |
|
176 |
declare Zero_int_def [symmetric, simp] |
|
177 |
declare One_int_def [symmetric, simp] |
|
178 |
||
179 |
lemmas diff_int_def_symmetric = diff_int_def [symmetric, simp] |
|
180 |
||
181 |
lemma nat_0: "nat 0 = 0" |
|
182 |
by (simp add: nat_eq_iff) |
|
183 |
||
184 |
lemma nat_1: "nat 1 = Suc 0" |
|
185 |
by (subst nat_eq_iff, simp) |
|
186 |
||
187 |
lemma nat_2: "nat 2 = Suc (Suc 0)" |
|
188 |
by (subst nat_eq_iff, simp) |
|
189 |
||
190 |
lemma one_less_nat_eq [simp]: "(Suc 0 < nat z) = (1 < z)" |
|
191 |
apply (insert zless_nat_conj [of 1 z]) |
|
192 |
apply (auto simp add: nat_1) |
|
193 |
done |
|
194 |
||
195 |
text{*This simplifies expressions of the form @{term "int n = z"} where |
|
196 |
z is an integer literal.*} |
|
197 |
lemmas int_eq_iff_number_of [simp] = int_eq_iff [of _ "number_of v", standard] |
|
198 |
||
23304
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
199 |
lemmas int_of_nat_eq_iff_number_of [simp] = |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
200 |
int_of_nat_eq_iff [of _ "number_of v", standard] |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
201 |
|
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
202 |
lemma split_nat': |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
203 |
"P(nat(i::int)) = ((\<forall>n. i = int_of_nat n \<longrightarrow> P n) & (i < 0 \<longrightarrow> P 0))" |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
204 |
(is "?P = (?L & ?R)") |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
205 |
proof (cases "i < 0") |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
206 |
case True thus ?thesis by simp |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
207 |
next |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
208 |
case False |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
209 |
have "?P = ?L" |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
210 |
proof |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
211 |
assume ?P thus ?L using False by clarsimp |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
212 |
next |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
213 |
assume ?L thus ?P using False by simp |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
214 |
qed |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
215 |
with False show ?thesis by simp |
83f3b6dc58b5
add int_of_nat versions of lemmas about int::nat=>int
huffman
parents:
23263
diff
changeset
|
216 |
qed |
23164 | 217 |
|
218 |
lemma split_nat [arith_split]: |
|
219 |
"P(nat(i::int)) = ((\<forall>n. i = int n \<longrightarrow> P n) & (i < 0 \<longrightarrow> P 0))" |
|
220 |
(is "?P = (?L & ?R)") |
|
221 |
proof (cases "i < 0") |
|
222 |
case True thus ?thesis by simp |
|
223 |
next |
|
224 |
case False |
|
225 |
have "?P = ?L" |
|
226 |
proof |
|
227 |
assume ?P thus ?L using False by clarsimp |
|
228 |
next |
|
229 |
assume ?L thus ?P using False by simp |
|
230 |
qed |
|
231 |
with False show ?thesis by simp |
|
232 |
qed |
|
233 |
||
234 |
||
235 |
(*Analogous to zadd_int*) |
|
236 |
lemma zdiff_int: "n \<le> m ==> int m - int n = int (m-n)" |
|
237 |
by (induct m n rule: diff_induct, simp_all) |
|
238 |
||
239 |
lemma nat_mult_distrib: "(0::int) \<le> z ==> nat (z*z') = nat z * nat z'" |
|
240 |
apply (cases "0 \<le> z'") |
|
241 |
apply (rule inj_int [THEN injD]) |
|
242 |
apply (simp add: int_mult zero_le_mult_iff) |
|
243 |
apply (simp add: mult_le_0_iff) |
|
244 |
done |
|
245 |
||
246 |
lemma nat_mult_distrib_neg: "z \<le> (0::int) ==> nat(z*z') = nat(-z) * nat(-z')" |
|
247 |
apply (rule trans) |
|
248 |
apply (rule_tac [2] nat_mult_distrib, auto) |
|
249 |
done |
|
250 |
||
251 |
lemma nat_abs_mult_distrib: "nat (abs (w * z)) = nat (abs w) * nat (abs z)" |
|
252 |
apply (cases "z=0 | w=0") |
|
253 |
apply (auto simp add: abs_if nat_mult_distrib [symmetric] |
|
254 |
nat_mult_distrib_neg [symmetric] mult_less_0_iff) |
|
255 |
done |
|
256 |
||
257 |
||
258 |
subsection "Induction principles for int" |
|
259 |
||
260 |
text{*Well-founded segments of the integers*} |
|
261 |
||
262 |
definition |
|
263 |
int_ge_less_than :: "int => (int * int) set" |
|
264 |
where |
|
265 |
"int_ge_less_than d = {(z',z). d \<le> z' & z' < z}" |
|
266 |
||
267 |
theorem wf_int_ge_less_than: "wf (int_ge_less_than d)" |
|
268 |
proof - |
|
269 |
have "int_ge_less_than d \<subseteq> measure (%z. nat (z-d))" |
|
270 |
by (auto simp add: int_ge_less_than_def) |
|
271 |
thus ?thesis |
|
272 |
by (rule wf_subset [OF wf_measure]) |
|
273 |
qed |
|
274 |
||
275 |
text{*This variant looks odd, but is typical of the relations suggested |
|
276 |
by RankFinder.*} |
|
277 |
||
278 |
definition |
|
279 |
int_ge_less_than2 :: "int => (int * int) set" |
|
280 |
where |
|
281 |
"int_ge_less_than2 d = {(z',z). d \<le> z & z' < z}" |
|
282 |
||
283 |
theorem wf_int_ge_less_than2: "wf (int_ge_less_than2 d)" |
|
284 |
proof - |
|
285 |
have "int_ge_less_than2 d \<subseteq> measure (%z. nat (1+z-d))" |
|
286 |
by (auto simp add: int_ge_less_than2_def) |
|
287 |
thus ?thesis |
|
288 |
by (rule wf_subset [OF wf_measure]) |
|
289 |
qed |
|
290 |
||
291 |
(* `set:int': dummy construction *) |
|
292 |
theorem int_ge_induct[case_names base step,induct set:int]: |
|
293 |
assumes ge: "k \<le> (i::int)" and |
|
294 |
base: "P(k)" and |
|
295 |
step: "\<And>i. \<lbrakk>k \<le> i; P i\<rbrakk> \<Longrightarrow> P(i+1)" |
|
296 |
shows "P i" |
|
297 |
proof - |
|
298 |
{ fix n have "\<And>i::int. n = nat(i-k) \<Longrightarrow> k \<le> i \<Longrightarrow> P i" |
|
299 |
proof (induct n) |
|
300 |
case 0 |
|
301 |
hence "i = k" by arith |
|
302 |
thus "P i" using base by simp |
|
303 |
next |
|
304 |
case (Suc n) |
|
305 |
hence "n = nat((i - 1) - k)" by arith |
|
306 |
moreover |
|
307 |
have ki1: "k \<le> i - 1" using Suc.prems by arith |
|
308 |
ultimately |
|
309 |
have "P(i - 1)" by(rule Suc.hyps) |
|
310 |
from step[OF ki1 this] show ?case by simp |
|
311 |
qed |
|
312 |
} |
|
313 |
with ge show ?thesis by fast |
|
314 |
qed |
|
315 |
||
316 |
(* `set:int': dummy construction *) |
|
317 |
theorem int_gr_induct[case_names base step,induct set:int]: |
|
318 |
assumes gr: "k < (i::int)" and |
|
319 |
base: "P(k+1)" and |
|
320 |
step: "\<And>i. \<lbrakk>k < i; P i\<rbrakk> \<Longrightarrow> P(i+1)" |
|
321 |
shows "P i" |
|
322 |
apply(rule int_ge_induct[of "k + 1"]) |
|
323 |
using gr apply arith |
|
324 |
apply(rule base) |
|
325 |
apply (rule step, simp+) |
|
326 |
done |
|
327 |
||
328 |
theorem int_le_induct[consumes 1,case_names base step]: |
|
329 |
assumes le: "i \<le> (k::int)" and |
|
330 |
base: "P(k)" and |
|
331 |
step: "\<And>i. \<lbrakk>i \<le> k; P i\<rbrakk> \<Longrightarrow> P(i - 1)" |
|
332 |
shows "P i" |
|
333 |
proof - |
|
334 |
{ fix n have "\<And>i::int. n = nat(k-i) \<Longrightarrow> i \<le> k \<Longrightarrow> P i" |
|
335 |
proof (induct n) |
|
336 |
case 0 |
|
337 |
hence "i = k" by arith |
|
338 |
thus "P i" using base by simp |
|
339 |
next |
|
340 |
case (Suc n) |
|
341 |
hence "n = nat(k - (i+1))" by arith |
|
342 |
moreover |
|
343 |
have ki1: "i + 1 \<le> k" using Suc.prems by arith |
|
344 |
ultimately |
|
345 |
have "P(i+1)" by(rule Suc.hyps) |
|
346 |
from step[OF ki1 this] show ?case by simp |
|
347 |
qed |
|
348 |
} |
|
349 |
with le show ?thesis by fast |
|
350 |
qed |
|
351 |
||
352 |
theorem int_less_induct [consumes 1,case_names base step]: |
|
353 |
assumes less: "(i::int) < k" and |
|
354 |
base: "P(k - 1)" and |
|
355 |
step: "\<And>i. \<lbrakk>i < k; P i\<rbrakk> \<Longrightarrow> P(i - 1)" |
|
356 |
shows "P i" |
|
357 |
apply(rule int_le_induct[of _ "k - 1"]) |
|
358 |
using less apply arith |
|
359 |
apply(rule base) |
|
360 |
apply (rule step, simp+) |
|
361 |
done |
|
362 |
||
363 |
subsection{*Intermediate value theorems*} |
|
364 |
||
365 |
lemma int_val_lemma: |
|
366 |
"(\<forall>i<n::nat. abs(f(i+1) - f i) \<le> 1) --> |
|
367 |
f 0 \<le> k --> k \<le> f n --> (\<exists>i \<le> n. f i = (k::int))" |
|
368 |
apply (induct_tac "n", simp) |
|
369 |
apply (intro strip) |
|
370 |
apply (erule impE, simp) |
|
371 |
apply (erule_tac x = n in allE, simp) |
|
372 |
apply (case_tac "k = f (n+1) ") |
|
373 |
apply force |
|
374 |
apply (erule impE) |
|
375 |
apply (simp add: abs_if split add: split_if_asm) |
|
376 |
apply (blast intro: le_SucI) |
|
377 |
done |
|
378 |
||
379 |
lemmas nat0_intermed_int_val = int_val_lemma [rule_format (no_asm)] |
|
380 |
||
381 |
lemma nat_intermed_int_val: |
|
382 |
"[| \<forall>i. m \<le> i & i < n --> abs(f(i + 1::nat) - f i) \<le> 1; m < n; |
|
383 |
f m \<le> k; k \<le> f n |] ==> ? i. m \<le> i & i \<le> n & f i = (k::int)" |
|
384 |
apply (cut_tac n = "n-m" and f = "%i. f (i+m) " and k = k |
|
385 |
in int_val_lemma) |
|
386 |
apply simp |
|
387 |
apply (erule exE) |
|
388 |
apply (rule_tac x = "i+m" in exI, arith) |
|
389 |
done |
|
390 |
||
391 |
||
392 |
subsection{*Products and 1, by T. M. Rasmussen*} |
|
393 |
||
394 |
lemma zabs_less_one_iff [simp]: "(\<bar>z\<bar> < 1) = (z = (0::int))" |
|
395 |
by arith |
|
396 |
||
397 |
lemma abs_zmult_eq_1: "(\<bar>m * n\<bar> = 1) ==> \<bar>m\<bar> = (1::int)" |
|
398 |
apply (cases "\<bar>n\<bar>=1") |
|
399 |
apply (simp add: abs_mult) |
|
400 |
apply (rule ccontr) |
|
401 |
apply (auto simp add: linorder_neq_iff abs_mult) |
|
402 |
apply (subgoal_tac "2 \<le> \<bar>m\<bar> & 2 \<le> \<bar>n\<bar>") |
|
403 |
prefer 2 apply arith |
|
404 |
apply (subgoal_tac "2*2 \<le> \<bar>m\<bar> * \<bar>n\<bar>", simp) |
|
405 |
apply (rule mult_mono, auto) |
|
406 |
done |
|
407 |
||
408 |
lemma pos_zmult_eq_1_iff_lemma: "(m * n = 1) ==> m = (1::int) | m = -1" |
|
409 |
by (insert abs_zmult_eq_1 [of m n], arith) |
|
410 |
||
411 |
lemma pos_zmult_eq_1_iff: "0 < (m::int) ==> (m * n = 1) = (m = 1 & n = 1)" |
|
412 |
apply (auto dest: pos_zmult_eq_1_iff_lemma) |
|
413 |
apply (simp add: mult_commute [of m]) |
|
414 |
apply (frule pos_zmult_eq_1_iff_lemma, auto) |
|
415 |
done |
|
416 |
||
417 |
lemma zmult_eq_1_iff: "(m*n = (1::int)) = ((m = 1 & n = 1) | (m = -1 & n = -1))" |
|
418 |
apply (rule iffI) |
|
419 |
apply (frule pos_zmult_eq_1_iff_lemma) |
|
420 |
apply (simp add: mult_commute [of m]) |
|
421 |
apply (frule pos_zmult_eq_1_iff_lemma, auto) |
|
422 |
done |
|
423 |
||
424 |
||
425 |
subsection {* Legacy ML bindings *} |
|
426 |
||
427 |
ML {* |
|
428 |
val of_int_number_of_eq = @{thm of_int_number_of_eq}; |
|
429 |
val nat_0 = @{thm nat_0}; |
|
430 |
val nat_1 = @{thm nat_1}; |
|
431 |
*} |
|
432 |
||
433 |
end |