src/HOL/Nat.thy
changeset 67691 db202a00a29c
parent 67673 c8caefb20564
child 68610 4fdc9f681479
equal deleted inserted replaced
67690:3c02b0522e23 67691:db202a00a29c
  1772 
  1772 
  1773 end
  1773 end
  1774 
  1774 
  1775 class ring_char_0 = ring_1 + semiring_char_0
  1775 class ring_char_0 = ring_1 + semiring_char_0
  1776 
  1776 
       
  1777 context linordered_nonzero_semiring
       
  1778 begin
       
  1779 
       
  1780 lemma of_nat_0_le_iff [simp]: "0 \<le> of_nat n"
       
  1781   by (induct n) simp_all
       
  1782 
       
  1783 lemma of_nat_less_0_iff [simp]: "\<not> of_nat m < 0"
       
  1784   by (simp add: not_less)
       
  1785 
       
  1786 lemma of_nat_mono[simp]: "i \<le> j \<Longrightarrow> of_nat i \<le> of_nat j"
       
  1787   by (auto simp: le_iff_add intro!: add_increasing2)
       
  1788 
       
  1789 lemma of_nat_less_iff [simp]: "of_nat m < of_nat n \<longleftrightarrow> m < n"
       
  1790 proof(induct m n rule: diff_induct)
       
  1791   case (1 m) then show ?case
       
  1792     by auto
       
  1793 next
       
  1794   case (2 n) then show ?case
       
  1795     by (simp add: add_pos_nonneg)
       
  1796 next
       
  1797   case (3 m n)
       
  1798   then show ?case
       
  1799     by (auto simp: add_commute [of 1] add_mono1 not_less add_right_mono leD)
       
  1800 qed
       
  1801 
       
  1802 lemma of_nat_le_iff [simp]: "of_nat m \<le> of_nat n \<longleftrightarrow> m \<le> n"
       
  1803   by (simp add: not_less [symmetric] linorder_not_less [symmetric])
       
  1804 
       
  1805 lemma less_imp_of_nat_less: "m < n \<Longrightarrow> of_nat m < of_nat n"
       
  1806   by simp
       
  1807 
       
  1808 lemma of_nat_less_imp_less: "of_nat m < of_nat n \<Longrightarrow> m < n"
       
  1809   by simp
       
  1810 
       
  1811 text \<open>Every \<open>linordered_nonzero_semiring\<close> has characteristic zero.\<close>
       
  1812 
       
  1813 subclass semiring_char_0
       
  1814   by standard (auto intro!: injI simp add: eq_iff)
       
  1815 
       
  1816 text \<open>Special cases where either operand is zero\<close>
       
  1817 
       
  1818 lemma of_nat_le_0_iff [simp]: "of_nat m \<le> 0 \<longleftrightarrow> m = 0"
       
  1819   by (rule of_nat_le_iff [of _ 0, simplified])
       
  1820 
       
  1821 lemma of_nat_0_less_iff [simp]: "0 < of_nat n \<longleftrightarrow> 0 < n"
       
  1822   by (rule of_nat_less_iff [of 0, simplified])
       
  1823 
       
  1824 end
       
  1825 
       
  1826 
  1777 context linordered_semidom
  1827 context linordered_semidom
  1778 begin
  1828 begin
  1779 
  1829 subclass linordered_nonzero_semiring ..
  1780 lemma of_nat_0_le_iff [simp]: "0 \<le> of_nat n"
  1830 subclass semiring_char_0 ..
  1781   by (induct n) simp_all
       
  1782 
       
  1783 lemma of_nat_less_0_iff [simp]: "\<not> of_nat m < 0"
       
  1784   by (simp add: not_less)
       
  1785 
       
  1786 lemma of_nat_less_iff [simp]: "of_nat m < of_nat n \<longleftrightarrow> m < n"
       
  1787   by (induct m n rule: diff_induct) (simp_all add: add_pos_nonneg)
       
  1788 
       
  1789 lemma of_nat_le_iff [simp]: "of_nat m \<le> of_nat n \<longleftrightarrow> m \<le> n"
       
  1790   by (simp add: not_less [symmetric] linorder_not_less [symmetric])
       
  1791 
       
  1792 lemma less_imp_of_nat_less: "m < n \<Longrightarrow> of_nat m < of_nat n"
       
  1793   by simp
       
  1794 
       
  1795 lemma of_nat_less_imp_less: "of_nat m < of_nat n \<Longrightarrow> m < n"
       
  1796   by simp
       
  1797 
       
  1798 text \<open>Every \<open>linordered_semidom\<close> has characteristic zero.\<close>
       
  1799 
       
  1800 subclass semiring_char_0
       
  1801   by standard (auto intro!: injI simp add: eq_iff)
       
  1802 
       
  1803 text \<open>Special cases where either operand is zero\<close>
       
  1804 
       
  1805 lemma of_nat_le_0_iff [simp]: "of_nat m \<le> 0 \<longleftrightarrow> m = 0"
       
  1806   by (rule of_nat_le_iff [of _ 0, simplified])
       
  1807 
       
  1808 lemma of_nat_0_less_iff [simp]: "0 < of_nat n \<longleftrightarrow> 0 < n"
       
  1809   by (rule of_nat_less_iff [of 0, simplified])
       
  1810 
       
  1811 end
  1831 end
       
  1832 
  1812 
  1833 
  1813 context linordered_idom
  1834 context linordered_idom
  1814 begin
  1835 begin
  1815 
  1836 
  1816 lemma abs_of_nat [simp]: "\<bar>of_nat n\<bar> = of_nat n"
  1837 lemma abs_of_nat [simp]: "\<bar>of_nat n\<bar> = of_nat n"