]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/nlibrary/algebra/magmas.ma
Composite coercions are here!
[helm.git] / helm / software / matita / nlibrary / algebra / magmas.ma
index e83c62227f51759973934ee48f30aa70d6974529..f7757ba096a0d76ad62d625bd720567821b4a8dd 100644 (file)
 
 include "sets/sets.ma".
 
-nrecord magma (A: Type) : Type[1] ≝
- { carr: Ω \sup A;
-   op: A → A → A(*;
-   op_closed: ∀x,y. x ∈ carr → y ∈ carr → op x y ∈ carr*)
- }.
\ No newline at end of file
+nrecord pre_magma : Type[1] ≝
+ { carr: Type;
+   op: carr → carr → carr
+ }.
+(* this is a projection *)
+ndefinition carr: pre_magma → Type
+ ≝ λM: pre_magma. match M with [ mk_pre_magma carr _ ⇒ carr ].
+ncoercion carr: ∀M:pre_magma. Type ≝ carr on _M: pre_magma to Type.
+ndefinition op ≝
+ λM: pre_magma. match M return λM:pre_magma. M → M → M with [ mk_pre_magma _ op ⇒ op ].
+
+nrecord magma (A: pre_magma) : Type[1] ≝
+ { mcarr: Ω \sup 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 ].
+ncoercion mcarr: ∀A.∀M: magma A. Ω \sup A ≝ mcarr
+ on _M: magma ? to Ω \sup ?.
+ndefinition op_closed ≝
+ λA.λM: magma A.
+  match M return λM: magma A.∀x,y. x ∈ M → y ∈ M → op ? x y ∈ M with
+   [ mk_magma _ opc ⇒ opc ].
+
+nrecord pre_magma_morphism (A,B: pre_magma) : Type ≝
+ { mmcarr: A → B;
+   mmprop: ∀x,y. mmcarr (op ? x y) = op ? (mmcarr x) (mmcarr y)
+ }.
+(* this is a projection *)
+ndefinition mmcarr ≝
+ λA,B.λf: pre_magma_morphism A B. match f with [ mk_pre_magma_morphism f _ ⇒ f ].
+ncoercion mmcarr: ∀A,B.∀M: pre_magma_morphism A B. A → B ≝ mmcarr
+ on _M: pre_magma_morphism ? ? to ∀_.?.
+
+nrecord magma_morphism (A) (B) (Ma: magma A) (Mb: magma B) : Type ≝
+ { mmmcarr: pre_magma_morphism A B;
+   mmclosed: ∀x. x ∈ Ma → mmmcarr x ∈ 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 ].
+ncoercion mmmcarr : ∀A,B,Ma,Mb.∀f: magma_morphism A B Ma Mb. pre_magma_morphism A B
+ ≝ mmmcarr
+ on _f: magma_morphism ???? to pre_magma_morphism ??.
+ndefinition mmclosed ≝
+ λA,B,Ma,Mb.λf: magma_morphism A B Ma Mb.
+  match f return λf: magma_morphism A B Ma Mb.∀x. x ∈ Ma → f x ∈ Mb with
+   [ mk_magma_morphism _ p ⇒ p ].
+ndefinition sub_magma ≝
+ λA.λM1,M2: magma A. M1 ⊆ M2.
+ndefinition image: ∀A,B. (A → B) → Ω \sup A → Ω \sup B ≝
+ λA,B,f,Sa. {y | ∃x. x ∈ Sa ∧ f x = y}.
+
+naxiom daemon: False.
+
+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 ?? (mmmcarr ???? f)) (mcarr ? Ma)) 
+  | #x; #y; nwhd in ⊢ (% → % → ?); *; #x0; *; #Hx0; #Hx1; *; #y0; *; #Hy0; #Hy1; nwhd;
+    napply (ex_intro ????)
+     [ napply (op ? x0 y0) 
+     | napply (conj ????)
+        [ napply (op_closed ??????); nassumption
+        | nelim daemon ]##]
+nqed.
\ No newline at end of file