1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "formal_topology/relations.ma".
16 include "datatypes/categories.ma".
18 record basic_pair: Type ≝
21 rel: arrows1 ? concr form
24 notation "x ⊩ y" with precedence 45 for @{'Vdash2 $x $y}.
25 notation "⊩" with precedence 60 for @{'Vdash}.
27 interpretation "basic pair relation" 'Vdash2 x y = (rel _ x y).
28 interpretation "basic pair relation (non applied)" 'Vdash = (rel _).
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 ∘ ⊩
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}.
39 interpretation "concrete relation" 'concr_rel r = (concr_rel __ r).
40 interpretation "formal relation" 'form_rel r = (form_rel __ r).
42 definition relation_pair_equality:
43 ∀o1,o2. equivalence_relation1 (relation_pair o1 o2).
46 [ apply (λr,r'. ⊩ ∘ r \sub\c = ⊩ ∘ r' \sub\c);
59 definition relation_pair_setoid: basic_pair → basic_pair → setoid1.
62 [ apply (relation_pair b b1)
63 | apply relation_pair_equality
67 lemma eq_to_eq': ∀o1,o2.∀r,r': relation_pair_setoid o1 o2. r=r' → r \sub\f ∘ ⊩ = r'\sub\f ∘ ⊩.
68 intros 7 (o1 o2 r r' H c1 f2);
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);
79 definition id_relation_pair: ∀o:basic_pair. relation_pair o o.
83 | lapply (id_neutral_right1 ? (concr o) ? (⊩)) as H;
84 lapply (id_neutral_left1 ?? (form o) (⊩)) as H1;
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).
95 [ apply (r1 \sub\c ∘ r \sub\c)
96 | apply (r1 \sub\f ∘ r \sub\f)
97 | lapply (commute ?? r) as H;
98 lapply (commute ?? r1) as H1;
101 apply (.= ASSOC1\sup -1);
105 change with (⊩ ∘ (b\sub\c ∘ a\sub\c) = ⊩ ∘ (b'\sub\c ∘ a'\sub\c));
106 change in H with (⊩ ∘ a \sub\c = ⊩ ∘ a' \sub\c);
107 change in H1 with (⊩ ∘ b \sub\c = ⊩ ∘ b' \sub\c);
110 apply (.= #‡(commute ?? b'));
111 apply (.= ASSOC1 \sup -1);
114 apply (.= #‡(commute ?? b')\sup -1);
115 apply (ASSOC1 \sup -1)]
118 definition BP: category1.
121 | apply relation_pair_setoid
122 | apply id_relation_pair
123 | apply relation_pair_composition
125 change with (⊩ ∘ (a34\sub\c ∘ (a23\sub\c ∘ a12\sub\c)) =
126 ⊩ ∘ ((a34\sub\c ∘ a23\sub\c) ∘ a12\sub\c));
129 change with (⊩ ∘ (a\sub\c ∘ (id_relation_pair o1)\sub\c) = ⊩ ∘ a\sub\c);
130 apply ((id_neutral_right1 ????)‡#);
132 change with (⊩ ∘ ((id_relation_pair o2)\sub\c ∘ a\sub\c) = ⊩ ∘ a\sub\c);
133 apply ((id_neutral_left1 ????)‡#);]
136 definition BPext: ∀o: BP. form o ⇒ Ω \sup (concr o).
137 intros; constructor 1;
138 [ apply (ext ? ? (rel o));
144 definition BPextS: ∀o: BP. Ω \sup (form o) ⇒ Ω \sup (concr o) ≝
147 definition fintersects: ∀o: BP. binary_morphism1 (form o) (form o) (Ω \sup (form o)).
148 intros (o); constructor 1;
149 [ apply (λa,b: form o.{c | BPext o c ⊆ BPext o a ∩ BPext o b });
150 intros; simplify; apply (.= (†H)‡#); apply refl1
151 | intros; split; simplify; intros;
152 [ apply (. #‡((†H)‡(†H1))); assumption
153 | apply (. #‡((†H\sup -1)‡(†H1\sup -1))); assumption]]
156 interpretation "fintersects" 'fintersects U V = (fun1 ___ (fintersects _) U V).
158 definition fintersectsS:
159 ∀o:BP. binary_morphism1 (Ω \sup (form o)) (Ω \sup (form o)) (Ω \sup (form o)).
160 intros (o); constructor 1;
161 [ apply (λo: basic_pair.λa,b: Ω \sup (form o).{c | BPext o c ⊆ BPextS o a ∩ BPextS o b });
162 intros; simplify; apply (.= (†H)‡#); apply refl1
163 | intros; split; simplify; intros;
164 [ apply (. #‡((†H)‡(†H1))); assumption
165 | apply (. #‡((†H\sup -1)‡(†H1\sup -1))); assumption]]
168 interpretation "fintersectsS" 'fintersects U V = (fun1 ___ (fintersectsS _) U V).
170 definition relS: ∀o: BP. binary_morphism1 (concr o) (Ω \sup (form o)) CPROP.
171 intros (o); constructor 1;
172 [ apply (λx:concr o.λS: Ω \sup (form o).∃y: form o.y ∈ S ∧ x ⊩ y);
173 | intros; split; intros; cases H2; exists [1,3: apply w]
174 [ apply (. (#‡H1)‡(H‡#)); assumption
175 | apply (. (#‡H1 \sup -1)‡(H \sup -1‡#)); assumption]]
178 interpretation "basic pair relation for subsets" 'Vdash2 x y = (fun1 (concr _) __ (relS _) x y).
179 interpretation "basic pair relation for subsets (non applied)" 'Vdash = (fun1 ___ (relS _)).