src/HOL/Arith.thy
author clasohm
Fri Mar 03 12:02:25 1995 +0100 (1995-03-03)
changeset 923 ff1574a81019
child 965 24eef3860714
permissions -rw-r--r--
new version of HOL with curried function application
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@923
    15
  pred      :: "nat => nat"
clasohm@923
    16
  div, mod  :: "[nat, nat] => nat"  (infixl 70)
clasohm@923
    17
clasohm@923
    18
defs
clasohm@923
    19
  pred_def  "pred(m) == nat_rec m 0 (%n r.n)"
clasohm@923
    20
  add_def   "m+n == nat_rec m n (%u v. Suc(v))"
clasohm@923
    21
  diff_def  "m-n == nat_rec n m (%u v. pred(v))"
clasohm@923
    22
  mult_def  "m*n == nat_rec m 0 (%u v. n + v)"
clasohm@923
    23
  mod_def   "m mod n == wfrec (trancl pred_nat) m (%j f.(if (j<n) j (f (j-n))))"
clasohm@923
    24
  div_def   "m div n == wfrec (trancl pred_nat) m (%j f.(if (j<n) 0 (Suc (f (j-n)))))"
clasohm@923
    25
end
clasohm@923
    26
clasohm@923
    27
(*"Difference" is subtraction of natural numbers.
clasohm@923
    28
  There are no negative numbers; we have
clasohm@923
    29
     m - n = 0  iff  m<=n   and     m - n = Suc(k) iff m>n.
clasohm@923
    30
  Also, nat_rec(m, 0, %z w.z) is pred(m).   *)
clasohm@923
    31