src/HOL/Arith.thy
 author pusch Tue Feb 25 15:11:12 1997 +0100 (1997-02-25) changeset 2681 93ed51a91622 parent 2099 c5f004bfcbab child 2887 00b8ee790d89 permissions -rw-r--r--
definitions of +,-,* replaced by primrec definitions
```     1 (*  Title:      HOL/Arith.thy
```
```     2     ID:         \$Id\$
```
```     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
```
```     4     Copyright   1993  University of Cambridge
```
```     5
```
```     6 Arithmetic operators and their definitions
```
```     7 *)
```
```     8
```
```     9 Arith = Nat +
```
```    10
```
```    11 instance
```
```    12   nat :: {plus, minus, times}
```
```    13
```
```    14 consts
```
```    15   pred      :: nat => nat
```
```    16   div, mod  :: [nat, nat] => nat  (infixl 70)
```
```    17
```
```    18 defs
```
```    19   pred_def  "pred(m) == case m of 0 => 0 | Suc n => n"
```
```    20
```
```    21   mod_def   "m mod n == wfrec (trancl pred_nat)
```
```    22                           (%f j. if j<n then j else f (j-n)) m"
```
```    23   div_def   "m div n == wfrec (trancl pred_nat)
```
```    24                           (%f j. if j<n then 0 else Suc (f (j-n))) m"
```
```    25
```
```    26
```
```    27 primrec "op +" nat
```
```    28 "0 + n = n"
```
```    29 "Suc m + n = Suc(m + n)"
```
```    30
```
```    31
```
```    32 primrec "op -" nat
```
```    33 "m - 0 = m"
```
```    34 "m - Suc n = pred(m - n)"
```
```    35
```
```    36 primrec "op *"  nat
```
```    37 "0 * n = 0"
```
```    38 "Suc m * n = n + (m * n)"
```
```    39
```
```    40
```
```    41 end
```
```    42
```
```    43 (*"Difference" is subtraction of natural numbers.
```
```    44   There are no negative numbers; we have
```
```    45      m - n = 0  iff  m<=n   and     m - n = Suc(k) iff m)n.
```
```    46   Also, nat_rec(0, %z w.z, m) is pred(m).   *)
```
```    47
```