author | paulson |
Wed, 04 Jul 2007 13:56:26 +0200 | |
changeset 23563 | 42f2f90b51a6 |
parent 23476 | 839db6346cc8 |
child 23740 | d7f18c837ce7 |
permissions | -rw-r--r-- |
923 | 1 |
(* Title: HOL/Nat.thy |
2 |
ID: $Id$ |
|
21243 | 3 |
Author: Tobias Nipkow and Lawrence C Paulson and Markus Wenzel |
923 | 4 |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
7702
diff
changeset
|
5 |
Type "nat" is a linear order, and a datatype; arithmetic operators + - |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
7702
diff
changeset
|
6 |
and * (for div, mod and dvd, see theory Divides). |
923 | 7 |
*) |
8 |
||
13449 | 9 |
header {* Natural numbers *} |
10 |
||
15131 | 11 |
theory Nat |
15140 | 12 |
imports Wellfounded_Recursion Ring_and_Field |
23263 | 13 |
uses |
14 |
"~~/src/Tools/rat.ML" |
|
15 |
"~~/src/Provers/Arith/fast_lin_arith.ML" |
|
16 |
"~~/src/Provers/Arith/cancel_sums.ML" |
|
17 |
("arith_data.ML") |
|
15131 | 18 |
begin |
13449 | 19 |
|
20 |
subsection {* Type @{text ind} *} |
|
21 |
||
22 |
typedecl ind |
|
23 |
||
19573 | 24 |
axiomatization |
25 |
Zero_Rep :: ind and |
|
26 |
Suc_Rep :: "ind => ind" |
|
27 |
where |
|
13449 | 28 |
-- {* the axiom of infinity in 2 parts *} |
19573 | 29 |
inj_Suc_Rep: "inj Suc_Rep" and |
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
30 |
Suc_Rep_not_Zero_Rep: "Suc_Rep x \<noteq> Zero_Rep" |
19573 | 31 |
|
13449 | 32 |
|
33 |
subsection {* Type nat *} |
|
34 |
||
35 |
text {* Type definition *} |
|
36 |
||
22262 | 37 |
inductive2 Nat :: "ind \<Rightarrow> bool" |
38 |
where |
|
39 |
Zero_RepI: "Nat Zero_Rep" |
|
40 |
| Suc_RepI: "Nat i ==> Nat (Suc_Rep i)" |
|
13449 | 41 |
|
42 |
global |
|
43 |
||
44 |
typedef (open Nat) |
|
22262 | 45 |
nat = "Collect Nat" |
21243 | 46 |
proof |
22262 | 47 |
from Nat.Zero_RepI |
48 |
show "Zero_Rep : Collect Nat" .. |
|
21243 | 49 |
qed |
13449 | 50 |
|
51 |
text {* Abstract constants and syntax *} |
|
52 |
||
53 |
consts |
|
54 |
Suc :: "nat => nat" |
|
55 |
||
56 |
local |
|
57 |
||
58 |
defs |
|
18648 | 59 |
Suc_def: "Suc == (%n. Abs_Nat (Suc_Rep (Rep_Nat n)))" |
22718 | 60 |
|
61 |
definition |
|
62 |
pred_nat :: "(nat * nat) set" where |
|
63 |
"pred_nat = {(m, n). n = Suc m}" |
|
13449 | 64 |
|
21456 | 65 |
instance nat :: "{ord, zero, one}" |
66 |
Zero_nat_def: "0 == Abs_Nat Zero_Rep" |
|
67 |
One_nat_def [simp]: "1 == Suc 0" |
|
22262 | 68 |
less_def: "m < n == (m, n) : pred_nat^+" |
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22718
diff
changeset
|
69 |
le_def: "m \<le> (n::nat) == ~ (n < m)" .. |
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22718
diff
changeset
|
70 |
|
22845 | 71 |
lemmas [code func del] = less_def le_def |
13449 | 72 |
|
73 |
text {* Induction *} |
|
923 | 74 |
|
22718 | 75 |
lemma Rep_Nat': "Nat (Rep_Nat x)" |
76 |
by (rule Rep_Nat [simplified mem_Collect_eq]) |
|
77 |
||
78 |
lemma Abs_Nat_inverse': "Nat y \<Longrightarrow> Rep_Nat (Abs_Nat y) = y" |
|
79 |
by (rule Abs_Nat_inverse [simplified mem_Collect_eq]) |
|
22262 | 80 |
|
13449 | 81 |
theorem nat_induct: "P 0 ==> (!!n. P n ==> P (Suc n)) ==> P n" |
82 |
apply (unfold Zero_nat_def Suc_def) |
|
83 |
apply (rule Rep_Nat_inverse [THEN subst]) -- {* types force good instantiation *} |
|
22262 | 84 |
apply (erule Rep_Nat' [THEN Nat.induct]) |
85 |
apply (iprover elim: Abs_Nat_inverse' [THEN subst]) |
|
13449 | 86 |
done |
87 |
||
88 |
text {* Distinctness of constructors *} |
|
89 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
90 |
lemma Suc_not_Zero [iff]: "Suc m \<noteq> 0" |
22262 | 91 |
by (simp add: Zero_nat_def Suc_def Abs_Nat_inject Rep_Nat' Suc_RepI Zero_RepI |
22718 | 92 |
Suc_Rep_not_Zero_Rep) |
13449 | 93 |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
94 |
lemma Zero_not_Suc [iff]: "0 \<noteq> Suc m" |
13449 | 95 |
by (rule not_sym, rule Suc_not_Zero not_sym) |
96 |
||
97 |
lemma Suc_neq_Zero: "Suc m = 0 ==> R" |
|
98 |
by (rule notE, rule Suc_not_Zero) |
|
99 |
||
100 |
lemma Zero_neq_Suc: "0 = Suc m ==> R" |
|
101 |
by (rule Suc_neq_Zero, erule sym) |
|
102 |
||
103 |
text {* Injectiveness of @{term Suc} *} |
|
104 |
||
16733
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
nipkow
parents:
16635
diff
changeset
|
105 |
lemma inj_Suc[simp]: "inj_on Suc N" |
22718 | 106 |
by (simp add: Suc_def inj_on_def Abs_Nat_inject Rep_Nat' Suc_RepI |
107 |
inj_Suc_Rep [THEN inj_eq] Rep_Nat_inject) |
|
13449 | 108 |
|
109 |
lemma Suc_inject: "Suc x = Suc y ==> x = y" |
|
110 |
by (rule inj_Suc [THEN injD]) |
|
111 |
||
112 |
lemma Suc_Suc_eq [iff]: "(Suc m = Suc n) = (m = n)" |
|
15413 | 113 |
by (rule inj_Suc [THEN inj_eq]) |
13449 | 114 |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
115 |
lemma nat_not_singleton: "(\<forall>x. x = (0::nat)) = False" |
13449 | 116 |
by auto |
117 |
||
21411 | 118 |
text {* size of a datatype value *} |
21243 | 119 |
|
22473 | 120 |
class size = type + |
21411 | 121 |
fixes size :: "'a \<Rightarrow> nat" |
21243 | 122 |
|
13449 | 123 |
text {* @{typ nat} is a datatype *} |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
7702
diff
changeset
|
124 |
|
5188
633ec5f6c155
Declaration of type 'nat' as a datatype (this allows usage of
berghofe
parents:
4640
diff
changeset
|
125 |
rep_datatype nat |
13449 | 126 |
distinct Suc_not_Zero Zero_not_Suc |
127 |
inject Suc_Suc_eq |
|
21411 | 128 |
induction nat_induct |
129 |
||
130 |
declare nat.induct [case_names 0 Suc, induct type: nat] |
|
131 |
declare nat.exhaust [case_names 0 Suc, cases type: nat] |
|
13449 | 132 |
|
21672 | 133 |
lemmas nat_rec_0 = nat.recs(1) |
134 |
and nat_rec_Suc = nat.recs(2) |
|
135 |
||
136 |
lemmas nat_case_0 = nat.cases(1) |
|
137 |
and nat_case_Suc = nat.cases(2) |
|
138 |
||
139 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
140 |
lemma n_not_Suc_n: "n \<noteq> Suc n" |
13449 | 141 |
by (induct n) simp_all |
142 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
143 |
lemma Suc_n_not_n: "Suc t \<noteq> t" |
13449 | 144 |
by (rule not_sym, rule n_not_Suc_n) |
145 |
||
146 |
text {* A special form of induction for reasoning |
|
147 |
about @{term "m < n"} and @{term "m - n"} *} |
|
148 |
||
149 |
theorem diff_induct: "(!!x. P x 0) ==> (!!y. P 0 (Suc y)) ==> |
|
150 |
(!!x y. P x y ==> P (Suc x) (Suc y)) ==> P m n" |
|
14208 | 151 |
apply (rule_tac x = m in spec) |
15251 | 152 |
apply (induct n) |
13449 | 153 |
prefer 2 |
154 |
apply (rule allI) |
|
17589 | 155 |
apply (induct_tac x, iprover+) |
13449 | 156 |
done |
157 |
||
158 |
subsection {* Basic properties of "less than" *} |
|
159 |
||
160 |
lemma wf_pred_nat: "wf pred_nat" |
|
14208 | 161 |
apply (unfold wf_def pred_nat_def, clarify) |
162 |
apply (induct_tac x, blast+) |
|
13449 | 163 |
done |
164 |
||
165 |
lemma wf_less: "wf {(x, y::nat). x < y}" |
|
166 |
apply (unfold less_def) |
|
14208 | 167 |
apply (rule wf_pred_nat [THEN wf_trancl, THEN wf_subset], blast) |
13449 | 168 |
done |
169 |
||
170 |
lemma less_eq: "((m, n) : pred_nat^+) = (m < n)" |
|
171 |
apply (unfold less_def) |
|
172 |
apply (rule refl) |
|
173 |
done |
|
174 |
||
175 |
subsubsection {* Introduction properties *} |
|
176 |
||
177 |
lemma less_trans: "i < j ==> j < k ==> i < (k::nat)" |
|
178 |
apply (unfold less_def) |
|
14208 | 179 |
apply (rule trans_trancl [THEN transD], assumption+) |
13449 | 180 |
done |
181 |
||
182 |
lemma lessI [iff]: "n < Suc n" |
|
183 |
apply (unfold less_def pred_nat_def) |
|
184 |
apply (simp add: r_into_trancl) |
|
185 |
done |
|
186 |
||
187 |
lemma less_SucI: "i < j ==> i < Suc j" |
|
14208 | 188 |
apply (rule less_trans, assumption) |
13449 | 189 |
apply (rule lessI) |
190 |
done |
|
191 |
||
192 |
lemma zero_less_Suc [iff]: "0 < Suc n" |
|
193 |
apply (induct n) |
|
194 |
apply (rule lessI) |
|
195 |
apply (erule less_trans) |
|
196 |
apply (rule lessI) |
|
197 |
done |
|
198 |
||
199 |
subsubsection {* Elimination properties *} |
|
200 |
||
201 |
lemma less_not_sym: "n < m ==> ~ m < (n::nat)" |
|
202 |
apply (unfold less_def) |
|
203 |
apply (blast intro: wf_pred_nat wf_trancl [THEN wf_asym]) |
|
204 |
done |
|
205 |
||
206 |
lemma less_asym: |
|
207 |
assumes h1: "(n::nat) < m" and h2: "~ P ==> m < n" shows P |
|
208 |
apply (rule contrapos_np) |
|
209 |
apply (rule less_not_sym) |
|
210 |
apply (rule h1) |
|
211 |
apply (erule h2) |
|
212 |
done |
|
213 |
||
214 |
lemma less_not_refl: "~ n < (n::nat)" |
|
215 |
apply (unfold less_def) |
|
216 |
apply (rule wf_pred_nat [THEN wf_trancl, THEN wf_not_refl]) |
|
217 |
done |
|
218 |
||
219 |
lemma less_irrefl [elim!]: "(n::nat) < n ==> R" |
|
220 |
by (rule notE, rule less_not_refl) |
|
221 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
222 |
lemma less_not_refl2: "n < m ==> m \<noteq> (n::nat)" by blast |
13449 | 223 |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
224 |
lemma less_not_refl3: "(s::nat) < t ==> s \<noteq> t" |
13449 | 225 |
by (rule not_sym, rule less_not_refl2) |
226 |
||
227 |
lemma lessE: |
|
228 |
assumes major: "i < k" |
|
229 |
and p1: "k = Suc i ==> P" and p2: "!!j. i < j ==> k = Suc j ==> P" |
|
230 |
shows P |
|
14208 | 231 |
apply (rule major [unfolded less_def pred_nat_def, THEN tranclE], simp_all) |
13449 | 232 |
apply (erule p1) |
233 |
apply (rule p2) |
|
14208 | 234 |
apply (simp add: less_def pred_nat_def, assumption) |
13449 | 235 |
done |
236 |
||
237 |
lemma not_less0 [iff]: "~ n < (0::nat)" |
|
238 |
by (blast elim: lessE) |
|
239 |
||
240 |
lemma less_zeroE: "(n::nat) < 0 ==> R" |
|
241 |
by (rule notE, rule not_less0) |
|
242 |
||
243 |
lemma less_SucE: assumes major: "m < Suc n" |
|
244 |
and less: "m < n ==> P" and eq: "m = n ==> P" shows P |
|
245 |
apply (rule major [THEN lessE]) |
|
14208 | 246 |
apply (rule eq, blast) |
247 |
apply (rule less, blast) |
|
13449 | 248 |
done |
249 |
||
250 |
lemma less_Suc_eq: "(m < Suc n) = (m < n | m = n)" |
|
251 |
by (blast elim!: less_SucE intro: less_trans) |
|
252 |
||
253 |
lemma less_one [iff]: "(n < (1::nat)) = (n = 0)" |
|
254 |
by (simp add: less_Suc_eq) |
|
255 |
||
256 |
lemma less_Suc0 [iff]: "(n < Suc 0) = (n = 0)" |
|
257 |
by (simp add: less_Suc_eq) |
|
258 |
||
259 |
lemma Suc_mono: "m < n ==> Suc m < Suc n" |
|
260 |
by (induct n) (fast elim: less_trans lessE)+ |
|
261 |
||
262 |
text {* "Less than" is a linear ordering *} |
|
263 |
lemma less_linear: "m < n | m = n | n < (m::nat)" |
|
15251 | 264 |
apply (induct m) |
265 |
apply (induct n) |
|
13449 | 266 |
apply (rule refl [THEN disjI1, THEN disjI2]) |
267 |
apply (rule zero_less_Suc [THEN disjI1]) |
|
268 |
apply (blast intro: Suc_mono less_SucI elim: lessE) |
|
269 |
done |
|
270 |
||
14302 | 271 |
text {* "Less than" is antisymmetric, sort of *} |
272 |
lemma less_antisym: "\<lbrakk> \<not> n < m; n < Suc m \<rbrakk> \<Longrightarrow> m = n" |
|
22718 | 273 |
apply(simp only:less_Suc_eq) |
274 |
apply blast |
|
275 |
done |
|
14302 | 276 |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
277 |
lemma nat_neq_iff: "((m::nat) \<noteq> n) = (m < n | n < m)" |
13449 | 278 |
using less_linear by blast |
279 |
||
280 |
lemma nat_less_cases: assumes major: "(m::nat) < n ==> P n m" |
|
281 |
and eqCase: "m = n ==> P n m" and lessCase: "n<m ==> P n m" |
|
282 |
shows "P n m" |
|
283 |
apply (rule less_linear [THEN disjE]) |
|
284 |
apply (erule_tac [2] disjE) |
|
285 |
apply (erule lessCase) |
|
286 |
apply (erule sym [THEN eqCase]) |
|
287 |
apply (erule major) |
|
288 |
done |
|
289 |
||
290 |
||
291 |
subsubsection {* Inductive (?) properties *} |
|
292 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
293 |
lemma Suc_lessI: "m < n ==> Suc m \<noteq> n ==> Suc m < n" |
13449 | 294 |
apply (simp add: nat_neq_iff) |
295 |
apply (blast elim!: less_irrefl less_SucE elim: less_asym) |
|
296 |
done |
|
297 |
||
298 |
lemma Suc_lessD: "Suc m < n ==> m < n" |
|
299 |
apply (induct n) |
|
300 |
apply (fast intro!: lessI [THEN less_SucI] elim: less_trans lessE)+ |
|
301 |
done |
|
302 |
||
303 |
lemma Suc_lessE: assumes major: "Suc i < k" |
|
304 |
and minor: "!!j. i < j ==> k = Suc j ==> P" shows P |
|
305 |
apply (rule major [THEN lessE]) |
|
306 |
apply (erule lessI [THEN minor]) |
|
14208 | 307 |
apply (erule Suc_lessD [THEN minor], assumption) |
13449 | 308 |
done |
309 |
||
310 |
lemma Suc_less_SucD: "Suc m < Suc n ==> m < n" |
|
311 |
by (blast elim: lessE dest: Suc_lessD) |
|
4104 | 312 |
|
16635 | 313 |
lemma Suc_less_eq [iff, code]: "(Suc m < Suc n) = (m < n)" |
13449 | 314 |
apply (rule iffI) |
315 |
apply (erule Suc_less_SucD) |
|
316 |
apply (erule Suc_mono) |
|
317 |
done |
|
318 |
||
319 |
lemma less_trans_Suc: |
|
320 |
assumes le: "i < j" shows "j < k ==> Suc i < k" |
|
14208 | 321 |
apply (induct k, simp_all) |
13449 | 322 |
apply (insert le) |
323 |
apply (simp add: less_Suc_eq) |
|
324 |
apply (blast dest: Suc_lessD) |
|
325 |
done |
|
326 |
||
16635 | 327 |
lemma [code]: "((n::nat) < 0) = False" by simp |
328 |
lemma [code]: "(0 < Suc n) = True" by simp |
|
329 |
||
13449 | 330 |
text {* Can be used with @{text less_Suc_eq} to get @{term "n = m | n < m"} *} |
331 |
lemma not_less_eq: "(~ m < n) = (n < Suc m)" |
|
22718 | 332 |
by (induct m n rule: diff_induct) simp_all |
13449 | 333 |
|
334 |
text {* Complete induction, aka course-of-values induction *} |
|
335 |
lemma nat_less_induct: |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
336 |
assumes prem: "!!n. \<forall>m::nat. m < n --> P m ==> P n" shows "P n" |
22718 | 337 |
apply (induct n rule: wf_induct [OF wf_pred_nat [THEN wf_trancl]]) |
13449 | 338 |
apply (rule prem) |
14208 | 339 |
apply (unfold less_def, assumption) |
13449 | 340 |
done |
341 |
||
14131 | 342 |
lemmas less_induct = nat_less_induct [rule_format, case_names less] |
343 |
||
21243 | 344 |
|
14131 | 345 |
subsection {* Properties of "less than or equal" *} |
13449 | 346 |
|
347 |
text {* Was @{text le_eq_less_Suc}, but this orientation is more useful *} |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
348 |
lemma less_Suc_eq_le: "(m < Suc n) = (m \<le> n)" |
22718 | 349 |
unfolding le_def by (rule not_less_eq [symmetric]) |
13449 | 350 |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
351 |
lemma le_imp_less_Suc: "m \<le> n ==> m < Suc n" |
13449 | 352 |
by (rule less_Suc_eq_le [THEN iffD2]) |
353 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
354 |
lemma le0 [iff]: "(0::nat) \<le> n" |
22718 | 355 |
unfolding le_def by (rule not_less0) |
13449 | 356 |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
357 |
lemma Suc_n_not_le_n: "~ Suc n \<le> n" |
13449 | 358 |
by (simp add: le_def) |
359 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
360 |
lemma le_0_eq [iff]: "((i::nat) \<le> 0) = (i = 0)" |
13449 | 361 |
by (induct i) (simp_all add: le_def) |
362 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
363 |
lemma le_Suc_eq: "(m \<le> Suc n) = (m \<le> n | m = Suc n)" |
13449 | 364 |
by (simp del: less_Suc_eq_le add: less_Suc_eq_le [symmetric] less_Suc_eq) |
365 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
366 |
lemma le_SucE: "m \<le> Suc n ==> (m \<le> n ==> R) ==> (m = Suc n ==> R) ==> R" |
17589 | 367 |
by (drule le_Suc_eq [THEN iffD1], iprover+) |
13449 | 368 |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
369 |
lemma Suc_leI: "m < n ==> Suc(m) \<le> n" |
13449 | 370 |
apply (simp add: le_def less_Suc_eq) |
371 |
apply (blast elim!: less_irrefl less_asym) |
|
372 |
done -- {* formerly called lessD *} |
|
373 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
374 |
lemma Suc_leD: "Suc(m) \<le> n ==> m \<le> n" |
13449 | 375 |
by (simp add: le_def less_Suc_eq) |
376 |
||
377 |
text {* Stronger version of @{text Suc_leD} *} |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
378 |
lemma Suc_le_lessD: "Suc m \<le> n ==> m < n" |
13449 | 379 |
apply (simp add: le_def less_Suc_eq) |
380 |
using less_linear |
|
381 |
apply blast |
|
382 |
done |
|
383 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
384 |
lemma Suc_le_eq: "(Suc m \<le> n) = (m < n)" |
13449 | 385 |
by (blast intro: Suc_leI Suc_le_lessD) |
386 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
387 |
lemma le_SucI: "m \<le> n ==> m \<le> Suc n" |
13449 | 388 |
by (unfold le_def) (blast dest: Suc_lessD) |
389 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
390 |
lemma less_imp_le: "m < n ==> m \<le> (n::nat)" |
13449 | 391 |
by (unfold le_def) (blast elim: less_asym) |
392 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
393 |
text {* For instance, @{text "(Suc m < Suc n) = (Suc m \<le> n) = (m < n)"} *} |
13449 | 394 |
lemmas le_simps = less_imp_le less_Suc_eq_le Suc_le_eq |
395 |
||
396 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
397 |
text {* Equivalence of @{term "m \<le> n"} and @{term "m < n | m = n"} *} |
13449 | 398 |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
399 |
lemma le_imp_less_or_eq: "m \<le> n ==> m < n | m = (n::nat)" |
22718 | 400 |
unfolding le_def |
13449 | 401 |
using less_linear |
22718 | 402 |
by (blast elim: less_irrefl less_asym) |
13449 | 403 |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
404 |
lemma less_or_eq_imp_le: "m < n | m = n ==> m \<le> (n::nat)" |
22718 | 405 |
unfolding le_def |
13449 | 406 |
using less_linear |
22718 | 407 |
by (blast elim!: less_irrefl elim: less_asym) |
13449 | 408 |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
409 |
lemma le_eq_less_or_eq: "(m \<le> (n::nat)) = (m < n | m=n)" |
17589 | 410 |
by (iprover intro: less_or_eq_imp_le le_imp_less_or_eq) |
13449 | 411 |
|
22718 | 412 |
text {* Useful with @{text blast}. *} |
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
413 |
lemma eq_imp_le: "(m::nat) = n ==> m \<le> n" |
22718 | 414 |
by (rule less_or_eq_imp_le) (rule disjI2) |
13449 | 415 |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
416 |
lemma le_refl: "n \<le> (n::nat)" |
13449 | 417 |
by (simp add: le_eq_less_or_eq) |
418 |
||
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas |