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 "relations.ma".
17 record basic_pair: Type1 ≝
20 rel: arrows1 ? concr form
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).
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 ∘ ⊩
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}.
37 interpretation "concrete relation" 'concr_rel r = (concr_rel __ r).
38 interpretation "formal relation" 'form_rel r = (form_rel __ r).
40 definition relation_pair_equality:
41 ∀o1,o2. equivalence_relation1 (relation_pair o1 o2).
44 [ apply (λr,r'. ⊩ ∘ r \sub\c = ⊩ ∘ r' \sub\c);
57 definition relation_pair_setoid: basic_pair → basic_pair → setoid1.
60 [ apply (relation_pair b b1)
61 | apply relation_pair_equality
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.
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);
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);
82 definition id_relation_pair: ∀o:basic_pair. relation_pair o o.
86 | lapply (id_neutral_right1 ? (concr o) ? (⊩)) as H;
87 lapply (id_neutral_left1 ?? (form o) (⊩)) as H1;
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).
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".
106 alias symbol "invert" = "setoid1 symmetry".
107 apply (.= ASSOC ^ -1);
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);
116 apply (.= #‡(commute ?? b'));
117 apply (.= ASSOC ^ -1);
120 apply (.= #‡(commute ?? b')\sup -1);
124 definition BP: category1.
127 | apply relation_pair_setoid
128 | apply id_relation_pair
129 | apply relation_pair_composition
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".
137 change with (⊩ ∘ (a\sub\c ∘ (id_relation_pair o1)\sub\c) = ⊩ ∘ a\sub\c);
138 apply ((id_neutral_right1 ????)‡#);
140 change with (⊩ ∘ ((id_relation_pair o2)\sub\c ∘ a\sub\c) = ⊩ ∘ a\sub\c);
141 apply ((id_neutral_left1 ????)‡#);]
144 definition basic_pair_of_BP : objs1 BP → basic_pair ≝ λx.x.
145 coercion basic_pair_of_BP.
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.
151 definition BPext: ∀o: BP. form o ⇒ Ω \sup (concr o).
152 intros; constructor 1;
153 [ apply (ext ? ? (rel o));
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); ]
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]]
174 interpretation "fintersects" 'fintersects U V = (fun21 ___ (fintersects _) U V).
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]]
186 interpretation "fintersectsS" 'fintersects U V = (fun21 ___ (fintersectsS _) U V).
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]]
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)).