src/HOL/Nat.thy
author clasohm
Mon Feb 05 21:27:16 1996 +0100 (1996-02-05)
changeset 1475 7f5a4cd08209
parent 1370 7361ac9b024d
child 1531 e5eb247ad13c
permissions -rw-r--r--
expanded tabs; renamed subtype to typedef;
incorporated Konrad's changes
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
clasohm@1370
    46
  "0"           :: nat                ("0")
clasohm@1370
    47
  Suc           :: nat => nat
clasohm@1370
    48
  nat_case      :: ['a, nat => 'a, nat] => 'a
clasohm@923
    49
  pred_nat      :: "(nat * nat) set"
clasohm@1370
    50
  nat_rec       :: [nat, 'a, [nat, 'a] => 'a] => 'a
clasohm@923
    51
clasohm@923
    52
translations
clasohm@923
    53
  "case p of 0 => a | Suc(y) => b" == "nat_case a (%y.b) p"
clasohm@923
    54
clasohm@923
    55
defs
clasohm@923
    56
  Zero_def      "0 == Abs_Nat(Zero_Rep)"
clasohm@923
    57
  Suc_def       "Suc == (%n. Abs_Nat(Suc_Rep(Rep_Nat(n))))"
clasohm@923
    58
clasohm@923
    59
  (*nat operations and recursion*)
clasohm@1151
    60
  nat_case_def  "nat_case a f n == @z.  (n=0 --> z=a)  
clasohm@1151
    61
                                        & (!x. n=Suc(x) --> z=f(x))"
clasohm@972
    62
  pred_nat_def  "pred_nat == {p. ? n. p = (n, Suc(n))}"
clasohm@923
    63
clasohm@972
    64
  less_def "m<n == (m,n):trancl(pred_nat)"
clasohm@923
    65
clasohm@923
    66
  le_def   "m<=(n::nat) == ~(n<m)"
clasohm@923
    67
clasohm@1475
    68
nat_rec_def"nat_rec n c d == wfrec pred_nat (%f. nat_case c (%m. d m (f m))) n"
clasohm@923
    69
end