src/HOL/Arith.thy
author nipkow
Wed, 16 Oct 1996 10:37:17 +0200
changeset 2099 c5f004bfcbab
parent 1824 44254696843a
child 2681 93ed51a91622
permissions -rw-r--r--
Defined pred using nat_case rather than nat_rec. Added expand_nat_case
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
1370
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 972
diff changeset
    15
  pred      :: nat => nat
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 972
diff changeset
    16
  div, mod  :: [nat, nat] => nat  (infixl 70)
923
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
2099
c5f004bfcbab Defined pred using nat_case rather than nat_rec.
nipkow
parents: 1824
diff changeset
    19
  pred_def  "pred(m) == case m of 0 => 0 | Suc n => n"
1824
44254696843a Changed argument order of nat_rec.
berghofe
parents: 1796
diff changeset
    20
  add_def   "m+n == nat_rec n (%u v. Suc(v)) m"
44254696843a Changed argument order of nat_rec.
berghofe
parents: 1796
diff changeset
    21
  diff_def  "m-n == nat_rec m (%u v. pred(v)) n"
44254696843a Changed argument order of nat_rec.
berghofe
parents: 1796
diff changeset
    22
  mult_def  "m*n == nat_rec 0 (%u v. n + v) m"
1796
c42db9ab8728 Tidied spacing
paulson
parents: 1475
diff changeset
    23
c42db9ab8728 Tidied spacing
paulson
parents: 1475
diff changeset
    24
  mod_def   "m mod n == wfrec (trancl pred_nat)
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1370
diff changeset
    25
                          (%f j. if j<n then j else f (j-n)) m"
1796
c42db9ab8728 Tidied spacing
paulson
parents: 1475
diff changeset
    26
  div_def   "m div n == wfrec (trancl pred_nat) 
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1370
diff changeset
    27
                          (%f j. if j<n then 0 else Suc (f (j-n))) m"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    28
end
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    29
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    30
(*"Difference" is subtraction of natural numbers.
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    31
  There are no negative numbers; we have
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 965
diff changeset
    32
     m - n = 0  iff  m<=n   and     m - n = Suc(k) iff m)n.
1824
44254696843a Changed argument order of nat_rec.
berghofe
parents: 1796
diff changeset
    33
  Also, nat_rec(0, %z w.z, m) is pred(m).   *)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    34