author | paulson |
Wed, 07 May 1997 13:51:22 +0200 | |
changeset 3125 | 3f0ab2c306f7 |
parent 2887 | 00b8ee790d89 |
child 3235 | 351565b7321b |
permissions | -rw-r--r-- |
923 | 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 |
|
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 | 17 |
|
18 |
defs |
|
2099 | 19 |
pred_def "pred(m) == case m of 0 => 0 | Suc n => n" |
1796 | 20 |
|
21 |
mod_def "m mod n == wfrec (trancl pred_nat) |
|
1475 | 22 |
(%f j. if j<n then j else f (j-n)) m" |
1796 | 23 |
div_def "m div n == wfrec (trancl pred_nat) |
1475 | 24 |
(%f j. if j<n then 0 else Suc (f (j-n))) m" |
2681
93ed51a91622
definitions of +,-,* replaced by primrec definitions
pusch
parents:
2099
diff
changeset
|
25 |
|
93ed51a91622
definitions of +,-,* replaced by primrec definitions
pusch
parents:
2099
diff
changeset
|
26 |
primrec "op +" nat |
2887 | 27 |
"0 + n = n" |
28 |
"Suc m + n = Suc(m + n)" |
|
2681
93ed51a91622
definitions of +,-,* replaced by primrec definitions
pusch
parents:
2099
diff
changeset
|
29 |
|
93ed51a91622
definitions of +,-,* replaced by primrec definitions
pusch
parents:
2099
diff
changeset
|
30 |
primrec "op -" nat |
2887 | 31 |
"m - 0 = m" |
32 |
"m - Suc n = pred(m - n)" |
|
2681
93ed51a91622
definitions of +,-,* replaced by primrec definitions
pusch
parents:
2099
diff
changeset
|
33 |
|
93ed51a91622
definitions of +,-,* replaced by primrec definitions
pusch
parents:
2099
diff
changeset
|
34 |
primrec "op *" nat |
2887 | 35 |
"0 * n = 0" |
36 |
"Suc m * n = n + (m * n)" |
|
2681
93ed51a91622
definitions of +,-,* replaced by primrec definitions
pusch
parents:
2099
diff
changeset
|
37 |
|
923 | 38 |
end |