src/HOL/Nat.thy
author wenzelm
Tue Jul 25 00:06:46 2000 +0200 (2000-07-25)
changeset 9436 62bb04ab4b01
parent 7702 35c7e0df749f
child 10435 b100e8d2c355
permissions -rw-r--r--
rearranged setup of arithmetic procedures, avoiding global reference values;
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
paulson@3370
    21
consts
paulson@3370
    22
  "^"           :: ['a::power,nat] => 'a            (infixr 80)
paulson@3370
    23
wenzelm@9436
    24
wenzelm@9436
    25
(* arithmetic operators + - and * *)
wenzelm@9436
    26
wenzelm@9436
    27
instance
wenzelm@9436
    28
  nat :: {plus, minus, times, power}
wenzelm@9436
    29
wenzelm@9436
    30
(* size of a datatype value; overloaded *)
wenzelm@9436
    31
consts size :: 'a => nat
wenzelm@9436
    32
wenzelm@9436
    33
primrec
wenzelm@9436
    34
  add_0    "0 + n = n"
wenzelm@9436
    35
  add_Suc  "Suc m + n = Suc(m + n)"
wenzelm@9436
    36
wenzelm@9436
    37
primrec
wenzelm@9436
    38
  diff_0   "m - 0 = m"
wenzelm@9436
    39
  diff_Suc "m - Suc n = (case m - n of 0 => 0 | Suc k => k)"
wenzelm@9436
    40
wenzelm@9436
    41
primrec
wenzelm@9436
    42
  mult_0   "0 * n = 0"
wenzelm@9436
    43
  mult_Suc "Suc m * n = n + (m * n)"
wenzelm@9436
    44
clasohm@923
    45
end