]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/nlibrary/algebra/magmas.ma
\ldots used here and there. Cool!
[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  { carr:> Type;
19    op: carr → carr → carr
20  }.
21
22 nrecord magma (A: magma_type) : Type[1] ≝
23  { mcarr:> Ω \sup A;
24    op_closed: ∀x,y. x ∈ mcarr → y ∈ mcarr → op A x y ∈ mcarr
25  }.
26
27 nrecord magma_morphism_type (A,B: magma_type) : Type ≝
28  { mmcarr:1> A → B;
29    mmprop: ∀x,y. mmcarr (op ? x y) = op ? (mmcarr x) (mmcarr y)
30  }.
31
32 nrecord magma_morphism (A) (B) (Ma: magma A) (Mb: magma B) : Type ≝
33  { mmmcarr:> magma_morphism_type A B;
34    mmclosed: ∀x. x ∈ Ma → mmmcarr x ∈ Mb
35  }.
36  
37 ndefinition image: ∀A,B. (A → B) → Ω \sup A → Ω \sup B ≝
38  λA,B,f,Sa. {y | ∃x. x ∈ Sa ∧ f x = y}.
39
40 ndefinition mm_image:
41  ∀A,B. ∀Ma: magma A. ∀Mb: magma B. magma_morphism ?? Ma Mb → magma B.
42  #A; #B; #Ma; #Mb; #f;
43  napply (mk_magma …)
44   [ napply (image … f Ma)
45   | #x; #y; nwhd in ⊢ (% → % → ?); *; #x0; *; #Hx0; #Hx1; *; #y0; *; #Hy0; #Hy1; nwhd;
46     napply (ex_intro …)
47      [ napply (op … x0 y0) 
48      | napply (conj …)
49         [ napply (op_closed …); nassumption
50         | nrewrite < Hx1;
51           nrewrite < Hy1;
52           napply (mmprop … f …)]##]
53 nqed.
54
55 ndefinition counter_image: ∀A,B. (A → B) → Ω \sup B → Ω \sup A ≝
56  λA,B,f,Sb. {x | ∃y. y ∈ Sb ∧ f x = y}.
57  
58 ndefinition mm_counter_image:
59  ∀A,B. ∀Ma: magma A. ∀Mb: magma B. magma_morphism ?? Ma Mb → magma A.
60   #A; #B; #Ma; #Mb; #f;
61   napply (mk_magma …)
62    [ napply (counter_image … f Mb)
63    | #x; #y; nwhd in ⊢ (% → % → ?); *; #x0; *; #Hx0; #Hx1; *; #y0; *; #Hy0; #Hy1; nwhd;
64      napply (ex_intro …)
65       [ napply (op … x0 y0)
66       | napply (conj …)
67          [ napply (op_closed …); nassumption
68          | nrewrite < Hx1;
69            nrewrite < Hy1;
70            napply (mmprop … f …)]##]
71 nqed.
72
73 ndefinition m_intersect: ∀A. magma A → magma A → magma A.
74  #A; #M1; #M2;
75  napply (mk_magma …)
76   [ napply (M1 ∩ M2)
77   | #x; #y; nwhd in ⊢ (% → % → %); *; #Hx1; #Hx2; *; #Hy1; #Hy2;
78     napply (conj …); napply (op_closed …); nassumption ]
79 nqed.