src/HOL/Integ/IntDef.thy
author wenzelm
Thu Jan 19 21:22:08 2006 +0100 (2006-01-19 ago)
changeset 18708 4b3dadb4fe33
parent 18704 2c86ced392a8
child 18757 f0d901bc0686
permissions -rw-r--r--
setup: theory -> theory;
     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_Relations 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 text{*Reduces equality on abstractions to equality on representatives:
    79   @{term "\<lbrakk>x \<in> Integ; y \<in> Integ\<rbrakk> \<Longrightarrow> (Abs_Integ x = Abs_Integ y) = (x=y)"} *}
    80 declare Abs_Integ_inject [simp]  Abs_Integ_inverse [simp]
    81 
    82 text{*Case analysis on the representation of an integer as an equivalence
    83       class of pairs of naturals.*}
    84 lemma eq_Abs_Integ [case_names Abs_Integ, cases type: int]:
    85      "(!!x y. z = Abs_Integ(intrel``{(x,y)}) ==> P) ==> P"
    86 apply (rule Abs_Integ_cases [of z]) 
    87 apply (auto simp add: Integ_def quotient_def) 
    88 done
    89 
    90 
    91 subsubsection{*@{term int}: Embedding the Naturals into the Integers*}
    92 
    93 lemma inj_int: "inj int"
    94 by (simp add: inj_on_def int_def)
    95 
    96 lemma int_int_eq [iff]: "(int m = int n) = (m = n)"
    97 by (fast elim!: inj_int [THEN injD])
    98 
    99 
   100 subsubsection{*Integer Unary Negation*}
   101 
   102 lemma minus: "- Abs_Integ(intrel``{(x,y)}) = Abs_Integ(intrel `` {(y,x)})"
   103 proof -
   104   have "(\<lambda>(x,y). intrel``{(y,x)}) respects intrel"
   105     by (simp add: congruent_def) 
   106   thus ?thesis
   107     by (simp add: minus_int_def UN_equiv_class [OF equiv_intrel])
   108 qed
   109 
   110 lemma zminus_zminus: "- (- z) = (z::int)"
   111 by (cases z, simp add: minus)
   112 
   113 lemma zminus_0: "- 0 = (0::int)"
   114 by (simp add: int_def Zero_int_def minus)
   115 
   116 
   117 subsection{*Integer Addition*}
   118 
   119 lemma add:
   120      "Abs_Integ (intrel``{(x,y)}) + Abs_Integ (intrel``{(u,v)}) =
   121       Abs_Integ (intrel``{(x+u, y+v)})"
   122 proof -
   123   have "(\<lambda>z w. (\<lambda>(x,y). (\<lambda>(u,v). intrel `` {(x+u, y+v)}) w) z) 
   124         respects2 intrel"
   125     by (simp add: congruent2_def)
   126   thus ?thesis
   127     by (simp add: add_int_def UN_UN_split_split_eq
   128                   UN_equiv_class2 [OF equiv_intrel equiv_intrel])
   129 qed
   130 
   131 lemma zminus_zadd_distrib: "- (z + w) = (- z) + (- w::int)"
   132 by (cases z, cases w, simp add: minus add)
   133 
   134 lemma zadd_commute: "(z::int) + w = w + z"
   135 by (cases z, cases w, simp add: add_ac add)
   136 
   137 lemma zadd_assoc: "((z1::int) + z2) + z3 = z1 + (z2 + z3)"
   138 by (cases z1, cases z2, cases z3, simp add: add add_assoc)
   139 
   140 (*For AC rewriting*)
   141 lemma zadd_left_commute: "x + (y + z) = y + ((x + z)  ::int)"
   142   apply (rule mk_left_commute [of "op +"])
   143   apply (rule zadd_assoc)
   144   apply (rule zadd_commute)
   145   done
   146 
   147 lemmas zadd_ac = zadd_assoc zadd_commute zadd_left_commute
   148 
   149 lemmas zmult_ac = OrderedGroup.mult_ac
   150 
   151 lemma zadd_int: "(int m) + (int n) = int (m + n)"
   152 by (simp add: int_def add)
   153 
   154 lemma zadd_int_left: "(int m) + (int n + z) = int (m + n) + z"
   155 by (simp add: zadd_int zadd_assoc [symmetric])
   156 
   157 lemma int_Suc: "int (Suc m) = 1 + (int m)"
   158 by (simp add: One_int_def zadd_int)
   159 
   160 (*also for the instance declaration int :: comm_monoid_add*)
   161 lemma zadd_0: "(0::int) + z = z"
   162 apply (simp add: Zero_int_def int_def)
   163 apply (cases z, simp add: add)
   164 done
   165 
   166 lemma zadd_0_right: "z + (0::int) = z"
   167 by (rule trans [OF zadd_commute zadd_0])
   168 
   169 lemma zadd_zminus_inverse2: "(- z) + z = (0::int)"
   170 by (cases z, simp add: int_def Zero_int_def minus add)
   171 
   172 
   173 subsection{*Integer Multiplication*}
   174 
   175 text{*Congruence property for multiplication*}
   176 lemma mult_congruent2:
   177      "(%p1 p2. (%(x,y). (%(u,v). intrel``{(x*u + y*v, x*v + y*u)}) p2) p1)
   178       respects2 intrel"
   179 apply (rule equiv_intrel [THEN congruent2_commuteI])
   180  apply (force simp add: mult_ac, clarify) 
   181 apply (simp add: congruent_def mult_ac)  
   182 apply (rename_tac u v w x y z)
   183 apply (subgoal_tac "u*y + x*y = w*y + v*y  &  u*z + x*z = w*z + v*z")
   184 apply (simp add: mult_ac)
   185 apply (simp add: add_mult_distrib [symmetric])
   186 done
   187 
   188 
   189 lemma mult:
   190      "Abs_Integ((intrel``{(x,y)})) * Abs_Integ((intrel``{(u,v)})) =
   191       Abs_Integ(intrel `` {(x*u + y*v, x*v + y*u)})"
   192 by (simp add: mult_int_def UN_UN_split_split_eq mult_congruent2
   193               UN_equiv_class2 [OF equiv_intrel equiv_intrel])
   194 
   195 lemma zmult_zminus: "(- z) * w = - (z * (w::int))"
   196 by (cases z, cases w, simp add: minus mult add_ac)
   197 
   198 lemma zmult_commute: "(z::int) * w = w * z"
   199 by (cases z, cases w, simp add: mult add_ac mult_ac)
   200 
   201 lemma zmult_assoc: "((z1::int) * z2) * z3 = z1 * (z2 * z3)"
   202 by (cases z1, cases z2, cases z3, simp add: mult add_mult_distrib2 mult_ac)
   203 
   204 lemma zadd_zmult_distrib: "((z1::int) + z2) * w = (z1 * w) + (z2 * w)"
   205 by (cases z1, cases z2, cases w, simp add: add mult add_mult_distrib2 mult_ac)
   206 
   207 lemma zadd_zmult_distrib2: "(w::int) * (z1 + z2) = (w * z1) + (w * z2)"
   208 by (simp add: zmult_commute [of w] zadd_zmult_distrib)
   209 
   210 lemma zdiff_zmult_distrib: "((z1::int) - z2) * w = (z1 * w) - (z2 * w)"
   211 by (simp add: diff_int_def zadd_zmult_distrib zmult_zminus)
   212 
   213 lemma zdiff_zmult_distrib2: "(w::int) * (z1 - z2) = (w * z1) - (w * z2)"
   214 by (simp add: zmult_commute [of w] zdiff_zmult_distrib)
   215 
   216 lemmas int_distrib =
   217   zadd_zmult_distrib zadd_zmult_distrib2
   218   zdiff_zmult_distrib zdiff_zmult_distrib2
   219 
   220 lemma int_mult: "int (m * n) = (int m) * (int n)"
   221 by (simp add: int_def mult)
   222 
   223 text{*Compatibility binding*}
   224 lemmas zmult_int = int_mult [symmetric]
   225 
   226 lemma zmult_1: "(1::int) * z = z"
   227 by (cases z, simp add: One_int_def int_def mult)
   228 
   229 lemma zmult_1_right: "z * (1::int) = z"
   230 by (rule trans [OF zmult_commute zmult_1])
   231 
   232 
   233 text{*The integers form a @{text comm_ring_1}*}
   234 instance int :: comm_ring_1
   235 proof
   236   fix i j k :: int
   237   show "(i + j) + k = i + (j + k)" by (simp add: zadd_assoc)
   238   show "i + j = j + i" by (simp add: zadd_commute)
   239   show "0 + i = i" by (rule zadd_0)
   240   show "- i + i = 0" by (rule zadd_zminus_inverse2)
   241   show "i - j = i + (-j)" by (simp add: diff_int_def)
   242   show "(i * j) * k = i * (j * k)" by (rule zmult_assoc)
   243   show "i * j = j * i" by (rule zmult_commute)
   244   show "1 * i = i" by (rule zmult_1) 
   245   show "(i + j) * k = i * k + j * k" by (simp add: int_distrib)
   246   show "0 \<noteq> (1::int)"
   247     by (simp only: Zero_int_def One_int_def One_nat_def int_int_eq)
   248 qed
   249 
   250 
   251 subsection{*The @{text "\<le>"} Ordering*}
   252 
   253 lemma le:
   254   "(Abs_Integ(intrel``{(x,y)}) \<le> Abs_Integ(intrel``{(u,v)})) = (x+v \<le> u+y)"
   255 by (force simp add: le_int_def)
   256 
   257 lemma zle_refl: "w \<le> (w::int)"
   258 by (cases w, simp add: le)
   259 
   260 lemma zle_trans: "[| i \<le> j; j \<le> k |] ==> i \<le> (k::int)"
   261 by (cases i, cases j, cases k, simp add: le)
   262 
   263 lemma zle_anti_sym: "[| z \<le> w; w \<le> z |] ==> z = (w::int)"
   264 by (cases w, cases z, simp add: le)
   265 
   266 (* Axiom 'order_less_le' of class 'order': *)
   267 lemma zless_le: "((w::int) < z) = (w \<le> z & w \<noteq> z)"
   268 by (simp add: less_int_def)
   269 
   270 instance int :: order
   271   by intro_classes
   272     (assumption |
   273       rule zle_refl zle_trans zle_anti_sym zless_le)+
   274 
   275 (* Axiom 'linorder_linear' of class 'linorder': *)
   276 lemma zle_linear: "(z::int) \<le> w | w \<le> z"
   277 by (cases z, cases w) (simp add: le linorder_linear)
   278 
   279 instance int :: linorder
   280   by intro_classes (rule zle_linear)
   281 
   282 
   283 lemmas zless_linear = linorder_less_linear [where 'a = int]
   284 lemmas linorder_neqE_int = linorder_neqE[where 'a = int]
   285 
   286 
   287 lemma int_eq_0_conv [simp]: "(int n = 0) = (n = 0)"
   288 by (simp add: Zero_int_def)
   289 
   290 lemma zless_int [simp]: "(int m < int n) = (m<n)"
   291 by (simp add: le add int_def linorder_not_le [symmetric]) 
   292 
   293 lemma int_less_0_conv [simp]: "~ (int k < 0)"
   294 by (simp add: Zero_int_def)
   295 
   296 lemma zero_less_int_conv [simp]: "(0 < int n) = (0 < n)"
   297 by (simp add: Zero_int_def)
   298 
   299 lemma int_0_less_1: "0 < (1::int)"
   300 by (simp only: Zero_int_def One_int_def One_nat_def zless_int)
   301 
   302 lemma int_0_neq_1 [simp]: "0 \<noteq> (1::int)"
   303 by (simp only: Zero_int_def One_int_def One_nat_def int_int_eq)
   304 
   305 lemma zle_int [simp]: "(int m \<le> int n) = (m\<le>n)"
   306 by (simp add: linorder_not_less [symmetric])
   307 
   308 lemma zero_zle_int [simp]: "(0 \<le> int n)"
   309 by (simp add: Zero_int_def)
   310 
   311 lemma int_le_0_conv [simp]: "(int n \<le> 0) = (n = 0)"
   312 by (simp add: Zero_int_def)
   313 
   314 lemma int_0 [simp]: "int 0 = (0::int)"
   315 by (simp add: Zero_int_def)
   316 
   317 lemma int_1 [simp]: "int 1 = 1"
   318 by (simp add: One_int_def)
   319 
   320 lemma int_Suc0_eq_1: "int (Suc 0) = 1"
   321 by (simp add: One_int_def One_nat_def)
   322 
   323 
   324 subsection{*Monotonicity results*}
   325 
   326 lemma zadd_left_mono: "i \<le> j ==> k + i \<le> k + (j::int)"
   327 by (cases i, cases j, cases k, simp add: le add)
   328 
   329 lemma zadd_strict_right_mono: "i < j ==> i + k < j + (k::int)"
   330 apply (cases i, cases j, cases k)
   331 apply (simp add: linorder_not_le [where 'a = int, symmetric]
   332                  linorder_not_le [where 'a = nat]  le add)
   333 done
   334 
   335 lemma zadd_zless_mono: "[| w'<w; z'\<le>z |] ==> w' + z' < w + (z::int)"
   336 by (rule order_less_le_trans [OF zadd_strict_right_mono zadd_left_mono])
   337 
   338 
   339 subsection{*Strict Monotonicity of Multiplication*}
   340 
   341 text{*strict, in 1st argument; proof is by induction on k>0*}
   342 lemma zmult_zless_mono2_lemma:
   343      "i<j ==> 0<k ==> int k * i < int k * j"
   344 apply (induct "k", simp)
   345 apply (simp add: int_Suc)
   346 apply (case_tac "k=0")
   347 apply (simp_all add: zadd_zmult_distrib int_Suc0_eq_1 order_le_less)
   348 apply (simp add: zadd_zless_mono int_Suc0_eq_1 order_le_less)
   349 done
   350 
   351 lemma zero_le_imp_eq_int: "0 \<le> k ==> \<exists>n. k = int n"
   352 apply (cases k)
   353 apply (auto simp add: le add int_def Zero_int_def)
   354 apply (rule_tac x="x-y" in exI, simp)
   355 done
   356 
   357 lemma zmult_zless_mono2: "[| i<j;  (0::int) < k |] ==> k*i < k*j"
   358 apply (frule order_less_imp_le [THEN zero_le_imp_eq_int])
   359 apply (auto simp add: zmult_zless_mono2_lemma)
   360 done
   361 
   362 
   363 defs (overloaded)
   364     zabs_def:  "abs(i::int) == if i < 0 then -i else i"
   365 
   366 
   367 text{*The integers form an ordered @{text comm_ring_1}*}
   368 instance int :: ordered_idom
   369 proof
   370   fix i j k :: int
   371   show "i \<le> j ==> k + i \<le> k + j" by (rule zadd_left_mono)
   372   show "i < j ==> 0 < k ==> k * i < k * j" by (rule zmult_zless_mono2)
   373   show "\<bar>i\<bar> = (if i < 0 then -i else i)" by (simp only: zabs_def)
   374 qed
   375 
   376 
   377 lemma zless_imp_add1_zle: "w<z ==> w + (1::int) \<le> z"
   378 apply (cases w, cases z) 
   379 apply (simp add: linorder_not_le [symmetric] le int_def add One_int_def)
   380 done
   381 
   382 subsection{*Magnitide of an Integer, as a Natural Number: @{term nat}*}
   383 
   384 constdefs
   385    nat  :: "int => nat"
   386     "nat z == contents (\<Union>(x,y) \<in> Rep_Integ z. { x-y })"
   387 
   388 lemma nat: "nat (Abs_Integ (intrel``{(x,y)})) = x-y"
   389 proof -
   390   have "(\<lambda>(x,y). {x-y}) respects intrel"
   391     by (simp add: congruent_def, arith) 
   392   thus ?thesis
   393     by (simp add: nat_def UN_equiv_class [OF equiv_intrel])
   394 qed
   395 
   396 lemma nat_int [simp]: "nat(int n) = n"
   397 by (simp add: nat int_def) 
   398 
   399 lemma nat_zero [simp]: "nat 0 = 0"
   400 by (simp only: Zero_int_def nat_int)
   401 
   402 lemma int_nat_eq [simp]: "int (nat z) = (if 0 \<le> z then z else 0)"
   403 by (cases z, simp add: nat le int_def Zero_int_def)
   404 
   405 corollary nat_0_le: "0 \<le> z ==> int (nat z) = z"
   406 by simp
   407 
   408 lemma nat_le_0 [simp]: "z \<le> 0 ==> nat z = 0"
   409 by (cases z, simp add: nat le int_def Zero_int_def)
   410 
   411 lemma nat_le_eq_zle: "0 < w | 0 \<le> z ==> (nat w \<le> nat z) = (w\<le>z)"
   412 apply (cases w, cases z) 
   413 apply (simp add: nat le linorder_not_le [symmetric] int_def Zero_int_def, arith)
   414 done
   415 
   416 text{*An alternative condition is @{term "0 \<le> w"} *}
   417 corollary nat_mono_iff: "0 < z ==> (nat w < nat z) = (w < z)"
   418 by (simp add: nat_le_eq_zle linorder_not_le [symmetric]) 
   419 
   420 corollary nat_less_eq_zless: "0 \<le> w ==> (nat w < nat z) = (w<z)"
   421 by (simp add: nat_le_eq_zle linorder_not_le [symmetric]) 
   422 
   423 lemma zless_nat_conj: "(nat w < nat z) = (0 < z & w < z)"
   424 apply (cases w, cases z) 
   425 apply (simp add: nat le int_def Zero_int_def linorder_not_le [symmetric], arith)
   426 done
   427 
   428 lemma nonneg_eq_int: "[| 0 \<le> z;  !!m. z = int m ==> P |] ==> P"
   429 by (blast dest: nat_0_le sym)
   430 
   431 lemma nat_eq_iff: "(nat w = m) = (if 0 \<le> w then w = int m else m=0)"
   432 by (cases w, simp add: nat le int_def Zero_int_def, arith)
   433 
   434 corollary nat_eq_iff2: "(m = nat w) = (if 0 \<le> w then w = int m else m=0)"
   435 by (simp only: eq_commute [of m] nat_eq_iff) 
   436 
   437 lemma nat_less_iff: "0 \<le> w ==> (nat w < m) = (w < int m)"
   438 apply (cases w)
   439 apply (simp add: nat le int_def Zero_int_def linorder_not_le [symmetric], arith)
   440 done
   441 
   442 lemma int_eq_iff: "(int m = z) = (m = nat z & 0 \<le> z)"
   443 by (auto simp add: nat_eq_iff2)
   444 
   445 lemma zero_less_nat_eq [simp]: "(0 < nat z) = (0 < z)"
   446 by (insert zless_nat_conj [of 0], auto)
   447 
   448 lemma nat_add_distrib:
   449      "[| (0::int) \<le> z;  0 \<le> z' |] ==> nat (z+z') = nat z + nat z'"
   450 by (cases z, cases z', simp add: nat add le int_def Zero_int_def)
   451 
   452 lemma nat_diff_distrib:
   453      "[| (0::int) \<le> z';  z' \<le> z |] ==> nat (z-z') = nat z - nat z'"
   454 by (cases z, cases z', 
   455     simp add: nat add minus diff_minus le int_def Zero_int_def)
   456 
   457 
   458 lemma nat_zminus_int [simp]: "nat (- (int n)) = 0"
   459 by (simp add: int_def minus nat Zero_int_def) 
   460 
   461 lemma zless_nat_eq_int_zless: "(m < nat z) = (int m < z)"
   462 by (cases z, simp add: nat le int_def  linorder_not_le [symmetric], arith)
   463 
   464 
   465 subsection{*Lemmas about the Function @{term int} and Orderings*}
   466 
   467 lemma negative_zless_0: "- (int (Suc n)) < 0"
   468 by (simp add: order_less_le)
   469 
   470 lemma negative_zless [iff]: "- (int (Suc n)) < int m"
   471 by (rule negative_zless_0 [THEN order_less_le_trans], simp)
   472 
   473 lemma negative_zle_0: "- int n \<le> 0"
   474 by (simp add: minus_le_iff)
   475 
   476 lemma negative_zle [iff]: "- int n \<le> int m"
   477 by (rule order_trans [OF negative_zle_0 zero_zle_int])
   478 
   479 lemma not_zle_0_negative [simp]: "~ (0 \<le> - (int (Suc n)))"
   480 by (subst le_minus_iff, simp)
   481 
   482 lemma int_zle_neg: "(int n \<le> - int m) = (n = 0 & m = 0)"
   483 by (simp add: int_def le minus Zero_int_def) 
   484 
   485 lemma not_int_zless_negative [simp]: "~ (int n < - int m)"
   486 by (simp add: linorder_not_less)
   487 
   488 lemma negative_eq_positive [simp]: "(- int n = int m) = (n = 0 & m = 0)"
   489 by (force simp add: order_eq_iff [of "- int n"] int_zle_neg)
   490 
   491 lemma zle_iff_zadd: "(w \<le> z) = (\<exists>n. z = w + int n)"
   492 proof (cases w, cases z, simp add: le add int_def)
   493   fix a b c d
   494   assume "w = Abs_Integ (intrel `` {(a,b)})" "z = Abs_Integ (intrel `` {(c,d)})"
   495   show "(a+d \<le> c+b) = (\<exists>n. c+b = a+n+d)"
   496   proof
   497     assume "a + d \<le> c + b" 
   498     thus "\<exists>n. c + b = a + n + d" 
   499       by (auto intro!: exI [where x="c+b - (a+d)"])
   500   next    
   501     assume "\<exists>n. c + b = a + n + d" 
   502     then obtain n where "c + b = a + n + d" ..
   503     thus "a + d \<le> c + b" by arith
   504   qed
   505 qed
   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{*The Set of Natural Numbers*}
   566 
   567 constdefs
   568    Nats  :: "'a::comm_semiring_1_cancel set"
   569     "Nats == range of_nat"
   570 
   571 syntax (xsymbols)    Nats :: "'a set"   ("\<nat>")
   572 
   573 lemma of_nat_in_Nats [simp]: "of_nat n \<in> Nats"
   574 by (simp add: Nats_def)
   575 
   576 lemma Nats_0 [simp]: "0 \<in> Nats"
   577 apply (simp add: Nats_def)
   578 apply (rule range_eqI)
   579 apply (rule of_nat_0 [symmetric])
   580 done
   581 
   582 lemma Nats_1 [simp]: "1 \<in> Nats"
   583 apply (simp add: Nats_def)
   584 apply (rule range_eqI)
   585 apply (rule of_nat_1 [symmetric])
   586 done
   587 
   588 lemma Nats_add [simp]: "[|a \<in> Nats; b \<in> Nats|] ==> a+b \<in> Nats"
   589 apply (auto simp add: Nats_def)
   590 apply (rule range_eqI)
   591 apply (rule of_nat_add [symmetric])
   592 done
   593 
   594 lemma Nats_mult [simp]: "[|a \<in> Nats; b \<in> Nats|] ==> a*b \<in> Nats"
   595 apply (auto simp add: Nats_def)
   596 apply (rule range_eqI)
   597 apply (rule of_nat_mult [symmetric])
   598 done
   599 
   600 text{*Agreement with the specific embedding for the integers*}
   601 lemma int_eq_of_nat: "int = (of_nat :: nat => int)"
   602 proof
   603   fix n
   604   show "int n = of_nat n"  by (induct n, simp_all add: int_Suc add_ac)
   605 qed
   606 
   607 lemma of_nat_eq_id [simp]: "of_nat = (id :: nat => nat)"
   608 proof
   609   fix n
   610   show "of_nat n = id n"  by (induct n, simp_all)
   611 qed
   612 
   613 
   614 subsection{*Embedding of the Integers into any @{text comm_ring_1}:
   615 @{term of_int}*}
   616 
   617 constdefs
   618    of_int :: "int => 'a::comm_ring_1"
   619    "of_int z == contents (\<Union>(i,j) \<in> Rep_Integ z. { of_nat i - of_nat j })"
   620 
   621 
   622 lemma of_int: "of_int (Abs_Integ (intrel `` {(i,j)})) = of_nat i - of_nat j"
   623 proof -
   624   have "(\<lambda>(i,j). { of_nat i - (of_nat j :: 'a) }) respects intrel"
   625     by (simp add: congruent_def compare_rls of_nat_add [symmetric]
   626             del: of_nat_add) 
   627   thus ?thesis
   628     by (simp add: of_int_def UN_equiv_class [OF equiv_intrel])
   629 qed
   630 
   631 lemma of_int_0 [simp]: "of_int 0 = 0"
   632 by (simp add: of_int Zero_int_def int_def)
   633 
   634 lemma of_int_1 [simp]: "of_int 1 = 1"
   635 by (simp add: of_int One_int_def int_def)
   636 
   637 lemma of_int_add [simp]: "of_int (w+z) = of_int w + of_int z"
   638 by (cases w, cases z, simp add: compare_rls of_int add)
   639 
   640 lemma of_int_minus [simp]: "of_int (-z) = - (of_int z)"
   641 by (cases z, simp add: compare_rls of_int minus)
   642 
   643 lemma of_int_diff [simp]: "of_int (w-z) = of_int w - of_int z"
   644 by (simp add: diff_minus)
   645 
   646 lemma of_int_mult [simp]: "of_int (w*z) = of_int w * of_int z"
   647 apply (cases w, cases z)
   648 apply (simp add: compare_rls of_int left_diff_distrib right_diff_distrib
   649                  mult add_ac)
   650 done
   651 
   652 lemma of_int_le_iff [simp]:
   653      "(of_int w \<le> (of_int z::'a::ordered_idom)) = (w \<le> z)"
   654 apply (cases w)
   655 apply (cases z)
   656 apply (simp add: compare_rls of_int le diff_int_def add minus
   657                  of_nat_add [symmetric]   del: of_nat_add)
   658 done
   659 
   660 text{*Special cases where either operand is zero*}
   661 lemmas of_int_0_le_iff = of_int_le_iff [of 0, simplified]
   662 lemmas of_int_le_0_iff = of_int_le_iff [of _ 0, simplified]
   663 declare of_int_0_le_iff [simp]
   664 declare of_int_le_0_iff [simp]
   665 
   666 lemma of_int_less_iff [simp]:
   667      "(of_int w < (of_int z::'a::ordered_idom)) = (w < z)"
   668 by (simp add: linorder_not_le [symmetric])
   669 
   670 text{*Special cases where either operand is zero*}
   671 lemmas of_int_0_less_iff = of_int_less_iff [of 0, simplified]
   672 lemmas of_int_less_0_iff = of_int_less_iff [of _ 0, simplified]
   673 declare of_int_0_less_iff [simp]
   674 declare of_int_less_0_iff [simp]
   675 
   676 text{*The ordering on the @{text comm_ring_1} is necessary.
   677  See @{text of_nat_eq_iff} above.*}
   678 lemma of_int_eq_iff [simp]:
   679      "(of_int w = (of_int z::'a::ordered_idom)) = (w = z)"
   680 by (simp add: order_eq_iff)
   681 
   682 text{*Special cases where either operand is zero*}
   683 lemmas of_int_0_eq_iff = of_int_eq_iff [of 0, simplified]
   684 lemmas of_int_eq_0_iff = of_int_eq_iff [of _ 0, simplified]
   685 declare of_int_0_eq_iff [simp]
   686 declare of_int_eq_0_iff [simp]
   687 
   688 lemma of_int_eq_id [simp]: "of_int = (id :: int => int)"
   689 proof
   690  fix z
   691  show "of_int z = id z"  
   692   by (cases z,
   693       simp add: of_int add minus int_eq_of_nat [symmetric] int_def diff_minus)
   694 qed
   695 
   696 
   697 subsection{*The Set of Integers*}
   698 
   699 constdefs
   700    Ints  :: "'a::comm_ring_1 set"
   701     "Ints == range of_int"
   702 
   703 
   704 syntax (xsymbols)
   705   Ints      :: "'a set"                   ("\<int>")
   706 
   707 lemma Ints_0 [simp]: "0 \<in> Ints"
   708 apply (simp add: Ints_def)
   709 apply (rule range_eqI)
   710 apply (rule of_int_0 [symmetric])
   711 done
   712 
   713 lemma Ints_1 [simp]: "1 \<in> Ints"
   714 apply (simp add: Ints_def)
   715 apply (rule range_eqI)
   716 apply (rule of_int_1 [symmetric])
   717 done
   718 
   719 lemma Ints_add [simp]: "[|a \<in> Ints; b \<in> Ints|] ==> a+b \<in> Ints"
   720 apply (auto simp add: Ints_def)
   721 apply (rule range_eqI)
   722 apply (rule of_int_add [symmetric])
   723 done
   724 
   725 lemma Ints_minus [simp]: "a \<in> Ints ==> -a \<in> Ints"
   726 apply (auto simp add: Ints_def)
   727 apply (rule range_eqI)
   728 apply (rule of_int_minus [symmetric])
   729 done
   730 
   731 lemma Ints_diff [simp]: "[|a \<in> Ints; b \<in> Ints|] ==> a-b \<in> Ints"
   732 apply (auto simp add: Ints_def)
   733 apply (rule range_eqI)
   734 apply (rule of_int_diff [symmetric])
   735 done
   736 
   737 lemma Ints_mult [simp]: "[|a \<in> Ints; b \<in> Ints|] ==> a*b \<in> Ints"
   738 apply (auto simp add: Ints_def)
   739 apply (rule range_eqI)
   740 apply (rule of_int_mult [symmetric])
   741 done
   742 
   743 text{*Collapse nested embeddings*}
   744 lemma of_int_of_nat_eq [simp]: "of_int (of_nat n) = of_nat n"
   745 by (induct n, auto)
   746 
   747 lemma of_int_int_eq [simp]: "of_int (int n) = of_nat n"
   748 by (simp add: int_eq_of_nat)
   749 
   750 lemma Ints_cases [case_names of_int, cases set: Ints]:
   751   "q \<in> \<int> ==> (!!z. q = of_int z ==> C) ==> C"
   752 proof (simp add: Ints_def)
   753   assume "!!z. q = of_int z ==> C"
   754   assume "q \<in> range of_int" thus C ..
   755 qed
   756 
   757 lemma Ints_induct [case_names of_int, induct set: Ints]:
   758   "q \<in> \<int> ==> (!!z. P (of_int z)) ==> P q"
   759   by (rule Ints_cases) auto
   760 
   761 
   762 (* int (Suc n) = 1 + int n *)
   763 declare int_Suc [simp]
   764 
   765 
   766 subsection{*More Properties of @{term setsum} and  @{term setprod}*}
   767 
   768 text{*By Jeremy Avigad*}
   769 
   770 
   771 lemma of_nat_setsum: "of_nat (setsum f A) = (\<Sum>x\<in>A. of_nat(f x))"
   772   apply (case_tac "finite A")
   773   apply (erule finite_induct, auto)
   774   done
   775 
   776 lemma of_int_setsum: "of_int (setsum f A) = (\<Sum>x\<in>A. of_int(f x))"
   777   apply (case_tac "finite A")
   778   apply (erule finite_induct, auto)
   779   done
   780 
   781 lemma int_setsum: "int (setsum f A) = (\<Sum>x\<in>A. int(f x))"
   782   by (simp add: int_eq_of_nat of_nat_setsum)
   783 
   784 lemma of_nat_setprod: "of_nat (setprod f A) = (\<Prod>x\<in>A. of_nat(f x))"
   785   apply (case_tac "finite A")
   786   apply (erule finite_induct, auto)
   787   done
   788 
   789 lemma of_int_setprod: "of_int (setprod f A) = (\<Prod>x\<in>A. of_int(f x))"
   790   apply (case_tac "finite A")
   791   apply (erule finite_induct, auto)
   792   done
   793 
   794 lemma int_setprod: "int (setprod f A) = (\<Prod>x\<in>A. int(f x))"
   795   by (simp add: int_eq_of_nat of_nat_setprod)
   796 
   797 lemma setprod_nonzero_nat:
   798     "finite A ==> (\<forall>x \<in> A. f x \<noteq> (0::nat)) ==> setprod f A \<noteq> 0"
   799   by (rule setprod_nonzero, auto)
   800 
   801 lemma setprod_zero_eq_nat:
   802     "finite A ==> (setprod f A = (0::nat)) = (\<exists>x \<in> A. f x = 0)"
   803   by (rule setprod_zero_eq, auto)
   804 
   805 lemma setprod_nonzero_int:
   806     "finite A ==> (\<forall>x \<in> A. f x \<noteq> (0::int)) ==> setprod f A \<noteq> 0"
   807   by (rule setprod_nonzero, auto)
   808 
   809 lemma setprod_zero_eq_int:
   810     "finite A ==> (setprod f A = (0::int)) = (\<exists>x \<in> A. f x = 0)"
   811   by (rule setprod_zero_eq, auto)
   812 
   813 
   814 text{*Now we replace the case analysis rule by a more conventional one:
   815 whether an integer is negative or not.*}
   816 
   817 lemma zless_iff_Suc_zadd:
   818     "(w < z) = (\<exists>n. z = w + int(Suc n))"
   819 apply (cases z, cases w)
   820 apply (auto simp add: le add int_def linorder_not_le [symmetric]) 
   821 apply (rename_tac a b c d) 
   822 apply (rule_tac x="a+d - Suc(c+b)" in exI) 
   823 apply arith
   824 done
   825 
   826 lemma negD: "x<0 ==> \<exists>n. x = - (int (Suc n))"
   827 apply (cases x)
   828 apply (auto simp add: le minus Zero_int_def int_def order_less_le) 
   829 apply (rule_tac x="y - Suc x" in exI, arith)
   830 done
   831 
   832 theorem int_cases [cases type: int, case_names nonneg neg]:
   833      "[|!! n. z = int n ==> P;  !! n. z =  - (int (Suc n)) ==> P |] ==> P"
   834 apply (case_tac "z < 0", blast dest!: negD)
   835 apply (simp add: linorder_not_less)
   836 apply (blast dest: nat_0_le [THEN sym])
   837 done
   838 
   839 theorem int_induct [induct type: int, case_names nonneg neg]:
   840      "[|!! n. P (int n);  !!n. P (- (int (Suc n))) |] ==> P z"
   841   by (cases z) auto
   842 
   843 text{*Contributed by Brian Huffman*}
   844 theorem int_diff_cases [case_names diff]:
   845 assumes prem: "!!m n. z = int m - int n ==> P" shows "P"
   846  apply (rule_tac z=z in int_cases)
   847   apply (rule_tac m=n and n=0 in prem, simp)
   848  apply (rule_tac m=0 and n="Suc n" in prem, simp)
   849 done
   850 
   851 lemma of_nat_nat: "0 \<le> z ==> of_nat (nat z) = of_int z"
   852 apply (cases z)
   853 apply (simp_all add: not_zle_0_negative del: int_Suc)
   854 done
   855 
   856 
   857 subsection {* Configuration of the code generator *}
   858 
   859 (*FIXME: the IntInf.fromInt below hides a dependence on fixed-precision ints!*)
   860 
   861 types_code
   862   "int" ("int")
   863 attach (term_of) {*
   864 val term_of_int = HOLogic.mk_int o IntInf.fromInt;
   865 *}
   866 attach (test) {*
   867 fun gen_int i = one_of [~1, 1] * random_range 0 i;
   868 *}
   869 
   870 constdefs
   871   int_aux :: "int \<Rightarrow> nat \<Rightarrow> int"
   872   "int_aux i n == (i + int n)"
   873   nat_aux :: "nat \<Rightarrow> int \<Rightarrow> nat"
   874   "nat_aux n i == (n + nat i)"
   875 
   876 lemma [code]:
   877   "int_aux i 0 = i"
   878   "int_aux i (Suc n) = int_aux (i + 1) n" -- {* tail recursive *}
   879   "int n = int_aux 0 n"
   880   by (simp add: int_aux_def)+
   881 
   882 lemma [code]: "nat_aux n i = (if i <= 0 then n else nat_aux (Suc n) (i - 1))"
   883   -- {* tail recursive *}
   884   by (auto simp add: nat_aux_def nat_eq_iff linorder_not_le order_less_imp_le
   885     dest: zless_imp_add1_zle)
   886 lemma [code]: "nat i = nat_aux 0 i"
   887   by (simp add: nat_aux_def)
   888 
   889 consts_code
   890   "0" :: "int"                  ("0")
   891   "1" :: "int"                  ("1")
   892   "uminus" :: "int => int"      ("~")
   893   "op +" :: "int => int => int" ("(_ +/ _)")
   894   "op *" :: "int => int => int" ("(_ */ _)")
   895   "op <" :: "int => int => bool" ("(_ </ _)")
   896   "op <=" :: "int => int => bool" ("(_ <=/ _)")
   897   "neg"                         ("(_ < 0)")
   898 
   899 code_syntax_tyco int
   900   ml (atom "IntInf.int")
   901   haskell (atom "Integer")
   902 
   903 code_syntax_const
   904   0 :: "int"
   905     ml (atom "(0:IntInf.int)")
   906     haskell (atom "0")
   907   1 :: "int"
   908     ml (atom "(1:IntInf.int)")
   909     haskell (atom "1")
   910   "op +" :: "int \<Rightarrow> int \<Rightarrow> int"
   911     ml (infixl 8 "+")
   912     haskell (infixl 6 "+")
   913   "op *" :: "int \<Rightarrow> int \<Rightarrow> int"
   914     ml (infixl 9 "*")
   915     haskell (infixl 7 "*")
   916   uminus :: "int \<Rightarrow> int"
   917     ml (atom "~")
   918     haskell (atom "negate")
   919   "op <" :: "int \<Rightarrow> int \<Rightarrow> bool"
   920     ml (infix 6 "<")
   921     haskell (infix 4 "<")
   922   "op <=" :: "int \<Rightarrow> int \<Rightarrow> bool"
   923     ml (infix 6 "<=")
   924     haskell (infix 4 "<=")
   925   "neg" :: "int \<Rightarrow> bool"
   926     ml ("_/ </ 0")
   927     haskell ("_/ </ 0")
   928 
   929 ML {*
   930 fun mk_int_to_nat bin =
   931   Const ("IntDef.nat", HOLogic.intT --> HOLogic.natT)
   932   $ (Const ("Numeral.number_of", HOLogic.binT --> HOLogic.intT) $ bin);
   933 
   934 fun bin_to_int bin = HOLogic.dest_binum bin
   935   handle TERM _
   936     => error ("not a number: " ^ Sign.string_of_term thy bin);
   937 
   938 fun number_of_codegen thy defs gr dep module b (Const ("Numeral.number_of",
   939       Type ("fun", [_, T as Type ("IntDef.int", [])])) $ bin) =
   940         (SOME (fst (Codegen.invoke_tycodegen thy defs dep module false (gr, T)),
   941            Pretty.str (IntInf.toString (HOLogic.dest_binum bin))) handle TERM _ => NONE)
   942   | number_of_codegen thy defs gr s thyname b (Const ("Numeral.number_of",
   943       Type ("fun", [_, Type ("nat", [])])) $ bin) =
   944         SOME (Codegen.invoke_codegen thy defs s thyname b (gr,
   945           Const ("IntDef.nat", HOLogic.intT --> HOLogic.natT) $
   946             (Const ("Numeral.number_of", HOLogic.binT --> HOLogic.intT) $ bin)))
   947   | number_of_codegen _ _ _ _ _ _ _ = NONE;
   948 
   949 *}
   950 
   951 setup {*
   952   Codegen.add_codegen "number_of_codegen" number_of_codegen #>
   953   CodegenPackage.add_appconst
   954     ("Numeral.number_of", ((1, 1), CodegenPackage.appgen_number_of mk_int_to_nat bin_to_int "IntDef.int" "nat")) #>
   955   CodegenPackage.set_int_tyco "IntDef.int"
   956 *}
   957 
   958 quickcheck_params [default_type = int]
   959 
   960 
   961 (*Legacy ML bindings, but no longer the structure Int.*)
   962 ML
   963 {*
   964 val zabs_def = thm "zabs_def"
   965 
   966 val int_0 = thm "int_0";
   967 val int_1 = thm "int_1";
   968 val int_Suc0_eq_1 = thm "int_Suc0_eq_1";
   969 val neg_eq_less_0 = thm "neg_eq_less_0";
   970 val not_neg_eq_ge_0 = thm "not_neg_eq_ge_0";
   971 val not_neg_0 = thm "not_neg_0";
   972 val not_neg_1 = thm "not_neg_1";
   973 val iszero_0 = thm "iszero_0";
   974 val not_iszero_1 = thm "not_iszero_1";
   975 val int_0_less_1 = thm "int_0_less_1";
   976 val int_0_neq_1 = thm "int_0_neq_1";
   977 val negative_zless = thm "negative_zless";
   978 val negative_zle = thm "negative_zle";
   979 val not_zle_0_negative = thm "not_zle_0_negative";
   980 val not_int_zless_negative = thm "not_int_zless_negative";
   981 val negative_eq_positive = thm "negative_eq_positive";
   982 val zle_iff_zadd = thm "zle_iff_zadd";
   983 val abs_int_eq = thm "abs_int_eq";
   984 val abs_split = thm"abs_split";
   985 val nat_int = thm "nat_int";
   986 val nat_zminus_int = thm "nat_zminus_int";
   987 val nat_zero = thm "nat_zero";
   988 val not_neg_nat = thm "not_neg_nat";
   989 val neg_nat = thm "neg_nat";
   990 val zless_nat_eq_int_zless = thm "zless_nat_eq_int_zless";
   991 val nat_0_le = thm "nat_0_le";
   992 val nat_le_0 = thm "nat_le_0";
   993 val zless_nat_conj = thm "zless_nat_conj";
   994 val int_cases = thm "int_cases";
   995 
   996 val int_def = thm "int_def";
   997 val Zero_int_def = thm "Zero_int_def";
   998 val One_int_def = thm "One_int_def";
   999 val diff_int_def = thm "diff_int_def";
  1000 
  1001 val inj_int = thm "inj_int";
  1002 val zminus_zminus = thm "zminus_zminus";
  1003 val zminus_0 = thm "zminus_0";
  1004 val zminus_zadd_distrib = thm "zminus_zadd_distrib";
  1005 val zadd_commute = thm "zadd_commute";
  1006 val zadd_assoc = thm "zadd_assoc";
  1007 val zadd_left_commute = thm "zadd_left_commute";
  1008 val zadd_ac = thms "zadd_ac";
  1009 val zmult_ac = thms "zmult_ac";
  1010 val zadd_int = thm "zadd_int";
  1011 val zadd_int_left = thm "zadd_int_left";
  1012 val int_Suc = thm "int_Suc";
  1013 val zadd_0 = thm "zadd_0";
  1014 val zadd_0_right = thm "zadd_0_right";
  1015 val zmult_zminus = thm "zmult_zminus";
  1016 val zmult_commute = thm "zmult_commute";
  1017 val zmult_assoc = thm "zmult_assoc";
  1018 val zadd_zmult_distrib = thm "zadd_zmult_distrib";
  1019 val zadd_zmult_distrib2 = thm "zadd_zmult_distrib2";
  1020 val zdiff_zmult_distrib = thm "zdiff_zmult_distrib";
  1021 val zdiff_zmult_distrib2 = thm "zdiff_zmult_distrib2";
  1022 val int_distrib = thms "int_distrib";
  1023 val zmult_int = thm "zmult_int";
  1024 val zmult_1 = thm "zmult_1";
  1025 val zmult_1_right = thm "zmult_1_right";
  1026 val int_int_eq = thm "int_int_eq";
  1027 val int_eq_0_conv = thm "int_eq_0_conv";
  1028 val zless_int = thm "zless_int";
  1029 val int_less_0_conv = thm "int_less_0_conv";
  1030 val zero_less_int_conv = thm "zero_less_int_conv";
  1031 val zle_int = thm "zle_int";
  1032 val zero_zle_int = thm "zero_zle_int";
  1033 val int_le_0_conv = thm "int_le_0_conv";
  1034 val zle_refl = thm "zle_refl";
  1035 val zle_linear = thm "zle_linear";
  1036 val zle_trans = thm "zle_trans";
  1037 val zle_anti_sym = thm "zle_anti_sym";
  1038 
  1039 val Ints_def = thm "Ints_def";
  1040 val Nats_def = thm "Nats_def";
  1041 
  1042 val of_nat_0 = thm "of_nat_0";
  1043 val of_nat_Suc = thm "of_nat_Suc";
  1044 val of_nat_1 = thm "of_nat_1";
  1045 val of_nat_add = thm "of_nat_add";
  1046 val of_nat_mult = thm "of_nat_mult";
  1047 val zero_le_imp_of_nat = thm "zero_le_imp_of_nat";
  1048 val less_imp_of_nat_less = thm "less_imp_of_nat_less";
  1049 val of_nat_less_imp_less = thm "of_nat_less_imp_less";
  1050 val of_nat_less_iff = thm "of_nat_less_iff";
  1051 val of_nat_le_iff = thm "of_nat_le_iff";
  1052 val of_nat_eq_iff = thm "of_nat_eq_iff";
  1053 val Nats_0 = thm "Nats_0";
  1054 val Nats_1 = thm "Nats_1";
  1055 val Nats_add = thm "Nats_add";
  1056 val Nats_mult = thm "Nats_mult";
  1057 val int_eq_of_nat = thm"int_eq_of_nat";
  1058 val of_int = thm "of_int";
  1059 val of_int_0 = thm "of_int_0";
  1060 val of_int_1 = thm "of_int_1";
  1061 val of_int_add = thm "of_int_add";
  1062 val of_int_minus = thm "of_int_minus";
  1063 val of_int_diff = thm "of_int_diff";
  1064 val of_int_mult = thm "of_int_mult";
  1065 val of_int_le_iff = thm "of_int_le_iff";
  1066 val of_int_less_iff = thm "of_int_less_iff";
  1067 val of_int_eq_iff = thm "of_int_eq_iff";
  1068 val Ints_0 = thm "Ints_0";
  1069 val Ints_1 = thm "Ints_1";
  1070 val Ints_add = thm "Ints_add";
  1071 val Ints_minus = thm "Ints_minus";
  1072 val Ints_diff = thm "Ints_diff";
  1073 val Ints_mult = thm "Ints_mult";
  1074 val of_int_of_nat_eq = thm"of_int_of_nat_eq";
  1075 val Ints_cases = thm "Ints_cases";
  1076 val Ints_induct = thm "Ints_induct";
  1077 *}
  1078 
  1079 end