src/HOL/Matrix/ComputeFloat.thy
 author wenzelm Fri Jan 14 15:44:47 2011 +0100 (2011-01-14) changeset 41550 efa734d9b221 parent 41413 64cd30d6b0b8 child 41959 b460124855b8 permissions -rw-r--r--
eliminated global prems;
tuned proofs;
```     1 (*  Title:  HOL/Tools/ComputeFloat.thy
```
```     2     Author: Steven Obua
```
```     3 *)
```
```     4
```
```     5 header {* Floating Point Representation of the Reals *}
```
```     6
```
```     7 theory ComputeFloat
```
```     8 imports Complex_Main "~~/src/HOL/Library/Lattice_Algebras"
```
```     9 uses "~~/src/Tools/float.ML" ("~~/src/HOL/Tools/float_arith.ML")
```
```    10 begin
```
```    11
```
```    12 definition pow2 :: "int \<Rightarrow> real"
```
```    13   where "pow2 a = (if (0 <= a) then (2^(nat a)) else (inverse (2^(nat (-a)))))"
```
```    14
```
```    15 definition float :: "int * int \<Rightarrow> real"
```
```    16   where "float x = real (fst x) * pow2 (snd x)"
```
```    17
```
```    18 lemma pow2_0[simp]: "pow2 0 = 1"
```
```    19 by (simp add: pow2_def)
```
```    20
```
```    21 lemma pow2_1[simp]: "pow2 1 = 2"
```
```    22 by (simp add: pow2_def)
```
```    23
```
```    24 lemma pow2_neg: "pow2 x = inverse (pow2 (-x))"
```
```    25 by (simp add: pow2_def)
```
```    26
```
```    27 lemma pow2_add1: "pow2 (1 + a) = 2 * (pow2 a)"
```
```    28 proof -
```
```    29   have h: "! n. nat (2 + int n) - Suc 0 = nat (1 + int n)" by arith
```
```    30   have g: "! a b. a - -1 = a + (1::int)" by arith
```
```    31   have pos: "! n. pow2 (int n + 1) = 2 * pow2 (int n)"
```
```    32     apply (auto, induct_tac n)
```
```    33     apply (simp_all add: pow2_def)
```
```    34     apply (rule_tac m1="2" and n1="nat (2 + int na)" in ssubst[OF realpow_num_eq_if])
```
```    35     by (auto simp add: h)
```
```    36   show ?thesis
```
```    37   proof (induct a)
```
```    38     case (1 n)
```
```    39     from pos show ?case by (simp add: algebra_simps)
```
```    40   next
```
```    41     case (2 n)
```
```    42     show ?case
```
```    43       apply (auto)
```
```    44       apply (subst pow2_neg[of "- int n"])
```
```    45       apply (subst pow2_neg[of "-1 - int n"])
```
```    46       apply (auto simp add: g pos)
```
```    47       done
```
```    48   qed
```
```    49 qed
```
```    50
```
```    51 lemma pow2_add: "pow2 (a+b) = (pow2 a) * (pow2 b)"
```
```    52 proof (induct b)
```
```    53   case (1 n)
```
```    54   show ?case
```
```    55   proof (induct n)
```
```    56     case 0
```
```    57     show ?case by simp
```
```    58   next
```
```    59     case (Suc m)
```
```    60     show ?case by (auto simp add: algebra_simps pow2_add1 1 Suc)
```
```    61   qed
```
```    62 next
```
```    63   case (2 n)
```
```    64   show ?case
```
```    65   proof (induct n)
```
```    66     case 0
```
```    67     show ?case
```
```    68       apply (auto)
```
```    69       apply (subst pow2_neg[of "a + -1"])
```
```    70       apply (subst pow2_neg[of "-1"])
```
```    71       apply (simp)
```
```    72       apply (insert pow2_add1[of "-a"])
```
```    73       apply (simp add: algebra_simps)
```
```    74       apply (subst pow2_neg[of "-a"])
```
```    75       apply (simp)
```
```    76       done
```
```    77     case (Suc m)
```
```    78     have a: "int m - (a + -2) =  1 + (int m - a + 1)" by arith
```
```    79     have b: "int m - -2 = 1 + (int m + 1)" by arith
```
```    80     show ?case
```
```    81       apply (auto)
```
```    82       apply (subst pow2_neg[of "a + (-2 - int m)"])
```
```    83       apply (subst pow2_neg[of "-2 - int m"])
```
```    84       apply (auto simp add: algebra_simps)
```
```    85       apply (subst a)
```
```    86       apply (subst b)
```
```    87       apply (simp only: pow2_add1)
```
```    88       apply (subst pow2_neg[of "int m - a + 1"])
```
```    89       apply (subst pow2_neg[of "int m + 1"])
```
```    90       apply auto
```
```    91       apply (insert Suc)
```
```    92       apply (auto simp add: algebra_simps)
```
```    93       done
```
```    94   qed
```
```    95 qed
```
```    96
```
```    97 lemma "float (a, e) + float (b, e) = float (a + b, e)"
```
```    98 by (simp add: float_def algebra_simps)
```
```    99
```
```   100 definition int_of_real :: "real \<Rightarrow> int"
```
```   101   where "int_of_real x = (SOME y. real y = x)"
```
```   102
```
```   103 definition real_is_int :: "real \<Rightarrow> bool"
```
```   104   where "real_is_int x = (EX (u::int). x = real u)"
```
```   105
```
```   106 lemma real_is_int_def2: "real_is_int x = (x = real (int_of_real x))"
```
```   107 by (auto simp add: real_is_int_def int_of_real_def)
```
```   108
```
```   109 lemma float_transfer: "real_is_int ((real a)*(pow2 c)) \<Longrightarrow> float (a, b) = float (int_of_real ((real a)*(pow2 c)), b - c)"
```
```   110 by (simp add: float_def real_is_int_def2 pow2_add[symmetric])
```
```   111
```
```   112 lemma pow2_int: "pow2 (int c) = 2^c"
```
```   113 by (simp add: pow2_def)
```
```   114
```
```   115 lemma float_transfer_nat: "float (a, b) = float (a * 2^c, b - int c)"
```
```   116 by (simp add: float_def pow2_int[symmetric] pow2_add[symmetric])
```
```   117
```
```   118 lemma real_is_int_real[simp]: "real_is_int (real (x::int))"
```
```   119 by (auto simp add: real_is_int_def int_of_real_def)
```
```   120
```
```   121 lemma int_of_real_real[simp]: "int_of_real (real x) = x"
```
```   122 by (simp add: int_of_real_def)
```
```   123
```
```   124 lemma real_int_of_real[simp]: "real_is_int x \<Longrightarrow> real (int_of_real x) = x"
```
```   125 by (auto simp add: int_of_real_def real_is_int_def)
```
```   126
```
```   127 lemma real_is_int_add_int_of_real: "real_is_int a \<Longrightarrow> real_is_int b \<Longrightarrow> (int_of_real (a+b)) = (int_of_real a) + (int_of_real b)"
```
```   128 by (auto simp add: int_of_real_def real_is_int_def)
```
```   129
```
```   130 lemma real_is_int_add[simp]: "real_is_int a \<Longrightarrow> real_is_int b \<Longrightarrow> real_is_int (a+b)"
```
```   131 apply (subst real_is_int_def2)
```
```   132 apply (simp add: real_is_int_add_int_of_real real_int_of_real)
```
```   133 done
```
```   134
```
```   135 lemma int_of_real_sub: "real_is_int a \<Longrightarrow> real_is_int b \<Longrightarrow> (int_of_real (a-b)) = (int_of_real a) - (int_of_real b)"
```
```   136 by (auto simp add: int_of_real_def real_is_int_def)
```
```   137
```
```   138 lemma real_is_int_sub[simp]: "real_is_int a \<Longrightarrow> real_is_int b \<Longrightarrow> real_is_int (a-b)"
```
```   139 apply (subst real_is_int_def2)
```
```   140 apply (simp add: int_of_real_sub real_int_of_real)
```
```   141 done
```
```   142
```
```   143 lemma real_is_int_rep: "real_is_int x \<Longrightarrow> ?! (a::int). real a = x"
```
```   144 by (auto simp add: real_is_int_def)
```
```   145
```
```   146 lemma int_of_real_mult:
```
```   147   assumes "real_is_int a" "real_is_int b"
```
```   148   shows "(int_of_real (a*b)) = (int_of_real a) * (int_of_real b)"
```
```   149 proof -
```
```   150   from assms have a: "?! (a'::int). real a' = a" by (rule_tac real_is_int_rep, auto)
```
```   151   from assms have b: "?! (b'::int). real b' = b" by (rule_tac real_is_int_rep, auto)
```
```   152   from a obtain a'::int where a':"a = real a'" by auto
```
```   153   from b obtain b'::int where b':"b = real b'" by auto
```
```   154   have r: "real a' * real b' = real (a' * b')" by auto
```
```   155   show ?thesis
```
```   156     apply (simp add: a' b')
```
```   157     apply (subst r)
```
```   158     apply (simp only: int_of_real_real)
```
```   159     done
```
```   160 qed
```
```   161
```
```   162 lemma real_is_int_mult[simp]: "real_is_int a \<Longrightarrow> real_is_int b \<Longrightarrow> real_is_int (a*b)"
```
```   163 apply (subst real_is_int_def2)
```
```   164 apply (simp add: int_of_real_mult)
```
```   165 done
```
```   166
```
```   167 lemma real_is_int_0[simp]: "real_is_int (0::real)"
```
```   168 by (simp add: real_is_int_def int_of_real_def)
```
```   169
```
```   170 lemma real_is_int_1[simp]: "real_is_int (1::real)"
```
```   171 proof -
```
```   172   have "real_is_int (1::real) = real_is_int(real (1::int))" by auto
```
```   173   also have "\<dots> = True" by (simp only: real_is_int_real)
```
```   174   ultimately show ?thesis by auto
```
```   175 qed
```
```   176
```
```   177 lemma real_is_int_n1: "real_is_int (-1::real)"
```
```   178 proof -
```
```   179   have "real_is_int (-1::real) = real_is_int(real (-1::int))" by auto
```
```   180   also have "\<dots> = True" by (simp only: real_is_int_real)
```
```   181   ultimately show ?thesis by auto
```
```   182 qed
```
```   183
```
```   184 lemma real_is_int_number_of[simp]: "real_is_int ((number_of \<Colon> int \<Rightarrow> real) x)"
```
```   185 proof -
```
```   186   have neg1: "real_is_int (-1::real)"
```
```   187   proof -
```
```   188     have "real_is_int (-1::real) = real_is_int(real (-1::int))" by auto
```
```   189     also have "\<dots> = True" by (simp only: real_is_int_real)
```
```   190     ultimately show ?thesis by auto
```
```   191   qed
```
```   192
```
```   193   {
```
```   194     fix x :: int
```
```   195     have "real_is_int ((number_of \<Colon> int \<Rightarrow> real) x)"
```
```   196       unfolding number_of_eq
```
```   197       apply (induct x)
```
```   198       apply (induct_tac n)
```
```   199       apply (simp)
```
```   200       apply (simp)
```
```   201       apply (induct_tac n)
```
```   202       apply (simp add: neg1)
```
```   203     proof -
```
```   204       fix n :: nat
```
```   205       assume rn: "(real_is_int (of_int (- (int (Suc n)))))"
```
```   206       have s: "-(int (Suc (Suc n))) = -1 + - (int (Suc n))" by simp
```
```   207       show "real_is_int (of_int (- (int (Suc (Suc n)))))"
```
```   208         apply (simp only: s of_int_add)
```
```   209         apply (rule real_is_int_add)
```
```   210         apply (simp add: neg1)
```
```   211         apply (simp only: rn)
```
```   212         done
```
```   213     qed
```
```   214   }
```
```   215   note Abs_Bin = this
```
```   216   {
```
```   217     fix x :: int
```
```   218     have "? u. x = u"
```
```   219       apply (rule exI[where x = "x"])
```
```   220       apply (simp)
```
```   221       done
```
```   222   }
```
```   223   then obtain u::int where "x = u" by auto
```
```   224   with Abs_Bin show ?thesis by auto
```
```   225 qed
```
```   226
```
```   227 lemma int_of_real_0[simp]: "int_of_real (0::real) = (0::int)"
```
```   228 by (simp add: int_of_real_def)
```
```   229
```
```   230 lemma int_of_real_1[simp]: "int_of_real (1::real) = (1::int)"
```
```   231 proof -
```
```   232   have 1: "(1::real) = real (1::int)" by auto
```
```   233   show ?thesis by (simp only: 1 int_of_real_real)
```
```   234 qed
```
```   235
```
```   236 lemma int_of_real_number_of[simp]: "int_of_real (number_of b) = number_of b"
```
```   237 proof -
```
```   238   have "real_is_int (number_of b)" by simp
```
```   239   then have uu: "?! u::int. number_of b = real u" by (auto simp add: real_is_int_rep)
```
```   240   then obtain u::int where u:"number_of b = real u" by auto
```
```   241   have "number_of b = real ((number_of b)::int)"
```
```   242     by (simp add: number_of_eq real_of_int_def)
```
```   243   have ub: "number_of b = real ((number_of b)::int)"
```
```   244     by (simp add: number_of_eq real_of_int_def)
```
```   245   from uu u ub have unb: "u = number_of b"
```
```   246     by blast
```
```   247   have "int_of_real (number_of b) = u" by (simp add: u)
```
```   248   with unb show ?thesis by simp
```
```   249 qed
```
```   250
```
```   251 lemma float_transfer_even: "even a \<Longrightarrow> float (a, b) = float (a div 2, b+1)"
```
```   252   apply (subst float_transfer[where a="a" and b="b" and c="-1", simplified])
```
```   253   apply (simp_all add: pow2_def even_def real_is_int_def algebra_simps)
```
```   254   apply (auto)
```
```   255 proof -
```
```   256   fix q::int
```
```   257   have a:"b - (-1\<Colon>int) = (1\<Colon>int) + b" by arith
```
```   258   show "(float (q, (b - (-1\<Colon>int)))) = (float (q, ((1\<Colon>int) + b)))"
```
```   259     by (simp add: a)
```
```   260 qed
```
```   261
```
```   262 lemma int_div_zdiv: "int (a div b) = (int a) div (int b)"
```
```   263 by (rule zdiv_int)
```
```   264
```
```   265 lemma int_mod_zmod: "int (a mod b) = (int a) mod (int b)"
```
```   266 by (rule zmod_int)
```
```   267
```
```   268 lemma abs_div_2_less: "a \<noteq> 0 \<Longrightarrow> a \<noteq> -1 \<Longrightarrow> abs((a::int) div 2) < abs a"
```
```   269 by arith
```
```   270
```
```   271 function norm_float :: "int \<Rightarrow> int \<Rightarrow> int \<times> int" where
```
```   272   "norm_float a b = (if a \<noteq> 0 \<and> even a then norm_float (a div 2) (b + 1)
```
```   273     else if a = 0 then (0, 0) else (a, b))"
```
```   274 by auto
```
```   275
```
```   276 termination by (relation "measure (nat o abs o fst)")
```
```   277   (auto intro: abs_div_2_less)
```
```   278
```
```   279 lemma norm_float: "float x = float (split norm_float x)"
```
```   280 proof -
```
```   281   {
```
```   282     fix a b :: int
```
```   283     have norm_float_pair: "float (a, b) = float (norm_float a b)"
```
```   284     proof (induct a b rule: norm_float.induct)
```
```   285       case (1 u v)
```
```   286       show ?case
```
```   287       proof cases
```
```   288         assume u: "u \<noteq> 0 \<and> even u"
```
```   289         with 1 have ind: "float (u div 2, v + 1) = float (norm_float (u div 2) (v + 1))" by auto
```
```   290         with u have "float (u,v) = float (u div 2, v+1)" by (simp add: float_transfer_even)
```
```   291         then show ?thesis
```
```   292           apply (subst norm_float.simps)
```
```   293           apply (simp add: ind)
```
```   294           done
```
```   295       next
```
```   296         assume nu: "~(u \<noteq> 0 \<and> even u)"
```
```   297         show ?thesis
```
```   298           by (simp add: nu float_def)
```
```   299       qed
```
```   300     qed
```
```   301   }
```
```   302   note helper = this
```
```   303   have "? a b. x = (a,b)" by auto
```
```   304   then obtain a b where "x = (a, b)" by blast
```
```   305   then show ?thesis by (simp add: helper)
```
```   306 qed
```
```   307
```
```   308 lemma float_add_l0: "float (0, e) + x = x"
```
```   309   by (simp add: float_def)
```
```   310
```
```   311 lemma float_add_r0: "x + float (0, e) = x"
```
```   312   by (simp add: float_def)
```
```   313
```
```   314 lemma float_add:
```
```   315   "float (a1, e1) + float (a2, e2) =
```
```   316   (if e1<=e2 then float (a1+a2*2^(nat(e2-e1)), e1)
```
```   317   else float (a1*2^(nat (e1-e2))+a2, e2))"
```
```   318   apply (simp add: float_def algebra_simps)
```
```   319   apply (auto simp add: pow2_int[symmetric] pow2_add[symmetric])
```
```   320   done
```
```   321
```
```   322 lemma float_add_assoc1:
```
```   323   "(x + float (y1, e1)) + float (y2, e2) = (float (y1, e1) + float (y2, e2)) + x"
```
```   324   by simp
```
```   325
```
```   326 lemma float_add_assoc2:
```
```   327   "(float (y1, e1) + x) + float (y2, e2) = (float (y1, e1) + float (y2, e2)) + x"
```
```   328   by simp
```
```   329
```
```   330 lemma float_add_assoc3:
```
```   331   "float (y1, e1) + (x + float (y2, e2)) = (float (y1, e1) + float (y2, e2)) + x"
```
```   332   by simp
```
```   333
```
```   334 lemma float_add_assoc4:
```
```   335   "float (y1, e1) + (float (y2, e2) + x) = (float (y1, e1) + float (y2, e2)) + x"
```
```   336   by simp
```
```   337
```
```   338 lemma float_mult_l0: "float (0, e) * x = float (0, 0)"
```
```   339   by (simp add: float_def)
```
```   340
```
```   341 lemma float_mult_r0: "x * float (0, e) = float (0, 0)"
```
```   342   by (simp add: float_def)
```
```   343
```
```   344 definition lbound :: "real \<Rightarrow> real"
```
```   345   where "lbound x = min 0 x"
```
```   346
```
```   347 definition ubound :: "real \<Rightarrow> real"
```
```   348   where "ubound x = max 0 x"
```
```   349
```
```   350 lemma lbound: "lbound x \<le> x"
```
```   351   by (simp add: lbound_def)
```
```   352
```
```   353 lemma ubound: "x \<le> ubound x"
```
```   354   by (simp add: ubound_def)
```
```   355
```
```   356 lemma float_mult:
```
```   357   "float (a1, e1) * float (a2, e2) =
```
```   358   (float (a1 * a2, e1 + e2))"
```
```   359   by (simp add: float_def pow2_add)
```
```   360
```
```   361 lemma float_minus:
```
```   362   "- (float (a,b)) = float (-a, b)"
```
```   363   by (simp add: float_def)
```
```   364
```
```   365 lemma zero_less_pow2:
```
```   366   "0 < pow2 x"
```
```   367 proof -
```
```   368   {
```
```   369     fix y
```
```   370     have "0 <= y \<Longrightarrow> 0 < pow2 y"
```
```   371       by (induct y, induct_tac n, simp_all add: pow2_add)
```
```   372   }
```
```   373   note helper=this
```
```   374   show ?thesis
```
```   375     apply (case_tac "0 <= x")
```
```   376     apply (simp add: helper)
```
```   377     apply (subst pow2_neg)
```
```   378     apply (simp add: helper)
```
```   379     done
```
```   380 qed
```
```   381
```
```   382 lemma zero_le_float:
```
```   383   "(0 <= float (a,b)) = (0 <= a)"
```
```   384   apply (auto simp add: float_def)
```
```   385   apply (auto simp add: zero_le_mult_iff zero_less_pow2)
```
```   386   apply (insert zero_less_pow2[of b])
```
```   387   apply (simp_all)
```
```   388   done
```
```   389
```
```   390 lemma float_le_zero:
```
```   391   "(float (a,b) <= 0) = (a <= 0)"
```
```   392   apply (auto simp add: float_def)
```
```   393   apply (auto simp add: mult_le_0_iff)
```
```   394   apply (insert zero_less_pow2[of b])
```
```   395   apply auto
```
```   396   done
```
```   397
```
```   398 lemma float_abs:
```
```   399   "abs (float (a,b)) = (if 0 <= a then (float (a,b)) else (float (-a,b)))"
```
```   400   apply (auto simp add: abs_if)
```
```   401   apply (simp_all add: zero_le_float[symmetric, of a b] float_minus)
```
```   402   done
```
```   403
```
```   404 lemma float_zero:
```
```   405   "float (0, b) = 0"
```
```   406   by (simp add: float_def)
```
```   407
```
```   408 lemma float_pprt:
```
```   409   "pprt (float (a, b)) = (if 0 <= a then (float (a,b)) else (float (0, b)))"
```
```   410   by (auto simp add: zero_le_float float_le_zero float_zero)
```
```   411
```
```   412 lemma pprt_lbound: "pprt (lbound x) = float (0, 0)"
```
```   413   apply (simp add: float_def)
```
```   414   apply (rule pprt_eq_0)
```
```   415   apply (simp add: lbound_def)
```
```   416   done
```
```   417
```
```   418 lemma nprt_ubound: "nprt (ubound x) = float (0, 0)"
```
```   419   apply (simp add: float_def)
```
```   420   apply (rule nprt_eq_0)
```
```   421   apply (simp add: ubound_def)
```
```   422   done
```
```   423
```
```   424 lemma float_nprt:
```
```   425   "nprt (float (a, b)) = (if 0 <= a then (float (0,b)) else (float (a, b)))"
```
```   426   by (auto simp add: zero_le_float float_le_zero float_zero)
```
```   427
```
```   428 lemma norm_0_1: "(0::_::number_ring) = Numeral0 & (1::_::number_ring) = Numeral1"
```
```   429   by auto
```
```   430
```
```   431 lemma add_left_zero: "0 + a = (a::'a::comm_monoid_add)"
```
```   432   by simp
```
```   433
```
```   434 lemma add_right_zero: "a + 0 = (a::'a::comm_monoid_add)"
```
```   435   by simp
```
```   436
```
```   437 lemma mult_left_one: "1 * a = (a::'a::semiring_1)"
```
```   438   by simp
```
```   439
```
```   440 lemma mult_right_one: "a * 1 = (a::'a::semiring_1)"
```
```   441   by simp
```
```   442
```
```   443 lemma int_pow_0: "(a::int)^(Numeral0) = 1"
```
```   444   by simp
```
```   445
```
```   446 lemma int_pow_1: "(a::int)^(Numeral1) = a"
```
```   447   by simp
```
```   448
```
```   449 lemma zero_eq_Numeral0_nring: "(0::'a::number_ring) = Numeral0"
```
```   450   by simp
```
```   451
```
```   452 lemma one_eq_Numeral1_nring: "(1::'a::number_ring) = Numeral1"
```
```   453   by simp
```
```   454
```
```   455 lemma zero_eq_Numeral0_nat: "(0::nat) = Numeral0"
```
```   456   by simp
```
```   457
```
```   458 lemma one_eq_Numeral1_nat: "(1::nat) = Numeral1"
```
```   459   by simp
```
```   460
```
```   461 lemma zpower_Pls: "(z::int)^Numeral0 = Numeral1"
```
```   462   by simp
```
```   463
```
```   464 lemma zpower_Min: "(z::int)^((-1)::nat) = Numeral1"
```
```   465 proof -
```
```   466   have 1:"((-1)::nat) = 0"
```
```   467     by simp
```
```   468   show ?thesis by (simp add: 1)
```
```   469 qed
```
```   470
```
```   471 lemma fst_cong: "a=a' \<Longrightarrow> fst (a,b) = fst (a',b)"
```
```   472   by simp
```
```   473
```
```   474 lemma snd_cong: "b=b' \<Longrightarrow> snd (a,b) = snd (a,b')"
```
```   475   by simp
```
```   476
```
```   477 lemma lift_bool: "x \<Longrightarrow> x=True"
```
```   478   by simp
```
```   479
```
```   480 lemma nlift_bool: "~x \<Longrightarrow> x=False"
```
```   481   by simp
```
```   482
```
```   483 lemma not_false_eq_true: "(~ False) = True" by simp
```
```   484
```
```   485 lemma not_true_eq_false: "(~ True) = False" by simp
```
```   486
```
```   487 lemmas binarith =
```
```   488   normalize_bin_simps
```
```   489   pred_bin_simps succ_bin_simps
```
```   490   add_bin_simps minus_bin_simps mult_bin_simps
```
```   491
```
```   492 lemma int_eq_number_of_eq:
```
```   493   "(((number_of v)::int)=(number_of w)) = iszero ((number_of (v + uminus w))::int)"
```
```   494   by (rule eq_number_of_eq)
```
```   495
```
```   496 lemma int_iszero_number_of_Pls: "iszero (Numeral0::int)"
```
```   497   by (simp only: iszero_number_of_Pls)
```
```   498
```
```   499 lemma int_nonzero_number_of_Min: "~(iszero ((-1)::int))"
```
```   500   by simp
```
```   501
```
```   502 lemma int_iszero_number_of_Bit0: "iszero ((number_of (Int.Bit0 w))::int) = iszero ((number_of w)::int)"
```
```   503   by simp
```
```   504
```
```   505 lemma int_iszero_number_of_Bit1: "\<not> iszero ((number_of (Int.Bit1 w))::int)"
```
```   506   by simp
```
```   507
```
```   508 lemma int_less_number_of_eq_neg: "(((number_of x)::int) < number_of y) = neg ((number_of (x + (uminus y)))::int)"
```
```   509   unfolding neg_def number_of_is_id by simp
```
```   510
```
```   511 lemma int_not_neg_number_of_Pls: "\<not> (neg (Numeral0::int))"
```
```   512   by simp
```
```   513
```
```   514 lemma int_neg_number_of_Min: "neg (-1::int)"
```
```   515   by simp
```
```   516
```
```   517 lemma int_neg_number_of_Bit0: "neg ((number_of (Int.Bit0 w))::int) = neg ((number_of w)::int)"
```
```   518   by simp
```
```   519
```
```   520 lemma int_neg_number_of_Bit1: "neg ((number_of (Int.Bit1 w))::int) = neg ((number_of w)::int)"
```
```   521   by simp
```
```   522
```
```   523 lemma int_le_number_of_eq: "(((number_of x)::int) \<le> number_of y) = (\<not> neg ((number_of (y + (uminus x)))::int))"
```
```   524   unfolding neg_def number_of_is_id by (simp add: not_less)
```
```   525
```
```   526 lemmas intarithrel =
```
```   527   int_eq_number_of_eq
```
```   528   lift_bool[OF int_iszero_number_of_Pls] nlift_bool[OF int_nonzero_number_of_Min] int_iszero_number_of_Bit0
```
```   529   lift_bool[OF int_iszero_number_of_Bit1] int_less_number_of_eq_neg nlift_bool[OF int_not_neg_number_of_Pls] lift_bool[OF int_neg_number_of_Min]
```
```   530   int_neg_number_of_Bit0 int_neg_number_of_Bit1 int_le_number_of_eq
```
```   531
```
```   532 lemma int_number_of_add_sym: "((number_of v)::int) + number_of w = number_of (v + w)"
```
```   533   by simp
```
```   534
```
```   535 lemma int_number_of_diff_sym: "((number_of v)::int) - number_of w = number_of (v + (uminus w))"
```
```   536   by simp
```
```   537
```
```   538 lemma int_number_of_mult_sym: "((number_of v)::int) * number_of w = number_of (v * w)"
```
```   539   by simp
```
```   540
```
```   541 lemma int_number_of_minus_sym: "- ((number_of v)::int) = number_of (uminus v)"
```
```   542   by simp
```
```   543
```
```   544 lemmas intarith = int_number_of_add_sym int_number_of_minus_sym int_number_of_diff_sym int_number_of_mult_sym
```
```   545
```
```   546 lemmas natarith = add_nat_number_of diff_nat_number_of mult_nat_number_of eq_nat_number_of less_nat_number_of
```
```   547
```
```   548 lemmas powerarith = nat_number_of zpower_number_of_even
```
```   549   zpower_number_of_odd[simplified zero_eq_Numeral0_nring one_eq_Numeral1_nring]
```
```   550   zpower_Pls zpower_Min
```
```   551
```
```   552 lemmas floatarith[simplified norm_0_1] = float_add float_add_l0 float_add_r0 float_mult float_mult_l0 float_mult_r0
```
```   553           float_minus float_abs zero_le_float float_pprt float_nprt pprt_lbound nprt_ubound
```
```   554
```
```   555 (* for use with the compute oracle *)
```
```   556 lemmas arith = binarith intarith intarithrel natarith powerarith floatarith not_false_eq_true not_true_eq_false
```
```   557
```
```   558 use "~~/src/HOL/Tools/float_arith.ML"
```
```   559
```
```   560 end
```