]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/library/formal_topology/basic_pairs.ma
3ee8649374e598918cfb24477a439f09089c62fd
[helm.git] / helm / software / matita / library / formal_topology / basic_pairs.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 "formal_topology/relations.ma".
16 include "datatypes/categories.ma".
17
18 record basic_pair: Type ≝
19  { concr: REL;
20    form: REL;
21    rel: arrows1 ? concr form
22  }.
23
24 notation "x ⊩ y" with precedence 45 for @{'Vdash2 $x $y}.
25 notation "⊩" with precedence 60 for @{'Vdash}.
26
27 interpretation "basic pair relation" 'Vdash2 x y = (rel _ x y).
28 interpretation "basic pair relation (non applied)" 'Vdash = (rel _).
29
30 record relation_pair (BP1,BP2: basic_pair): Type ≝
31  { concr_rel: arrows1 ? (concr BP1) (concr BP2);
32    form_rel: arrows1 ? (form BP1) (form BP2);
33    commute: concr_rel ∘ ⊩ = ⊩ ∘ form_rel
34  }.
35
36 notation "hvbox (r \sub \c)"  with precedence 90 for @{'concr_rel $r}.
37 notation "hvbox (r \sub \f)"  with precedence 90 for @{'form_rel $r}.
38
39 interpretation "concrete relation" 'concr_rel r = (concr_rel __ r). 
40 interpretation "formal relation" 'form_rel r = (form_rel __ r). 
41
42 definition relation_pair_equality:
43  ∀o1,o2. equivalence_relation1 (relation_pair o1 o2).
44  intros;
45  constructor 1;
46   [ apply (λr,r'. r \sub\c ∘ ⊩ = r' \sub\c ∘ ⊩);
47   | simplify;
48     intros;
49     apply refl1;
50   | simplify;
51     intros 2;
52     apply sym1;
53   | simplify;
54     intros 3;
55     apply trans1;
56   ]      
57 qed.
58
59 definition relation_pair_setoid: basic_pair → basic_pair → setoid1.
60  intros;
61  constructor 1;
62   [ apply (relation_pair b b1)
63   | apply relation_pair_equality
64   ]
65 qed.
66
67 lemma eq_to_eq': ∀o1,o2.∀r,r': relation_pair_setoid o1 o2. r=r' → ⊩ \circ r \sub\f = ⊩ \circ r'\sub\f.
68  intros 7 (o1 o2 r r' H c1 f2);
69  split; intro H1;
70   [ lapply (fi ?? (commute ?? r c1 f2) H1) as H2;
71     lapply (if ?? (H c1 f2) H2) as H3;
72     apply (if ?? (commute ?? r' c1 f2) H3);
73   | lapply (fi ?? (commute ?? r' c1 f2) H1) as H2;
74     lapply (fi ?? (H c1 f2) H2) as H3;
75     apply (if ?? (commute ?? r c1 f2) H3);
76   ]
77 qed.
78
79 definition id: ∀o:basic_pair. relation_pair o o.
80  intro;
81  constructor 1;
82   [1,2: apply id1;
83   | lapply (id_neutral_left1 ? (concr o) ? (⊩)) as H;
84     lapply (id_neutral_right1 ?? (form o) (⊩)) as H1;
85     apply (.= H);
86     apply (H1 \sup -1);]
87 qed.
88
89 definition relation_pair_composition:
90  ∀o1,o2,o3. binary_morphism1 (relation_pair_setoid o1 o2) (relation_pair_setoid o2 o3) (relation_pair_setoid o1 o3).
91  intros;
92  constructor 1;
93   [ intros (r r1);
94     constructor 1;
95      [ apply (r \sub\c ∘ r1 \sub\c) 
96      | apply (r \sub\f ∘ r1 \sub\f)
97      | lapply (commute ?? r) as H;
98        lapply (commute ?? r1) as H1;
99        apply (.= ASSOC1);
100        apply (.= #‡H1);
101        apply (.= ASSOC1\sup -1);
102        apply (.= H‡#);
103        apply ASSOC1]
104   | intros;
105     change with (a\sub\c ∘ b\sub\c ∘ ⊩ = a'\sub\c ∘ b'\sub\c ∘ ⊩);  
106     change in H with (a \sub\c ∘ ⊩ = a' \sub\c ∘ ⊩);
107     change in H1 with (b \sub\c ∘ ⊩ = b' \sub\c ∘ ⊩);
108     apply (.= ASSOC1);
109     apply (.= #‡H1);
110     apply (.= #‡(commute ?? b'));
111     apply (.= ASSOC1 \sup -1);
112     apply (.= H‡#);
113     apply (.= ASSOC1);
114     apply (.= #‡(commute ?? b')\sup -1);
115     apply (ASSOC1 \sup -1)]
116 qed.
117     
118 definition BP: category1.
119  constructor 1;
120   [ apply basic_pair
121   | apply relation_pair_setoid
122   | apply id
123   | apply relation_pair_composition
124   | intros;
125     change with (a12\sub\c ∘ a23\sub\c ∘ a34\sub\c ∘ ⊩ =
126                  (a12\sub\c ∘ (a23\sub\c ∘ a34\sub\c) ∘ ⊩));
127     apply (ASSOC1‡#);
128   | intros;
129     change with ((id o1)\sub\c ∘ a\sub\c ∘ ⊩ = a\sub\c ∘ ⊩);
130     apply ((id_neutral_left1 ????)‡#);
131   | intros;
132     change with (a\sub\c ∘ (id o2)\sub\c ∘ ⊩ = a\sub\c ∘ ⊩);
133     apply ((id_neutral_right1 ????)‡#);
134   ]
135 qed.