src/HOL/Arith.thy
author wenzelm
Thu Jan 23 14:19:16 1997 +0100 (1997-01-23)
changeset 2545 d10abc8c11fb
parent 2099 c5f004bfcbab
child 2681 93ed51a91622
permissions -rw-r--r--
added AxClasses test;
clasohm@923
     1
(*  Title:      HOL/Arith.thy
clasohm@923
     2
    ID:         $Id$
clasohm@923
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@923
     4
    Copyright   1993  University of Cambridge
clasohm@923
     5
clasohm@923
     6
Arithmetic operators and their definitions
clasohm@923
     7
*)
clasohm@923
     8
clasohm@923
     9
Arith = Nat +
clasohm@923
    10
clasohm@923
    11
instance
clasohm@923
    12
  nat :: {plus, minus, times}
clasohm@923
    13
clasohm@923
    14
consts
clasohm@1370
    15
  pred      :: nat => nat
clasohm@1370
    16
  div, mod  :: [nat, nat] => nat  (infixl 70)
clasohm@923
    17
clasohm@923
    18
defs
nipkow@2099
    19
  pred_def  "pred(m) == case m of 0 => 0 | Suc n => n"
berghofe@1824
    20
  add_def   "m+n == nat_rec n (%u v. Suc(v)) m"
berghofe@1824
    21
  diff_def  "m-n == nat_rec m (%u v. pred(v)) n"
berghofe@1824
    22
  mult_def  "m*n == nat_rec 0 (%u v. n + v) m"
paulson@1796
    23
paulson@1796
    24
  mod_def   "m mod n == wfrec (trancl pred_nat)
clasohm@1475
    25
                          (%f j. if j<n then j else f (j-n)) m"
paulson@1796
    26
  div_def   "m div n == wfrec (trancl pred_nat) 
clasohm@1475
    27
                          (%f j. if j<n then 0 else Suc (f (j-n))) m"
clasohm@923
    28
end
clasohm@923
    29
clasohm@923
    30
(*"Difference" is subtraction of natural numbers.
clasohm@923
    31
  There are no negative numbers; we have
clasohm@972
    32
     m - n = 0  iff  m<=n   and     m - n = Suc(k) iff m)n.
berghofe@1824
    33
  Also, nat_rec(0, %z w.z, m) is pred(m).   *)
clasohm@923
    34