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