src/HOL/Int.thy
changeset 62348 9a5f43dac883
parent 62347 2230b7047376
child 62390 842917225d56
equal deleted inserted replaced
62347:2230b7047376 62348:9a5f43dac883
   568 by (simp add: linorder_not_less)
   568 by (simp add: linorder_not_less)
   569 
   569 
   570 lemma negative_eq_positive [simp]: "(- int n = of_nat m) = (n = 0 & m = 0)"
   570 lemma negative_eq_positive [simp]: "(- int n = of_nat m) = (n = 0 & m = 0)"
   571 by (force simp add: order_eq_iff [of "- of_nat n"] int_zle_neg)
   571 by (force simp add: order_eq_iff [of "- of_nat n"] int_zle_neg)
   572 
   572 
   573 lemma zle_iff_zadd: "w \<le> z \<longleftrightarrow> (\<exists>n. z = w + int n)"
   573 lemma zle_iff_zadd:
   574 proof -
   574   "w \<le> z \<longleftrightarrow> (\<exists>n. z = w + int n)" (is "?P \<longleftrightarrow> ?Q")
   575   have "(w \<le> z) = (0 \<le> z - w)"
   575 proof
   576     by (simp only: le_diff_eq add_0_left)
   576   assume ?Q
   577   also have "\<dots> = (\<exists>n. z - w = of_nat n)"
   577   then show ?P by auto
   578     by (auto elim: zero_le_imp_eq_int)
   578 next
   579   also have "\<dots> = (\<exists>n. z = w + of_nat n)"
   579   assume ?P
   580     by (simp only: algebra_simps)
   580   then have "0 \<le> z - w" by simp
   581   finally show ?thesis .
   581   then obtain n where "z - w = int n"
       
   582     using zero_le_imp_eq_int [of "z - w"] by blast
       
   583   then have "z = w + int n"
       
   584     by simp
       
   585   then show ?Q ..
   582 qed
   586 qed
   583 
   587 
   584 lemma zadd_int_left: "int m + (int n + z) = int (m + n) + z"
   588 lemma zadd_int_left: "int m + (int n + z) = int (m + n) + z"
   585 by simp
   589 by simp
   586 
   590 
  1723 quickcheck_params [default_type = int]
  1727 quickcheck_params [default_type = int]
  1724 
  1728 
  1725 hide_const (open) Pos Neg sub dup
  1729 hide_const (open) Pos Neg sub dup
  1726 
  1730 
  1727 
  1731 
  1728 subsection \<open>Legacy theorems\<close>
       
  1729 
       
  1730 lemmas inj_int = inj_of_nat [where 'a=int]
       
  1731 lemmas zadd_int = of_nat_add [where 'a=int, symmetric]
       
  1732 lemmas int_mult = of_nat_mult [where 'a=int]
       
  1733 lemmas int_eq_0_conv = of_nat_eq_0_iff [where 'a=int and m="n"] for n
       
  1734 lemmas zless_int = of_nat_less_iff [where 'a=int]
       
  1735 lemmas int_less_0_conv = of_nat_less_0_iff [where 'a=int and m="k"] for k
       
  1736 lemmas zero_less_int_conv = of_nat_0_less_iff [where 'a=int]
       
  1737 lemmas zero_zle_int = of_nat_0_le_iff [where 'a=int]
       
  1738 lemmas int_le_0_conv = of_nat_le_0_iff [where 'a=int and m="n"] for n
       
  1739 lemmas int_0 = of_nat_0 [where 'a=int]
       
  1740 lemmas int_1 = of_nat_1 [where 'a=int]
       
  1741 lemmas int_Suc = of_nat_Suc [where 'a=int]
       
  1742 lemmas int_numeral = of_nat_numeral [where 'a=int]
       
  1743 lemmas abs_int_eq = abs_of_nat [where 'a=int and n="m"] for m
       
  1744 lemmas of_int_int_eq = of_int_of_nat_eq [where 'a=int]
       
  1745 lemmas zdiff_int = of_nat_diff [where 'a=int, symmetric]
       
  1746 lemmas zpower_numeral_even = power_numeral_even [where 'a=int]
       
  1747 lemmas zpower_numeral_odd = power_numeral_odd [where 'a=int]
       
  1748 
       
  1749 text \<open>De-register \<open>int\<close> as a quotient type:\<close>
  1732 text \<open>De-register \<open>int\<close> as a quotient type:\<close>
  1750 
  1733 
  1751 lifting_update int.lifting
  1734 lifting_update int.lifting
  1752 lifting_forget int.lifting
  1735 lifting_forget int.lifting
  1753 
  1736 
  1754 text\<open>Also the class for fields with characteristic zero.\<close>
       
  1755 class field_char_0 = field + ring_char_0
       
  1756 subclass (in linordered_field) field_char_0 ..
       
  1757 
       
  1758 end
  1737 end