]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/nlibrary/algebra/magmas.ma
24203f2098422059a1fc6ec95396267cb5b0b91b
[helm.git] / helm / software / matita / nlibrary / algebra / magmas.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "sets/sets.ma".
16
17 nrecord magma_type : Type[1] ≝
18  { mtcarr:> setoid;
19    op: binary_morphism mtcarr mtcarr mtcarr
20  }.
21
22 nrecord magma (A: magma_type) : Type[1] ≝
23  { mcarr:> qpowerclass A;
24    op_closed: ∀x,y. x ∈ mcarr → y ∈ mcarr → op A x y ∈ mcarr
25  }.
26
27 ncoercion mcarr' : ∀A. ∀M: magma A. carr1 (qpowerclass_setoid (mtcarr A))
28  ≝ λA.λM: magma A.mcarr ? M
29  on _M: magma ? to carr1 (qpowerclass_setoid (mtcarr ?)).
30
31 nrecord magma_morphism_type (A,B: magma_type) : Type[0] ≝
32  { mmcarr:> unary_morphism A B;
33    mmprop: ∀x,y:A. mmcarr (op ? x y) = op … (mmcarr x) (mmcarr y)
34  }.
35
36 nrecord magma_morphism (A) (B) (Ma: magma A) (Mb: magma B) : Type[0] ≝
37  { mmmcarr:> magma_morphism_type A B;
38    mmclosed: ∀x:A. x ∈ mcarr ? Ma → mmmcarr x ∈ mcarr ? Mb
39  }.
40
41 (*
42 ndefinition mm_image:
43  ∀A,B. ∀Ma: magma A. ∀Mb: magma B. magma_morphism … Ma Mb → magma B.
44  #A; #B; #Ma; #Mb; #f;
45  napply mk_magma
46   [ napply (image … f Ma)
47   | #x; #y; nwhd in ⊢ (% → % → ?); *; #x0; *; #Hx0; #Hx1; *; #y0; *; #Hy0; #Hy1; nwhd;
48     napply ex_intro
49      [ napply (op … x0 y0) 
50      | napply conj
51         [ napply op_closed; nassumption
52         | nrewrite < Hx1;
53           nrewrite < Hy1;
54           napply (mmprop … f)]##]
55 nqed.
56
57 ndefinition mm_counter_image:
58  ∀A,B. ∀Ma: magma A. ∀Mb: magma B. magma_morphism … Ma Mb → magma A.
59   #A; #B; #Ma; #Mb; #f;
60   napply mk_magma
61    [ napply (counter_image … f Mb)
62    | #x; #y; nwhd in ⊢ (% → % → ?); *; #x0; *; #Hx0; #Hx1; *; #y0; *; #Hy0; #Hy1; nwhd;
63      napply ex_intro
64       [ napply (op … x0 y0)
65       | napply conj
66          [ napply op_closed; nassumption
67          | nrewrite < Hx1;
68            nrewrite < Hy1;
69            napply (mmprop … f)]##]
70 nqed.
71 *)
72
73 ndefinition m_intersect: ∀A. magma A → magma A → magma A.
74  #A; #M1; #M2;
75  napply (mk_magma …)
76   [ napply (intersect_ok ? M1 M2)
77   | #x; #y; nwhd in ⊢ (% → % → %); *; #Hx1; #Hx2; *; #Hy1; #Hy2;
78     napply conj; napply op_closed; nassumption ]
79 nqed.