src/HOL/Arith.thy
author paulson
Mon Oct 07 10:28:44 1996 +0200 (1996-10-07)
changeset 2056 93c093620c28
parent 1824 44254696843a
child 2099 c5f004bfcbab
permissions -rw-r--r--
Removed commands made redundant by new one-point rules
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
berghofe@1824
    19
  pred_def  "pred(m) == nat_rec 0 (%n r.n) m"
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