src/HOL/Integ/IntDef.thy
changeset 14378 69c4d5997669
parent 14348 744c868ee0b7
child 14387 e96d5c42c4b0
     1.1 --- a/src/HOL/Integ/IntDef.thy	Thu Feb 05 10:45:28 2004 +0100
     1.2 +++ b/src/HOL/Integ/IntDef.thy	Tue Feb 10 12:02:11 2004 +0100
     1.3 @@ -27,13 +27,6 @@
     1.4  
     1.5    int :: "nat => int"
     1.6    "int m == Abs_Integ(intrel `` {(m,0)})"
     1.7 -
     1.8 -  neg   :: "int => bool"
     1.9 -  "neg(Z) == \<exists>x y. x<y & (x,y::nat):Rep_Integ(Z)"
    1.10 -
    1.11 -  (*For simplifying equalities*)
    1.12 -  iszero :: "int => bool"
    1.13 -  "iszero z == z = (0::int)"
    1.14    
    1.15  defs (overloaded)
    1.16    
    1.17 @@ -48,16 +41,17 @@
    1.18  		 intrel``{(x1+x2, y1+y2)})"
    1.19  
    1.20    zdiff_def:  "z - (w::int) == z + (-w)"
    1.21 -
    1.22 -  zless_def:  "z<w == neg(z - w)"
    1.23 -
    1.24 -  zle_def:    "z <= (w::int) == ~(w < z)"
    1.25 -
    1.26    zmult_def:
    1.27     "z * w == 
    1.28         Abs_Integ(\<Union>(x1,y1) \<in> Rep_Integ(z). \<Union>(x2,y2) \<in> Rep_Integ(w).   
    1.29  		 intrel``{(x1*x2 + y1*y2, x1*y2 + y1*x2)})"
    1.30  
    1.31 +  zless_def: "(z < (w::int)) == (z \<le> w & z \<noteq> w)"
    1.32 +
    1.33 +  zle_def:
    1.34 +  "z \<le> (w::int) == \<exists>x1 y1 x2 y2. x1 + y2 \<le> x2 + y1 &
    1.35 +                            (x1,y1) \<in> Rep_Integ z & (x2,y2) \<in> Rep_Integ w"
    1.36 +
    1.37  lemma intrel_iff [simp]: "(((x1,y1),(x2,y2)) \<in>  intrel) = (x1+y2 = x2+y1)"
    1.38  by (unfold intrel_def, blast)
    1.39  
    1.40 @@ -121,8 +115,8 @@
    1.41  done
    1.42  
    1.43  lemma zminus_zminus [simp]: "- (- z) = (z::int)"
    1.44 -apply (rule_tac z = z in eq_Abs_Integ)
    1.45 -apply (simp (no_asm_simp) add: zminus)
    1.46 +apply (rule eq_Abs_Integ [of z])
    1.47 +apply (simp add: zminus)
    1.48  done
    1.49  
    1.50  lemma inj_zminus: "inj(%z::int. -z)"
    1.51 @@ -134,16 +128,6 @@
    1.52  by (simp add: int_def Zero_int_def zminus)
    1.53  
    1.54  
    1.55 -subsection{*neg: the test for negative integers*}
    1.56 -
    1.57 -
    1.58 -lemma not_neg_int [simp]: "~ neg(int n)"
    1.59 -by (simp add: neg_def int_def)
    1.60 -
    1.61 -lemma neg_zminus_int [simp]: "neg(- (int (Suc n)))"
    1.62 -by (simp add: neg_def int_def zminus)
    1.63 -
    1.64 -
    1.65  subsection{*zadd: addition on Integ*}
    1.66  
    1.67  lemma zadd: 
    1.68 @@ -155,22 +139,22 @@
    1.69  done
    1.70  
    1.71  lemma zminus_zadd_distrib [simp]: "- (z + w) = (- z) + (- w::int)"
    1.72 -apply (rule_tac z = z in eq_Abs_Integ)
    1.73 -apply (rule_tac z = w in eq_Abs_Integ)
    1.74 -apply (simp (no_asm_simp) add: zminus zadd)
    1.75 +apply (rule eq_Abs_Integ [of z])
    1.76 +apply (rule eq_Abs_Integ [of w])
    1.77 +apply (simp add: zminus zadd)
    1.78  done
    1.79  
    1.80  lemma zadd_commute: "(z::int) + w = w + z"
    1.81 -apply (rule_tac z = z in eq_Abs_Integ)
    1.82 -apply (rule_tac z = w in eq_Abs_Integ)
    1.83 -apply (simp (no_asm_simp) add: add_ac zadd)
    1.84 +apply (rule eq_Abs_Integ [of z])
    1.85 +apply (rule eq_Abs_Integ [of w])
    1.86 +apply (simp add: add_ac zadd)
    1.87  done
    1.88  
    1.89  lemma zadd_assoc: "((z1::int) + z2) + z3 = z1 + (z2 + z3)"
    1.90 -apply (rule_tac z = z1 in eq_Abs_Integ)
    1.91 -apply (rule_tac z = z2 in eq_Abs_Integ)
    1.92 -apply (rule_tac z = z3 in eq_Abs_Integ)
    1.93 -apply (simp (no_asm_simp) add: zadd add_assoc)
    1.94 +apply (rule eq_Abs_Integ [of z1])
    1.95 +apply (rule eq_Abs_Integ [of z2])
    1.96 +apply (rule eq_Abs_Integ [of z3])
    1.97 +apply (simp add: zadd add_assoc)
    1.98  done
    1.99  
   1.100  (*For AC rewriting*)
   1.101 @@ -197,8 +181,8 @@
   1.102  (*also for the instance declaration int :: plus_ac0*)
   1.103  lemma zadd_0 [simp]: "(0::int) + z = z"
   1.104  apply (unfold Zero_int_def int_def)
   1.105 -apply (rule_tac z = z in eq_Abs_Integ)
   1.106 -apply (simp (no_asm_simp) add: zadd)
   1.107 +apply (rule eq_Abs_Integ [of z])
   1.108 +apply (simp add: zadd)
   1.109  done
   1.110  
   1.111  lemma zadd_0_right [simp]: "z + (0::int) = z"
   1.112 @@ -206,8 +190,8 @@
   1.113  
   1.114  lemma zadd_zminus_inverse [simp]: "z + (- z) = (0::int)"
   1.115  apply (unfold int_def Zero_int_def)
   1.116 -apply (rule_tac z = z in eq_Abs_Integ)
   1.117 -apply (simp (no_asm_simp) add: zminus zadd add_commute)
   1.118 +apply (rule eq_Abs_Integ [of z])
   1.119 +apply (simp add: zminus zadd add_commute)
   1.120  done
   1.121  
   1.122  lemma zadd_zminus_inverse2 [simp]: "(- z) + z = (0::int)"
   1.123 @@ -236,57 +220,52 @@
   1.124  lemma zadd_assoc_cong: "(z::int) + v = z' + v' ==> z + (v + w) = z' + (v' + w)"
   1.125  by (simp add: zadd_assoc [symmetric])
   1.126  
   1.127 -lemma zadd_assoc_swap: "(z::int) + (v + w) = v + (z + w)"
   1.128 -by (rule zadd_commute [THEN zadd_assoc_cong])
   1.129 -
   1.130  
   1.131  subsection{*zmult: multiplication on Integ*}
   1.132  
   1.133 -(*Congruence property for multiplication*)
   1.134 +text{*Congruence property for multiplication*}
   1.135  lemma zmult_congruent2: "congruent2 intrel  
   1.136          (%p1 p2. (%(x1,y1). (%(x2,y2).    
   1.137                      intrel``{(x1*x2 + y1*y2, x1*y2 + y1*x2)}) p2) p1)"
   1.138  apply (rule equiv_intrel [THEN congruent2_commuteI])
   1.139 -apply (rule_tac [2] p=w in PairE)  
   1.140 -apply (force simp add: add_ac mult_ac, clarify) 
   1.141 -apply (simp (no_asm_simp) del: equiv_intrel_iff add: add_ac mult_ac)
   1.142 + apply (force simp add: add_ac mult_ac) 
   1.143 +apply (clarify, simp del: equiv_intrel_iff add: add_ac mult_ac)
   1.144  apply (rename_tac x1 x2 y1 y2 z1 z2)
   1.145  apply (rule equiv_class_eq [OF equiv_intrel intrel_iff [THEN iffD2]])
   1.146 -apply (simp add: intrel_def)
   1.147 -apply (subgoal_tac "x1*z1 + y2*z1 = y1*z1 + x2*z1 & x1*z2 + y2*z2 = y1*z2 + x2*z2", arith)
   1.148 +apply (subgoal_tac "x1*z1 + y2*z1 = y1*z1 + x2*z1 & x1*z2 + y2*z2 = y1*z2 + x2*z2")
   1.149 +apply (simp add: mult_ac, arith) 
   1.150  apply (simp add: add_mult_distrib [symmetric])
   1.151  done
   1.152  
   1.153  lemma zmult: 
   1.154     "Abs_Integ((intrel``{(x1,y1)})) * Abs_Integ((intrel``{(x2,y2)})) =    
   1.155      Abs_Integ(intrel `` {(x1*x2 + y1*y2, x1*y2 + y1*x2)})"
   1.156 -apply (unfold zmult_def)
   1.157 -apply (simp (no_asm_simp) add: UN_UN_split_split_eq zmult_congruent2 equiv_intrel [THEN UN_equiv_class2])
   1.158 -done
   1.159 +by (simp add: zmult_def UN_UN_split_split_eq zmult_congruent2 
   1.160 +              equiv_intrel [THEN UN_equiv_class2])
   1.161  
   1.162  lemma zmult_zminus: "(- z) * w = - (z * (w::int))"
   1.163 -apply (rule_tac z = z in eq_Abs_Integ)
   1.164 -apply (rule_tac z = w in eq_Abs_Integ)
   1.165 -apply (simp (no_asm_simp) add: zminus zmult add_ac)
   1.166 +apply (rule eq_Abs_Integ [of z])
   1.167 +apply (rule eq_Abs_Integ [of w])
   1.168 +apply (simp add: zminus zmult add_ac)
   1.169  done
   1.170  
   1.171  lemma zmult_commute: "(z::int) * w = w * z"
   1.172 -apply (rule_tac z = z in eq_Abs_Integ)
   1.173 -apply (rule_tac z = w in eq_Abs_Integ)
   1.174 -apply (simp (no_asm_simp) add: zmult add_ac mult_ac)
   1.175 +apply (rule eq_Abs_Integ [of z])
   1.176 +apply (rule eq_Abs_Integ [of w])
   1.177 +apply (simp add: zmult add_ac mult_ac)
   1.178  done
   1.179  
   1.180  lemma zmult_assoc: "((z1::int) * z2) * z3 = z1 * (z2 * z3)"
   1.181 -apply (rule_tac z = z1 in eq_Abs_Integ)
   1.182 -apply (rule_tac z = z2 in eq_Abs_Integ)
   1.183 -apply (rule_tac z = z3 in eq_Abs_Integ)
   1.184 -apply (simp (no_asm_simp) add: add_mult_distrib2 zmult add_ac mult_ac)
   1.185 +apply (rule eq_Abs_Integ [of z1])
   1.186 +apply (rule eq_Abs_Integ [of z2])
   1.187 +apply (rule eq_Abs_Integ [of z3])
   1.188 +apply (simp add: add_mult_distrib2 zmult add_ac mult_ac)
   1.189  done
   1.190  
   1.191  lemma zadd_zmult_distrib: "((z1::int) + z2) * w = (z1 * w) + (z2 * w)"
   1.192 -apply (rule_tac z = z1 in eq_Abs_Integ)
   1.193 -apply (rule_tac z = z2 in eq_Abs_Integ)
   1.194 -apply (rule_tac z = w in eq_Abs_Integ)
   1.195 +apply (rule eq_Abs_Integ [of z1])
   1.196 +apply (rule eq_Abs_Integ [of z2])
   1.197 +apply (rule eq_Abs_Integ [of w])
   1.198  apply (simp add: add_mult_distrib2 zadd zmult add_ac mult_ac)
   1.199  done
   1.200  
   1.201 @@ -314,14 +293,14 @@
   1.202  
   1.203  lemma zmult_0 [simp]: "0 * z = (0::int)"
   1.204  apply (unfold Zero_int_def int_def)
   1.205 -apply (rule_tac z = z in eq_Abs_Integ)
   1.206 -apply (simp (no_asm_simp) add: zmult)
   1.207 +apply (rule eq_Abs_Integ [of z])
   1.208 +apply (simp add: zmult)
   1.209  done
   1.210  
   1.211  lemma zmult_1 [simp]: "(1::int) * z = z"
   1.212  apply (unfold One_int_def int_def)
   1.213 -apply (rule_tac z = z in eq_Abs_Integ)
   1.214 -apply (simp (no_asm_simp) add: zmult)
   1.215 +apply (rule eq_Abs_Integ [of z])
   1.216 +apply (simp add: zmult)
   1.217  done
   1.218  
   1.219  lemma zmult_0_right [simp]: "z * 0 = (0::int)"
   1.220 @@ -352,64 +331,73 @@
   1.221  qed
   1.222  
   1.223  
   1.224 -subsection{*Theorems about the Ordering*}
   1.225 +subsection{*The @{text "\<le>"} Ordering*}
   1.226 +
   1.227 +lemma zle: 
   1.228 +  "(Abs_Integ(intrel``{(x1,y1)}) \<le> Abs_Integ(intrel``{(x2,y2)})) =  
   1.229 +   (x1 + y2 \<le> x2 + y1)"
   1.230 +by (force simp add: zle_def)
   1.231 +
   1.232 +lemma zle_refl: "w \<le> (w::int)"
   1.233 +apply (rule eq_Abs_Integ [of w])
   1.234 +apply (force simp add: zle)
   1.235 +done
   1.236 +
   1.237 +lemma zle_trans: "[| i \<le> j; j \<le> k |] ==> i \<le> (k::int)"
   1.238 +apply (rule eq_Abs_Integ [of i]) 
   1.239 +apply (rule eq_Abs_Integ [of j]) 
   1.240 +apply (rule eq_Abs_Integ [of k]) 
   1.241 +apply (simp add: zle) 
   1.242 +done
   1.243 +
   1.244 +lemma zle_anti_sym: "[| z \<le> w; w \<le> z |] ==> z = (w::int)"
   1.245 +apply (rule eq_Abs_Integ [of w]) 
   1.246 +apply (rule eq_Abs_Integ [of z]) 
   1.247 +apply (simp add: zle) 
   1.248 +done
   1.249 +
   1.250 +(* Axiom 'order_less_le' of class 'order': *)
   1.251 +lemma zless_le: "((w::int) < z) = (w \<le> z & w \<noteq> z)"
   1.252 +by (simp add: zless_def)
   1.253 +
   1.254 +instance int :: order
   1.255 +proof qed
   1.256 + (assumption |
   1.257 +  rule zle_refl zle_trans zle_anti_sym zless_le)+
   1.258 +
   1.259 +(* Axiom 'linorder_linear' of class 'linorder': *)
   1.260 +lemma zle_linear: "(z::int) \<le> w | w \<le> z"
   1.261 +apply (rule eq_Abs_Integ [of z])
   1.262 +apply (rule eq_Abs_Integ [of w])
   1.263 +apply (simp add: zle linorder_linear) 
   1.264 +done
   1.265 +
   1.266 +instance int :: plus_ac0
   1.267 +proof qed (rule zadd_commute zadd_assoc zadd_0)+
   1.268 +
   1.269 +instance int :: linorder
   1.270 +proof qed (rule zle_linear)
   1.271 +
   1.272 +
   1.273 +lemmas zless_linear = linorder_less_linear [where 'a = int]
   1.274 +
   1.275 +
   1.276 +lemma int_eq_0_conv [simp]: "(int n = 0) = (n = 0)"
   1.277 +by (simp add: Zero_int_def)
   1.278  
   1.279  (*This lemma allows direct proofs of other <-properties*)
   1.280  lemma zless_iff_Suc_zadd: 
   1.281      "(w < z) = (\<exists>n. z = w + int(Suc n))"
   1.282 -apply (unfold zless_def neg_def zdiff_def int_def)
   1.283 -apply (rule_tac z = z in eq_Abs_Integ)
   1.284 -apply (rule_tac z = w in eq_Abs_Integ, clarify)
   1.285 -apply (simp add: zadd zminus)
   1.286 +apply (rule eq_Abs_Integ [of z])
   1.287 +apply (rule eq_Abs_Integ [of w])
   1.288 +apply (simp add: linorder_not_le [where 'a = int, symmetric] 
   1.289 +                 linorder_not_le [where 'a = nat] 
   1.290 +                 zle int_def zdiff_def zadd zminus) 
   1.291  apply (safe dest!: less_imp_Suc_add)
   1.292  apply (rule_tac x = k in exI)
   1.293  apply (simp_all add: add_ac)
   1.294  done
   1.295  
   1.296 -lemma zless_zadd_Suc: "z < z + int (Suc n)"
   1.297 -by (auto simp add: zless_iff_Suc_zadd zadd_assoc zadd_int)
   1.298 -
   1.299 -lemma zless_trans: "[| z1<z2; z2<z3 |] ==> z1 < (z3::int)"
   1.300 -by (auto simp add: zless_iff_Suc_zadd zadd_assoc zadd_int)
   1.301 -
   1.302 -lemma zless_not_sym: "!!w::int. z<w ==> ~w<z"
   1.303 -apply (safe dest!: zless_iff_Suc_zadd [THEN iffD1])
   1.304 -apply (rule_tac z = z in eq_Abs_Integ, safe)
   1.305 -apply (simp add: int_def zadd)
   1.306 -done
   1.307 -
   1.308 -(* [| n<m;  ~P ==> m<n |] ==> P *)
   1.309 -lemmas zless_asym = zless_not_sym [THEN swap, standard]
   1.310 -
   1.311 -lemma zless_not_refl: "!!z::int. ~ z<z"
   1.312 -apply (rule zless_asym [THEN notI])
   1.313 -apply (assumption+)
   1.314 -done
   1.315 -
   1.316 -(* z<z ==> R *)
   1.317 -lemmas zless_irrefl = zless_not_refl [THEN notE, standard, elim!]
   1.318 -
   1.319 -
   1.320 -(*"Less than" is a linear ordering*)
   1.321 -lemma zless_linear: 
   1.322 -    "z<w | z=w | w<(z::int)"
   1.323 -apply (unfold zless_def neg_def zdiff_def)
   1.324 -apply (rule_tac z = z in eq_Abs_Integ)
   1.325 -apply (rule_tac z = w in eq_Abs_Integ, safe)
   1.326 -apply (simp add: zadd zminus Image_iff Bex_def)
   1.327 -apply (rule_tac m1 = "x+ya" and n1 = "xa+y" in less_linear [THEN disjE])
   1.328 -apply (force simp add: add_ac)+
   1.329 -done
   1.330 -
   1.331 -lemma int_neq_iff: "!!w::int. (w ~= z) = (w<z | z<w)"
   1.332 -by (cut_tac zless_linear, blast)
   1.333 -
   1.334 -(*** eliminates ~= in premises ***)
   1.335 -lemmas int_neqE = int_neq_iff [THEN iffD1, THEN disjE, standard]
   1.336 -
   1.337 -lemma int_eq_0_conv [simp]: "(int n = 0) = (n = 0)"
   1.338 -by (simp add: Zero_int_def)
   1.339 -
   1.340  lemma zless_int [simp]: "(int m < int n) = (m<n)"
   1.341  by (simp add: less_iff_Suc_add zless_iff_Suc_zadd zadd_int)
   1.342  
   1.343 @@ -425,84 +413,553 @@
   1.344  lemma int_0_neq_1 [simp]: "0 \<noteq> (1::int)"
   1.345  by (simp only: Zero_int_def One_int_def One_nat_def int_int_eq)
   1.346  
   1.347 -
   1.348 -subsection{*Properties of the @{text "\<le>"} Relation*}
   1.349 +lemma zle_int [simp]: "(int m \<le> int n) = (m\<le>n)"
   1.350 +by (simp add: linorder_not_less [symmetric])
   1.351  
   1.352 -lemma zle_int [simp]: "(int m <= int n) = (m<=n)"
   1.353 -by (simp add: zle_def le_def)
   1.354 +lemma zero_zle_int [simp]: "(0 \<le> int n)"
   1.355 +by (simp add: Zero_int_def)
   1.356  
   1.357 -lemma zero_zle_int [simp]: "(0 <= int n)"
   1.358 +lemma int_le_0_conv [simp]: "(int n \<le> 0) = (n = 0)"
   1.359 +by (simp add: Zero_int_def)
   1.360 +
   1.361 +lemma int_0 [simp]: "int 0 = (0::int)"
   1.362  by (simp add: Zero_int_def)
   1.363  
   1.364 -lemma int_le_0_conv [simp]: "(int n <= 0) = (n = 0)"
   1.365 -by (simp add: Zero_int_def)
   1.366 +lemma int_1 [simp]: "int 1 = 1"
   1.367 +by (simp add: One_int_def)
   1.368 +
   1.369 +lemma int_Suc0_eq_1: "int (Suc 0) = 1"
   1.370 +by (simp add: One_int_def One_nat_def)
   1.371 +
   1.372 +subsection{*Monotonicity results*}
   1.373 +
   1.374 +lemma zadd_left_mono: "i \<le> j ==> k + i \<le> k + (j::int)" 
   1.375 +apply (rule eq_Abs_Integ [of i]) 
   1.376 +apply (rule eq_Abs_Integ [of j]) 
   1.377 +apply (rule eq_Abs_Integ [of k]) 
   1.378 +apply (simp add: zle zadd) 
   1.379 +done
   1.380 +
   1.381 +lemma zadd_strict_right_mono: "i < j ==> i + k < j + (k::int)" 
   1.382 +apply (rule eq_Abs_Integ [of i]) 
   1.383 +apply (rule eq_Abs_Integ [of j]) 
   1.384 +apply (rule eq_Abs_Integ [of k]) 
   1.385 +apply (simp add: linorder_not_le [where 'a = int, symmetric] 
   1.386 +                 linorder_not_le [where 'a = nat]  zle zadd)
   1.387 +done
   1.388 +
   1.389 +lemma zadd_zless_mono: "[| w'<w; z'\<le>z |] ==> w' + z' < w + (z::int)"
   1.390 +by (rule order_less_le_trans [OF zadd_strict_right_mono zadd_left_mono]) 
   1.391 +
   1.392 +
   1.393 +subsection{*Strict Monotonicity of Multiplication*}
   1.394 +
   1.395 +text{*strict, in 1st argument; proof is by induction on k>0*}
   1.396 +lemma zmult_zless_mono2_lemma [rule_format]:
   1.397 +     "i<j ==> 0<k --> int k * i < int k * j"
   1.398 +apply (induct_tac "k", simp) 
   1.399 +apply (simp add: int_Suc)
   1.400 +apply (case_tac "n=0")
   1.401 +apply (simp_all add: zadd_zmult_distrib int_Suc0_eq_1 order_le_less)
   1.402 +apply (simp add: zadd_zless_mono int_Suc0_eq_1 order_le_less)
   1.403 +done
   1.404  
   1.405 -lemma zle_imp_zless_or_eq: "z <= w ==> z < w | z=(w::int)"
   1.406 -apply (unfold zle_def)
   1.407 -apply (cut_tac zless_linear)
   1.408 -apply (blast elim: zless_asym)
   1.409 +lemma zero_le_imp_eq_int: "0 \<le> k ==> \<exists>n. k = int n"
   1.410 +apply (rule eq_Abs_Integ [of k]) 
   1.411 +apply (auto simp add: zle zadd int_def Zero_int_def)
   1.412 +apply (rule_tac x="x-y" in exI, simp) 
   1.413 +done
   1.414 +
   1.415 +lemma zmult_zless_mono2: "[| i<j;  (0::int) < k |] ==> k*i < k*j"
   1.416 +apply (frule order_less_imp_le [THEN zero_le_imp_eq_int]) 
   1.417 +apply (auto simp add: zmult_zless_mono2_lemma) 
   1.418 +done
   1.419 +
   1.420 +
   1.421 +defs (overloaded)
   1.422 +    zabs_def:  "abs(i::int) == if i < 0 then -i else i"
   1.423 +
   1.424 +
   1.425 +text{*The Integers Form an Ordered Ring*}
   1.426 +instance int :: ordered_ring
   1.427 +proof
   1.428 +  fix i j k :: int
   1.429 +  show "0 < (1::int)" by (rule int_0_less_1)
   1.430 +  show "i \<le> j ==> k + i \<le> k + j" by (rule zadd_left_mono)
   1.431 +  show "i < j ==> 0 < k ==> k * i < k * j" by (rule zmult_zless_mono2)
   1.432 +  show "\<bar>i\<bar> = (if i < 0 then -i else i)" by (simp only: zabs_def)
   1.433 +qed
   1.434 +
   1.435 +
   1.436 +subsection{*Magnitide of an Integer, as a Natural Number: @{term nat}*}
   1.437 +
   1.438 +constdefs
   1.439 +   nat  :: "int => nat"
   1.440 +    "nat(Z) == if Z<0 then 0 else (THE m. Z = int m)"
   1.441 +
   1.442 +lemma nat_int [simp]: "nat(int n) = n"
   1.443 +by (unfold nat_def, auto)
   1.444 +
   1.445 +lemma nat_zero [simp]: "nat 0 = 0"
   1.446 +apply (unfold Zero_int_def)
   1.447 +apply (rule nat_int)
   1.448 +done
   1.449 +
   1.450 +lemma nat_0_le [simp]: "0 \<le> z ==> int (nat z) = z"
   1.451 +apply (rule eq_Abs_Integ [of z]) 
   1.452 +apply (simp add: nat_def linorder_not_le [symmetric] zle int_def Zero_int_def)
   1.453 +apply (subgoal_tac "(THE m. x = m + y) = x-y")
   1.454 +apply (auto simp add: the_equality) 
   1.455  done
   1.456  
   1.457 -lemma zless_or_eq_imp_zle: "z<w | z=w ==> z <= (w::int)"
   1.458 -apply (unfold zle_def)
   1.459 -apply (cut_tac zless_linear)
   1.460 -apply (blast elim: zless_asym)
   1.461 +lemma nat_le_0 [simp]: "z \<le> 0 ==> nat z = 0"
   1.462 +by (simp add: nat_def  order_less_le eq_commute [of 0])
   1.463 +
   1.464 +text{*An alternative condition is @{term "0 \<le> w"} *}
   1.465 +lemma nat_mono_iff: "0 < z ==> (nat w < nat z) = (w < z)"
   1.466 +apply (subst zless_int [symmetric])
   1.467 +apply (simp add: order_le_less)
   1.468 +apply (case_tac "w < 0")
   1.469 + apply (simp add: order_less_imp_le)
   1.470 + apply (blast intro: order_less_trans)
   1.471 +apply (simp add: linorder_not_less)
   1.472 +done
   1.473 +
   1.474 +lemma zless_nat_conj: "(nat w < nat z) = (0 < z & w < z)"
   1.475 +apply (case_tac "0 < z")
   1.476 +apply (auto simp add: nat_mono_iff linorder_not_less)
   1.477 +done
   1.478 +
   1.479 +
   1.480 +subsection{*Lemmas about the Function @{term int} and Orderings*}
   1.481 +
   1.482 +lemma negative_zless_0: "- (int (Suc n)) < 0"
   1.483 +by (simp add: zless_def)
   1.484 +
   1.485 +lemma negative_zless [iff]: "- (int (Suc n)) < int m"
   1.486 +by (rule negative_zless_0 [THEN order_less_le_trans], simp)
   1.487 +
   1.488 +lemma negative_zle_0: "- int n \<le> 0"
   1.489 +by (simp add: minus_le_iff)
   1.490 +
   1.491 +lemma negative_zle [iff]: "- int n \<le> int m"
   1.492 +by (rule order_trans [OF negative_zle_0 zero_zle_int])
   1.493 +
   1.494 +lemma not_zle_0_negative [simp]: "~ (0 \<le> - (int (Suc n)))"
   1.495 +by (subst le_minus_iff, simp)
   1.496 +
   1.497 +lemma int_zle_neg: "(int n \<le> - int m) = (n = 0 & m = 0)"
   1.498 +apply safe 
   1.499 +apply (drule_tac [2] le_minus_iff [THEN iffD1])
   1.500 +apply (auto dest: zle_trans [OF _ negative_zle_0]) 
   1.501  done
   1.502  
   1.503 -lemma int_le_less: "(x <= (y::int)) = (x < y | x=y)"
   1.504 -apply (rule iffI) 
   1.505 -apply (erule zle_imp_zless_or_eq) 
   1.506 -apply (erule zless_or_eq_imp_zle) 
   1.507 +lemma not_int_zless_negative [simp]: "~ (int n < - int m)"
   1.508 +by (simp add: linorder_not_less)
   1.509 +
   1.510 +lemma negative_eq_positive [simp]: "(- int n = int m) = (n = 0 & m = 0)"
   1.511 +by (force simp add: order_eq_iff [of "- int n"] int_zle_neg)
   1.512 +
   1.513 +lemma zle_iff_zadd: "(w \<le> z) = (\<exists>n. z = w + int n)"
   1.514 +by (force intro: exI [of _ "0::nat"] 
   1.515 +            intro!: not_sym [THEN not0_implies_Suc]
   1.516 +            simp add: zless_iff_Suc_zadd order_le_less)
   1.517 +
   1.518 +
   1.519 +text{*This version is proved for all ordered rings, not just integers!
   1.520 +      It is proved here because attribute @{text arith_split} is not available
   1.521 +      in theory @{text Ring_and_Field}.
   1.522 +      But is it really better than just rewriting with @{text abs_if}?*}
   1.523 +lemma abs_split [arith_split]:
   1.524 +     "P(abs(a::'a::ordered_ring)) = ((0 \<le> a --> P a) & (a < 0 --> P(-a)))"
   1.525 +by (force dest: order_less_le_trans simp add: abs_if linorder_not_less)
   1.526 +
   1.527 +lemma abs_int_eq [simp]: "abs (int m) = int m"
   1.528 +by (simp add: zabs_def)
   1.529 +
   1.530 +
   1.531 +subsection{*Misc Results*}
   1.532 +
   1.533 +lemma nat_zminus_int [simp]: "nat(- (int n)) = 0"
   1.534 +by (auto simp add: nat_def zero_reorient minus_less_iff)
   1.535 +
   1.536 +lemma zless_nat_eq_int_zless: "(m < nat z) = (int m < z)"
   1.537 +apply (case_tac "0 \<le> z")
   1.538 +apply (erule nat_0_le [THEN subst], simp) 
   1.539 +apply (simp add: linorder_not_le)
   1.540 +apply (auto dest: order_less_trans simp add: order_less_imp_le)
   1.541  done
   1.542  
   1.543 -lemma zle_refl: "w <= (w::int)"
   1.544 -by (simp add: int_le_less)
   1.545 +
   1.546 +
   1.547 +subsection{*Monotonicity of Multiplication*}
   1.548 +
   1.549 +lemma zmult_zle_mono2: "[| i \<le> j;  (0::int) \<le> k |] ==> k*i \<le> k*j"
   1.550 +  by (rule Ring_and_Field.mult_left_mono)
   1.551 +
   1.552 +lemma zmult_zless_cancel2: "(m*k < n*k) = (((0::int) < k & m<n) | (k<0 & n<m))"
   1.553 +  by (rule Ring_and_Field.mult_less_cancel_right)
   1.554 +
   1.555 +lemma zmult_zless_cancel1:
   1.556 +     "(k*m < k*n) = (((0::int) < k & m<n) | (k < 0 & n<m))"
   1.557 +  by (rule Ring_and_Field.mult_less_cancel_left)
   1.558  
   1.559 -(* Axiom 'linorder_linear' of class 'linorder': *)
   1.560 -lemma zle_linear: "(z::int) <= w | w <= z"
   1.561 -apply (simp add: int_le_less)
   1.562 -apply (cut_tac zless_linear, blast)
   1.563 +lemma zmult_zle_cancel1:
   1.564 +     "(k*m \<le> k*n) = (((0::int) < k --> m\<le>n) & (k < 0 --> n\<le>m))"
   1.565 +  by (rule Ring_and_Field.mult_le_cancel_left)
   1.566 +
   1.567 +
   1.568 +
   1.569 +text{*A case theorem distinguishing non-negative and negative int*}
   1.570 +
   1.571 +lemma negD: "x<0 ==> \<exists>n. x = - (int (Suc n))"
   1.572 +by (auto simp add: zless_iff_Suc_zadd 
   1.573 +                   diff_eq_eq [symmetric] zdiff_def)
   1.574 +
   1.575 +lemma int_cases [cases type: int, case_names nonneg neg]: 
   1.576 +     "[|!! n. z = int n ==> P;  !! n. z =  - (int (Suc n)) ==> P |] ==> P"
   1.577 +apply (case_tac "z < 0", blast dest!: negD)
   1.578 +apply (simp add: linorder_not_less)
   1.579 +apply (blast dest: nat_0_le [THEN sym])
   1.580  done
   1.581  
   1.582 -(* Axiom 'order_trans of class 'order': *)
   1.583 -lemma zle_trans: "[| i <= j; j <= k |] ==> i <= (k::int)"
   1.584 -apply (drule zle_imp_zless_or_eq) 
   1.585 -apply (drule zle_imp_zless_or_eq) 
   1.586 -apply (rule zless_or_eq_imp_zle) 
   1.587 -apply (blast intro: zless_trans) 
   1.588 +lemma int_induct [induct type: int, case_names nonneg neg]: 
   1.589 +     "[|!! n. P (int n);  !!n. P (- (int (Suc n))) |] ==> P z"
   1.590 +  by (cases z) auto
   1.591 +
   1.592 +
   1.593 +subsection{*The Constants @{term neg} and @{term iszero}*}
   1.594 +
   1.595 +constdefs
   1.596 +
   1.597 +  neg   :: "'a::ordered_ring => bool"
   1.598 +  "neg(Z) == Z < 0"
   1.599 +
   1.600 +  (*For simplifying equalities*)
   1.601 +  iszero :: "'a::semiring => bool"
   1.602 +  "iszero z == z = (0)"
   1.603 +  
   1.604 +
   1.605 +lemma not_neg_int [simp]: "~ neg(int n)"
   1.606 +by (simp add: neg_def)
   1.607 +
   1.608 +lemma neg_zminus_int [simp]: "neg(- (int (Suc n)))"
   1.609 +by (simp add: neg_def neg_less_0_iff_less)
   1.610 +
   1.611 +lemmas neg_eq_less_0 = neg_def
   1.612 +
   1.613 +lemma not_neg_eq_ge_0: "(~neg x) = (0 \<le> x)"
   1.614 +by (simp add: neg_def linorder_not_less)
   1.615 +
   1.616 +subsection{*To simplify inequalities when Numeral1 can get simplified to 1*}
   1.617 +
   1.618 +lemma not_neg_0: "~ neg 0"
   1.619 +by (simp add: One_int_def neg_def)
   1.620 +
   1.621 +lemma not_neg_1: "~ neg 1"
   1.622 +by (simp add: neg_def linorder_not_less zero_le_one) 
   1.623 +
   1.624 +lemma iszero_0: "iszero 0"
   1.625 +by (simp add: iszero_def)
   1.626 +
   1.627 +lemma not_iszero_1: "~ iszero 1"
   1.628 +by (simp add: iszero_def eq_commute) 
   1.629 +
   1.630 +lemma neg_nat: "neg z ==> nat z = 0"
   1.631 +by (simp add: nat_def neg_def) 
   1.632 +
   1.633 +lemma not_neg_nat: "~ neg z ==> int (nat z) = z"
   1.634 +by (simp add: linorder_not_less neg_def)
   1.635 +
   1.636 +
   1.637 +subsection{*Embedding of the Naturals into any Semiring: @{term of_nat}*}
   1.638 +
   1.639 +consts of_nat :: "nat => 'a::semiring"
   1.640 +
   1.641 +primrec
   1.642 +  of_nat_0:   "of_nat 0 = 0"
   1.643 +  of_nat_Suc: "of_nat (Suc m) = of_nat m + 1"
   1.644 +
   1.645 +lemma of_nat_1 [simp]: "of_nat 1 = 1"
   1.646 +by simp
   1.647 +
   1.648 +lemma of_nat_add [simp]: "of_nat (m+n) = of_nat m + of_nat n"
   1.649 +apply (induct m)
   1.650 +apply (simp_all add: add_ac) 
   1.651 +done
   1.652 +
   1.653 +lemma of_nat_mult [simp]: "of_nat (m*n) = of_nat m * of_nat n"
   1.654 +apply (induct m) 
   1.655 +apply (simp_all add: mult_ac add_ac right_distrib) 
   1.656 +done
   1.657 +
   1.658 +lemma zero_le_imp_of_nat: "0 \<le> (of_nat m::'a::ordered_semiring)"
   1.659 +apply (induct m, simp_all) 
   1.660 +apply (erule order_trans) 
   1.661 +apply (rule less_add_one [THEN order_less_imp_le]) 
   1.662  done
   1.663  
   1.664 -lemma zle_anti_sym: "[| z <= w; w <= z |] ==> z = (w::int)"
   1.665 -apply (drule zle_imp_zless_or_eq) 
   1.666 -apply (drule zle_imp_zless_or_eq) 
   1.667 -apply (blast elim: zless_asym) 
   1.668 +lemma less_imp_of_nat_less:
   1.669 +     "m < n ==> of_nat m < (of_nat n::'a::ordered_semiring)"
   1.670 +apply (induct m n rule: diff_induct, simp_all) 
   1.671 +apply (insert add_le_less_mono [OF zero_le_imp_of_nat zero_less_one], force) 
   1.672 +done
   1.673 +
   1.674 +lemma of_nat_less_imp_less:
   1.675 +     "of_nat m < (of_nat n::'a::ordered_semiring) ==> m < n"
   1.676 +apply (induct m n rule: diff_induct, simp_all) 
   1.677 +apply (insert zero_le_imp_of_nat) 
   1.678 +apply (force simp add: linorder_not_less [symmetric]) 
   1.679  done
   1.680  
   1.681 -(* Axiom 'order_less_le' of class 'order': *)
   1.682 -lemma int_less_le: "((w::int) < z) = (w <= z & w ~= z)"
   1.683 -apply (simp add: zle_def int_neq_iff)
   1.684 -apply (blast elim!: zless_asym)
   1.685 +lemma of_nat_less_iff [simp]:
   1.686 +     "(of_nat m < (of_nat n::'a::ordered_semiring)) = (m<n)"
   1.687 +by (blast intro: of_nat_less_imp_less less_imp_of_nat_less ) 
   1.688 +
   1.689 +text{*Special cases where either operand is zero*}
   1.690 +declare of_nat_less_iff [of 0, simplified, simp]
   1.691 +declare of_nat_less_iff [of _ 0, simplified, simp]
   1.692 +
   1.693 +lemma of_nat_le_iff [simp]:
   1.694 +     "(of_nat m \<le> (of_nat n::'a::ordered_semiring)) = (m \<le> n)"
   1.695 +by (simp add: linorder_not_less [symmetric]) 
   1.696 +
   1.697 +text{*Special cases where either operand is zero*}
   1.698 +declare of_nat_le_iff [of 0, simplified, simp]
   1.699 +declare of_nat_le_iff [of _ 0, simplified, simp]
   1.700 +
   1.701 +lemma of_nat_eq_iff [simp]:
   1.702 +     "(of_nat m = (of_nat n::'a::ordered_semiring)) = (m = n)"
   1.703 +by (simp add: order_eq_iff) 
   1.704 +
   1.705 +text{*Special cases where either operand is zero*}
   1.706 +declare of_nat_eq_iff [of 0, simplified, simp]
   1.707 +declare of_nat_eq_iff [of _ 0, simplified, simp]
   1.708 +
   1.709 +lemma of_nat_diff [simp]:
   1.710 +     "n \<le> m ==> of_nat (m - n) = of_nat m - (of_nat n :: 'a::ring)"
   1.711 +by (simp del: of_nat_add
   1.712 +	 add: compare_rls of_nat_add [symmetric] split add: nat_diff_split) 
   1.713 +
   1.714 +
   1.715 +subsection{*The Set of Natural Numbers*}
   1.716 +
   1.717 +constdefs
   1.718 +   Nats  :: "'a::semiring set"
   1.719 +    "Nats == range of_nat"
   1.720 +
   1.721 +syntax (xsymbols)    Nats :: "'a set"   ("\<nat>")
   1.722 +
   1.723 +lemma of_nat_in_Nats [simp]: "of_nat n \<in> Nats"
   1.724 +by (simp add: Nats_def) 
   1.725 +
   1.726 +lemma Nats_0 [simp]: "0 \<in> Nats"
   1.727 +apply (simp add: Nats_def) 
   1.728 +apply (rule range_eqI) 
   1.729 +apply (rule of_nat_0 [symmetric])
   1.730 +done
   1.731 +
   1.732 +lemma Nats_1 [simp]: "1 \<in> Nats"
   1.733 +apply (simp add: Nats_def) 
   1.734 +apply (rule range_eqI) 
   1.735 +apply (rule of_nat_1 [symmetric])
   1.736 +done
   1.737 +
   1.738 +lemma Nats_add [simp]: "[|a \<in> Nats; b \<in> Nats|] ==> a+b \<in> Nats"
   1.739 +apply (auto simp add: Nats_def) 
   1.740 +apply (rule range_eqI) 
   1.741 +apply (rule of_nat_add [symmetric])
   1.742 +done
   1.743 +
   1.744 +lemma Nats_mult [simp]: "[|a \<in> Nats; b \<in> Nats|] ==> a*b \<in> Nats"
   1.745 +apply (auto simp add: Nats_def) 
   1.746 +apply (rule range_eqI) 
   1.747 +apply (rule of_nat_mult [symmetric])
   1.748  done
   1.749  
   1.750 -instance int :: order
   1.751 -proof qed (assumption | rule zle_refl zle_trans zle_anti_sym int_less_le)+
   1.752 +text{*Agreement with the specific embedding for the integers*}
   1.753 +lemma int_eq_of_nat: "int = (of_nat :: nat => int)"
   1.754 +proof
   1.755 +  fix n
   1.756 +  show "int n = of_nat n"  by (induct n, simp_all add: int_Suc add_ac) 
   1.757 +qed
   1.758 +
   1.759 +
   1.760 +subsection{*Embedding of the Integers into any Ring: @{term of_int}*}
   1.761 +
   1.762 +constdefs
   1.763 +   of_int :: "int => 'a::ring"
   1.764 +   "of_int z ==
   1.765 +      (THE a. \<exists>i j. (i,j) \<in> Rep_Integ z & a = (of_nat i) - (of_nat j))"
   1.766 +
   1.767 +
   1.768 +lemma of_int: "of_int (Abs_Integ (intrel `` {(i,j)})) = of_nat i - of_nat j"
   1.769 +apply (simp add: of_int_def)
   1.770 +apply (rule the_equality, auto) 
   1.771 +apply (simp add: compare_rls add_ac of_nat_add [symmetric]
   1.772 +            del: of_nat_add) 
   1.773 +done
   1.774 +
   1.775 +lemma of_int_0 [simp]: "of_int 0 = 0"
   1.776 +by (simp add: of_int Zero_int_def int_def)
   1.777 +
   1.778 +lemma of_int_1 [simp]: "of_int 1 = 1"
   1.779 +by (simp add: of_int One_int_def int_def)
   1.780 +
   1.781 +lemma of_int_add [simp]: "of_int (w+z) = of_int w + of_int z"
   1.782 +apply (rule eq_Abs_Integ [of w])
   1.783 +apply (rule eq_Abs_Integ [of z])
   1.784 +apply (simp add: compare_rls of_int zadd) 
   1.785 +done
   1.786 +
   1.787 +lemma of_int_minus [simp]: "of_int (-z) = - (of_int z)"
   1.788 +apply (rule eq_Abs_Integ [of z])
   1.789 +apply (simp add: compare_rls of_int zminus) 
   1.790 +done
   1.791  
   1.792 -instance int :: plus_ac0
   1.793 -proof qed (rule zadd_commute zadd_assoc zadd_0)+
   1.794 +lemma of_int_diff [simp]: "of_int (w-z) = of_int w - of_int z"
   1.795 +by (simp add: diff_minus)
   1.796 +
   1.797 +lemma of_int_mult [simp]: "of_int (w*z) = of_int w * of_int z"
   1.798 +apply (rule eq_Abs_Integ [of w])
   1.799 +apply (rule eq_Abs_Integ [of z])
   1.800 +apply (simp add: compare_rls of_int left_diff_distrib right_diff_distrib 
   1.801 +                 zmult add_ac) 
   1.802 +done
   1.803 +
   1.804 +lemma of_int_le_iff [simp]:
   1.805 +     "(of_int w \<le> (of_int z::'a::ordered_ring)) = (w \<le> z)"
   1.806 +apply (rule eq_Abs_Integ [of w])
   1.807 +apply (rule eq_Abs_Integ [of z])
   1.808 +apply (simp add: compare_rls of_int zle zdiff_def zadd zminus 
   1.809 +                 of_nat_add [symmetric]   del: of_nat_add) 
   1.810 +done
   1.811 +
   1.812 +text{*Special cases where either operand is zero*}
   1.813 +declare of_int_le_iff [of 0, simplified, simp]
   1.814 +declare of_int_le_iff [of _ 0, simplified, simp]
   1.815  
   1.816 -instance int :: linorder
   1.817 -proof qed (rule zle_linear)
   1.818 +lemma of_int_less_iff [simp]:
   1.819 +     "(of_int w < (of_int z::'a::ordered_ring)) = (w < z)"
   1.820 +by (simp add: linorder_not_le [symmetric])
   1.821 +
   1.822 +text{*Special cases where either operand is zero*}
   1.823 +declare of_int_less_iff [of 0, simplified, simp]
   1.824 +declare of_int_less_iff [of _ 0, simplified, simp]
   1.825 +
   1.826 +lemma of_int_eq_iff [simp]:
   1.827 +     "(of_int w = (of_int z::'a::ordered_ring)) = (w = z)"
   1.828 +by (simp add: order_eq_iff) 
   1.829 +
   1.830 +text{*Special cases where either operand is zero*}
   1.831 +declare of_int_eq_iff [of 0, simplified, simp]
   1.832 +declare of_int_eq_iff [of _ 0, simplified, simp]
   1.833 +
   1.834 +
   1.835 +subsection{*The Set of Integers*}
   1.836 +
   1.837 +constdefs
   1.838 +   Ints  :: "'a::ring set"
   1.839 +    "Ints == range of_int"
   1.840  
   1.841  
   1.842 -lemma zadd_left_cancel [simp]: "!!w::int. (z + w' = z + w) = (w' = w)"
   1.843 -  by (rule add_left_cancel) 
   1.844 +syntax (xsymbols)
   1.845 +  Ints      :: "'a set"                   ("\<int>")
   1.846 +
   1.847 +lemma Ints_0 [simp]: "0 \<in> Ints"
   1.848 +apply (simp add: Ints_def) 
   1.849 +apply (rule range_eqI) 
   1.850 +apply (rule of_int_0 [symmetric])
   1.851 +done
   1.852 +
   1.853 +lemma Ints_1 [simp]: "1 \<in> Ints"
   1.854 +apply (simp add: Ints_def) 
   1.855 +apply (rule range_eqI) 
   1.856 +apply (rule of_int_1 [symmetric])
   1.857 +done
   1.858 +
   1.859 +lemma Ints_add [simp]: "[|a \<in> Ints; b \<in> Ints|] ==> a+b \<in> Ints"
   1.860 +apply (auto simp add: Ints_def) 
   1.861 +apply (rule range_eqI) 
   1.862 +apply (rule of_int_add [symmetric])
   1.863 +done
   1.864 +
   1.865 +lemma Ints_minus [simp]: "a \<in> Ints ==> -a \<in> Ints"
   1.866 +apply (auto simp add: Ints_def) 
   1.867 +apply (rule range_eqI) 
   1.868 +apply (rule of_int_minus [symmetric])
   1.869 +done
   1.870 +
   1.871 +lemma Ints_diff [simp]: "[|a \<in> Ints; b \<in> Ints|] ==> a-b \<in> Ints"
   1.872 +apply (auto simp add: Ints_def) 
   1.873 +apply (rule range_eqI) 
   1.874 +apply (rule of_int_diff [symmetric])
   1.875 +done
   1.876 +
   1.877 +lemma Ints_mult [simp]: "[|a \<in> Ints; b \<in> Ints|] ==> a*b \<in> Ints"
   1.878 +apply (auto simp add: Ints_def) 
   1.879 +apply (rule range_eqI) 
   1.880 +apply (rule of_int_mult [symmetric])
   1.881 +done
   1.882 +
   1.883 +text{*Collapse nested embeddings*}
   1.884 +lemma of_int_of_nat_eq [simp]: "of_int (of_nat n) = of_nat n"
   1.885 +by (induct n, auto) 
   1.886 +
   1.887 +lemma of_int_int_eq [simp]: "of_int (int n) = int n"
   1.888 +by (simp add: int_eq_of_nat) 
   1.889  
   1.890  
   1.891 +lemma Ints_cases [case_names of_int, cases set: Ints]:
   1.892 +  "q \<in> \<int> ==> (!!z. q = of_int z ==> C) ==> C"
   1.893 +proof (unfold Ints_def)
   1.894 +  assume "!!z. q = of_int z ==> C"
   1.895 +  assume "q \<in> range of_int" thus C ..
   1.896 +qed
   1.897 +
   1.898 +lemma Ints_induct [case_names of_int, induct set: Ints]:
   1.899 +  "q \<in> \<int> ==> (!!z. P (of_int z)) ==> P q"
   1.900 +  by (rule Ints_cases) auto
   1.901 +
   1.902 +
   1.903 +
   1.904 +(*Legacy ML bindings, but no longer the structure Int.*)
   1.905  ML
   1.906  {*
   1.907 +val zabs_def = thm "zabs_def"
   1.908 +val nat_def  = thm "nat_def"
   1.909 +
   1.910 +val int_0 = thm "int_0";
   1.911 +val int_1 = thm "int_1";
   1.912 +val int_Suc0_eq_1 = thm "int_Suc0_eq_1";
   1.913 +val neg_eq_less_0 = thm "neg_eq_less_0";
   1.914 +val not_neg_eq_ge_0 = thm "not_neg_eq_ge_0";
   1.915 +val not_neg_0 = thm "not_neg_0";
   1.916 +val not_neg_1 = thm "not_neg_1";
   1.917 +val iszero_0 = thm "iszero_0";
   1.918 +val not_iszero_1 = thm "not_iszero_1";
   1.919 +val int_0_less_1 = thm "int_0_less_1";
   1.920 +val int_0_neq_1 = thm "int_0_neq_1";
   1.921 +val negative_zless = thm "negative_zless";
   1.922 +val negative_zle = thm "negative_zle";
   1.923 +val not_zle_0_negative = thm "not_zle_0_negative";
   1.924 +val not_int_zless_negative = thm "not_int_zless_negative";
   1.925 +val negative_eq_positive = thm "negative_eq_positive";
   1.926 +val zle_iff_zadd = thm "zle_iff_zadd";
   1.927 +val abs_int_eq = thm "abs_int_eq";
   1.928 +val abs_split = thm"abs_split";
   1.929 +val nat_int = thm "nat_int";
   1.930 +val nat_zminus_int = thm "nat_zminus_int";
   1.931 +val nat_zero = thm "nat_zero";
   1.932 +val not_neg_nat = thm "not_neg_nat";
   1.933 +val neg_nat = thm "neg_nat";
   1.934 +val zless_nat_eq_int_zless = thm "zless_nat_eq_int_zless";
   1.935 +val nat_0_le = thm "nat_0_le";
   1.936 +val nat_le_0 = thm "nat_le_0";
   1.937 +val zless_nat_conj = thm "zless_nat_conj";
   1.938 +val int_cases = thm "int_cases";
   1.939 +
   1.940  val int_def = thm "int_def";
   1.941 -val neg_def = thm "neg_def";
   1.942 -val iszero_def = thm "iszero_def";
   1.943  val Zero_int_def = thm "Zero_int_def";
   1.944  val One_int_def = thm "One_int_def";
   1.945  val zadd_def = thm "zadd_def";
   1.946 @@ -524,8 +981,6 @@
   1.947  val zminus_zminus = thm "zminus_zminus";
   1.948  val inj_zminus = thm "inj_zminus";
   1.949  val zminus_0 = thm "zminus_0";
   1.950 -val not_neg_int = thm "not_neg_int";
   1.951 -val neg_zminus_int = thm "neg_zminus_int";
   1.952  val zadd = thm "zadd";
   1.953  val zminus_zadd_distrib = thm "zminus_zadd_distrib";
   1.954  val zadd_commute = thm "zadd_commute";
   1.955 @@ -545,8 +1000,6 @@
   1.956  val zdiff0 = thm "zdiff0";
   1.957  val zdiff0_right = thm "zdiff0_right";
   1.958  val zdiff_self = thm "zdiff_self";
   1.959 -val zadd_assoc_cong = thm "zadd_assoc_cong";
   1.960 -val zadd_assoc_swap = thm "zadd_assoc_swap";
   1.961  val zmult_congruent2 = thm "zmult_congruent2";
   1.962  val zmult = thm "zmult";
   1.963  val zmult_zminus = thm "zmult_zminus";
   1.964 @@ -564,15 +1017,6 @@
   1.965  val zmult_0_right = thm "zmult_0_right";
   1.966  val zmult_1_right = thm "zmult_1_right";
   1.967  val zless_iff_Suc_zadd = thm "zless_iff_Suc_zadd";
   1.968 -val zless_zadd_Suc = thm "zless_zadd_Suc";
   1.969 -val zless_trans = thm "zless_trans";
   1.970 -val zless_not_sym = thm "zless_not_sym";
   1.971 -val zless_asym = thm "zless_asym";
   1.972 -val zless_not_refl = thm "zless_not_refl";
   1.973 -val zless_irrefl = thm "zless_irrefl";
   1.974 -val zless_linear = thm "zless_linear";
   1.975 -val int_neq_iff = thm "int_neq_iff";
   1.976 -val int_neqE = thm "int_neqE";
   1.977  val int_int_eq = thm "int_int_eq";
   1.978  val int_eq_0_conv = thm "int_eq_0_conv";
   1.979  val zless_int = thm "zless_int";
   1.980 @@ -581,15 +1025,48 @@
   1.981  val zle_int = thm "zle_int";
   1.982  val zero_zle_int = thm "zero_zle_int";
   1.983  val int_le_0_conv = thm "int_le_0_conv";
   1.984 -val zle_imp_zless_or_eq = thm "zle_imp_zless_or_eq";
   1.985 -val zless_or_eq_imp_zle = thm "zless_or_eq_imp_zle";
   1.986 -val int_le_less = thm "int_le_less";
   1.987  val zle_refl = thm "zle_refl";
   1.988  val zle_linear = thm "zle_linear";
   1.989  val zle_trans = thm "zle_trans";
   1.990  val zle_anti_sym = thm "zle_anti_sym";
   1.991 -val int_less_le = thm "int_less_le";
   1.992 -val zadd_left_cancel = thm "zadd_left_cancel";
   1.993 +
   1.994 +val Ints_def = thm "Ints_def";
   1.995 +val Nats_def = thm "Nats_def";
   1.996 +
   1.997 +val of_nat_0 = thm "of_nat_0";
   1.998 +val of_nat_Suc = thm "of_nat_Suc";
   1.999 +val of_nat_1 = thm "of_nat_1";
  1.1000 +val of_nat_add = thm "of_nat_add";
  1.1001 +val of_nat_mult = thm "of_nat_mult";
  1.1002 +val zero_le_imp_of_nat = thm "zero_le_imp_of_nat";
  1.1003 +val less_imp_of_nat_less = thm "less_imp_of_nat_less";
  1.1004 +val of_nat_less_imp_less = thm "of_nat_less_imp_less";
  1.1005 +val of_nat_less_iff = thm "of_nat_less_iff";
  1.1006 +val of_nat_le_iff = thm "of_nat_le_iff";
  1.1007 +val of_nat_eq_iff = thm "of_nat_eq_iff";
  1.1008 +val Nats_0 = thm "Nats_0";
  1.1009 +val Nats_1 = thm "Nats_1";
  1.1010 +val Nats_add = thm "Nats_add";
  1.1011 +val Nats_mult = thm "Nats_mult";
  1.1012 +val of_int = thm "of_int";
  1.1013 +val of_int_0 = thm "of_int_0";
  1.1014 +val of_int_1 = thm "of_int_1";
  1.1015 +val of_int_add = thm "of_int_add";
  1.1016 +val of_int_minus = thm "of_int_minus";
  1.1017 +val of_int_diff = thm "of_int_diff";
  1.1018 +val of_int_mult = thm "of_int_mult";
  1.1019 +val of_int_le_iff = thm "of_int_le_iff";
  1.1020 +val of_int_less_iff = thm "of_int_less_iff";
  1.1021 +val of_int_eq_iff = thm "of_int_eq_iff";
  1.1022 +val Ints_0 = thm "Ints_0";
  1.1023 +val Ints_1 = thm "Ints_1";
  1.1024 +val Ints_add = thm "Ints_add";
  1.1025 +val Ints_minus = thm "Ints_minus";
  1.1026 +val Ints_diff = thm "Ints_diff";
  1.1027 +val Ints_mult = thm "Ints_mult";
  1.1028 +val of_int_of_nat_eq = thm"of_int_of_nat_eq";
  1.1029 +val Ints_cases = thm "Ints_cases";
  1.1030 +val Ints_induct = thm "Ints_induct";
  1.1031  *}
  1.1032  
  1.1033  end