7998
|
1 |
(*
|
|
2 |
Abstract class ring (commutative, with 1)
|
|
3 |
$Id$
|
|
4 |
Author: Clemens Ballarin, started 9 December 1996
|
|
5 |
*)
|
|
6 |
|
|
7 |
Ring = Main +
|
|
8 |
|
|
9 |
(* Syntactic class ring *)
|
|
10 |
|
|
11 |
axclass
|
11093
|
12 |
ringS < zero, plus, minus, times, power, inverse
|
7998
|
13 |
|
|
14 |
consts
|
|
15 |
(* Basic rings *)
|
|
16 |
"<1>" :: 'a::ringS ("<1>")
|
|
17 |
"--" :: ['a, 'a] => 'a::ringS (infixl 65)
|
|
18 |
|
|
19 |
(* Divisibility *)
|
11093
|
20 |
assoc :: ['a::times, 'a] => bool (infixl 50)
|
7998
|
21 |
irred :: 'a::ringS => bool
|
|
22 |
prime :: 'a::ringS => bool
|
|
23 |
|
|
24 |
translations
|
|
25 |
"a -- b" == "a + (-b)"
|
|
26 |
|
|
27 |
(* Class ring and ring axioms *)
|
|
28 |
|
|
29 |
axclass
|
11778
|
30 |
ring < ringS, plus_ac0
|
7998
|
31 |
|
11778
|
32 |
(*a_assoc "(a + b) + c = a + (b + c)"*)
|
|
33 |
(*l_zero "0 + a = a"*)
|
11093
|
34 |
l_neg "(-a) + a = 0"
|
11778
|
35 |
(*a_comm "a + b = b + a"*)
|
7998
|
36 |
|
|
37 |
m_assoc "(a * b) * c = a * (b * c)"
|
|
38 |
l_one "<1> * a = a"
|
|
39 |
|
|
40 |
l_distr "(a + b) * c = a * c + b * c"
|
|
41 |
|
|
42 |
m_comm "a * b = b * a"
|
|
43 |
|
11093
|
44 |
(* Definition of derived operations *)
|
7998
|
45 |
|
11093
|
46 |
inverse_ax "inverse a = (if a dvd <1> then @x. a*x = <1> else 0)"
|
10447
|
47 |
divide_ax "a / b = a * inverse b"
|
7998
|
48 |
power_ax "a ^ n = nat_rec <1> (%u b. b * a) n"
|
|
49 |
|
|
50 |
defs
|
|
51 |
assoc_def "a assoc b == a dvd b & b dvd a"
|
11093
|
52 |
irred_def "irred a == a ~= 0 & ~ a dvd <1>
|
7998
|
53 |
& (ALL d. d dvd a --> d dvd <1> | a dvd d)"
|
11093
|
54 |
prime_def "prime p == p ~= 0 & ~ p dvd <1>
|
7998
|
55 |
& (ALL a b. p dvd (a*b) --> p dvd a | p dvd b)"
|
|
56 |
|
|
57 |
(* Integral domains *)
|
|
58 |
|
|
59 |
axclass
|
|
60 |
domain < ring
|
|
61 |
|
11093
|
62 |
one_not_zero "<1> ~= 0"
|
|
63 |
integral "a * b = 0 ==> a = 0 | b = 0"
|
7998
|
64 |
|
|
65 |
(* Factorial domains *)
|
|
66 |
|
|
67 |
axclass
|
|
68 |
factorial < domain
|
|
69 |
|
|
70 |
(*
|
|
71 |
Proper definition using divisor chain condition currently not supported.
|
|
72 |
factorial_divisor "wf {(a, b). a dvd b & ~ (b dvd a)}"
|
|
73 |
*)
|
|
74 |
factorial_divisor "True"
|
|
75 |
factorial_prime "irred a ==> prime a"
|
|
76 |
|
|
77 |
(* Euclidean domains *)
|
|
78 |
|
|
79 |
(*
|
|
80 |
axclass
|
|
81 |
euclidean < domain
|
|
82 |
|
11093
|
83 |
euclidean_ax "b ~= 0 ==> Ex (% (q, r, e_size::('a::ringS)=>nat).
|
7998
|
84 |
a = b * q + r & e_size r < e_size b)"
|
|
85 |
|
|
86 |
Nothing has been proved about euclidean domains, yet.
|
|
87 |
Design question:
|
|
88 |
Fix quo, rem and e_size as constants that are axiomatised with
|
|
89 |
euclidean_ax?
|
|
90 |
- advantage: more pragmatic and easier to use
|
|
91 |
- disadvantage: for every type, one definition of quo and rem will
|
|
92 |
be fixed, users may want to use differing ones;
|
|
93 |
also, it seems not possible to prove that fields are euclidean
|
|
94 |
domains, because that would require generic (type-independent)
|
|
95 |
definitions of quo and rem.
|
|
96 |
*)
|
|
97 |
|
|
98 |
(* Fields *)
|
|
99 |
|
|
100 |
axclass
|
|
101 |
field < ring
|
|
102 |
|
11093
|
103 |
field_one_not_zero "<1> ~= 0"
|
|
104 |
(* Avoid a common superclass as the first thing we will
|
|
105 |
prove about fields is that they are domains. *)
|
|
106 |
field_ax "a ~= 0 ==> a dvd <1>"
|
7998
|
107 |
|
|
108 |
end
|