]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/nlibrary/algebra/magmas.ma
f3d3fe3528a3c48bc1797b64913cc855f85a6456
[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:> powerset_setoid1 A;
24    op_closed: ∀x,y. x ∈ mcarr → y ∈ mcarr → op A x y ∈ mcarr
25  }.
26 (* le coercion non vanno; sospetto setoid1_of_setoid *)
27 nrecord magma_morphism_type (A,B: magma_type) : Type[0] ≝
28  { mmcarr:> unary_morphism A B;
29    mmprop: ∀x,y:carr A. mmcarr (op ? x y) = op … (mmcarr x) (mmcarr y)
30  }.
31 (* le coercion non vanno *)
32 nrecord magma_morphism (A) (B) (Ma: magma A) (Mb: magma B) : Type[0] ≝
33  { mmmcarr:> magma_morphism_type A B;
34    mmclosed: ∀x:carr A. x ∈ mcarr ? Ma → mmmcarr x ∈ mcarr ? Mb
35  }.
36 (*
37 (* qui non funziona una cippa *)
38 ndefinition image: ∀A,B. (carr A → carr B) → Ω \sup A → Ω \sup B ≝
39  λA,B:setoid.λf:carr A → carr B.λSa:Ω \sup A.
40   {y | ∃x. x ∈ Sa ∧ eq_rel (carr B) (eq B) ? ?(*(f x) y*)}.
41   ##[##2: napply (f x); ##|##3: napply y]
42  #a; #a'; #H; nwhd; nnormalize; (* per togliere setoid1_of_setoid *) napply (mk_iff ????);
43  *; #x; #Hx; napply (ex_intro … x)
44   [ napply (. (#‡(#‡#))); 
45
46 ndefinition mm_image:
47  ∀A,B. ∀Ma: magma A. ∀Mb: magma B. magma_morphism … Ma Mb → magma B.
48  #A; #B; #Ma; #Mb; #f;
49  napply mk_magma
50   [ napply (image … f Ma)
51   | #x; #y; nwhd in ⊢ (% → % → ?); *; #x0; *; #Hx0; #Hx1; *; #y0; *; #Hy0; #Hy1; nwhd;
52     napply ex_intro
53      [ napply (op … x0 y0) 
54      | napply conj
55         [ napply op_closed; nassumption
56         | nrewrite < Hx1;
57           nrewrite < Hy1;
58           napply (mmprop … f)]##]
59 nqed.
60
61 ndefinition counter_image: ∀A,B. (A → B) → Ω \sup B → Ω \sup A ≝
62  λA,B,f,Sb. {x | ∃y. y ∈ Sb ∧ f x = y}.
63  
64 ndefinition mm_counter_image:
65  ∀A,B. ∀Ma: magma A. ∀Mb: magma B. magma_morphism … Ma Mb → magma A.
66   #A; #B; #Ma; #Mb; #f;
67   napply mk_magma
68    [ napply (counter_image … f Mb)
69    | #x; #y; nwhd in ⊢ (% → % → ?); *; #x0; *; #Hx0; #Hx1; *; #y0; *; #Hy0; #Hy1; nwhd;
70      napply ex_intro
71       [ napply (op … x0 y0)
72       | napply conj
73          [ napply op_closed; nassumption
74          | nrewrite < Hx1;
75            nrewrite < Hy1;
76            napply (mmprop … f)]##]
77 nqed.
78
79 ndefinition m_intersect: ∀A. magma A → magma A → magma A.
80  #A; #M1; #M2;
81  napply (mk_magma …)
82   [ napply (M1 ∩ M2)
83   | #x; #y; nwhd in ⊢ (% → % → %); *; #Hx1; #Hx2; *; #Hy1; #Hy2;
84     napply conj; napply op_closed; nassumption ]
85 nqed.
86 *)