src/HOL/Arith.thy
author clasohm
Wed Nov 29 16:44:59 1995 +0100 (1995-11-29)
changeset 1370 7361ac9b024d
parent 972 e61b058d58d2
child 1475 7f5a4cd08209
permissions -rw-r--r--
removed quotes from types in consts and syntax sections
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
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@965
    23
  mod_def   "m mod n == wfrec (trancl pred_nat) m (%j f.if j<n then j else f (j-n))"
clasohm@965
    24
  div_def   "m div n == wfrec (trancl pred_nat) m (%j f.if j<n then 0 else 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@972
    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