src/HOL/Integ/IntDef.thy
 author nipkow Wed Aug 18 11:09:40 2004 +0200 (2004-08-18) changeset 15140 322485b816ac parent 15131 c69542757a4d child 15169 2b5da07a0b89 permissions -rw-r--r--
import -> imports
```     1 (*  Title:      IntDef.thy
```
```     2     ID:         \$Id\$
```
```     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
```
```     4     Copyright   1996  University of Cambridge
```
```     5
```
```     6 *)
```
```     7
```
```     8 header{*The Integers as Equivalence Classes over Pairs of Natural Numbers*}
```
```     9
```
```    10 theory IntDef
```
```    11 imports Equiv NatArith
```
```    12 begin
```
```    13
```
```    14 constdefs
```
```    15   intrel :: "((nat * nat) * (nat * nat)) set"
```
```    16     --{*the equivalence relation underlying the integers*}
```
```    17     "intrel == {((x,y),(u,v)) | x y u v. x+v = u+y}"
```
```    18
```
```    19 typedef (Integ)
```
```    20   int = "UNIV//intrel"
```
```    21     by (auto simp add: quotient_def)
```
```    22
```
```    23 instance int :: "{ord, zero, one, plus, times, minus}" ..
```
```    24
```
```    25 constdefs
```
```    26   int :: "nat => int"
```
```    27   "int m == Abs_Integ(intrel `` {(m,0)})"
```
```    28
```
```    29
```
```    30 defs (overloaded)
```
```    31
```
```    32   Zero_int_def:  "0 == int 0"
```
```    33   One_int_def:   "1 == int 1"
```
```    34
```
```    35   minus_int_def:
```
```    36     "- z == Abs_Integ (\<Union>(x,y) \<in> Rep_Integ z. intrel``{(y,x)})"
```
```    37
```
```    38   add_int_def:
```
```    39    "z + w ==
```
```    40        Abs_Integ (\<Union>(x,y) \<in> Rep_Integ z. \<Union>(u,v) \<in> Rep_Integ w.
```
```    41 		 intrel``{(x+u, y+v)})"
```
```    42
```
```    43   diff_int_def:  "z - (w::int) == z + (-w)"
```
```    44
```
```    45   mult_int_def:
```
```    46    "z * w ==
```
```    47        Abs_Integ (\<Union>(x,y) \<in> Rep_Integ z. \<Union>(u,v) \<in> Rep_Integ w.
```
```    48 		  intrel``{(x*u + y*v, x*v + y*u)})"
```
```    49
```
```    50   le_int_def:
```
```    51    "z \<le> (w::int) ==
```
```    52     \<exists>x y u v. x+v \<le> u+y & (x,y) \<in> Rep_Integ z & (u,v) \<in> Rep_Integ w"
```
```    53
```
```    54   less_int_def: "(z < (w::int)) == (z \<le> w & z \<noteq> w)"
```
```    55
```
```    56
```
```    57 subsection{*Construction of the Integers*}
```
```    58
```
```    59 subsubsection{*Preliminary Lemmas about the Equivalence Relation*}
```
```    60
```
```    61 lemma intrel_iff [simp]: "(((x,y),(u,v)) \<in> intrel) = (x+v = u+y)"
```
```    62 by (simp add: intrel_def)
```
```    63
```
```    64 lemma equiv_intrel: "equiv UNIV intrel"
```
```    65 by (simp add: intrel_def equiv_def refl_def sym_def trans_def)
```
```    66
```
```    67 text{*Reduces equality of equivalence classes to the @{term intrel} relation:
```
```    68   @{term "(intrel `` {x} = intrel `` {y}) = ((x,y) \<in> intrel)"} *}
```
```    69 lemmas equiv_intrel_iff = eq_equiv_class_iff [OF equiv_intrel UNIV_I UNIV_I]
```
```    70
```
```    71 declare equiv_intrel_iff [simp]
```
```    72
```
```    73
```
```    74 text{*All equivalence classes belong to set of representatives*}
```
```    75 lemma [simp]: "intrel``{(x,y)} \<in> Integ"
```
```    76 by (auto simp add: Integ_def intrel_def quotient_def)
```
```    77
```
```    78 lemma inj_on_Abs_Integ: "inj_on Abs_Integ Integ"
```
```    79 apply (rule inj_on_inverseI)
```
```    80 apply (erule Abs_Integ_inverse)
```
```    81 done
```
```    82
```
```    83 text{*This theorem reduces equality on abstractions to equality on
```
```    84       representatives:
```
```    85   @{term "\<lbrakk>x \<in> Integ; y \<in> Integ\<rbrakk> \<Longrightarrow> (Abs_Integ x = Abs_Integ y) = (x=y)"} *}
```
```    86 declare inj_on_Abs_Integ [THEN inj_on_iff, simp]
```
```    87
```
```    88 declare Abs_Integ_inverse [simp]
```
```    89
```
```    90 text{*Case analysis on the representation of an integer as an equivalence
```
```    91       class of pairs of naturals.*}
```
```    92 lemma eq_Abs_Integ [case_names Abs_Integ, cases type: int]:
```
```    93      "(!!x y. z = Abs_Integ(intrel``{(x,y)}) ==> P) ==> P"
```
```    94 apply (rule Rep_Integ [of z, unfolded Integ_def, THEN quotientE])
```
```    95 apply (drule arg_cong [where f=Abs_Integ])
```
```    96 apply (auto simp add: Rep_Integ_inverse)
```
```    97 done
```
```    98
```
```    99
```
```   100 subsubsection{*@{term int}: Embedding the Naturals into the Integers*}
```
```   101
```
```   102 lemma inj_int: "inj int"
```
```   103 by (simp add: inj_on_def int_def)
```
```   104
```
```   105 lemma int_int_eq [iff]: "(int m = int n) = (m = n)"
```
```   106 by (fast elim!: inj_int [THEN injD])
```
```   107
```
```   108
```
```   109 subsubsection{*Integer Unary Negation*}
```
```   110
```
```   111 lemma minus: "- Abs_Integ(intrel``{(x,y)}) = Abs_Integ(intrel `` {(y,x)})"
```
```   112 proof -
```
```   113   have "congruent intrel (\<lambda>(x,y). intrel``{(y,x)})"
```
```   114     by (simp add: congruent_def)
```
```   115   thus ?thesis
```
```   116     by (simp add: minus_int_def UN_equiv_class [OF equiv_intrel])
```
```   117 qed
```
```   118
```
```   119 lemma zminus_zminus: "- (- z) = (z::int)"
```
```   120 by (cases z, simp add: minus)
```
```   121
```
```   122 lemma zminus_0: "- 0 = (0::int)"
```
```   123 by (simp add: int_def Zero_int_def minus)
```
```   124
```
```   125
```
```   126 subsection{*Integer Addition*}
```
```   127
```
```   128 lemma add:
```
```   129      "Abs_Integ (intrel``{(x,y)}) + Abs_Integ (intrel``{(u,v)}) =
```
```   130       Abs_Integ (intrel``{(x+u, y+v)})"
```
```   131 proof -
```
```   132   have "congruent2 intrel intrel
```
```   133         (\<lambda>z w. (\<lambda>(x,y). (\<lambda>(u,v). intrel `` {(x+u, y+v)}) w) z)"
```
```   134     by (simp add: congruent2_def)
```
```   135   thus ?thesis
```
```   136     by (simp add: add_int_def UN_UN_split_split_eq
```
```   137                   UN_equiv_class2 [OF equiv_intrel equiv_intrel])
```
```   138 qed
```
```   139
```
```   140 lemma zminus_zadd_distrib: "- (z + w) = (- z) + (- w::int)"
```
```   141 by (cases z, cases w, simp add: minus add)
```
```   142
```
```   143 lemma zadd_commute: "(z::int) + w = w + z"
```
```   144 by (cases z, cases w, simp add: add_ac add)
```
```   145
```
```   146 lemma zadd_assoc: "((z1::int) + z2) + z3 = z1 + (z2 + z3)"
```
```   147 by (cases z1, cases z2, cases z3, simp add: add add_assoc)
```
```   148
```
```   149 (*For AC rewriting*)
```
```   150 lemma zadd_left_commute: "x + (y + z) = y + ((x + z)  ::int)"
```
```   151   apply (rule mk_left_commute [of "op +"])
```
```   152   apply (rule zadd_assoc)
```
```   153   apply (rule zadd_commute)
```
```   154   done
```
```   155
```
```   156 lemmas zadd_ac = zadd_assoc zadd_commute zadd_left_commute
```
```   157
```
```   158 lemmas zmult_ac = OrderedGroup.mult_ac
```
```   159
```
```   160 lemma zadd_int: "(int m) + (int n) = int (m + n)"
```
```   161 by (simp add: int_def add)
```
```   162
```
```   163 lemma zadd_int_left: "(int m) + (int n + z) = int (m + n) + z"
```
```   164 by (simp add: zadd_int zadd_assoc [symmetric])
```
```   165
```
```   166 lemma int_Suc: "int (Suc m) = 1 + (int m)"
```
```   167 by (simp add: One_int_def zadd_int)
```
```   168
```
```   169 (*also for the instance declaration int :: comm_monoid_add*)
```
```   170 lemma zadd_0: "(0::int) + z = z"
```
```   171 apply (simp add: Zero_int_def int_def)
```
```   172 apply (cases z, simp add: add)
```
```   173 done
```
```   174
```
```   175 lemma zadd_0_right: "z + (0::int) = z"
```
```   176 by (rule trans [OF zadd_commute zadd_0])
```
```   177
```
```   178 lemma zadd_zminus_inverse2: "(- z) + z = (0::int)"
```
```   179 by (cases z, simp add: int_def Zero_int_def minus add)
```
```   180
```
```   181
```
```   182 subsection{*Integer Multiplication*}
```
```   183
```
```   184 text{*Congruence property for multiplication*}
```
```   185 lemma mult_congruent2:
```
```   186      "congruent2 intrel intrel
```
```   187         (%p1 p2. (%(x,y). (%(u,v).
```
```   188                     intrel``{(x*u + y*v, x*v + y*u)}) p2) p1)"
```
```   189 apply (rule equiv_intrel [THEN congruent2_commuteI])
```
```   190  apply (force simp add: mult_ac, clarify)
```
```   191 apply (simp add: congruent_def mult_ac)
```
```   192 apply (rename_tac u v w x y z)
```
```   193 apply (subgoal_tac "u*y + x*y = w*y + v*y  &  u*z + x*z = w*z + v*z")
```
```   194 apply (simp add: mult_ac, arith)
```
```   195 apply (simp add: add_mult_distrib [symmetric])
```
```   196 done
```
```   197
```
```   198
```
```   199 lemma mult:
```
```   200      "Abs_Integ((intrel``{(x,y)})) * Abs_Integ((intrel``{(u,v)})) =
```
```   201       Abs_Integ(intrel `` {(x*u + y*v, x*v + y*u)})"
```
```   202 by (simp add: mult_int_def UN_UN_split_split_eq mult_congruent2
```
```   203               UN_equiv_class2 [OF equiv_intrel equiv_intrel])
```
```   204
```
```   205 lemma zmult_zminus: "(- z) * w = - (z * (w::int))"
```
```   206 by (cases z, cases w, simp add: minus mult add_ac)
```
```   207
```
```   208 lemma zmult_commute: "(z::int) * w = w * z"
```
```   209 by (cases z, cases w, simp add: mult add_ac mult_ac)
```
```   210
```
```   211 lemma zmult_assoc: "((z1::int) * z2) * z3 = z1 * (z2 * z3)"
```
```   212 by (cases z1, cases z2, cases z3, simp add: mult add_mult_distrib2 mult_ac)
```
```   213
```
```   214 lemma zadd_zmult_distrib: "((z1::int) + z2) * w = (z1 * w) + (z2 * w)"
```
```   215 by (cases z1, cases z2, cases w, simp add: add mult add_mult_distrib2 mult_ac)
```
```   216
```
```   217 lemma zadd_zmult_distrib2: "(w::int) * (z1 + z2) = (w * z1) + (w * z2)"
```
```   218 by (simp add: zmult_commute [of w] zadd_zmult_distrib)
```
```   219
```
```   220 lemma zdiff_zmult_distrib: "((z1::int) - z2) * w = (z1 * w) - (z2 * w)"
```
```   221 by (simp add: diff_int_def zadd_zmult_distrib zmult_zminus)
```
```   222
```
```   223 lemma zdiff_zmult_distrib2: "(w::int) * (z1 - z2) = (w * z1) - (w * z2)"
```
```   224 by (simp add: zmult_commute [of w] zdiff_zmult_distrib)
```
```   225
```
```   226 lemmas int_distrib =
```
```   227   zadd_zmult_distrib zadd_zmult_distrib2
```
```   228   zdiff_zmult_distrib zdiff_zmult_distrib2
```
```   229
```
```   230 lemma zmult_int: "(int m) * (int n) = int (m * n)"
```
```   231 by (simp add: int_def mult)
```
```   232
```
```   233 lemma zmult_1: "(1::int) * z = z"
```
```   234 by (cases z, simp add: One_int_def int_def mult)
```
```   235
```
```   236 lemma zmult_1_right: "z * (1::int) = z"
```
```   237 by (rule trans [OF zmult_commute zmult_1])
```
```   238
```
```   239
```
```   240 text{*The integers form a @{text comm_ring_1}*}
```
```   241 instance int :: comm_ring_1
```
```   242 proof
```
```   243   fix i j k :: int
```
```   244   show "(i + j) + k = i + (j + k)" by (simp add: zadd_assoc)
```
```   245   show "i + j = j + i" by (simp add: zadd_commute)
```
```   246   show "0 + i = i" by (rule zadd_0)
```
```   247   show "- i + i = 0" by (rule zadd_zminus_inverse2)
```
```   248   show "i - j = i + (-j)" by (simp add: diff_int_def)
```
```   249   show "(i * j) * k = i * (j * k)" by (rule zmult_assoc)
```
```   250   show "i * j = j * i" by (rule zmult_commute)
```
```   251   show "1 * i = i" by (rule zmult_1)
```
```   252   show "(i + j) * k = i * k + j * k" by (simp add: int_distrib)
```
```   253   show "0 \<noteq> (1::int)"
```
```   254     by (simp only: Zero_int_def One_int_def One_nat_def int_int_eq)
```
```   255 qed
```
```   256
```
```   257
```
```   258 subsection{*The @{text "\<le>"} Ordering*}
```
```   259
```
```   260 lemma le:
```
```   261   "(Abs_Integ(intrel``{(x,y)}) \<le> Abs_Integ(intrel``{(u,v)})) = (x+v \<le> u+y)"
```
```   262 by (force simp add: le_int_def)
```
```   263
```
```   264 lemma zle_refl: "w \<le> (w::int)"
```
```   265 by (cases w, simp add: le)
```
```   266
```
```   267 lemma zle_trans: "[| i \<le> j; j \<le> k |] ==> i \<le> (k::int)"
```
```   268 by (cases i, cases j, cases k, simp add: le)
```
```   269
```
```   270 lemma zle_anti_sym: "[| z \<le> w; w \<le> z |] ==> z = (w::int)"
```
```   271 by (cases w, cases z, simp add: le)
```
```   272
```
```   273 (* Axiom 'order_less_le' of class 'order': *)
```
```   274 lemma zless_le: "((w::int) < z) = (w \<le> z & w \<noteq> z)"
```
```   275 by (simp add: less_int_def)
```
```   276
```
```   277 instance int :: order
```
```   278   by intro_classes
```
```   279     (assumption |
```
```   280       rule zle_refl zle_trans zle_anti_sym zless_le)+
```
```   281
```
```   282 (* Axiom 'linorder_linear' of class 'linorder': *)
```
```   283 lemma zle_linear: "(z::int) \<le> w | w \<le> z"
```
```   284 by (cases z, cases w) (simp add: le linorder_linear)
```
```   285
```
```   286 instance int :: linorder
```
```   287   by intro_classes (rule zle_linear)
```
```   288
```
```   289
```
```   290 lemmas zless_linear = linorder_less_linear [where 'a = int]
```
```   291
```
```   292
```
```   293 lemma int_eq_0_conv [simp]: "(int n = 0) = (n = 0)"
```
```   294 by (simp add: Zero_int_def)
```
```   295
```
```   296 lemma zless_int [simp]: "(int m < int n) = (m<n)"
```
```   297 by (simp add: le add int_def linorder_not_le [symmetric])
```
```   298
```
```   299 lemma int_less_0_conv [simp]: "~ (int k < 0)"
```
```   300 by (simp add: Zero_int_def)
```
```   301
```
```   302 lemma zero_less_int_conv [simp]: "(0 < int n) = (0 < n)"
```
```   303 by (simp add: Zero_int_def)
```
```   304
```
```   305 lemma int_0_less_1: "0 < (1::int)"
```
```   306 by (simp only: Zero_int_def One_int_def One_nat_def zless_int)
```
```   307
```
```   308 lemma int_0_neq_1 [simp]: "0 \<noteq> (1::int)"
```
```   309 by (simp only: Zero_int_def One_int_def One_nat_def int_int_eq)
```
```   310
```
```   311 lemma zle_int [simp]: "(int m \<le> int n) = (m\<le>n)"
```
```   312 by (simp add: linorder_not_less [symmetric])
```
```   313
```
```   314 lemma zero_zle_int [simp]: "(0 \<le> int n)"
```
```   315 by (simp add: Zero_int_def)
```
```   316
```
```   317 lemma int_le_0_conv [simp]: "(int n \<le> 0) = (n = 0)"
```
```   318 by (simp add: Zero_int_def)
```
```   319
```
```   320 lemma int_0 [simp]: "int 0 = (0::int)"
```
```   321 by (simp add: Zero_int_def)
```
```   322
```
```   323 lemma int_1 [simp]: "int 1 = 1"
```
```   324 by (simp add: One_int_def)
```
```   325
```
```   326 lemma int_Suc0_eq_1: "int (Suc 0) = 1"
```
```   327 by (simp add: One_int_def One_nat_def)
```
```   328
```
```   329
```
```   330 subsection{*Monotonicity results*}
```
```   331
```
```   332 lemma zadd_left_mono: "i \<le> j ==> k + i \<le> k + (j::int)"
```
```   333 by (cases i, cases j, cases k, simp add: le add)
```
```   334
```
```   335 lemma zadd_strict_right_mono: "i < j ==> i + k < j + (k::int)"
```
```   336 apply (cases i, cases j, cases k)
```
```   337 apply (simp add: linorder_not_le [where 'a = int, symmetric]
```
```   338                  linorder_not_le [where 'a = nat]  le add)
```
```   339 done
```
```   340
```
```   341 lemma zadd_zless_mono: "[| w'<w; z'\<le>z |] ==> w' + z' < w + (z::int)"
```
```   342 by (rule order_less_le_trans [OF zadd_strict_right_mono zadd_left_mono])
```
```   343
```
```   344
```
```   345 subsection{*Strict Monotonicity of Multiplication*}
```
```   346
```
```   347 text{*strict, in 1st argument; proof is by induction on k>0*}
```
```   348 lemma zmult_zless_mono2_lemma [rule_format]:
```
```   349      "i<j ==> 0<k --> int k * i < int k * j"
```
```   350 apply (induct_tac "k", simp)
```
```   351 apply (simp add: int_Suc)
```
```   352 apply (case_tac "n=0")
```
```   353 apply (simp_all add: zadd_zmult_distrib int_Suc0_eq_1 order_le_less)
```
```   354 apply (simp add: zadd_zless_mono int_Suc0_eq_1 order_le_less)
```
```   355 done
```
```   356
```
```   357 lemma zero_le_imp_eq_int: "0 \<le> k ==> \<exists>n. k = int n"
```
```   358 apply (cases k)
```
```   359 apply (auto simp add: le add int_def Zero_int_def)
```
```   360 apply (rule_tac x="x-y" in exI, simp)
```
```   361 done
```
```   362
```
```   363 lemma zmult_zless_mono2: "[| i<j;  (0::int) < k |] ==> k*i < k*j"
```
```   364 apply (frule order_less_imp_le [THEN zero_le_imp_eq_int])
```
```   365 apply (auto simp add: zmult_zless_mono2_lemma)
```
```   366 done
```
```   367
```
```   368
```
```   369 defs (overloaded)
```
```   370     zabs_def:  "abs(i::int) == if i < 0 then -i else i"
```
```   371
```
```   372
```
```   373 text{*The integers form an ordered @{text comm_ring_1}*}
```
```   374 instance int :: ordered_idom
```
```   375 proof
```
```   376   fix i j k :: int
```
```   377   show "i \<le> j ==> k + i \<le> k + j" by (rule zadd_left_mono)
```
```   378   show "i < j ==> 0 < k ==> k * i < k * j" by (rule zmult_zless_mono2)
```
```   379   show "\<bar>i\<bar> = (if i < 0 then -i else i)" by (simp only: zabs_def)
```
```   380 qed
```
```   381
```
```   382
```
```   383 lemma zless_imp_add1_zle: "w<z ==> w + (1::int) \<le> z"
```
```   384 apply (cases w, cases z)
```
```   385 apply (simp add: linorder_not_le [symmetric] le int_def add One_int_def)
```
```   386 done
```
```   387
```
```   388 subsection{*Magnitide of an Integer, as a Natural Number: @{term nat}*}
```
```   389
```
```   390 constdefs
```
```   391    nat  :: "int => nat"
```
```   392     "nat z == contents (\<Union>(x,y) \<in> Rep_Integ z. { x-y })"
```
```   393
```
```   394 lemma nat: "nat (Abs_Integ (intrel``{(x,y)})) = x-y"
```
```   395 proof -
```
```   396   have "congruent intrel (\<lambda>(x,y). {x-y})"
```
```   397     by (simp add: congruent_def, arith)
```
```   398   thus ?thesis
```
```   399     by (simp add: nat_def UN_equiv_class [OF equiv_intrel])
```
```   400 qed
```
```   401
```
```   402 lemma nat_int [simp]: "nat(int n) = n"
```
```   403 by (simp add: nat int_def)
```
```   404
```
```   405 lemma nat_zero [simp]: "nat 0 = 0"
```
```   406 by (simp only: Zero_int_def nat_int)
```
```   407
```
```   408 lemma int_nat_eq [simp]: "int (nat z) = (if 0 \<le> z then z else 0)"
```
```   409 by (cases z, simp add: nat le int_def Zero_int_def)
```
```   410
```
```   411 corollary nat_0_le: "0 \<le> z ==> int (nat z) = z"
```
```   412 apply simp
```
```   413 done
```
```   414
```
```   415 lemma nat_le_0 [simp]: "z \<le> 0 ==> nat z = 0"
```
```   416 by (cases z, simp add: nat le int_def Zero_int_def)
```
```   417
```
```   418 lemma nat_le_eq_zle: "0 < w | 0 \<le> z ==> (nat w \<le> nat z) = (w\<le>z)"
```
```   419 apply (cases w, cases z)
```
```   420 apply (simp add: nat le linorder_not_le [symmetric] int_def Zero_int_def, arith)
```
```   421 done
```
```   422
```
```   423 text{*An alternative condition is @{term "0 \<le> w"} *}
```
```   424 corollary nat_mono_iff: "0 < z ==> (nat w < nat z) = (w < z)"
```
```   425 by (simp add: nat_le_eq_zle linorder_not_le [symmetric])
```
```   426
```
```   427 corollary nat_less_eq_zless: "0 \<le> w ==> (nat w < nat z) = (w<z)"
```
```   428 by (simp add: nat_le_eq_zle linorder_not_le [symmetric])
```
```   429
```
```   430 lemma zless_nat_conj: "(nat w < nat z) = (0 < z & w < z)"
```
```   431 apply (cases w, cases z)
```
```   432 apply (simp add: nat le int_def Zero_int_def linorder_not_le [symmetric], arith)
```
```   433 done
```
```   434
```
```   435 lemma nonneg_eq_int: "[| 0 \<le> z;  !!m. z = int m ==> P |] ==> P"
```
```   436 by (blast dest: nat_0_le sym)
```
```   437
```
```   438 lemma nat_eq_iff: "(nat w = m) = (if 0 \<le> w then w = int m else m=0)"
```
```   439 by (cases w, simp add: nat le int_def Zero_int_def, arith)
```
```   440
```
```   441 corollary nat_eq_iff2: "(m = nat w) = (if 0 \<le> w then w = int m else m=0)"
```
```   442 by (simp only: eq_commute [of m] nat_eq_iff)
```
```   443
```
```   444 lemma nat_less_iff: "0 \<le> w ==> (nat w < m) = (w < int m)"
```
```   445 apply (cases w)
```
```   446 apply (simp add: nat le int_def Zero_int_def linorder_not_le [symmetric], arith)
```
```   447 done
```
```   448
```
```   449 lemma int_eq_iff: "(int m = z) = (m = nat z & 0 \<le> z)"
```
```   450 by (auto simp add: nat_eq_iff2)
```
```   451
```
```   452 lemma zero_less_nat_eq [simp]: "(0 < nat z) = (0 < z)"
```
```   453 by (insert zless_nat_conj [of 0], auto)
```
```   454
```
```   455
```
```   456 lemma nat_add_distrib:
```
```   457      "[| (0::int) \<le> z;  0 \<le> z' |] ==> nat (z+z') = nat z + nat z'"
```
```   458 by (cases z, cases z', simp add: nat add le int_def Zero_int_def)
```
```   459
```
```   460 lemma nat_diff_distrib:
```
```   461      "[| (0::int) \<le> z';  z' \<le> z |] ==> nat (z-z') = nat z - nat z'"
```
```   462 by (cases z, cases z',
```
```   463     simp add: nat add minus diff_minus le int_def Zero_int_def)
```
```   464
```
```   465
```
```   466 lemma nat_zminus_int [simp]: "nat (- (int n)) = 0"
```
```   467 by (simp add: int_def minus nat Zero_int_def)
```
```   468
```
```   469 lemma zless_nat_eq_int_zless: "(m < nat z) = (int m < z)"
```
```   470 by (cases z, simp add: nat le int_def  linorder_not_le [symmetric], arith)
```
```   471
```
```   472
```
```   473 subsection{*Lemmas about the Function @{term int} and Orderings*}
```
```   474
```
```   475 lemma negative_zless_0: "- (int (Suc n)) < 0"
```
```   476 by (simp add: order_less_le)
```
```   477
```
```   478 lemma negative_zless [iff]: "- (int (Suc n)) < int m"
```
```   479 by (rule negative_zless_0 [THEN order_less_le_trans], simp)
```
```   480
```
```   481 lemma negative_zle_0: "- int n \<le> 0"
```
```   482 by (simp add: minus_le_iff)
```
```   483
```
```   484 lemma negative_zle [iff]: "- int n \<le> int m"
```
```   485 by (rule order_trans [OF negative_zle_0 zero_zle_int])
```
```   486
```
```   487 lemma not_zle_0_negative [simp]: "~ (0 \<le> - (int (Suc n)))"
```
```   488 by (subst le_minus_iff, simp)
```
```   489
```
```   490 lemma int_zle_neg: "(int n \<le> - int m) = (n = 0 & m = 0)"
```
```   491 by (simp add: int_def le minus Zero_int_def)
```
```   492
```
```   493 lemma not_int_zless_negative [simp]: "~ (int n < - int m)"
```
```   494 by (simp add: linorder_not_less)
```
```   495
```
```   496 lemma negative_eq_positive [simp]: "(- int n = int m) = (n = 0 & m = 0)"
```
```   497 by (force simp add: order_eq_iff [of "- int n"] int_zle_neg)
```
```   498
```
```   499 lemma zle_iff_zadd: "(w \<le> z) = (\<exists>n. z = w + int n)"
```
```   500 apply (cases w, cases z)
```
```   501 apply (auto simp add: le add int_def)
```
```   502 apply (rename_tac a b c d)
```
```   503 apply (rule_tac x="c+b - (a+d)" in exI)
```
```   504 apply arith
```
```   505 done
```
```   506
```
```   507 lemma abs_int_eq [simp]: "abs (int m) = int m"
```
```   508 by (simp add: abs_if)
```
```   509
```
```   510 text{*This version is proved for all ordered rings, not just integers!
```
```   511       It is proved here because attribute @{text arith_split} is not available
```
```   512       in theory @{text Ring_and_Field}.
```
```   513       But is it really better than just rewriting with @{text abs_if}?*}
```
```   514 lemma abs_split [arith_split]:
```
```   515      "P(abs(a::'a::ordered_idom)) = ((0 \<le> a --> P a) & (a < 0 --> P(-a)))"
```
```   516 by (force dest: order_less_le_trans simp add: abs_if linorder_not_less)
```
```   517
```
```   518
```
```   519
```
```   520 subsection{*The Constants @{term neg} and @{term iszero}*}
```
```   521
```
```   522 constdefs
```
```   523
```
```   524   neg   :: "'a::ordered_idom => bool"
```
```   525   "neg(Z) == Z < 0"
```
```   526
```
```   527   (*For simplifying equalities*)
```
```   528   iszero :: "'a::comm_semiring_1_cancel => bool"
```
```   529   "iszero z == z = (0)"
```
```   530
```
```   531
```
```   532 lemma not_neg_int [simp]: "~ neg(int n)"
```
```   533 by (simp add: neg_def)
```
```   534
```
```   535 lemma neg_zminus_int [simp]: "neg(- (int (Suc n)))"
```
```   536 by (simp add: neg_def neg_less_0_iff_less)
```
```   537
```
```   538 lemmas neg_eq_less_0 = neg_def
```
```   539
```
```   540 lemma not_neg_eq_ge_0: "(~neg x) = (0 \<le> x)"
```
```   541 by (simp add: neg_def linorder_not_less)
```
```   542
```
```   543
```
```   544 subsection{*To simplify inequalities when Numeral1 can get simplified to 1*}
```
```   545
```
```   546 lemma not_neg_0: "~ neg 0"
```
```   547 by (simp add: One_int_def neg_def)
```
```   548
```
```   549 lemma not_neg_1: "~ neg 1"
```
```   550 by (simp add: neg_def linorder_not_less zero_le_one)
```
```   551
```
```   552 lemma iszero_0: "iszero 0"
```
```   553 by (simp add: iszero_def)
```
```   554
```
```   555 lemma not_iszero_1: "~ iszero 1"
```
```   556 by (simp add: iszero_def eq_commute)
```
```   557
```
```   558 lemma neg_nat: "neg z ==> nat z = 0"
```
```   559 by (simp add: neg_def order_less_imp_le)
```
```   560
```
```   561 lemma not_neg_nat: "~ neg z ==> int (nat z) = z"
```
```   562 by (simp add: linorder_not_less neg_def)
```
```   563
```
```   564
```
```   565 subsection{*Embedding of the Naturals into any @{text
```
```   566 comm_semiring_1_cancel}: @{term of_nat}*}
```
```   567
```
```   568 consts of_nat :: "nat => 'a::comm_semiring_1_cancel"
```
```   569
```
```   570 primrec
```
```   571   of_nat_0:   "of_nat 0 = 0"
```
```   572   of_nat_Suc: "of_nat (Suc m) = of_nat m + 1"
```
```   573
```
```   574 lemma of_nat_1 [simp]: "of_nat 1 = 1"
```
```   575 by simp
```
```   576
```
```   577 lemma of_nat_add [simp]: "of_nat (m+n) = of_nat m + of_nat n"
```
```   578 apply (induct m)
```
```   579 apply (simp_all add: add_ac)
```
```   580 done
```
```   581
```
```   582 lemma of_nat_mult [simp]: "of_nat (m*n) = of_nat m * of_nat n"
```
```   583 apply (induct m)
```
```   584 apply (simp_all add: mult_ac add_ac right_distrib)
```
```   585 done
```
```   586
```
```   587 lemma zero_le_imp_of_nat: "0 \<le> (of_nat m::'a::ordered_semidom)"
```
```   588 apply (induct m, simp_all)
```
```   589 apply (erule order_trans)
```
```   590 apply (rule less_add_one [THEN order_less_imp_le])
```
```   591 done
```
```   592
```
```   593 lemma less_imp_of_nat_less:
```
```   594      "m < n ==> of_nat m < (of_nat n::'a::ordered_semidom)"
```
```   595 apply (induct m n rule: diff_induct, simp_all)
```
```   596 apply (insert add_le_less_mono [OF zero_le_imp_of_nat zero_less_one], force)
```
```   597 done
```
```   598
```
```   599 lemma of_nat_less_imp_less:
```
```   600      "of_nat m < (of_nat n::'a::ordered_semidom) ==> m < n"
```
```   601 apply (induct m n rule: diff_induct, simp_all)
```
```   602 apply (insert zero_le_imp_of_nat)
```
```   603 apply (force simp add: linorder_not_less [symmetric])
```
```   604 done
```
```   605
```
```   606 lemma of_nat_less_iff [simp]:
```
```   607      "(of_nat m < (of_nat n::'a::ordered_semidom)) = (m<n)"
```
```   608 by (blast intro: of_nat_less_imp_less less_imp_of_nat_less)
```
```   609
```
```   610 text{*Special cases where either operand is zero*}
```
```   611 declare of_nat_less_iff [of 0, simplified, simp]
```
```   612 declare of_nat_less_iff [of _ 0, simplified, simp]
```
```   613
```
```   614 lemma of_nat_le_iff [simp]:
```
```   615      "(of_nat m \<le> (of_nat n::'a::ordered_semidom)) = (m \<le> n)"
```
```   616 by (simp add: linorder_not_less [symmetric])
```
```   617
```
```   618 text{*Special cases where either operand is zero*}
```
```   619 declare of_nat_le_iff [of 0, simplified, simp]
```
```   620 declare of_nat_le_iff [of _ 0, simplified, simp]
```
```   621
```
```   622 text{*The ordering on the @{text comm_semiring_1_cancel} is necessary
```
```   623 to exclude the possibility of a finite field, which indeed wraps back to
```
```   624 zero.*}
```
```   625 lemma of_nat_eq_iff [simp]:
```
```   626      "(of_nat m = (of_nat n::'a::ordered_semidom)) = (m = n)"
```
```   627 by (simp add: order_eq_iff)
```
```   628
```
```   629 text{*Special cases where either operand is zero*}
```
```   630 declare of_nat_eq_iff [of 0, simplified, simp]
```
```   631 declare of_nat_eq_iff [of _ 0, simplified, simp]
```
```   632
```
```   633 lemma of_nat_diff [simp]:
```
```   634      "n \<le> m ==> of_nat (m - n) = of_nat m - (of_nat n :: 'a::comm_ring_1)"
```
```   635 by (simp del: of_nat_add
```
```   636 	 add: compare_rls of_nat_add [symmetric] split add: nat_diff_split)
```
```   637
```
```   638
```
```   639 subsection{*The Set of Natural Numbers*}
```
```   640
```
```   641 constdefs
```
```   642    Nats  :: "'a::comm_semiring_1_cancel set"
```
```   643     "Nats == range of_nat"
```
```   644
```
```   645 syntax (xsymbols)    Nats :: "'a set"   ("\<nat>")
```
```   646
```
```   647 lemma of_nat_in_Nats [simp]: "of_nat n \<in> Nats"
```
```   648 by (simp add: Nats_def)
```
```   649
```
```   650 lemma Nats_0 [simp]: "0 \<in> Nats"
```
```   651 apply (simp add: Nats_def)
```
```   652 apply (rule range_eqI)
```
```   653 apply (rule of_nat_0 [symmetric])
```
```   654 done
```
```   655
```
```   656 lemma Nats_1 [simp]: "1 \<in> Nats"
```
```   657 apply (simp add: Nats_def)
```
```   658 apply (rule range_eqI)
```
```   659 apply (rule of_nat_1 [symmetric])
```
```   660 done
```
```   661
```
```   662 lemma Nats_add [simp]: "[|a \<in> Nats; b \<in> Nats|] ==> a+b \<in> Nats"
```
```   663 apply (auto simp add: Nats_def)
```
```   664 apply (rule range_eqI)
```
```   665 apply (rule of_nat_add [symmetric])
```
```   666 done
```
```   667
```
```   668 lemma Nats_mult [simp]: "[|a \<in> Nats; b \<in> Nats|] ==> a*b \<in> Nats"
```
```   669 apply (auto simp add: Nats_def)
```
```   670 apply (rule range_eqI)
```
```   671 apply (rule of_nat_mult [symmetric])
```
```   672 done
```
```   673
```
```   674 text{*Agreement with the specific embedding for the integers*}
```
```   675 lemma int_eq_of_nat: "int = (of_nat :: nat => int)"
```
```   676 proof
```
```   677   fix n
```
```   678   show "int n = of_nat n"  by (induct n, simp_all add: int_Suc add_ac)
```
```   679 qed
```
```   680
```
```   681 lemma of_nat_eq_id [simp]: "of_nat = (id :: nat => nat)"
```
```   682 proof
```
```   683   fix n
```
```   684   show "of_nat n = id n"  by (induct n, simp_all)
```
```   685 qed
```
```   686
```
```   687
```
```   688 subsection{*Embedding of the Integers into any @{text comm_ring_1}:
```
```   689 @{term of_int}*}
```
```   690
```
```   691 constdefs
```
```   692    of_int :: "int => 'a::comm_ring_1"
```
```   693    "of_int z == contents (\<Union>(i,j) \<in> Rep_Integ z. { of_nat i - of_nat j })"
```
```   694
```
```   695
```
```   696 lemma of_int: "of_int (Abs_Integ (intrel `` {(i,j)})) = of_nat i - of_nat j"
```
```   697 proof -
```
```   698   have "congruent intrel (\<lambda>(i,j). { of_nat i - (of_nat j :: 'a) })"
```
```   699     by (simp add: congruent_def compare_rls of_nat_add [symmetric]
```
```   700             del: of_nat_add)
```
```   701   thus ?thesis
```
```   702     by (simp add: of_int_def UN_equiv_class [OF equiv_intrel])
```
```   703 qed
```
```   704
```
```   705 lemma of_int_0 [simp]: "of_int 0 = 0"
```
```   706 by (simp add: of_int Zero_int_def int_def)
```
```   707
```
```   708 lemma of_int_1 [simp]: "of_int 1 = 1"
```
```   709 by (simp add: of_int One_int_def int_def)
```
```   710
```
```   711 lemma of_int_add [simp]: "of_int (w+z) = of_int w + of_int z"
```
```   712 by (cases w, cases z, simp add: compare_rls of_int add)
```
```   713
```
```   714 lemma of_int_minus [simp]: "of_int (-z) = - (of_int z)"
```
```   715 by (cases z, simp add: compare_rls of_int minus)
```
```   716
```
```   717 lemma of_int_diff [simp]: "of_int (w-z) = of_int w - of_int z"
```
```   718 by (simp add: diff_minus)
```
```   719
```
```   720 lemma of_int_mult [simp]: "of_int (w*z) = of_int w * of_int z"
```
```   721 apply (cases w, cases z)
```
```   722 apply (simp add: compare_rls of_int left_diff_distrib right_diff_distrib
```
```   723                  mult add_ac)
```
```   724 done
```
```   725
```
```   726 lemma of_int_le_iff [simp]:
```
```   727      "(of_int w \<le> (of_int z::'a::ordered_idom)) = (w \<le> z)"
```
```   728 apply (cases w)
```
```   729 apply (cases z)
```
```   730 apply (simp add: compare_rls of_int le diff_int_def add minus
```
```   731                  of_nat_add [symmetric]   del: of_nat_add)
```
```   732 done
```
```   733
```
```   734 text{*Special cases where either operand is zero*}
```
```   735 declare of_int_le_iff [of 0, simplified, simp]
```
```   736 declare of_int_le_iff [of _ 0, simplified, simp]
```
```   737
```
```   738 lemma of_int_less_iff [simp]:
```
```   739      "(of_int w < (of_int z::'a::ordered_idom)) = (w < z)"
```
```   740 by (simp add: linorder_not_le [symmetric])
```
```   741
```
```   742 text{*Special cases where either operand is zero*}
```
```   743 declare of_int_less_iff [of 0, simplified, simp]
```
```   744 declare of_int_less_iff [of _ 0, simplified, simp]
```
```   745
```
```   746 text{*The ordering on the @{text comm_ring_1} is necessary.
```
```   747  See @{text of_nat_eq_iff} above.*}
```
```   748 lemma of_int_eq_iff [simp]:
```
```   749      "(of_int w = (of_int z::'a::ordered_idom)) = (w = z)"
```
```   750 by (simp add: order_eq_iff)
```
```   751
```
```   752 text{*Special cases where either operand is zero*}
```
```   753 declare of_int_eq_iff [of 0, simplified, simp]
```
```   754 declare of_int_eq_iff [of _ 0, simplified, simp]
```
```   755
```
```   756 lemma of_int_eq_id [simp]: "of_int = (id :: int => int)"
```
```   757 proof
```
```   758  fix z
```
```   759  show "of_int z = id z"
```
```   760   by (cases z,
```
```   761       simp add: of_int add minus int_eq_of_nat [symmetric] int_def diff_minus)
```
```   762 qed
```
```   763
```
```   764
```
```   765 subsection{*The Set of Integers*}
```
```   766
```
```   767 constdefs
```
```   768    Ints  :: "'a::comm_ring_1 set"
```
```   769     "Ints == range of_int"
```
```   770
```
```   771
```
```   772 syntax (xsymbols)
```
```   773   Ints      :: "'a set"                   ("\<int>")
```
```   774
```
```   775 lemma Ints_0 [simp]: "0 \<in> Ints"
```
```   776 apply (simp add: Ints_def)
```
```   777 apply (rule range_eqI)
```
```   778 apply (rule of_int_0 [symmetric])
```
```   779 done
```
```   780
```
```   781 lemma Ints_1 [simp]: "1 \<in> Ints"
```
```   782 apply (simp add: Ints_def)
```
```   783 apply (rule range_eqI)
```
```   784 apply (rule of_int_1 [symmetric])
```
```   785 done
```
```   786
```
```   787 lemma Ints_add [simp]: "[|a \<in> Ints; b \<in> Ints|] ==> a+b \<in> Ints"
```
```   788 apply (auto simp add: Ints_def)
```
```   789 apply (rule range_eqI)
```
```   790 apply (rule of_int_add [symmetric])
```
```   791 done
```
```   792
```
```   793 lemma Ints_minus [simp]: "a \<in> Ints ==> -a \<in> Ints"
```
```   794 apply (auto simp add: Ints_def)
```
```   795 apply (rule range_eqI)
```
```   796 apply (rule of_int_minus [symmetric])
```
```   797 done
```
```   798
```
```   799 lemma Ints_diff [simp]: "[|a \<in> Ints; b \<in> Ints|] ==> a-b \<in> Ints"
```
```   800 apply (auto simp add: Ints_def)
```
```   801 apply (rule range_eqI)
```
```   802 apply (rule of_int_diff [symmetric])
```
```   803 done
```
```   804
```
```   805 lemma Ints_mult [simp]: "[|a \<in> Ints; b \<in> Ints|] ==> a*b \<in> Ints"
```
```   806 apply (auto simp add: Ints_def)
```
```   807 apply (rule range_eqI)
```
```   808 apply (rule of_int_mult [symmetric])
```
```   809 done
```
```   810
```
```   811 text{*Collapse nested embeddings*}
```
```   812 lemma of_int_of_nat_eq [simp]: "of_int (of_nat n) = of_nat n"
```
```   813 by (induct n, auto)
```
```   814
```
```   815 lemma of_int_int_eq [simp]: "of_int (int n) = of_nat n"
```
```   816 by (simp add: int_eq_of_nat)
```
```   817
```
```   818 lemma Ints_cases [case_names of_int, cases set: Ints]:
```
```   819   "q \<in> \<int> ==> (!!z. q = of_int z ==> C) ==> C"
```
```   820 proof (simp add: Ints_def)
```
```   821   assume "!!z. q = of_int z ==> C"
```
```   822   assume "q \<in> range of_int" thus C ..
```
```   823 qed
```
```   824
```
```   825 lemma Ints_induct [case_names of_int, induct set: Ints]:
```
```   826   "q \<in> \<int> ==> (!!z. P (of_int z)) ==> P q"
```
```   827   by (rule Ints_cases) auto
```
```   828
```
```   829
```
```   830 (* int (Suc n) = 1 + int n *)
```
```   831 declare int_Suc [simp]
```
```   832
```
```   833 text{*Simplification of @{term "x-y < 0"}, etc.*}
```
```   834 declare less_iff_diff_less_0 [symmetric, simp]
```
```   835 declare eq_iff_diff_eq_0 [symmetric, simp]
```
```   836 declare le_iff_diff_le_0 [symmetric, simp]
```
```   837
```
```   838
```
```   839 subsection{*More Properties of @{term setsum} and  @{term setprod}*}
```
```   840
```
```   841 text{*By Jeremy Avigad*}
```
```   842
```
```   843
```
```   844 lemma setsum_of_nat: "of_nat (setsum f A) = setsum (of_nat \<circ> f) A"
```
```   845   apply (case_tac "finite A")
```
```   846   apply (erule finite_induct, auto)
```
```   847   apply (simp add: setsum_def)
```
```   848   done
```
```   849
```
```   850 lemma setsum_of_int: "of_int (setsum f A) = setsum (of_int \<circ> f) A"
```
```   851   apply (case_tac "finite A")
```
```   852   apply (erule finite_induct, auto)
```
```   853   apply (simp add: setsum_def)
```
```   854   done
```
```   855
```
```   856 lemma int_setsum: "int (setsum f A) = setsum (int \<circ> f) A"
```
```   857   by (subst int_eq_of_nat, rule setsum_of_nat)
```
```   858
```
```   859 lemma setprod_of_nat: "of_nat (setprod f A) = setprod (of_nat \<circ> f) A"
```
```   860   apply (case_tac "finite A")
```
```   861   apply (erule finite_induct, auto)
```
```   862   apply (simp add: setprod_def)
```
```   863   done
```
```   864
```
```   865 lemma setprod_of_int: "of_int (setprod f A) = setprod (of_int \<circ> f) A"
```
```   866   apply (case_tac "finite A")
```
```   867   apply (erule finite_induct, auto)
```
```   868   apply (simp add: setprod_def)
```
```   869   done
```
```   870
```
```   871 lemma int_setprod: "int (setprod f A) = setprod (int \<circ> f) A"
```
```   872   by (subst int_eq_of_nat, rule setprod_of_nat)
```
```   873
```
```   874 lemma setsum_constant [simp]: "finite A ==> (\<Sum>x \<in> A. y) = of_nat(card A) * y"
```
```   875   apply (erule finite_induct)
```
```   876   apply (auto simp add: ring_distrib add_ac)
```
```   877   done
```
```   878
```
```   879 lemma setprod_nonzero_nat:
```
```   880     "finite A ==> (\<forall>x \<in> A. f x \<noteq> (0::nat)) ==> setprod f A \<noteq> 0"
```
```   881   by (rule setprod_nonzero, auto)
```
```   882
```
```   883 lemma setprod_zero_eq_nat:
```
```   884     "finite A ==> (setprod f A = (0::nat)) = (\<exists>x \<in> A. f x = 0)"
```
```   885   by (rule setprod_zero_eq, auto)
```
```   886
```
```   887 lemma setprod_nonzero_int:
```
```   888     "finite A ==> (\<forall>x \<in> A. f x \<noteq> (0::int)) ==> setprod f A \<noteq> 0"
```
```   889   by (rule setprod_nonzero, auto)
```
```   890
```
```   891 lemma setprod_zero_eq_int:
```
```   892     "finite A ==> (setprod f A = (0::int)) = (\<exists>x \<in> A. f x = 0)"
```
```   893   by (rule setprod_zero_eq, auto)
```
```   894
```
```   895
```
```   896 text{*Now we replace the case analysis rule by a more conventional one:
```
```   897 whether an integer is negative or not.*}
```
```   898
```
```   899 lemma zless_iff_Suc_zadd:
```
```   900     "(w < z) = (\<exists>n. z = w + int(Suc n))"
```
```   901 apply (cases z, cases w)
```
```   902 apply (auto simp add: le add int_def linorder_not_le [symmetric])
```
```   903 apply (rename_tac a b c d)
```
```   904 apply (rule_tac x="a+d - Suc(c+b)" in exI)
```
```   905 apply arith
```
```   906 done
```
```   907
```
```   908 lemma negD: "x<0 ==> \<exists>n. x = - (int (Suc n))"
```
```   909 apply (cases x)
```
```   910 apply (auto simp add: le minus Zero_int_def int_def order_less_le)
```
```   911 apply (rule_tac x="y - Suc x" in exI, arith)
```
```   912 done
```
```   913
```
```   914 theorem int_cases [cases type: int, case_names nonneg neg]:
```
```   915      "[|!! n. z = int n ==> P;  !! n. z =  - (int (Suc n)) ==> P |] ==> P"
```
```   916 apply (case_tac "z < 0", blast dest!: negD)
```
```   917 apply (simp add: linorder_not_less)
```
```   918 apply (blast dest: nat_0_le [THEN sym])
```
```   919 done
```
```   920
```
```   921 theorem int_induct [induct type: int, case_names nonneg neg]:
```
```   922      "[|!! n. P (int n);  !!n. P (- (int (Suc n))) |] ==> P z"
```
```   923   by (cases z) auto
```
```   924
```
```   925
```
```   926 lemma of_nat_nat: "0 \<le> z ==> of_nat (nat z) = of_int z"
```
```   927 apply (cases z)
```
```   928 apply (simp_all add: not_zle_0_negative del: int_Suc)
```
```   929 done
```
```   930
```
```   931
```
```   932 (*Legacy ML bindings, but no longer the structure Int.*)
```
```   933 ML
```
```   934 {*
```
```   935 val zabs_def = thm "zabs_def"
```
```   936
```
```   937 val int_0 = thm "int_0";
```
```   938 val int_1 = thm "int_1";
```
```   939 val int_Suc0_eq_1 = thm "int_Suc0_eq_1";
```
```   940 val neg_eq_less_0 = thm "neg_eq_less_0";
```
```   941 val not_neg_eq_ge_0 = thm "not_neg_eq_ge_0";
```
```   942 val not_neg_0 = thm "not_neg_0";
```
```   943 val not_neg_1 = thm "not_neg_1";
```
```   944 val iszero_0 = thm "iszero_0";
```
```   945 val not_iszero_1 = thm "not_iszero_1";
```
```   946 val int_0_less_1 = thm "int_0_less_1";
```
```   947 val int_0_neq_1 = thm "int_0_neq_1";
```
```   948 val negative_zless = thm "negative_zless";
```
```   949 val negative_zle = thm "negative_zle";
```
```   950 val not_zle_0_negative = thm "not_zle_0_negative";
```
```   951 val not_int_zless_negative = thm "not_int_zless_negative";
```
```   952 val negative_eq_positive = thm "negative_eq_positive";
```
```   953 val zle_iff_zadd = thm "zle_iff_zadd";
```
```   954 val abs_int_eq = thm "abs_int_eq";
```
```   955 val abs_split = thm"abs_split";
```
```   956 val nat_int = thm "nat_int";
```
```   957 val nat_zminus_int = thm "nat_zminus_int";
```
```   958 val nat_zero = thm "nat_zero";
```
```   959 val not_neg_nat = thm "not_neg_nat";
```
```   960 val neg_nat = thm "neg_nat";
```
```   961 val zless_nat_eq_int_zless = thm "zless_nat_eq_int_zless";
```
```   962 val nat_0_le = thm "nat_0_le";
```
```   963 val nat_le_0 = thm "nat_le_0";
```
```   964 val zless_nat_conj = thm "zless_nat_conj";
```
```   965 val int_cases = thm "int_cases";
```
```   966
```
```   967 val int_def = thm "int_def";
```
```   968 val Zero_int_def = thm "Zero_int_def";
```
```   969 val One_int_def = thm "One_int_def";
```
```   970 val diff_int_def = thm "diff_int_def";
```
```   971
```
```   972 val inj_int = thm "inj_int";
```
```   973 val zminus_zminus = thm "zminus_zminus";
```
```   974 val zminus_0 = thm "zminus_0";
```
```   975 val zminus_zadd_distrib = thm "zminus_zadd_distrib";
```
```   976 val zadd_commute = thm "zadd_commute";
```
```   977 val zadd_assoc = thm "zadd_assoc";
```
```   978 val zadd_left_commute = thm "zadd_left_commute";
```
```   979 val zadd_ac = thms "zadd_ac";
```
```   980 val zmult_ac = thms "zmult_ac";
```
```   981 val zadd_int = thm "zadd_int";
```
```   982 val zadd_int_left = thm "zadd_int_left";
```
```   983 val int_Suc = thm "int_Suc";
```
```   984 val zadd_0 = thm "zadd_0";
```
```   985 val zadd_0_right = thm "zadd_0_right";
```
```   986 val zmult_zminus = thm "zmult_zminus";
```
```   987 val zmult_commute = thm "zmult_commute";
```
```   988 val zmult_assoc = thm "zmult_assoc";
```
```   989 val zadd_zmult_distrib = thm "zadd_zmult_distrib";
```
```   990 val zadd_zmult_distrib2 = thm "zadd_zmult_distrib2";
```
```   991 val zdiff_zmult_distrib = thm "zdiff_zmult_distrib";
```
```   992 val zdiff_zmult_distrib2 = thm "zdiff_zmult_distrib2";
```
```   993 val int_distrib = thms "int_distrib";
```
```   994 val zmult_int = thm "zmult_int";
```
```   995 val zmult_1 = thm "zmult_1";
```
```   996 val zmult_1_right = thm "zmult_1_right";
```
```   997 val int_int_eq = thm "int_int_eq";
```
```   998 val int_eq_0_conv = thm "int_eq_0_conv";
```
```   999 val zless_int = thm "zless_int";
```
```  1000 val int_less_0_conv = thm "int_less_0_conv";
```
```  1001 val zero_less_int_conv = thm "zero_less_int_conv";
```
```  1002 val zle_int = thm "zle_int";
```
```  1003 val zero_zle_int = thm "zero_zle_int";
```
```  1004 val int_le_0_conv = thm "int_le_0_conv";
```
```  1005 val zle_refl = thm "zle_refl";
```
```  1006 val zle_linear = thm "zle_linear";
```
```  1007 val zle_trans = thm "zle_trans";
```
```  1008 val zle_anti_sym = thm "zle_anti_sym";
```
```  1009
```
```  1010 val Ints_def = thm "Ints_def";
```
```  1011 val Nats_def = thm "Nats_def";
```
```  1012
```
```  1013 val of_nat_0 = thm "of_nat_0";
```
```  1014 val of_nat_Suc = thm "of_nat_Suc";
```
```  1015 val of_nat_1 = thm "of_nat_1";
```
```  1016 val of_nat_add = thm "of_nat_add";
```
```  1017 val of_nat_mult = thm "of_nat_mult";
```
```  1018 val zero_le_imp_of_nat = thm "zero_le_imp_of_nat";
```
```  1019 val less_imp_of_nat_less = thm "less_imp_of_nat_less";
```
```  1020 val of_nat_less_imp_less = thm "of_nat_less_imp_less";
```
```  1021 val of_nat_less_iff = thm "of_nat_less_iff";
```
```  1022 val of_nat_le_iff = thm "of_nat_le_iff";
```
```  1023 val of_nat_eq_iff = thm "of_nat_eq_iff";
```
```  1024 val Nats_0 = thm "Nats_0";
```
```  1025 val Nats_1 = thm "Nats_1";
```
```  1026 val Nats_add = thm "Nats_add";
```
```  1027 val Nats_mult = thm "Nats_mult";
```
```  1028 val int_eq_of_nat = thm"int_eq_of_nat";
```
```  1029 val of_int = thm "of_int";
```
```  1030 val of_int_0 = thm "of_int_0";
```
```  1031 val of_int_1 = thm "of_int_1";
```
```  1032 val of_int_add = thm "of_int_add";
```
```  1033 val of_int_minus = thm "of_int_minus";
```
```  1034 val of_int_diff = thm "of_int_diff";
```
```  1035 val of_int_mult = thm "of_int_mult";
```
```  1036 val of_int_le_iff = thm "of_int_le_iff";
```
```  1037 val of_int_less_iff = thm "of_int_less_iff";
```
```  1038 val of_int_eq_iff = thm "of_int_eq_iff";
```
```  1039 val Ints_0 = thm "Ints_0";
```
```  1040 val Ints_1 = thm "Ints_1";
```
```  1041 val Ints_add = thm "Ints_add";
```
```  1042 val Ints_minus = thm "Ints_minus";
```
```  1043 val Ints_diff = thm "Ints_diff";
```
```  1044 val Ints_mult = thm "Ints_mult";
```
```  1045 val of_int_of_nat_eq = thm"of_int_of_nat_eq";
```
```  1046 val Ints_cases = thm "Ints_cases";
```
```  1047 val Ints_induct = thm "Ints_induct";
```
```  1048 *}
```
```  1049
```
```  1050 end
```