1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "sets/sets.ma".
17 nrecord pre_magma : Type[1] ≝
19 op: carr → carr → carr
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.
26 λM: pre_magma. match M return λM:pre_magma. M → M → M with [ mk_pre_magma _ op ⇒ op ].
28 nrecord magma (A: pre_magma) : Type[1] ≝
30 op_closed: ∀x,y. x ∈ mcarr → y ∈ mcarr → op A x y ∈ mcarr
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 ≝
38 match M return λM: magma A.∀x,y. x ∈ M → y ∈ M → op ? x y ∈ M with
39 [ mk_magma _ opc ⇒ opc ].
41 nrecord pre_magma_morphism (A,B: pre_magma) : Type ≝
43 mmprop: ∀x,y. mmcarr (op ? x y) = op ? (mmcarr x) (mmcarr y)
45 (* this is a projection *)
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 ∀_.?.
52 match M return λM:pre_magma_morphism A B.∀x,y. M (op ? x y) = op ? (M x) (M y) with
53 [ mk_pre_magma_morphism _ p ⇒ p ].
55 nrecord magma_morphism (A) (B) (Ma: magma A) (Mb: magma B) : Type ≝
56 { mmmcarr: pre_magma_morphism A B;
57 mmclosed: ∀x. x ∈ Ma → mmmcarr x ∈ Mb
59 (* this is a projection *)
61 λA,B,Ma,Mb.λf: magma_morphism A B Ma Mb. match f with [ mk_magma_morphism f _ ⇒ f ].
62 ncoercion mmmcarr : ∀A,B,Ma,Mb.∀f: magma_morphism A B Ma Mb. pre_magma_morphism A B
64 on _f: magma_morphism ???? to pre_magma_morphism ??.
65 ndefinition mmclosed ≝
66 λA,B,Ma,Mb.λf: magma_morphism A B Ma Mb.
67 match f return λf: magma_morphism A B Ma Mb.∀x. x ∈ Ma → f x ∈ Mb with
68 [ mk_magma_morphism _ p ⇒ p ].
70 ndefinition sub_magma ≝
71 λA.λM1,M2: magma A. M1 ⊆ M2.
73 ndefinition image: ∀A,B. (A → B) → Ω \sup A → Ω \sup B ≝
74 λA,B,f,Sa. {y | ∃x. x ∈ Sa ∧ f x = y}.
79 ∀A,B. ∀Ma: magma A. ∀Mb: magma B. magma_morphism ?? Ma Mb → magma B.
82 [ napply (image ?? (mmcarr ?? (mmmcarr ???? f)) Ma) (* NO COMPOSITE! *)
83 | #x; #y; nwhd in ⊢ (% → % → ?); *; #x0; *; #Hx0; #Hx1; *; #y0; *; #Hy0; #Hy1; nwhd;
84 napply (ex_intro ????)
87 [ napply (op_closed ??????); nassumption
88 | (* nrewrite < Hx1; DOES NOT WORK *)
89 napply (eq_rect ?? (λ_.?) ?? Hx1);
90 napply (eq_rect ?? (λ_.?) ?? Hy1);
91 napply (mmprop ?? f ??)]##]