src/HOL/Arith.thy
author nipkow
Wed, 22 May 1996 17:11:54 +0200
changeset 1757 f7a573c46611
parent 1475 7f5a4cd08209
child 1796 c42db9ab8728
permissions -rw-r--r--
Added the second half of the W/I correspondence.

(*  Title:      HOL/Arith.thy
    ID:         $Id$
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
    Copyright   1993  University of Cambridge

Arithmetic operators and their definitions
*)

Arith = Nat +

instance
  nat :: {plus, minus, times}

consts
  pred      :: nat => nat
  div, mod  :: [nat, nat] => nat  (infixl 70)

defs
  pred_def  "pred(m) == nat_rec m 0 (%n r.n)"
  add_def   "m+n == nat_rec m n (%u v. Suc(v))"
  diff_def  "m-n == nat_rec n m (%u v. pred(v))"
  mult_def  "m*n == nat_rec m 0 (%u v. n + v)"
mod_def "m mod n == wfrec (trancl pred_nat)
                          (%f j. if j<n then j else f (j-n)) m"
div_def "m div n == wfrec (trancl pred_nat) 
                          (%f j. if j<n then 0 else Suc (f (j-n))) m"
end

(*"Difference" is subtraction of natural numbers.
  There are no negative numbers; we have
     m - n = 0  iff  m<=n   and     m - n = Suc(k) iff m)n.
  Also, nat_rec(m, 0, %z w.z) is pred(m).   *)