author | paulson |
Thu, 08 Jul 1999 13:48:11 +0200 | |
changeset 6921 | 78a2ce8fb8df |
parent 6455 | 34c6c2944908 |
child 8698 | 8812dad6ef12 |
permissions | -rw-r--r-- |
1804 | 1 |
(* Title: HOL/ex/Primes.thy |
2 |
ID: $Id$ |
|
3 |
Author: Christophe Tabacznyj and Lawrence C Paulson |
|
4 |
Copyright 1996 University of Cambridge |
|
5 |
||
3376 | 6 |
The Greatest Common Divisor and Euclid's algorithm |
3495
04739732b13e
New comments on how to deal with unproved termination conditions
paulson
parents:
3376
diff
changeset
|
7 |
|
04739732b13e
New comments on how to deal with unproved termination conditions
paulson
parents:
3376
diff
changeset
|
8 |
The "simpset" clause in the recdef declaration is omitted on purpose: |
04739732b13e
New comments on how to deal with unproved termination conditions
paulson
parents:
3376
diff
changeset
|
9 |
in order to demonstrate the treatment of definitions that have |
04739732b13e
New comments on how to deal with unproved termination conditions
paulson
parents:
3376
diff
changeset
|
10 |
unproved termination conditions. Restoring the clause lets |
04739732b13e
New comments on how to deal with unproved termination conditions
paulson
parents:
3376
diff
changeset
|
11 |
Isabelle prove those conditions. |
1804 | 12 |
*) |
13 |
||
6455 | 14 |
Primes = Main + |
1804 | 15 |
consts |
3242
406ae5ced4e9
Renamed egcd and gcd; defined the gcd function using TFL
paulson
parents:
1804
diff
changeset
|
16 |
is_gcd :: [nat,nat,nat]=>bool (*gcd as a relation*) |
406ae5ced4e9
Renamed egcd and gcd; defined the gcd function using TFL
paulson
parents:
1804
diff
changeset
|
17 |
gcd :: "nat*nat=>nat" (*Euclid's algorithm *) |
406ae5ced4e9
Renamed egcd and gcd; defined the gcd function using TFL
paulson
parents:
1804
diff
changeset
|
18 |
coprime :: [nat,nat]=>bool |
3376 | 19 |
prime :: nat set |
1804 | 20 |
|
3495
04739732b13e
New comments on how to deal with unproved termination conditions
paulson
parents:
3376
diff
changeset
|
21 |
recdef gcd "measure ((%(m,n).n) ::nat*nat=>nat)" |
6455 | 22 |
(* simpset "simpset() addsimps [mod_less_divisor, zero_less_eq]" *) |
3242
406ae5ced4e9
Renamed egcd and gcd; defined the gcd function using TFL
paulson
parents:
1804
diff
changeset
|
23 |
"gcd (m, n) = (if n=0 then m else gcd(n, m mod n))" |
406ae5ced4e9
Renamed egcd and gcd; defined the gcd function using TFL
paulson
parents:
1804
diff
changeset
|
24 |
|
1804 | 25 |
defs |
3242
406ae5ced4e9
Renamed egcd and gcd; defined the gcd function using TFL
paulson
parents:
1804
diff
changeset
|
26 |
is_gcd_def "is_gcd p m n == p dvd m & p dvd n & |
406ae5ced4e9
Renamed egcd and gcd; defined the gcd function using TFL
paulson
parents:
1804
diff
changeset
|
27 |
(ALL d. d dvd m & d dvd n --> d dvd p)" |
1804 | 28 |
|
3242
406ae5ced4e9
Renamed egcd and gcd; defined the gcd function using TFL
paulson
parents:
1804
diff
changeset
|
29 |
coprime_def "coprime m n == gcd(m,n) = 1" |
1804 | 30 |
|
3376 | 31 |
prime_def "prime == {p. 1<p & (ALL m. m dvd p --> m=1 | m=p)}" |
1804 | 32 |
|
33 |
end |