]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/contribs/formal_topology/overlap/categories.ma
more composites to make all happy!
[helm.git] / helm / software / matita / contribs / formal_topology / overlap / categories.ma
index 655c5076034328872447c628855bf65b1479dba9..d83fd031914b681514986efb963be58c9e708373 100644 (file)
 (*                                                                        *)
 (**************************************************************************)
 
-include "logic/cprop_connectives.ma".
-
-definition Type0 := Type.
-definition Type1 := Type.
-definition Type2 := Type.
-definition Type3 := Type.
-definition Type0_lt_Type1 := (Type0 : Type1).
-definition Type1_lt_Type2 := (Type1 : Type2).
-definition Type2_lt_Type3 := (Type2 : Type3).
-
-definition Type_OF_Type0: Type0 → Type := λx.x.
-definition Type_OF_Type1: Type1 → Type := λx.x.
-definition Type_OF_Type2: Type2 → Type := λx.x.
-definition Type_OF_Type3: Type3 → Type := λx.x.
-coercion Type_OF_Type0.
-coercion Type_OF_Type1.
-coercion Type_OF_Type2.
-coercion Type_OF_Type3.
-
-definition CProp0 := CProp.
-definition CProp1 := CProp.
-definition CProp2 := CProp.
-definition CProp0_lt_CProp1 := (CProp0 : CProp1).
-definition CProp1_lt_CProp2 := (CProp1 : CProp2).
-
-definition CProp_OF_CProp0: CProp0 → CProp := λx.x.
-definition CProp_OF_CProp1: CProp1 → CProp := λx.x.
-definition CProp_OF_CProp2: CProp2 → CProp := λx.x.
+include "cprop_connectives.ma".
 
 record equivalence_relation (A:Type0) : Type1 ≝
  { eq_rel:2> A → A → CProp0;
@@ -53,11 +26,11 @@ record setoid : Type1 ≝
    eq: equivalence_relation carr
  }.
 
-definition reflexive1 ≝ λA:Type1.λR:A→A→CProp1.∀x:A.R x x.
-definition symmetric1 ≝ λC:Type1.λlt:C→C→CProp1. ∀x,y:C.lt x y → lt y x.
-definition transitive1 ≝ λA:Type1.λR:A→A→CProp1.∀x,y,z:A.R x y → R y z → R x z.
+definition reflexive1: ∀A:Type1.∀R:A→A→CProp1.CProp1 ≝ λA:Type1.λR:A→A→CProp1.∀x:A.R x x.
+definition symmetric1: ∀A:Type1.∀R:A→A→CProp1.CProp1 ≝ λC:Type1.λlt:C→C→CProp1. ∀x,y:C.lt x y → lt y x.
+definition transitive1: ∀A:Type1.∀R:A→A→CProp1.CProp1 ≝ λA:Type1.λR:A→A→CProp1.∀x,y,z:A.R x y → R y z → R x z.
 
-record equivalence_relation1 (A:Type1) : Type1 ≝
+record equivalence_relation1 (A:Type1) : Type2 ≝
  { eq_rel1:2> A → A → CProp1;
    refl1: reflexive1 ? eq_rel1;
    sym1: symmetric1 ? eq_rel1;
@@ -81,14 +54,13 @@ definition setoid1_of_setoid: setoid → setoid1.
     | apply (trans s)]]
 qed.
 
