1608 qed |
1608 qed |
1609 } |
1609 } |
1610 with ge show ?thesis by fast |
1610 with ge show ?thesis by fast |
1611 qed |
1611 qed |
1612 |
1612 |
1613 (* `set:int': dummy construction *) |
1613 (* `set:int': dummy construction *) |
1614 theorem int_gr_induct[case_names base step,induct set:int]: |
1614 theorem int_gr_induct [case_names base step, induct set: int]: |
1615 assumes gr: "k < (i::int)" and |
1615 assumes gr: "k < (i::int)" and |
1616 base: "P(k+1)" and |
1616 base: "P(k+1)" and |
1617 step: "\<And>i. \<lbrakk>k < i; P i\<rbrakk> \<Longrightarrow> P(i+1)" |
1617 step: "\<And>i. \<lbrakk>k < i; P i\<rbrakk> \<Longrightarrow> P(i+1)" |
1618 shows "P i" |
1618 shows "P i" |
1619 apply(rule int_ge_induct[of "k + 1"]) |
1619 apply(rule int_ge_induct[of "k + 1"]) |
1735 |
1735 |
1736 code_datatype Pls Min Bit "number_of \<Colon> int \<Rightarrow> int" |
1736 code_datatype Pls Min Bit "number_of \<Colon> int \<Rightarrow> int" |
1737 |
1737 |
1738 definition |
1738 definition |
1739 int_aux :: "nat \<Rightarrow> int \<Rightarrow> int" where |
1739 int_aux :: "nat \<Rightarrow> int \<Rightarrow> int" where |
1740 "int_aux n i = int n + i" |
1740 [code func del]: "int_aux = of_nat_aux" |
1741 |
1741 |
1742 lemma [code]: |
1742 lemmas int_aux_code = of_nat_aux_code [where ?'a = int, simplified int_aux_def [symmetric], code] |
1743 "int_aux 0 i = i" |
|
1744 "int_aux (Suc n) i = int_aux n (i + 1)" -- {* tail recursive *} |
|
1745 by (simp add: int_aux_def)+ |
|
1746 |
1743 |
1747 lemma [code, code unfold, code inline del]: |
1744 lemma [code, code unfold, code inline del]: |
1748 "int n = int_aux n 0" |
1745 "of_nat n = int_aux n 0" |
1749 by (simp add: int_aux_def) |
1746 by (simp add: int_aux_def of_nat_aux_def) |
1750 |
1747 |
1751 definition |
1748 definition |
1752 nat_aux :: "int \<Rightarrow> nat \<Rightarrow> nat" where |
1749 nat_aux :: "int \<Rightarrow> nat \<Rightarrow> nat" where |
1753 "nat_aux i n = nat i + n" |
1750 "nat_aux i n = nat i + n" |
1754 |
1751 |
1758 dest: zless_imp_add1_zle) |
1755 dest: zless_imp_add1_zle) |
1759 |
1756 |
1760 lemma [code]: "nat i = nat_aux i 0" |
1757 lemma [code]: "nat i = nat_aux i 0" |
1761 by (simp add: nat_aux_def) |
1758 by (simp add: nat_aux_def) |
1762 |
1759 |
|
1760 hide (open) const int_aux nat_aux |
|
1761 |
1763 lemma zero_is_num_zero [code func, code inline, symmetric, code post]: |
1762 lemma zero_is_num_zero [code func, code inline, symmetric, code post]: |
1764 "(0\<Colon>int) = Numeral0" |
1763 "(0\<Colon>int) = Numeral0" |
1765 by simp |
1764 by simp |
1766 |
1765 |
1767 lemma one_is_num_one [code func, code inline, symmetric, code post]: |
1766 lemma one_is_num_one [code func, code inline, symmetric, code post]: |
1768 "(1\<Colon>int) = Numeral1" |
1767 "(1\<Colon>int) = Numeral1" |
1769 by simp |
1768 by simp |
1770 |
1769 |
1771 code_modulename SML |
1770 code_modulename SML |
1772 IntDef Integer |
1771 Int Integer |
1773 |
1772 |
1774 code_modulename OCaml |
1773 code_modulename OCaml |
1775 IntDef Integer |
1774 Int Integer |
1776 |
1775 |
1777 code_modulename Haskell |
1776 code_modulename Haskell |
1778 IntDef Integer |
1777 Int Integer |
1779 |
|
1780 code_modulename SML |
|
1781 Numeral Integer |
|
1782 |
|
1783 code_modulename OCaml |
|
1784 Numeral Integer |
|
1785 |
|
1786 code_modulename Haskell |
|
1787 Numeral Integer |
|
1788 |
1778 |
1789 types_code |
1779 types_code |
1790 "int" ("int") |
1780 "int" ("int") |
1791 attach (term_of) {* |
1781 attach (term_of) {* |
1792 val term_of_int = HOLogic.mk_number HOLogic.intT; |
1782 val term_of_int = HOLogic.mk_number HOLogic.intT; |