src/HOL/Nat.thy
author nipkow
Mon Mar 04 14:37:33 1996 +0100 (1996-03-04)
changeset 1531 e5eb247ad13c
parent 1475 7f5a4cd08209
child 1540 eacaa07e9078
permissions -rw-r--r--
Added a constant UNIV == {x.True}
Added many new rewrite rules for sets.
Moved LEAST into Nat.
Added cardinality to Finite.
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")
nipkow@1531
    47
  Suc       :: nat => nat
nipkow@1531
    48
  nat_case  :: ['a, nat => 'a, nat] => 'a
nipkow@1531
    49
  pred_nat  :: "(nat * nat) set"
nipkow@1531
    50
  nat_rec   :: [nat, 'a, [nat, 'a] => 'a] => 'a
nipkow@1531
    51
nipkow@1531
    52
  Least     :: (nat=>bool) => nat    (binder "LEAST " 10)
clasohm@923
    53
clasohm@923
    54
translations
clasohm@923
    55
  "case p of 0 => a | Suc(y) => b" == "nat_case a (%y.b) p"
clasohm@923
    56
clasohm@923
    57
defs
clasohm@923
    58
  Zero_def      "0 == Abs_Nat(Zero_Rep)"
clasohm@923
    59
  Suc_def       "Suc == (%n. Abs_Nat(Suc_Rep(Rep_Nat(n))))"
clasohm@923
    60
clasohm@923
    61
  (*nat operations and recursion*)
clasohm@1151
    62
  nat_case_def  "nat_case a f n == @z.  (n=0 --> z=a)  
clasohm@1151
    63
                                        & (!x. n=Suc(x) --> z=f(x))"
clasohm@972
    64
  pred_nat_def  "pred_nat == {p. ? n. p = (n, Suc(n))}"
clasohm@923
    65
nipkow@1531
    66
  less_def      "m<n == (m,n):trancl(pred_nat)"
nipkow@1531
    67
nipkow@1531
    68
  le_def        "m<=(n::nat) == ~(n<m)"
clasohm@923
    69
nipkow@1531
    70
  nat_rec_def   "nat_rec n c d ==
nipkow@1531
    71
		 wfrec pred_nat (%f. nat_case c (%m. d m (f m))) n"
nipkow@1531
    72
  (*least number operator*)
nipkow@1531
    73
  Least_def     "Least(P) == @k. P(k) & (ALL j. j<k --> ~P(j))"
clasohm@923
    74
clasohm@923
    75
end