src/HOL/Nat.thy
author wenzelm
Fri Nov 10 19:04:31 2000 +0100 (2000-11-10)
changeset 10435 b100e8d2c355
parent 9436 62bb04ab4b01
child 11134 8bc06c4202cd
permissions -rw-r--r--
added axclass power (from HOL.thy);
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
berghofe@5188
     9
Nat = NatDef + Inductive +
clasohm@923
    10
wenzelm@9436
    11
(* type "nat" is a 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@1660
    20
wenzelm@10435
    21
axclass power < term
wenzelm@10435
    22
paulson@3370
    23
consts
wenzelm@10435
    24
  power :: ['a::power, nat] => 'a            (infixr "^" 80)
paulson@3370
    25
wenzelm@9436
    26
wenzelm@9436
    27
(* arithmetic operators + - and * *)
wenzelm@9436
    28
wenzelm@9436
    29
instance
wenzelm@9436
    30
  nat :: {plus, minus, times, power}
wenzelm@9436
    31
wenzelm@9436
    32
(* size of a datatype value; overloaded *)
wenzelm@9436
    33
consts size :: 'a => nat
wenzelm@9436
    34
wenzelm@9436
    35
primrec
wenzelm@9436
    36
  add_0    "0 + n = n"
wenzelm@9436
    37
  add_Suc  "Suc m + n = Suc(m + n)"
wenzelm@9436
    38
wenzelm@9436
    39
primrec
wenzelm@9436
    40
  diff_0   "m - 0 = m"
wenzelm@9436
    41
  diff_Suc "m - Suc n = (case m - n of 0 => 0 | Suc k => k)"
wenzelm@9436
    42
wenzelm@9436
    43
primrec
wenzelm@9436
    44
  mult_0   "0 * n = 0"
wenzelm@9436
    45
  mult_Suc "Suc m * n = n + (m * n)"
wenzelm@9436
    46
clasohm@923
    47
end