-(* questa coercion e' necessaria per problemi di unificazione *)
 coercion setoid1_of_setoid.
 
-definition reflexive2 ≝ λA:Type2.λR:A→A→CProp2.∀x:A.R x x.
-definition symmetric2 ≝ λC:Type2.λlt:C→C→CProp2. ∀x,y:C.lt x y → lt y x.
-definition transitive2 ≝ λA:Type2.λR:A→A→CProp2.∀x,y,z:A.R x y → R y z → R x z.
+definition reflexive2: ∀A:Type2.∀R:A→A→CProp2.CProp2 ≝ λA:Type2.λR:A→A→CProp2.∀x:A.R x x.
+definition symmetric2: ∀A:Type2.∀R:A→A→CProp2.CProp2 ≝ λC:Type2.λlt:C→C→CProp2. ∀x,y:C.lt x y → lt y x.
+definition transitive2: ∀A:Type2.∀R:A→A→CProp2.CProp2 ≝ λA:Type2.λR:A→A→CProp2.∀x,y,z:A.R x y → R y z → R x z.
 
-record equivalence_relation2 (A:Type2) : Type2 ≝
+record equivalence_relation2 (A:Type2) : Type3 ≝
  { eq_rel2:2> A → A → CProp2;
    refl2: reflexive2 ? eq_rel2;
    sym2: symmetric2 ? eq_rel2;
@@ -114,24 +86,6 @@ qed.
 
 coercion setoid2_of_setoid1.
 
-(*
-definition Leibniz: Type → setoid.
- intro;
- constructor 1;
-  [ apply T
-  | constructor 1;
-     [ apply (λx,y:T.cic:/matita/logic/equality/eq.ind#xpointer(1/1) ? x y)
-     | alias id "refl_eq" = "cic:/matita/logic/equality/eq.ind#xpointer(1/1/1)".
-       apply refl_eq
-     | alias id "sym_eq" = "cic:/matita/logic/equality/sym_eq.con".
-       apply sym_eq
-     | alias id "trans_eq" = "cic:/matita/logic/equality/trans_eq.con".
-       apply trans_eq ]]
-qed.
-
-coercion Leibniz.
-*)
-
 interpretation "setoid2 eq" 'eq x y = (eq_rel2 _ (eq2 _) x y).
 interpretation "setoid1 eq" 'eq x y = (eq_rel1 _ (eq1 _) x y).
 interpretation "setoid eq" 'eq x y = (eq_rel _ (eq _) x y).
@@ -181,6 +135,7 @@ interpretation "prop11" 'prop1 c = (prop11 _____ c).
 interpretation "prop12" 'prop1 c = (prop12 _____ c).
 interpretation "prop2" 'prop2 l r = (prop2 ________ l r).
 interpretation "prop21" 'prop2 l r = (prop21 ________ l r).
+interpretation "prop22" 'prop2 l r = (prop22 ________ l r).
 interpretation "refl" 'refl = (refl ___).
 interpretation "refl1" 'refl = (refl1 ___).
 interpretation "refl2" 'refl = (refl2 ___).
@@ -191,26 +146,26 @@ definition CPROP: setoid1.
   | constructor 1;
      [ apply Iff
      | intros 1; split; intro; assumption
-     | intros 3; cases H; split; assumption
-     | intros 5; cases H; cases H1; split; intro;
-        [ apply (H4 (H2 x1)) | apply (H3 (H5 z1))]]]
+     | intros 3; cases i; split; assumption
+     | intros 5; cases i; cases i1; split; intro;
+        [ apply (f2 (f x1)) | apply (f1 (f3 z1))]]]
 qed.
 
 alias symbol "eq" = "setoid1 eq".
-definition if': ∀A,B:CPROP. A = B → A → B.
- intros; apply (if ?? e); assumption.
+definition fi': ∀A,B:CPROP. A = B → B → A.
+ intros; apply (fi ?? e); assumption.
 qed.
 
