src/HOL/Nat.thy
author oheimb
Wed Apr 17 17:59:58 1996 +0200 (1996-04-17)
changeset 1660 8cb42cd97579
parent 1625 40501958d0f6
child 1672 2c109cd2fdd0
permissions -rw-r--r--
*** empty log message ***
clasohm@923
     1
(*  Title:      HOL/Nat.thy
clasohm@923
     2
    ID:         $Id$
clasohm@923
     3
    Author:     Tobias Nipkow, Cambridge University Computer Laboratory
clasohm@923
     4
    Copyright   1991  University of Cambridge
clasohm@923
     5
clasohm@923
     6
Definition of types ind and nat.
clasohm@923
     7
clasohm@923
     8
Type nat is defined as a set Nat over type ind.
clasohm@923
     9
*)
clasohm@923
    10
clasohm@923
    11
Nat = WF +
clasohm@923
    12
clasohm@923
    13
(** type ind **)
clasohm@923
    14
clasohm@923
    15
types
clasohm@923
    16
  ind
clasohm@923
    17
clasohm@923
    18
arities
clasohm@923
    19
  ind :: term
clasohm@923
    20
clasohm@923
    21
consts
clasohm@1370
    22
  Zero_Rep      :: ind
clasohm@1370
    23
  Suc_Rep       :: ind => ind
clasohm@923
    24
clasohm@923
    25
rules
clasohm@923
    26
  (*the axiom of infinity in 2 parts*)
clasohm@923
    27
  inj_Suc_Rep           "inj(Suc_Rep)"
clasohm@923
    28
  Suc_Rep_not_Zero_Rep  "Suc_Rep(x) ~= Zero_Rep"
clasohm@923
    29
clasohm@923
    30
clasohm@923
    31
clasohm@923
    32
(** type nat **)
clasohm@923
    33
clasohm@923
    34
(* type definition *)
clasohm@923
    35
clasohm@1475
    36
typedef (Nat)
clasohm@923
    37
  nat = "lfp(%X. {Zero_Rep} Un (Suc_Rep``X))"   (lfp_def)
clasohm@923
    38
clasohm@923
    39
instance
clasohm@923
    40
  nat :: ord
clasohm@923
    41
clasohm@923
    42
clasohm@923
    43
(* abstract constants and syntax *)
clasohm@923
    44
clasohm@923
    45
consts
nipkow@1531
    46
  "0"       :: nat                ("0")
paulson@1625
    47
  "1"       :: nat                ("1")
paulson@1625
    48
  "2"       :: nat                ("2")
nipkow@1531
    49
  Suc       :: nat => nat
nipkow@1531
    50
  nat_case  :: ['a, nat => 'a, nat] => 'a
nipkow@1531
    51
  pred_nat  :: "(nat * nat) set"
nipkow@1531
    52
  nat_rec   :: [nat, 'a, [nat, 'a] => 'a] => 'a
nipkow@1531
    53
nipkow@1531
    54
  Least     :: (nat=>bool) => nat    (binder "LEAST " 10)
clasohm@923
    55
clasohm@923
    56
translations
paulson@1625
    57
   "1"  == "Suc(0)"
paulson@1625
    58
   "2"  == "Suc(1)"
clasohm@923
    59
  "case p of 0 => a | Suc(y) => b" == "nat_case a (%y.b) p"
clasohm@923
    60
clasohm@923
    61
defs
clasohm@923
    62
  Zero_def      "0 == Abs_Nat(Zero_Rep)"
clasohm@923
    63
  Suc_def       "Suc == (%n. Abs_Nat(Suc_Rep(Rep_Nat(n))))"
clasohm@923
    64
clasohm@923
    65
  (*nat operations and recursion*)
clasohm@1151
    66
  nat_case_def  "nat_case a f n == @z.  (n=0 --> z=a)  
clasohm@1151
    67
                                        & (!x. n=Suc(x) --> z=f(x))"
clasohm@972
    68
  pred_nat_def  "pred_nat == {p. ? n. p = (n, Suc(n))}"
clasohm@923
    69
nipkow@1531
    70
  less_def      "m<n == (m,n):trancl(pred_nat)"
nipkow@1531
    71
nipkow@1531
    72
  le_def        "m<=(n::nat) == ~(n<m)"
clasohm@923
    73
nipkow@1531
    74
  nat_rec_def   "nat_rec n c d ==
paulson@1540
    75
                 wfrec pred_nat (%f. nat_case c (%m. d m (f m))) n"
nipkow@1531
    76
  (*least number operator*)
nipkow@1531
    77
  Least_def     "Least(P) == @k. P(k) & (ALL j. j<k --> ~P(j))"
clasohm@923
    78
oheimb@1660
    79
(* start 8bit 1 *)
oheimb@1660
    80
(* end 8bit 1 *)
oheimb@1660
    81
clasohm@923
    82
end