]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/formal_topology/overlap/basic_pairs.ma
1. new coercion(s) from CPropi to CProp
[helm.git] / helm / software / matita / contribs / formal_topology / overlap / 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 "relations.ma".
16
17 record basic_pair: Type1 ≝
18  { concr: REL;
19    form: REL;
20    rel: arrows1 ? concr form
21  }.
22
23 interpretation "basic pair relation" 'Vdash2 x y c = (fun21 ___ (rel c) x y).
24 interpretation "basic pair relation (non applied)" 'Vdash c = (rel c).
25
26 alias symbol "eq" = "setoid1 eq".
27 alias symbol "compose" = "category1 composition".
28 record relation_pair (BP1,BP2: basic_pair): Type1 ≝
29  { concr_rel: arrows1 ? (concr BP1) (concr BP2);
30    form_rel: arrows1 ? (form BP1) (form BP2);
31    commute: ⊩ ∘ concr_rel = form_rel ∘ ⊩
32  }.
33
34 notation "hvbox (r \sub \c)"  with precedence 90 for @{'concr_rel $r}.
35 notation "hvbox (r \sub \f)"  with precedence 90 for @{'form_rel $r}.
36
37 interpretation "concrete relation" 'concr_rel r = (concr_rel __ r). 
38 interpretation "formal relation" 'form_rel r = (form_rel __ r).
39
40 definition relation_pair_equality:
41  ∀o1,o2. equivalence_relation1 (relation_pair o1 o2).
42  intros;
43  constructor 1;
44   [ apply (λr,r'. ⊩ ∘ r \sub\c = ⊩ ∘ r' \sub\c);
45   | simplify;
46     intros;
47     apply refl1;
48   | simplify;
49     intros 2;
50     apply sym1;
51   | simplify;
52     intros 3;
53     apply trans1;
54   ]      
55 qed.
56
57 definition relation_pair_setoid: basic_pair → basic_pair → setoid1.
58  intros;
59  constructor 1;
60   [ apply (relation_pair b b1)
61   | apply relation_pair_equality
62   ]
63 qed.
64
65 definition relation_pair_of_relation_pair_setoid :
66   ∀P,Q. relation_pair_setoid P Q → relation_pair P Q ≝ λP,Q,x.x.
67 coercion relation_pair_of_relation_pair_setoid.
68
69 lemma eq_to_eq': 
70   ∀o1,o2.∀r,r':relation_pair_setoid o1 o2. r=r' → r \sub\f ∘ ⊩ = r'\sub\f ∘ ⊩.
71  intros 7 (o1 o2 r r' H c1 f2);
72  split; intro H1;
73   [ lapply (fi ?? (commute ?? r c1 f2) H1) as H2;
74     lapply (if ?? (H c1 f2) H2) as H3;
75     apply (if ?? (commute ?? r' c1 f2) H3);
76   | lapply (fi ?? (commute ?? r' c1 f2) H1) as H2;
77     lapply (fi ?? (H c1 f2) H2) as H3;
78     apply (if ?? (commute ?? r c1 f2) H3);
79   ]
80 qed.
81
82 definition id_relation_pair: ∀o:basic_pair. relation_pair o o.
83  intro;
84  constructor 1;
85   [1,2: apply id1;
86   | lapply (id_neutral_right1 ? (concr o) ? (⊩)) as H;
87     lapply (id_neutral_left1 ?? (form o) (⊩)) as H1;
88     apply (.= H);
89     apply (H1 \sup -1);]
90 qed.
91
92 definition relation_pair_composition:
93  ∀o1,o2,o3. binary_morphism1 (relation_pair_setoid o1 o2) (relation_pair_setoid o2 o3) (relation_pair_setoid o1 o3).
94  intros;
95  constructor 1;
96   [ intros (r r1);
97     constructor 1;
98      [ apply (r1 \sub\c ∘ r \sub\c) 
99      | apply (r1 \sub\f ∘ r \sub\f)
100      | lapply (commute ?? r) as H;
101        lapply (commute ?? r1) as H1;
102        alias symbol "trans" = "trans1".
103        alias symbol "assoc" = "category1 assoc".
104        apply (.= ASSOC);
105        apply (.= #‡H1);
106        alias symbol "invert" = "setoid1 symmetry".
107        apply (.= ASSOC ^ -1);
108        apply (.= H‡#);
109        apply ASSOC]
110   | intros;
111     change with (⊩ ∘ (b\sub\c ∘ a\sub\c) = ⊩ ∘ (b'\sub\c ∘ a'\sub\c));  
112     change in e with (⊩ ∘ a \sub\c = ⊩ ∘ a' \sub\c);
113     change in e1 with (⊩ ∘ b \sub\c = ⊩ ∘ b' \sub\c);
114     apply (.= ASSOC);
115     apply (.= #‡e1);
116     apply (.= #‡(commute ?? b'));
117     apply (.= ASSOC ^ -1);
118     apply (.= e‡#);
119     apply (.= ASSOC);
120     apply (.= #‡(commute ?? b')\sup -1);
121     apply (ASSOC ^ -1)]
122 qed.
123     
124 definition BP: category1.
125  constructor 1;
126   [ apply basic_pair
127   | apply relation_pair_setoid
128   | apply id_relation_pair
129   | apply relation_pair_composition
130   | intros;
131     change with (⊩ ∘ (a34\sub\c ∘ (a23\sub\c ∘ a12\sub\c)) =
132                  ⊩ ∘ ((a34\sub\c ∘ a23\sub\c) ∘ a12\sub\c));
133     alias symbol "refl" = "refl1".
134     alias symbol "prop2" = "prop21".
135     apply (ASSOC‡#);
136   | intros;
137     change with (⊩ ∘ (a\sub\c ∘ (id_relation_pair o1)\sub\c) = ⊩ ∘ a\sub\c);
138     apply ((id_neutral_right1 ????)‡#);
139   | intros;
140     change with (⊩ ∘ ((id_relation_pair o2)\sub\c ∘ a\sub\c) = ⊩ ∘ a\sub\c);
141     apply ((id_neutral_left1 ????)‡#);]
142 qed.
143
144 definition basic_pair_of_BP : objs1 BP → basic_pair ≝ λx.x.
145 coercion basic_pair_of_BP.
146
147 definition relation_pair_setoid_of_arrows1_BP :
148   ∀P,Q. arrows1 BP P Q → relation_pair_setoid P Q ≝ λP,Q,x.x.
149 coercion relation_pair_setoid_of_arrows1_BP.
150
151 definition BPext: ∀o: BP. form o ⇒ Ω \sup (concr o).
152  intros; constructor 1;
153   [ apply (ext ? ? (rel o));
154   | intros;
155     apply (.= #‡e);
156     apply refl1]
157 qed.
158
159 definition BPextS: ∀o: BP. Ω \sup (form o) ⇒ Ω \sup (concr o).
160  intros; constructor 1;
161   [ apply (minus_image ?? (rel o));
162   | intros; apply (#‡e); ]
163 qed.
164
165 definition fintersects: ∀o: BP. binary_morphism1 (form o) (form o) (Ω \sup (form o)).
166  intros (o); constructor 1;
167   [ apply (λa,b: form o.{c | BPext o c ⊆ BPext o a ∩ BPext o b });
168     intros; simplify; apply (.= (†e)‡#); apply refl1
169   | intros; split; simplify; intros;
170      [ apply (. #‡((†e^-1)‡(†e1^-1))); assumption
171      | apply (. #‡((†e)‡(†e1))); assumption]]
172 qed.
173
174 interpretation "fintersects" 'fintersects U V = (fun21 ___ (fintersects _) U V).
175
176 definition fintersectsS:
177  ∀o:BP. binary_morphism1 (Ω \sup (form o)) (Ω \sup (form o)) (Ω \sup (form o)).
178  intros (o); constructor 1;
179   [ apply (λo: basic_pair.λa,b: Ω \sup (form o).{c | BPext o c ⊆ BPextS o a ∩ BPextS o b });
180     intros; simplify; apply (.= (†e)‡#); apply refl1
181   | intros; split; simplify; intros;
182      [ apply (. #‡((†e^-1)‡(†e1^-1))); assumption
183      | apply (. #‡((†e)‡(†e1))); assumption]]
184 qed.
185
186 interpretation "fintersectsS" 'fintersects U V = (fun21 ___ (fintersectsS _) U V).
187
188 definition relS: ∀o: BP. binary_morphism1 (concr o) (Ω \sup (form o)) CPROP.
189  intros (o); constructor 1;
190   [ apply (λx:concr o.λS: Ω \sup (form o).∃y:form o.y ∈ S ∧ x ⊩_o y);
191   | intros; split; intros; cases e2; exists [1,3: apply w]
192      [ apply (. (#‡e1^-1)‡(e^-1‡#)); assumption
193      | apply (. (#‡e1)‡(e‡#)); assumption]]
194 qed.
195
196 interpretation "basic pair relation for subsets" 'Vdash2 x y c = (fun21 (concr _) __ (relS c) x y).
197 interpretation "basic pair relation for subsets (non applied)" 'Vdash c = (fun21 ___ (relS c)).