188 "nat_of_integer 0 = 0" |
188 "nat_of_integer 0 = 0" |
189 "nat_of_integer 1 = 1" |
189 "nat_of_integer 1 = 1" |
190 "nat_of_integer (numeral k) = numeral k" |
190 "nat_of_integer (numeral k) = numeral k" |
191 including integer.lifting by (transfer, simp)+ |
191 including integer.lifting by (transfer, simp)+ |
192 |
192 |
|
193 context |
|
194 includes integer.lifting and bit_operations_syntax |
|
195 begin |
|
196 |
|
197 declare [[code drop: \<open>bit :: nat \<Rightarrow> _\<close> |
|
198 \<open>and :: nat \<Rightarrow> _\<close> \<open>or :: nat \<Rightarrow> _\<close> \<open>xor :: nat \<Rightarrow> _\<close> |
|
199 \<open>push_bit :: _ \<Rightarrow> _ \<Rightarrow> nat\<close> \<open>drop_bit :: _ \<Rightarrow> _ \<Rightarrow> nat\<close> \<open>take_bit :: _ \<Rightarrow> _ \<Rightarrow> nat\<close>]] |
|
200 |
|
201 lemma [code]: |
|
202 \<open>bit m n \<longleftrightarrow> bit (integer_of_nat m) n\<close> |
|
203 by transfer (simp add: bit_simps) |
|
204 |
|
205 lemma [code]: |
|
206 \<open>integer_of_nat (m AND n) = integer_of_nat m AND integer_of_nat n\<close> |
|
207 by transfer (simp add: of_nat_and_eq) |
|
208 |
|
209 lemma [code]: |
|
210 \<open>integer_of_nat (m OR n) = integer_of_nat m OR integer_of_nat n\<close> |
|
211 by transfer (simp add: of_nat_or_eq) |
|
212 |
|
213 lemma [code]: |
|
214 \<open>integer_of_nat (m XOR n) = integer_of_nat m XOR integer_of_nat n\<close> |
|
215 by transfer (simp add: of_nat_xor_eq) |
|
216 |
|
217 lemma [code]: |
|
218 \<open>integer_of_nat (push_bit n m) = push_bit n (integer_of_nat m)\<close> |
|
219 by transfer (simp add: of_nat_push_bit) |
|
220 |
|
221 lemma [code]: |
|
222 \<open>integer_of_nat (drop_bit n m) = drop_bit n (integer_of_nat m)\<close> |
|
223 by transfer (simp add: of_nat_drop_bit) |
|
224 |
|
225 lemma [code]: |
|
226 \<open>integer_of_nat (take_bit n m) = take_bit n (integer_of_nat m)\<close> |
|
227 by transfer (simp add: of_nat_take_bit) |
|
228 |
|
229 lemma [code]: |
|
230 \<open>integer_of_nat (mask n) = mask n\<close> |
|
231 by transfer (simp add: of_nat_mask_eq) |
|
232 |
|
233 lemma [code]: |
|
234 \<open>integer_of_nat (set_bit n m) = set_bit n (integer_of_nat m)\<close> |
|
235 by transfer (simp add: of_nat_set_bit_eq) |
|
236 |
|
237 lemma [code]: |
|
238 \<open>integer_of_nat (unset_bit n m) = unset_bit n (integer_of_nat m)\<close> |
|
239 by transfer (simp add: of_nat_unset_bit_eq) |
|
240 |
|
241 lemma [code]: |
|
242 \<open>integer_of_nat (flip_bit n m) = flip_bit n (integer_of_nat m)\<close> |
|
243 by transfer (simp add: of_nat_flip_bit_eq) |
|
244 |
|
245 end |
|
246 |
193 code_identifier |
247 code_identifier |
194 code_module Code_Target_Nat \<rightharpoonup> |
248 code_module Code_Target_Nat \<rightharpoonup> |
195 (SML) Arith and (OCaml) Arith and (Haskell) Arith |
249 (SML) Arith and (OCaml) Arith and (Haskell) Arith |
196 |
250 |
197 end |
251 end |