equal
deleted
inserted
replaced
163 with prem show "int_of_nat n = 1 + int_of_nat (nat_of_int (int_of_nat n - 1))" unfolding int_of_nat_def by simp |
163 with prem show "int_of_nat n = 1 + int_of_nat (nat_of_int (int_of_nat n - 1))" unfolding int_of_nat_def by simp |
164 qed |
164 qed |
165 then show ?thesis unfolding int_aux_def int_of_nat_def by auto |
165 then show ?thesis unfolding int_aux_def int_of_nat_def by auto |
166 qed |
166 qed |
167 |
167 |
168 lemma index_of_nat_code [code func, code inline]: |
|
169 "index_of_nat n = index_of_int (int_of_nat n)" |
|
170 unfolding index_of_nat_def int_of_nat_def by simp |
|
171 |
|
172 lemma nat_of_index_code [code func, code inline]: |
|
173 "nat_of_index k = nat (int_of_index k)" |
|
174 unfolding nat_of_index_def by simp |
|
175 |
|
176 |
168 |
177 subsection {* Code generator setup for basic functions *} |
169 subsection {* Code generator setup for basic functions *} |
178 |
170 |
179 text {* |
171 text {* |
180 @{typ nat} is no longer a datatype but embedded into the integers. |
172 @{typ nat} is no longer a datatype but embedded into the integers. |
219 code_const int_of_nat |
211 code_const int_of_nat |
220 (SML "_") |
212 (SML "_") |
221 (OCaml "_") |
213 (OCaml "_") |
222 (Haskell "_") |
214 (Haskell "_") |
223 |
215 |
|
216 code_const index_of_nat |
|
217 (SML "_") |
|
218 (OCaml "_") |
|
219 (Haskell "_") |
|
220 |
224 code_const nat_of_int |
221 code_const nat_of_int |
225 (SML "_") |
222 (SML "_") |
226 (OCaml "_") |
223 (OCaml "_") |
227 (Haskell "_") |
224 (Haskell "_") |
|
225 |
|
226 code_const nat_of_index |
|
227 (SML "_") |
|
228 (OCaml "_") |
|
229 (Haskell "_") |
|
230 |
228 |
231 |
229 text {* Using target language div and mod *} |
232 text {* Using target language div and mod *} |
230 |
233 |
231 code_const "op div \<Colon> nat \<Rightarrow> nat \<Rightarrow> nat" |
234 code_const "op div \<Colon> nat \<Rightarrow> nat \<Rightarrow> nat" |
232 (SML "IntInf.div ((_), (_))") |
235 (SML "IntInf.div ((_), (_))") |