src/HOL/Nat.thy
author paulson
Wed Jul 25 13:13:01 2001 +0200 (2001-07-25)
changeset 11451 8abfb4f7bd02
parent 11325 a5e0289dd56c
child 12338 de0f4a63baa5
permissions -rw-r--r--
partial restructuring to reduce dependence on Axiom of Choice
clasohm@923
     1
(*  Title:      HOL/Nat.thy
clasohm@923
     2
    ID:         $Id$
wenzelm@9436
     3
    Author:     Tobias Nipkow and Lawrence C Paulson
clasohm@923
     4
wenzelm@9436
     5
Type "nat" is a linear order, and a datatype; arithmetic operators + -
wenzelm@9436
     6
and * (for div, mod and dvd, see theory Divides).
clasohm@923
     7
*)
clasohm@923
     8
paulson@11451
     9
Nat = NatDef + 
clasohm@923
    10
oheimb@11134
    11
(* type "nat" is a wellfounded linear order, and a datatype *)
wenzelm@9436
    12
berghofe@5188
    13
rep_datatype nat
berghofe@5714
    14
  distinct Suc_not_Zero, Zero_not_Suc
berghofe@5714
    15
  inject   Suc_Suc_eq
berghofe@5188
    16
  induct   nat_induct
wenzelm@4104
    17
nipkow@2608
    18
instance nat :: order (le_refl,le_trans,le_anti_sym,nat_less_le)
nipkow@4640
    19
instance nat :: linorder (nat_le_linear)
oheimb@11134
    20
instance nat :: wellorder (wf_less)
oheimb@1660
    21
wenzelm@10435
    22
axclass power < term
wenzelm@10435
    23
paulson@3370
    24
consts
wenzelm@10435
    25
  power :: ['a::power, nat] => 'a            (infixr "^" 80)
paulson@3370
    26
wenzelm@9436
    27
wenzelm@9436
    28
(* arithmetic operators + - and * *)
wenzelm@9436
    29
wenzelm@9436
    30
instance
wenzelm@9436
    31
  nat :: {plus, minus, times, power}
wenzelm@9436
    32
wenzelm@9436
    33
(* size of a datatype value; overloaded *)
wenzelm@9436
    34
consts size :: 'a => nat
wenzelm@9436
    35
wenzelm@9436
    36
primrec
wenzelm@9436
    37
  add_0    "0 + n = n"
wenzelm@9436
    38
  add_Suc  "Suc m + n = Suc(m + n)"
wenzelm@9436
    39
wenzelm@9436
    40
primrec
wenzelm@9436
    41
  diff_0   "m - 0 = m"
wenzelm@9436
    42
  diff_Suc "m - Suc n = (case m - n of 0 => 0 | Suc k => k)"
wenzelm@9436
    43
wenzelm@9436
    44
primrec
wenzelm@9436
    45
  mult_0   "0 * n = 0"
wenzelm@9436
    46
  mult_Suc "Suc m * n = n + (m * n)"
wenzelm@9436
    47
clasohm@923
    48
end