src/HOL/Arith.thy
author nipkow
Thu, 16 Nov 1995 19:50:40 +0100
changeset 1334 32a9fde85699
parent 972 e61b058d58d2
child 1370 7361ac9b024d
permissions -rw-r--r--
added rev_contrapos
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     1
(*  Title:      HOL/Arith.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     6
Arithmetic operators and their definitions
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     9
Arith = Nat +
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    11
instance
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    12
  nat :: {plus, minus, times}
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
consts
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
  pred      :: "nat => nat"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
  div, mod  :: "[nat, nat] => nat"  (infixl 70)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
defs
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
  pred_def  "pred(m) == nat_rec m 0 (%n r.n)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
  add_def   "m+n == nat_rec m n (%u v. Suc(v))"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
  diff_def  "m-n == nat_rec n m (%u v. pred(v))"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    22
  mult_def  "m*n == nat_rec m 0 (%u v. n + v)"
965
24eef3860714 changed syntax of "if"
clasohm
parents: 923
diff changeset
    23
  mod_def   "m mod n == wfrec (trancl pred_nat) m (%j f.if j<n then j else f (j-n))"
24eef3860714 changed syntax of "if"
clasohm
parents: 923
diff changeset
    24
  div_def   "m div n == wfrec (trancl pred_nat) m (%j f.if j<n then 0 else Suc (f (j-n)))"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    25
end
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    26
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    27
(*"Difference" is subtraction of natural numbers.
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    28
  There are no negative numbers; we have
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 965
diff changeset
    29
     m - n = 0  iff  m<=n   and     m - n = Suc(k) iff m)n.
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    30
  Also, nat_rec(m, 0, %z w.z) is pred(m).   *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    31