author | kleing |
Thu, 17 Jan 2002 15:06:36 +0100 | |
changeset 12791 | ccc0f45ad2c4 |
parent 12440 | fb5851b71a82 |
child 12838 | 093d9b8979f2 |
permissions | -rw-r--r-- |
7032 | 1 |
(* Title: HOL/NatBin.thy |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1999 University of Cambridge |
|
5 |
||
6 |
Binary arithmetic for the natural numbers |
|
7 |
||
8 |
This case is simply reduced to that for the non-negative integers |
|
9 |
*) |
|
10 |
||
10574
8f98f0301d67
Linear arithmetic now copes with mixed nat/int formulae.
nipkow
parents:
9509
diff
changeset
|
11 |
theory NatBin = IntPower |
8f98f0301d67
Linear arithmetic now copes with mixed nat/int formulae.
nipkow
parents:
9509
diff
changeset
|
12 |
files ("nat_bin.ML"): |
7032 | 13 |
|
10574
8f98f0301d67
Linear arithmetic now copes with mixed nat/int formulae.
nipkow
parents:
9509
diff
changeset
|
14 |
instance nat :: number .. |
7032 | 15 |
|
16 |
defs |
|
10574
8f98f0301d67
Linear arithmetic now copes with mixed nat/int formulae.
nipkow
parents:
9509
diff
changeset
|
17 |
nat_number_of_def: |
7032 | 18 |
"number_of v == nat (number_of v)" |
19 |
(*::bin=>nat ::bin=>int*) |
|
20 |
||
10574
8f98f0301d67
Linear arithmetic now copes with mixed nat/int formulae.
nipkow
parents:
9509
diff
changeset
|
21 |
use "nat_bin.ML" setup nat_bin_arith_setup |
8f98f0301d67
Linear arithmetic now copes with mixed nat/int formulae.
nipkow
parents:
9509
diff
changeset
|
22 |
|
12440 | 23 |
|
24 |
subsection {* Configuration of the code generator *} |
|
25 |
||
26 |
types_code |
|
27 |
"int" ("int") |
|
28 |
||
29 |
lemmas [code] = int_0 int_Suc |
|
30 |
||
31 |
lemma [code]: "nat x = (if x <= 0 then 0 else Suc (nat (x - 1)))" |
|
32 |
by (simp add: Suc_nat_eq_nat_zadd1) |
|
33 |
||
34 |
consts_code |
|
35 |
"0" :: "int" ("0") |
|
36 |
"1" :: "int" ("1") |
|
37 |
"uminus" :: "int => int" ("~") |
|
38 |
"op +" :: "int => int => int" ("(_ +/ _)") |
|
39 |
"op *" :: "int => int => int" ("(_ */ _)") |
|
40 |
"neg" ("(_ < 0)") |
|
41 |
||
7032 | 42 |
end |