1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| A.Asperti, C.Sacerdoti Coen, *)
8 (* ||A|| E.Tassi, S.Zacchiroli *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU Lesser General Public License Version 2.1 *)
13 (**************************************************************************)
15 (* $Id: CSemiGroups.v,v 1.10 2004/09/24 15:30:34 loeb Exp $ *)
16 (* printing [+] %\ensuremath+% #+# *)
17 (* printing {+} %\ensuremath+% #+# *)
19 (* Require Export CSetoidInc. *)
23 set "baseuri" "cic:/matita/algebra/CoRN/CSemiGroups".
24 include "algebra/CoRN/SetoidInc.ma".
26 (*------------------------------------------------------------------*)
27 (* Semigroups - Definition of the notion of Constructive Semigroup *)
28 (*------------------------------------------------------------------*)
30 definition is_CSemiGroup : \forall A : CSetoid. \forall op: CSetoid_bin_op A. Prop \def
31 \lambda A : CSetoid. \lambda op: CSetoid_bin_op A. CSassociative A (csbf_fun A A A op).
33 record CSemiGroup : Type \def
35 csg_op : CSetoid_bin_op csg_crr;
36 csg_proof : is_CSemiGroup csg_crr csg_op}.
39 Implicit Arguments csg_op [c].
40 Infix "[+]" := csg_op (at level 50, left associativity).
45 (*--------------------------------------------------------------*)
46 (* Semigroup axioms - The axiomatic properties of a semi group *)
47 (*--------------------------------------------------------------*)
48 (* Variable G : CSemiGroup. *)
50 lemma CSemiGroup_is_CSemiGroup : \forall G : CSemiGroup. is_CSemiGroup (csg_crr G) (csg_op G).
52 elim G. simplify. exact H.
55 Lemma CSemiGroup_is_CSemiGroup : is_CSemiGroup G csg_op.*)
57 lemma plus_assoc : \forall G : CSemiGroup.
58 CSassociative G (csbf_fun G G G (csg_op G)).
59 exact CSemiGroup_is_CSemiGroup.
62 (*--------------------------------------------------------------*)
63 (* Semigroup basics *)
64 (*--------------------------------------------------------------*)
66 lemma plus_assoc_unfolded : \forall G : CSemiGroup. \forall x,y,z : ?.
67 (csbf_fun G G G (csg_op G) x (csbf_fun G G G (csg_op G) y z)) =
68 (csbf_fun G G G (csg_op G) (csbf_fun G G G (csg_op G) x y) z).
77 Let [S1 S2:CSemiGroup].
81 (* Variable S1:CSemiGroup.
82 Variable S2:CSemiGroup. *)
84 definition morphism_of_CSemiGroups: \forall S1,S2: CSemiGroup. \forall f: CSetoid_fun S1 S2.
86 \lambda S1,S2: CSemiGroup. \lambda f: CSetoid_fun S1 S2.
87 (\forall a,b:S1. (csf_fun S1 S2 f (csbf_fun ? ? ? (csg_op ?) a b)) =
88 (csbf_fun ? ? ? (csg_op ?) (csf_fun S1 S2 f a) (csf_fun S1 S2 f b))).
96 definition is_rht_unit: \forall S: CSemiGroup. \forall op : CSetoid_bin_op S. \forall Zero: ?. Prop
98 \lambda S: CSemiGroup. \lambda op : CSetoid_bin_op S. \lambda Zero: ?.
99 \forall x:?. (csbf_fun ? ? ? op x Zero) = x.
101 (* Definition is_rht_unit S (op : CSetoid_bin_op S) Zero : Prop := forall x, op x Zero [=] x. *)
105 definition is_lft_unit: \forall S: CSemiGroup. \forall op : CSetoid_bin_op S. \forall Zero: ?. Prop
107 \lambda S: CSemiGroup. \lambda op : CSetoid_bin_op S. \lambda Zero: ?.
108 \forall x:?. (csbf_fun ? ? ? op Zero x) = x.
111 (* Implicit Arguments is_lft_unit [S]. *)
113 (* Begin_SpecReals *)
115 (* Implicit Arguments is_rht_unit [S]. *)
117 (* An alternative definition:
120 definition is_unit: \forall S:CSemiGroup. S \to Prop \def
121 \lambda S:CSemiGroup.
122 \lambda e. (\forall (a:S). (csbf_fun ? ? ? (csg_op ?) e a) = a \and (csbf_fun ? ? ? (csg_op ?) a e)
125 lemma cs_unique_unit : \forall S:CSemiGroup. \forall e,f:S.
126 (is_unit S e) \and (is_unit S f) \to e = f.
150 (* Hint Resolve plus_assoc_unfolded: algebra. *)
152 (* Functional operations
153 We can also define a similar addition operator, which will be denoted by [{+}], on partial functions.
155 %\begin{convention}% Whenever possible, we will denote the functional construction corresponding to an algebraic operation by the same symbol enclosed in curly braces.
158 At this stage, we will always consider autobatchmorphisms; we %{\em %could%}% treat this in a more general setting, but we feel that it wouldn't really be a useful effort.
160 %\begin{convention}% Let [G:CSemiGroup] and [F,F':(PartFunct G)] and denote by [P] and [Q], respectively, the predicates characterizing their domains.
164 (* Section Part_Function_Plus. *)
166 (* Variable G : CSemiGroup.
167 Variables F F' : PartFunct G. *)
173 definition NP : \forall G:CSemiGroup. \forall F,F': PartFunct G. ? \def
174 \lambda G:CSemiGroup. \lambda F,F': PartFunct G.
176 definition NQ : \forall G:CSemiGroup. \forall F,F': PartFunct G. ? \def
177 \lambda G:CSemiGroup. \lambda F,F': PartFunct G.
180 lemma part_function_plus_strext : \forall G:CSemiGroup. \forall F,F': PartFunct G.
181 \forall x, y:G. \forall Hx : conjP G (pfdom G F) (pfdom G F') x.
182 \forall Hy : conjP G (pfdom G F) (pfdom G F') y.
183 (csbf_fun ? ? ? (csg_op G) (pfpfun ? F x (prj1 G (pfdom G F) (pfdom G F') x Hx))
184 (pfpfun ? F' x (prj2 G (pfdom G F) (pfdom G F') x Hx)))
185 \neq (csbf_fun ? ? ? (csg_op G) (pfpfun ? F y (prj1 G (pfdom G F) (pfdom G F') y Hy))
186 (pfpfun ? F' y (prj2 G (pfdom G F) (pfdom G F') y Hy)))
188 intros (G F F' x y Hx Hy H).
189 elim (bin_op_strext_unfolded ? ? ? ? ? ? H)[
190 apply pfstrx[apply F|elim Hx.apply a|elim Hy.apply a|exact H1]|
191 apply pfstrx[apply F'|elim Hx.apply b|elim Hy.apply b|exact H1]]
194 definition Fplus : \forall G:CSemiGroup. \forall F,F': PartFunct G. ? \def
195 \lambda G:CSemiGroup. \lambda F,F': PartFunct G.
196 mk_PartFunct G ? (conj_wd ? ? ? (dom_wd ? F) (dom_wd ? F'))
197 (\lambda x,Hx. (csbf_fun ? ? ? (csg_op ?)
198 (pfpfun ? F x (prj1 ? ? ? ? Hx)) (pfpfun ? F' x (prj2 ? ? ? ? Hx))))
199 (part_function_plus_strext G F F').
202 %\begin{convention}% Let [R:G->CProp].
206 (* Variable R : G -> CProp. *)
208 lemma included_FPlus : \forall G:CSemiGroup. \forall R : G \to Type. \forall F,F': PartFunct G.
209 included ? R (NP G F F' ) -> included ? R (NQ G F F') \to included ? R (pfdom ? (Fplus G F F')).
210 intros; unfold Fplus;simplify. apply included_conj; assumption.
213 lemma included_FPlus' : \forall G:CSemiGroup. \forall R : G \to Type. \forall F,F': PartFunct G.
214 included ? R (pfdom ? (Fplus G F F')) \to included ? R (NP G F F').
215 intros. unfold Fplus in i. simplify in i; unfold NP.
216 apply (included_conj_lft ? ? ? ? i); apply H.
219 lemma included_FPlus'' : \forall G:CSemiGroup. \forall R : G \to Type. \forall F,F': PartFunct G.
220 included ? R (pfdom ? (Fplus G F F')) -> included ? R (NQ G F F').
221 intros (G R F F'H); unfold Fplus in H. simplify in H;
222 unfold NQ. apply (included_conj_rht ? (pfdom G F)); apply H.
225 (* End Part_Function_Plus. *)
227 (* Implicit Arguments Fplus [G].
228 Infix "{+}" := Fplus (at level 50, left associativity).
230 Hint Resolve included_FPlus : included.
232 Hint Immediate included_FPlus' included_FPlus'' : included.
237 Let [csg] a semi-group and [P] a non-empty
238 predicate on the semi-group which is preserved by [[+]].
242 (* Section SubCSemiGroups. *)
244 (* Variable csg : CSemiGroup.
245 Variable P : csg -> CProp.
246 Variable op_pres_P : bin_op_pres_pred _ P csg_op. *)
248 definition subcrr : \forall csg: CSemiGroup. \forall P : csg -> Prop. CSetoid \def
249 \lambda csg: CSemiGroup. \lambda P : csg -> Prop.
251 definition mk_SubCSemiGroup :\forall csg: CSemiGroup. \forall P : csg -> Prop.
252 \forall op_pres_P : bin_op_pres_pred csg P (csg_op csg). CSemiGroup \def
253 \lambda csg: CSemiGroup. \lambda P : csg -> Prop.
254 \lambda op_pres_P : bin_op_pres_pred csg P (csg_op csg).
255 mk_CSemiGroup (subcrr csg P) (mk_SubCSetoid_bin_op ? ? ? op_pres_P )
256 (restr_f_assoc csg P ? op_pres_P (plus_assoc csg)).
261 Let [M1 M2:CSemiGroup]
265 (* Variable M1 M2: CSemiGroup. *)
267 definition dprod: \forall M1,M2:CSemiGroup. \forall x:ProdCSetoid (csg_crr M1) (csg_crr M2).
268 \forall y:ProdCSetoid (csg_crr M1) (csg_crr M2). (ProdCSetoid (csg_crr M1) (csg_crr M2)) \def
269 \lambda M1,M2:CSemiGroup. \lambda x:ProdCSetoid (csg_crr M1) (csg_crr M2).
270 \lambda y:ProdCSetoid (csg_crr M1) (csg_crr M2).
272 [pair (x1: (cs_crr (csg_crr M1))) (x2: (cs_crr (csg_crr M2))) \Rightarrow
274 [pair (y1: (cs_crr (csg_crr M1))) (y2: (cs_crr (csg_crr M2))) \Rightarrow
275 pair (cs_crr (csg_crr M1)) (cs_crr (csg_crr M2))
276 (csbf_fun ? ? ? (csg_op M1) x1 y1) (csbf_fun ? ? ? (csg_op M2) x2 y2)]].
278 lemma dprod_strext: \forall M1,M2:CSemiGroup.
279 (bin_fun_strext (ProdCSetoid M1 M2)(ProdCSetoid M1 M2)
280 (ProdCSetoid M1 M2) (dprod M1 M2)).
281 unfold bin_fun_strext.
282 intros 6 (M1 M2 x1 x2 y1 y2).
297 cut (a1 \neq b1 \lor c1 \neq d1).
298 elim Hcut[left.left.assumption|right.left.assumption]
299 |intros.simplify in H1.
301 cut (a2 \neq b2 \lor c2 \neq d2).
302 elim Hcut [left.right.assumption|right.right.assumption]
304 letin H0 \def (csg_op M1).
306 unfold CSetoid_bin_op in H0.
307 letin H1 \def (csbf_strext M1 M1 M1 H0).
308 unfold csbf_strext in H1.
309 unfold bin_fun_strext in H1.
312 letin H0 \def (csg_op M2).
314 unfold CSetoid_bin_op in H0.
315 letin H2 \def (csbf_strext M2 M2 M2 H0).
316 unfold csbf_strext in H2.
317 unfold bin_fun_strext in H2.
322 definition dprod_as_csb_fun: \forall M1,M2:CSemiGroup.
323 CSetoid_bin_fun (ProdCSetoid M1 M2) (ProdCSetoid M1 M2)(ProdCSetoid M1 M2)\def
324 \lambda M1,M2:CSemiGroup.
325 mk_CSetoid_bin_fun (ProdCSetoid M1 M2)(ProdCSetoid M1 M2)
326 (ProdCSetoid M1 M2) (dprod M1 M2) (dprod_strext M1 M2).
328 lemma direct_product_is_CSemiGroup: \forall M1,M2:CSemiGroup.
329 (is_CSemiGroup (ProdCSetoid M1 M2) (dprod_as_csb_fun M1 M2)).
331 unfold is_CSemiGroup.
332 unfold CSassociative.
340 split[unfold dprod_as_csb_fun. simplify.apply CSemiGroup_is_CSemiGroup|
341 unfold dprod_as_csb_fun. simplify.apply CSemiGroup_is_CSemiGroup].
344 definition direct_product_as_CSemiGroup : \forall M1,M2:CSemiGroup. ? \def
345 \lambda M1,M2: CSemiGroup.
346 mk_CSemiGroup (ProdCSetoid M1 M2) (dprod_as_csb_fun M1 M2)
347 (direct_product_is_CSemiGroup M1 M2).
351 (* The SemiGroup of Setoid functions *)
353 lemma FS_is_CSemiGroup:\forall X:CSetoid.
354 is_CSemiGroup (FS_as_CSetoid X X) (comp_as_bin_op X ).
356 unfold is_CSemiGroup.
360 definition FS_as_CSemiGroup : \forall A : CSetoid. ? \def \lambda A:CSetoid.
361 mk_CSemiGroup (FS_as_CSetoid A A) (comp_as_bin_op A) (assoc_comp A).
363 (* Section p66E2b4. *)
365 (* The Free SemiGroup
366 %\begin{convention}% Let [A:CSetoid].
370 (* Variable A:CSetoid. *)
372 lemma Astar_is_CSemiGroup: \forall A:CSetoid.
373 (is_CSemiGroup (free_csetoid_as_csetoid A) (app_as_csb_fun A)).
375 unfold is_CSemiGroup.
376 unfold CSassociative.
378 unfold app_as_csb_fun.
385 apply eq_reflexive_unfolded.
386 simplify. left. apply eq_reflexive_unfolded.assumption.
389 intros.unfold appA in H.
390 generalize in match (H y z).intros.unfold appA in H1.left.
391 apply eq_reflexive_unfolded.
395 definition Astar_as_CSemiGroup: \forall A:CSetoid. ? \def
397 mk_CSemiGroup (free_csetoid_as_csetoid A) (app_as_csb_fun A)
398 (Astar_is_CSemiGroup A).