-notation ". r" with precedence 50 for @{'if $r}.
-interpretation "if" 'if r = (if' __ r).
+notation ". r" with precedence 50 for @{'fi $r}.
+interpretation "fi" 'fi r = (fi' __ r).
 
 definition and_morphism: binary_morphism1 CPROP CPROP CPROP.
  constructor 1;
   [ apply And
-  | intros; split; intro; cases H; split;
-     [ apply (if ?? e a1)
+  | intros; split; intro; cases a1; split;
+     [ apply (if ?? e a2)
      | apply (if ?? e1 b1)
-     | apply (fi ?? e a1)
+     | apply (fi ?? e a2)
      | apply (fi ?? e1 b1)]]
 qed.
 
@@ -219,7 +174,7 @@ interpretation "and_morphism" 'and a b = (fun21 ___ and_morphism a b).
 definition or_morphism: binary_morphism1 CPROP CPROP CPROP.
  constructor 1;
   [ apply Or
-  | intros; split; intro; cases H; [1,3:left |2,4: right]
+  | intros; split; intro; cases o; [1,3:left |2,4: right]
      [ apply (if ?? e a1)
      | apply (fi ?? e a1)
      | apply (if ?? e1 b1)
@@ -232,24 +187,9 @@ definition if_morphism: binary_morphism1 CPROP CPROP CPROP.
  constructor 1;
   [ apply (λA,B. A → B)
   | intros; split; intros;
-     [ apply (if ?? e1); apply H; apply (fi ?? e); assumption
-     | apply (fi ?? e1); apply H; apply (if ?? e); assumption]]
-qed.
-
-(*
-definition eq_morphism: ∀S:setoid. binary_morphism S S CPROP.
- intro;
- constructor 1;
-  [ apply (eq_rel ? (eq S))
-  | intros; split; intro;
-     [ apply (.= H \sup -1);
-       apply (.= H2);
-       assumption
-     | apply (.= H);
-       apply (.= H2);
-       apply (H1 \sup -1)]]
+     [ apply (if ?? e1); apply f; apply (fi ?? e); assumption
+     | apply (fi ?? e1); apply f; apply (if ?? e); assumption]]
 qed.
-*)
 
 record category : Type1 ≝
  { objs:> Type0;
@@ -285,18 +225,14 @@ record category2 : Type3 ≝
  }.
 
 notation "'ASSOC'" with precedence 90 for @{'assoc}.
-notation "'ASSOC1'" with precedence 90 for @{'assoc1}.
-notation "'ASSOC2'" with precedence 90 for @{'assoc2}.
 
-interpretation "category1 composition" 'compose x y = (fun22 ___ (comp2 ____) y x).
-interpretation "category1 assoc" 'assoc1 = (comp_assoc2 ________).
+interpretation "category2 composition" 'compose x y = (fun22 ___ (comp2 ____) y x).
+interpretation "category2 assoc" 'assoc = (comp_assoc2 ________).
 interpretation "category1 composition" 'compose x y = (fun21 ___ (comp1 ____) y x).
-interpretation "category1 assoc" 'assoc1 = (comp_assoc1 ________).
+interpretation "category1 assoc" 'assoc = (comp_assoc1 ________).
 interpretation "category composition" 'compose x y = (fun2 ___ (comp ____) y x).
 interpretation "category assoc" 'assoc = (comp_assoc ________).
 
-(* bug grande come una casa?
-   Ma come fa a passare la quantificazione larga??? *)
 definition unary_morphism_setoid: setoid → setoid → setoid.
  intros;
  constructor 1;
@@ -304,8 +240,8 @@ definition unary_morphism_setoid: setoid → setoid → setoid.
   | constructor 1;
      [ intros (f g); apply (∀a:s. eq ? (f a) (g a));
      | intros 1; simplify; intros; apply refl;
-     | simplify; intros; apply sym; apply H;
-     | simplify; intros; apply trans; [2: apply H; | skip | apply H1]]]
+     | simplify; intros; apply sym; apply f;
+     | simplify; intros; apply trans; [2: apply f; | skip | apply f1]]]
 qed.
 
 definition SET: category1.
@@ -328,25 +264,10 @@ definition setoid_of_SET: objs1 SET → setoid.
  intros; apply o; qed.
 coercion setoid_of_SET.
 
-definition setoid1_of_SET: SET → setoid1.
- intro; whd in t; apply setoid1_of_setoid; apply t.
-qed.
-coercion setoid1_of_SET.
-
-definition eq': ∀w:SET.equivalence_relation ? := λw.eq w.
-
-definition prop1_SET : 
- ∀A,B:SET.∀w:arrows1 SET A B.∀a,b:Type_OF_objs1 A.eq' ? a b→eq' ? (w a) (w b).
-intros; apply (prop1 A B w a b e);
-qed.
-
-
-interpretation "SET dagger" 'prop1 h = (prop1_SET _ _ _ _ _ h).
 notation "hbox(a break ⇒ b)" right associative with precedence 20 for @{ 'Imply $a $b }.
 interpretation "unary morphism" 'Imply a b = (arrows1 SET a b).
-interpretation "SET eq" 'eq x y = (eq_rel _ (eq' _) x y).
 
-definition unary_morphism1_setoid1: setoid1 → setoid1 → setoid2.
+definition unary_morphism1_setoid1: setoid1 → setoid1 → setoid1.
  intros;
  constructor 1;
   [ apply (unary_morphism1 s s1);
@@ -355,8 +276,8 @@ definition unary_morphism1_setoid1: setoid1 → setoid1 → setoid2.
        alias symbol "eq" = "setoid1 eq".
        apply (∀a: carr1 s. f a = g a);
      | intros 1; simplify; intros; apply refl1;
-     | simplify; intros; apply sym1; apply H;
-     | simplify; intros; apply trans1; [2: apply H; | skip | apply H1]]]
+     | simplify; intros; apply sym1; apply f;
+     | simplify; intros; apply trans1; [2: apply f; | skip | apply f1]]]
 qed.
 
 definition SET1: category2.
