src/HOL/NatDef.thy
author paulson
Tue May 20 11:39:32 1997 +0200 (1997-05-20)
changeset 3236 882e125ed7da
parent 2608 450c9b682a92
child 3842 b55686a7b22c
permissions -rw-r--r--
New pattern-matching definition of pred_nat
nipkow@2608
     1
(*  Title:      HOL/NatDef.thy
nipkow@2608
     2
    ID:         $Id$
nipkow@2608
     3
    Author:     Tobias Nipkow, Cambridge University Computer Laboratory
nipkow@2608
     4
    Copyright   1991  University of Cambridge
nipkow@2608
     5
nipkow@2608
     6
Definition of types ind and nat.
nipkow@2608
     7
nipkow@2608
     8
Type nat is defined as a set Nat over type ind.
nipkow@2608
     9
*)
nipkow@2608
    10
nipkow@2608
    11
NatDef = WF +
nipkow@2608
    12
nipkow@2608
    13
(** type ind **)
nipkow@2608
    14
nipkow@2608
    15
types
nipkow@2608
    16
  ind
nipkow@2608
    17
nipkow@2608
    18
arities
nipkow@2608
    19
  ind :: term
nipkow@2608
    20
nipkow@2608
    21
consts
nipkow@2608
    22
  Zero_Rep      :: ind
nipkow@2608
    23
  Suc_Rep       :: ind => ind
nipkow@2608
    24
nipkow@2608
    25
rules
nipkow@2608
    26
  (*the axiom of infinity in 2 parts*)
nipkow@2608
    27
  inj_Suc_Rep           "inj(Suc_Rep)"
nipkow@2608
    28
  Suc_Rep_not_Zero_Rep  "Suc_Rep(x) ~= Zero_Rep"
nipkow@2608
    29
nipkow@2608
    30
nipkow@2608
    31
nipkow@2608
    32
(** type nat **)
nipkow@2608
    33
nipkow@2608
    34
(* type definition *)
nipkow@2608
    35
nipkow@2608
    36
typedef (Nat)
nipkow@2608
    37
  nat = "lfp(%X. {Zero_Rep} Un (Suc_Rep``X))"   (lfp_def)
nipkow@2608
    38
nipkow@2608
    39
instance
nipkow@2608
    40
  nat :: ord
nipkow@2608
    41
nipkow@2608
    42
nipkow@2608
    43
(* abstract constants and syntax *)
nipkow@2608
    44
nipkow@2608
    45
consts
nipkow@2608
    46
  "0"       :: nat                ("0")
nipkow@2608
    47
  Suc       :: nat => nat
nipkow@2608
    48
  nat_case  :: ['a, nat => 'a, nat] => 'a
nipkow@2608
    49
  pred_nat  :: "(nat * nat) set"
nipkow@2608
    50
  nat_rec   :: ['a, [nat, 'a] => 'a, nat] => 'a
nipkow@2608
    51
nipkow@2608
    52
syntax
nipkow@2608
    53
  "1"       :: nat                ("1")
nipkow@2608
    54
  "2"       :: nat                ("2")
nipkow@2608
    55
nipkow@2608
    56
translations
nipkow@2608
    57
   "1"  == "Suc 0"
nipkow@2608
    58
   "2"  == "Suc 1"
nipkow@2608
    59
  "case p of 0 => a | Suc y => b" == "nat_case a (%y.b) p"
nipkow@2608
    60
nipkow@2608
    61
nipkow@2608
    62
defs
nipkow@2608
    63
  Zero_def      "0 == Abs_Nat(Zero_Rep)"
nipkow@2608
    64
  Suc_def       "Suc == (%n. Abs_Nat(Suc_Rep(Rep_Nat(n))))"
nipkow@2608
    65
nipkow@2608
    66
  (*nat operations and recursion*)
nipkow@2608
    67
  nat_case_def  "nat_case a f n == @z.  (n=0 --> z=a)  
nipkow@2608
    68
                                        & (!x. n=Suc x --> z=f(x))"
paulson@3236
    69
  pred_nat_def  "pred_nat == {(m,n). n = Suc m}"
nipkow@2608
    70
nipkow@2608
    71
  less_def      "m<n == (m,n):trancl(pred_nat)"
nipkow@2608
    72
nipkow@2608
    73
  le_def        "m<=(n::nat) == ~(n<m)"
nipkow@2608
    74
nipkow@2608
    75
  nat_rec_def   "nat_rec c d ==
nipkow@2608
    76
                 wfrec pred_nat (%f. nat_case c (%m. d m (f m)))"
nipkow@2608
    77
end