| author | paulson | 
| Tue, 01 Aug 2000 15:28:21 +0200 | |
| changeset 9491 | 1a36151ee2fc | 
| parent 6070 | 032babd0120b | 
| child 9492 | 72e429c66608 | 
| permissions | -rw-r--r-- | 
| 1478 | 1  | 
(* Title: ZF/arith.thy  | 
| 0 | 2  | 
ID: $Id$  | 
| 1478 | 3  | 
Author: Lawrence C Paulson, Cambridge University Computer Laboratory  | 
| 0 | 4  | 
Copyright 1992 University of Cambridge  | 
5  | 
||
6  | 
Arithmetic operators and their definitions  | 
|
7  | 
*)  | 
|
8  | 
||
| 
9491
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
9  | 
Arith = Univ +  | 
| 6070 | 10  | 
|
| 
9491
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
11  | 
constdefs  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
12  | 
pred :: i=>i (*inverse of succ*)  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
13  | 
"pred(y) == THE x. y = succ(x)"  | 
| 6070 | 14  | 
|
| 
9491
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
15  | 
natify :: i=>i (*coerces non-nats to nats*)  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
16  | 
"natify == Vrecursor(%f a. if a = succ(pred(a)) then succ(f`pred(a))  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
17  | 
else 0)"  | 
| 6070 | 18  | 
|
| 0 | 19  | 
consts  | 
| 
9491
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
20  | 
"##*" :: [i,i]=>i (infixl 70)  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
21  | 
"##+" :: [i,i]=>i (infixl 65)  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
22  | 
"##-" :: [i,i]=>i (infixl 65)  | 
| 0 | 23  | 
|
| 6070 | 24  | 
primrec  | 
| 
9491
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
25  | 
raw_add_0 "0 ##+ n = n"  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
26  | 
raw_add_succ "succ(m) ##+ n = succ(m ##+ n)"  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
27  | 
|
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
28  | 
primrec  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
29  | 
raw_diff_0 "m ##- 0 = m"  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
30  | 
raw_diff_succ "m ##- succ(n) = nat_case(0, %x. x, m ##- n)"  | 
| 6070 | 31  | 
|
32  | 
primrec  | 
|
| 
9491
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
33  | 
raw_mult_0 "0 ##* n = 0"  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
34  | 
raw_mult_succ "succ(m) ##* n = n ##+ (m ##* n)"  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
35  | 
|
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
36  | 
constdefs  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
37  | 
add :: [i,i]=>i (infixl "#+" 65)  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
38  | 
"m #+ n == natify(m) ##+ natify(n)"  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
39  | 
|
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
40  | 
diff :: [i,i]=>i (infixl "#-" 65)  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
41  | 
"m #- n == natify(m) ##- natify(n)"  | 
| 0 | 42  | 
|
| 
9491
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
43  | 
mult :: [i,i]=>i (infixl "#*" 70)  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
44  | 
"m #* n == natify(m) ##* natify(n)"  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
45  | 
|
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
46  | 
div :: [i,i]=>i (infixl "div" 70)  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
47  | 
"m div n == transrec(m, %j f. if j<n then 0 else succ(f`(j#-n)))"  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
48  | 
|
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
49  | 
mod :: [i,i]=>i (infixl "mod" 70)  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
50  | 
"m mod n == transrec(m, %j f. if j<n then j else f`(j#-n))"  | 
| 
 
1a36151ee2fc
natify, a coercion to reduce the number of type constraints in arithmetic
 
paulson 
parents: 
6070 
diff
changeset
 | 
51  | 
|
| 0 | 52  | 
end  |