include "sets/sets.ma".
-nrecord magma (A: Type) : Type[1] ≝
- { mcarr: Ω \sup A;
- op: A → A → A;
- op_closed: ∀x,y. x ∈ mcarr → y ∈ mcarr → op x y ∈ mcarr
+nrecord pre_magma : Type[1] ≝
+ { carr: Type;
+ op: carr → carr → carr
}.
(* this is a projection *)
-ndefinition mcarr ≝ λA.λM: magma A. match M with [ mk_magma mcarr _ _ ⇒ mcarr ].
-ndefinition op ≝ λA.λM: magma A. match M with [ mk_magma _ op _ ⇒ op ].
+ndefinition carr ≝ λM: pre_magma. match M with [ mk_pre_magma carr _ ⇒ carr ].
+ndefinition op ≝
+ λM: pre_magma. match M return λM. carr M → carr M → carr M with [ mk_pre_magma _ op ⇒ op ].
+(* ncoercion carr. *)
-(* to be splitted *)
-nrecord magma_morphism (A,B: Type) (Ma: magma A) (Mb: magma B) : Type ≝
- { mmcarr: A → B;
- mmclosed: ∀x. x ∈ mcarr ? Ma → mmcarr x ∈ mcarr ? Mb;
- (* need a canonical structure in next line? *)
- mmprop: ∀x,y:A. x ∈ mcarr ? Ma → y ∈ mcarr ? Ma → mmcarr (op ? Ma x y) = op B Mb (mmcarr x) (mmcarr y)
+nrecord magma (A: pre_magma) : Type[1] ≝
+ { mcarr: Ω \sup (carr A);
+ op_closed: ∀x,y. x ∈ mcarr → y ∈ mcarr → op A x y ∈ mcarr
+ }.
+(* this is a projection *)
+ndefinition mcarr ≝ λA.λM: magma A. match M with [ mk_magma mcarr _ ⇒ mcarr ].
+ndefinition op_closed ≝
+ λA.λM: magma A.
+ match M return λM.∀x,y. x ∈ mcarr ? M → y ∈ mcarr ? M → op A x y ∈ mcarr ? M with
+ [ mk_magma _ opc ⇒ opc ].
+
+nrecord pre_magma_morphism (A,B: pre_magma) : Type ≝
+ { mmcarr: carr A → carr B;
+ mmprop: ∀x,y. mmcarr (op ? x y) = op ? (mmcarr x) (mmcarr y)
}.
(* this is a projection *)
ndefinition mmcarr ≝
- λA,B,Ma,Mb.λf: magma_morphism A B Ma Mb. match f with [ mk_magma_morphism f _ _ ⇒ f ].
+ λA,B.λf: pre_magma_morphism A B. match f with [ mk_pre_magma_morphism f _ ⇒ f ].
+
+nrecord magma_morphism (A) (B) (Ma: magma A) (Mb: magma B) : Type ≝
+ { mmmcarr: pre_magma_morphism A B;
+ mmclosed: ∀x. x ∈ mcarr ? Ma → mmcarr ?? mmmcarr x ∈ mcarr ? Mb
+ }.
+(* this is a projection *)
+ndefinition mmmcarr ≝
+ λA,B,Ma,Mb.λf: magma_morphism A B Ma Mb. match f with [ mk_magma_morphism f _ ⇒ f ].
+ndefinition mmclosed ≝
+ λA,B,Ma,Mb.λf: magma_morphism A B Ma Mb.
+ match f return λf.∀x. x ∈ mcarr ? Ma → mmcarr ?? (mmmcarr ???? f) x ∈ mcarr ? Mb with
+ [ mk_magma_morphism _ p ⇒ p ].
ndefinition sub_magma ≝
λA.λM1,M2: magma A. ∀x. x ∈ mcarr ? M1 → x ∈ mcarr ? M2.
ndefinition mm_image:
∀A,B. ∀Ma: magma A. ∀Mb: magma B. magma_morphism ?? Ma Mb → magma B.
#A; #B; #Ma; #Mb; #f;
- napply (mk_magma ????)
- [ napply (image ?? (mmcarr ???? f) (mcarr ? Ma))
- | napply (op ? Mb)
+ napply (mk_magma ???)
+ [ napply (image ?? (mmcarr ?? (mmmcarr ???? f)) (mcarr ? Ma))
| #x; #y; *; #x0; #Hx0; *; #y0; #Hy0; nwhd;
napply (ex_intro ????)
- [ napply (op ? Ma x0 y0) (* BAD HERE! need a canonical structure? *)
+ [ napply (op ? x0 y0)
| nelim daemon ]]
nqed.
\ No newline at end of file