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