2 (** {1 Basic Algebra Theories} *)
4 (** {2 Associativity} *)
10 axiom Assoc : forall x y z : t. op (op x y) z = op x (op y z)
14 (** {2 Commutativity} *)
20 axiom Comm : forall x y : t. op x y = op y x
24 (** {2 Associativity and Commutativity} *)
28 clone export Assoc with axiom Assoc
29 clone export Comm with type t = t, function op = op, axiom Comm
38 clone export Assoc with axiom Assoc
40 axiom Unit_def_l : forall x:t. op unit x = x
41 axiom Unit_def_r : forall x:t. op x unit = x
45 (** {2 Commutative Monoids} *)
47 module CommutativeMonoid
49 clone export Monoid with axiom Assoc, axiom Unit_def_l, axiom Unit_def_r
50 clone export Comm with type t = t, function op = op, axiom Comm
59 clone export Monoid with axiom Assoc, axiom Unit_def_l, axiom Unit_def_r
61 axiom Inv_def_l : forall x:t. op (inv x) x = unit
62 axiom Inv_def_r : forall x:t. op x (inv x) = unit
65 lemma Inv_unit : forall x y:t. op x (inv y) = unit -> x = y
70 (** {2 Commutative Groups} *)
72 module CommutativeGroup
74 clone export Group with axiom .
75 clone export Comm with type t = t, function op = op, axiom Comm
90 clone export CommutativeGroup with type t = t,
96 clone Assoc as MulAssoc with type t = t, function op = (*), axiom Assoc
98 axiom Mul_distr_l : forall x y z : t. x * (y + z) = x * y + x * z
99 axiom Mul_distr_r : forall x y z : t. (y + z) * x = y * x + z * x
103 (** {2 Commutative Rings} *)
105 module CommutativeRing
107 clone export Ring with axiom .
108 clone Comm as MulComm with type t = t, function op = (*), axiom Comm
113 (** {2 Commutative Rings with Unit} *)
115 module UnitaryCommutativeRing
117 clone export CommutativeRing with axiom .
119 axiom Unitary : forall x:t. one * x = x
120 axiom NonTrivialRing : zero <> one
124 (** {2 Ordered Commutative Rings} *)
126 module OrderedUnitaryCommutativeRing
128 clone export UnitaryCommutativeRing with axiom .
132 clone export relations.TotalOrder with
133 type t = t, predicate rel = (<=), axiom .
135 axiom ZeroLessOne : zero <= one
137 axiom CompatOrderAdd :
138 forall x y z : t. x <= y -> x + z <= y + z
140 axiom CompatOrderMult :
141 forall x y z : t. x <= y -> zero <= z -> x * z <= y * z
142 meta "remove_unused:dependency" axiom CompatOrderMult, function (*)
146 (** {2 Field theory} *)
150 clone export UnitaryCommutativeRing with axiom .
154 axiom Inverse : forall x:t. x <> zero -> x * inv x = one
156 function (-) (x y : t) : t = x + -y
157 function (/) (x y : t) : t = x * inv y
160 forall x y z : t. z <> zero -> (x+y)/z = x/z + y/z
161 meta "remove_unused:dependency" lemma add_div, function (/)
164 forall x y z : t. z <> zero -> (x-y)/z = x/z - y/z
165 meta "remove_unused:dependency" lemma sub_div, function (/)
168 forall x y : t. y <> zero -> (-x)/y = -(x/y)
169 meta "remove_unused:dependency" lemma neg_div, function (/)
171 lemma assoc_mul_div: forall x y z:t.
172 (* todo: discard the hypothesis ? *)
173 z <> zero -> (x*y)/z = x*(y/z)
174 meta "remove_unused:dependency" lemma assoc_mul_div, function (/)
176 lemma assoc_div_mul: forall x y z:t.
177 (* todo: discard the hypothesis ? *)
178 y <> zero /\ z <> zero -> (x/y)/z = x/(y*z)
179 meta "remove_unused:dependency" lemma assoc_div_mul, function (/)
181 lemma assoc_div_div: forall x y z:t.
182 (* todo: discard the hypothesis ? *)
183 y <> zero /\ z <> zero -> x/(y/z) = (x*z)/y
184 meta "remove_unused:dependency" lemma assoc_div_div, function (/)
188 (** {2 Ordered Fields} *)
192 clone export Field with axiom .
196 clone export relations.TotalOrder with
197 type t = t, predicate rel = (<=), axiom .
199 axiom ZeroLessOne : zero <= one
201 axiom CompatOrderAdd : forall x y z : t. x <= y -> x + z <= y + z
203 axiom CompatOrderMult :
204 forall x y z : t. x <= y -> zero <= z -> x * z <= y * z
209 to be discussed: should we add the following lemmas, and where
211 lemma InvMult : forall x y : t. (-x) * y = - (x * y) = x * (-y)
212 lemma InvSquare : forall x : t. x * x = (-x) * (-x)
213 lemma ZeroMult : forall x : t. x * zero = zero = zero * x
214 lemma SquareNonNeg1 : forall x : t. x <= zero -> zero <= x * x
215 lemma SquareNonNeg : forall x : t. zero <= x * x