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