src/HOL/Real/Float.thy
changeset 23431 25ca91279a9b
parent 23365 f31794033ae1
child 23477 f4b83f03cac9
equal deleted inserted replaced
23430:771117253634 23431:25ca91279a9b
    33   have g: "! a b. a - -1 = a + (1::int)" by arith
    33   have g: "! a b. a - -1 = a + (1::int)" by arith
    34   have pos: "! n. pow2 (int n + 1) = 2 * pow2 (int n)"
    34   have pos: "! n. pow2 (int n + 1) = 2 * pow2 (int n)"
    35     apply (auto, induct_tac n)
    35     apply (auto, induct_tac n)
    36     apply (simp_all add: pow2_def)
    36     apply (simp_all add: pow2_def)
    37     apply (rule_tac m1="2" and n1="nat (2 + int na)" in ssubst[OF realpow_num_eq_if])
    37     apply (rule_tac m1="2" and n1="nat (2 + int na)" in ssubst[OF realpow_num_eq_if])
    38     apply (auto simp add: h)
    38     by (auto simp add: h)
    39     by (simp add: add_commute)
       
    40   show ?thesis
    39   show ?thesis
    41   proof (induct a)
    40   proof (induct a)
    42     case (1 n)
    41     case (1 n)
    43     from pos show ?case by (simp add: ring_eq_simps)
    42     from pos show ?case by (simp add: ring_eq_simps)
    44   next
    43   next
    45     case (2 n)
    44     case (2 n)
    46     show ?case
    45     show ?case
    47       apply (auto)
    46       apply (auto)
    48       apply (subst pow2_neg[of "- int n"])
    47       apply (subst pow2_neg[of "- int n"])
    49       apply (subst pow2_neg[of "- int n + -1"])
    48       apply (subst pow2_neg[of "-1 - int n"])
    50       apply (auto simp add: g pos)
    49       apply (auto simp add: g pos)
    51       done
    50       done
    52   qed
    51   qed
    53 qed
    52 qed
    54 
    53 
   267 
   266 
   268 consts
   267 consts
   269   norm_float :: "int*int \<Rightarrow> int*int"
   268   norm_float :: "int*int \<Rightarrow> int*int"
   270 
   269 
   271 lemma int_div_zdiv: "int (a div b) = (int a) div (int b)"
   270 lemma int_div_zdiv: "int (a div b) = (int a) div (int b)"
   272 apply (subst split_div, auto)
   271 by (rule zdiv_int)
   273 apply (subst split_zdiv, auto)
       
   274 apply (rule_tac a="int (b * i) + int j" and b="int b" and r="int j" and r'=ja in IntDiv.unique_quotient)
       
   275 apply (auto simp add: IntDiv.quorem_def int_eq_of_nat)
       
   276 done
       
   277 
   272 
   278 lemma int_mod_zmod: "int (a mod b) = (int a) mod (int b)"
   273 lemma int_mod_zmod: "int (a mod b) = (int a) mod (int b)"
   279 apply (subst split_mod, auto)
   274 by (rule zmod_int)
   280 apply (subst split_zmod, auto)
       
   281 apply (rule_tac a="int (b * i) + int j" and b="int b" and q="int i" and q'=ia in IntDiv.unique_remainder)
       
   282 apply (auto simp add: IntDiv.quorem_def int_eq_of_nat)
       
   283 done
       
   284 
   275 
   285 lemma abs_div_2_less: "a \<noteq> 0 \<Longrightarrow> a \<noteq> -1 \<Longrightarrow> abs((a::int) div 2) < abs a"
   276 lemma abs_div_2_less: "a \<noteq> 0 \<Longrightarrow> a \<noteq> -1 \<Longrightarrow> abs((a::int) div 2) < abs a"
   286 by arith
   277 by arith
   287 
   278 
   288 lemma terminating_norm_float: "\<forall>a. (a::int) \<noteq> 0 \<and> even a \<longrightarrow> a \<noteq> 0 \<and> \<bar>a div 2\<bar> < \<bar>a\<bar>"
   279 lemma terminating_norm_float: "\<forall>a. (a::int) \<noteq> 0 \<and> even a \<longrightarrow> a \<noteq> 0 \<and> \<bar>a div 2\<bar> < \<bar>a\<bar>"