@@ -379,20 +300,29 @@ definition setoid1_OF_SET1: objs2 SET1 → setoid1.
  intros; apply o; qed.
 
 coercion setoid1_OF_SET1.
+definition setoid2_OF_category2: Type_OF_category2 SET1 → setoid2.
+ intro; apply (setoid2_of_setoid1 t); qed.
+coercion setoid2_OF_category2.
 
-definition eq'': ∀w:SET1.equivalence_relation1 ? := λw.eq1 w.
+definition objs2_OF_category1: Type_OF_category1 SET → objs2 SET1.
+ intro; apply (setoid1_of_setoid t); qed.
+coercion objs2_OF_category1.
 
-definition prop11_SET1 : 
- ∀A,B:SET1.∀w:arrows2 SET1 A B.∀a,b:Type_OF_objs2 A.eq'' ? a b→eq'' ? (w a) (w b).
-intros; apply (prop11 A B w a b e);
+definition Type1_OF_SET1: Type_OF_category2 SET1 → Type1.
+ intro; whd in t; apply (carr1 t);
 qed.
+coercion Type1_OF_SET1.
 
-definition hint: Type_OF_category2 SET1 → Type1.
- intro; whd in t; apply (carr1 t);
+definition Type_OF_setoid1_of_carr: ∀U. carr U → Type_OF_setoid1 ?(*(setoid1_of_SET U)*).
+ [ apply rule U; 
+ | intros; apply c;]
 qed.
-coercion hint.
+coercion Type_OF_setoid1_of_carr.
 
-interpretation "SET dagger" 'prop1 h = (prop11_SET1 _ _ _ _ _ h).
-notation "hbox(a break ⇒ b)" right associative with precedence 20 for @{ 'Imply $a $b }.
 interpretation "unary morphism1" 'Imply a b = (arrows2 SET1 a b).
-interpretation "SET1 eq" 'eq x y = (eq_rel1 _ (eq'' _) x y).
+
+lemma unary_morphism1_of_arrows1_SET1: ∀S,T. (S ⇒ T) → unary_morphism1 S T.
+ intros; apply t;
+qed.
+coercion unary_morphism1_of_arrows1_SET1.