]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/nlibrary/algebra/magmas.ma
7283cbc58f95d733587a3b15cfe9b5b01a8de5e6
[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 (* this is a projection *)
22 ndefinition carr: pre_magma → Type
23  ≝ λM: pre_magma. match M with [ mk_pre_magma carr _ ⇒ carr ].
24 ncoercion carr: ∀M:pre_magma. Type ≝ carr on _M: pre_magma to Type.
25 ndefinition op ≝
26  λM: pre_magma. match M return λM:pre_magma. M → M → M with [ mk_pre_magma _ op ⇒ op ].
27
28 nrecord magma (A: pre_magma) : Type[1] ≝
29  { mcarr: Ω \sup A;
30    op_closed: ∀x,y. x ∈ mcarr → y ∈ mcarr → op A x y ∈ mcarr
31  }.
32 (* this is a projection *)
33 ndefinition mcarr ≝ λA.λM: magma A. match M with [ mk_magma mcarr _ ⇒ mcarr ].
34 ncoercion mcarr: ∀A.∀M: magma A. Ω \sup A ≝ mcarr
35  on _M: magma ? to Ω \sup ?.
36 ndefinition op_closed ≝
37  λA.λM: magma A.
38   match M return λM: magma A.∀x,y. x ∈ M → y ∈ M → op ? x y ∈ M with
39    [ mk_magma _ opc ⇒ opc ].
40
41 nrecord pre_magma_morphism (A,B: pre_magma) : Type ≝
42  { mmcarr: A → B;
43    mmprop: ∀x,y. mmcarr (op ? x y) = op ? (mmcarr x) (mmcarr y)
44  }.
45 (* this is a projection *)
46 ndefinition mmcarr ≝
47  λA,B.λf: pre_magma_morphism A B. match f with [ mk_pre_magma_morphism f _ ⇒ f ].
48 ncoercion mmcarr: ∀A,B.∀M: pre_magma_morphism A B. A → B ≝ mmcarr
49  on _M: pre_magma_morphism ? ? to ∀_.?.
50
51 nrecord magma_morphism (A) (B) (Ma: magma A) (Mb: magma B) : Type ≝
52  { mmmcarr: pre_magma_morphism A B;
53    mmclosed: ∀x. x ∈ Ma → mmmcarr x ∈ Mb
54  }.
55 (* this is a projection *)
56 ndefinition mmmcarr ≝
57  λA,B,Ma,Mb.λf: magma_morphism A B Ma Mb. match f with [ mk_magma_morphism f _ ⇒ f ].
58 ncoercion mmmcarr : ∀A,B,Ma,Mb.∀f: magma_morphism A B Ma Mb. pre_magma_morphism A B
59  ≝ mmmcarr
60  on _f: magma_morphism ???? to pre_magma_morphism ??.
61 ndefinition mmclosed ≝
62  λA,B,Ma,Mb.λf: magma_morphism A B Ma Mb.
63   match f return λf: magma_morphism A B Ma Mb.∀x. x ∈ Ma → f x ∈ Mb with
64    [ mk_magma_morphism _ p ⇒ p ].
65  
66 ndefinition sub_magma ≝
67  λA.λM1,M2: magma A. M1 ⊆ M2.
68  
69 ndefinition image: ∀A,B. (A → B) → Ω \sup A → Ω \sup B ≝
70  λA,B,f,Sa. {y | ∃x. x ∈ Sa ∧ f x = y}.
71
72 naxiom daemon: False.
73
74 ndefinition mm_image:
75  ∀A,B. ∀Ma: magma A. ∀Mb: magma B. magma_morphism ?? Ma Mb → magma B.
76  #A; #B; #Ma; #Mb; #f;
77  napply (mk_magma ???)
78   [ napply (image ?? (mmcarr ?? (mmmcarr ???? f)) Ma) (* NO COMPOSITE! *)
79   | #x; #y; nwhd in ⊢ (% → % → ?); *; #x0; *; #Hx0; #Hx1; *; #y0; *; #Hy0; #Hy1; nwhd;
80     napply (ex_intro ????)
81      [ napply (op ? x0 y0) 
82      | napply (conj ????)
83         [ napply (op_closed ??????); nassumption
84         | nelim daemon ]##]
85 nqed.