1183 |
1183 |
1184 lemma Let_Suc [simp]: "Let (Suc n) f == f (Suc n)" |
1184 lemma Let_Suc [simp]: "Let (Suc n) f == f (Suc n)" |
1185 by (fact Let_def) |
1185 by (fact Let_def) |
1186 |
1186 |
1187 |
1187 |
1188 subsubsection {* Monotonicity of Multiplication *} |
1188 subsubsection {* Monotonicity of multiplication *} |
1189 |
1189 |
1190 lemma mult_le_mono1: "i \<le> (j::nat) ==> i * k \<le> j * k" |
1190 lemma mult_le_mono1: "i \<le> (j::nat) ==> i * k \<le> j * k" |
1191 by (simp add: mult_right_mono) |
1191 by (simp add: mult_right_mono) |
1192 |
1192 |
1193 lemma mult_le_mono2: "i \<le> (j::nat) ==> k * i \<le> k * j" |
1193 lemma mult_le_mono2: "i \<le> (j::nat) ==> k * i \<le> k * j" |
1823 |
1823 |
1824 lemma dec_induct[consumes 1, case_names base step]: |
1824 lemma dec_induct[consumes 1, case_names base step]: |
1825 "i \<le> j \<Longrightarrow> P i \<Longrightarrow> (\<And>n. i \<le> n \<Longrightarrow> n < j \<Longrightarrow> P n \<Longrightarrow> P (Suc n)) \<Longrightarrow> P j" |
1825 "i \<le> j \<Longrightarrow> P i \<Longrightarrow> (\<And>n. i \<le> n \<Longrightarrow> n < j \<Longrightarrow> P n \<Longrightarrow> P (Suc n)) \<Longrightarrow> P j" |
1826 by (induct j arbitrary: i) (auto simp: le_Suc_eq) |
1826 by (induct j arbitrary: i) (auto simp: le_Suc_eq) |
1827 |
1827 |
|
1828 |
1828 subsection {* The divides relation on @{typ nat} *} |
1829 subsection {* The divides relation on @{typ nat} *} |
1829 |
1830 |
1830 lemma dvd_1_left [iff]: "Suc 0 dvd k" |
1831 lemma dvd_1_left [iff]: "Suc 0 dvd k" |
1831 unfolding dvd_def by simp |
1832 unfolding dvd_def by simp |
1832 |
1833 |
1960 also have "\<dots> \<longleftrightarrow> m dvd n + (r * m - q)" by (simp add: add.commute) |
1961 also have "\<dots> \<longleftrightarrow> m dvd n + (r * m - q)" by (simp add: add.commute) |
1961 finally show ?thesis . |
1962 finally show ?thesis . |
1962 qed |
1963 qed |
1963 |
1964 |
1964 |
1965 |
1965 subsection {* aliases *} |
1966 subsection {* Aliases *} |
1966 |
1967 |
1967 lemma nat_mult_1: "(1::nat) * n = n" |
1968 lemma nat_mult_1: "(1::nat) * n = n" |
1968 by (rule mult_1_left) |
1969 by (rule mult_1_left) |
1969 |
1970 |
1970 lemma nat_mult_1_right: "n * (1::nat) = n" |
1971 lemma nat_mult_1_right: "n * (1::nat) = n" |
1971 by (rule mult_1_right) |
1972 by (rule mult_1_right) |
1972 |
1973 |
1973 |
1974 |
1974 subsection {* size of a datatype value *} |
1975 subsection {* Size of a datatype value *} |
1975 |
1976 |
1976 class size = |
1977 class size = |
1977 fixes size :: "'a \<Rightarrow> nat" -- {* see further theory @{text Wellfounded} *} |
1978 fixes size :: "'a \<Rightarrow> nat" -- {* see further theory @{text Wellfounded} *} |
1978 |
1979 |
1979 |
1980 instantiation nat :: size |
1980 subsection {* code module namespace *} |
1981 begin |
|
1982 |
|
1983 definition size_nat where |
|
1984 [simp, code]: "size (n \<Colon> nat) = n" |
|
1985 |
|
1986 instance .. |
|
1987 |
|
1988 end |
|
1989 |
|
1990 |
|
1991 subsection {* Code module namespace *} |
1981 |
1992 |
1982 code_identifier |
1993 code_identifier |
1983 code_module Nat \<rightharpoonup> (SML) Arith and (OCaml) Arith and (Haskell) Arith |
1994 code_module Nat \<rightharpoonup> (SML) Arith and (OCaml) Arith and (Haskell) Arith |
1984 |
1995 |
1985 hide_const (open) of_nat_aux |
1996 hide_const (open) of_nat_aux |