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 "o-algebra.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 < "x (⊩ \below c) y" with precedence 45 for @{'Vdash2 $x $y $c}.
26 notation < "⊩ \sub c" with precedence 60 for @{'Vdash $c}.
27 notation > "⊩ " with precedence 60 for @{'Vdash ?}.
29 interpretation "basic pair relation indexed" 'Vdash2 x y c = (rel c x y).
30 interpretation "basic pair relation (non applied)" 'Vdash c = (rel c).
32 alias symbol "eq" = "setoid1 eq".
33 alias symbol "compose" = "category1 composition".
34 record relation_pair (BP1,BP2: basic_pair): Type ≝
35 { concr_rel: arrows1 ? (concr BP1) (concr BP2);
36 form_rel: arrows1 ? (form BP1) (form BP2);
37 commute: ⊩ ∘ concr_rel = form_rel ∘ ⊩
40 notation "hvbox (r \sub \c)" with precedence 90 for @{'concr_rel $r}.
41 notation "hvbox (r \sub \f)" with precedence 90 for @{'form_rel $r}.
43 interpretation "concrete relation" 'concr_rel r = (concr_rel __ r).
44 interpretation "formal relation" 'form_rel r = (form_rel __ r).
46 definition relation_pair_equality:
47 ∀o1,o2. equivalence_relation1 (relation_pair o1 o2).
50 [ apply (λr,r'. ⊩ ∘ r \sub\c = ⊩ ∘ r' \sub\c);
63 (* qui setoid1 e' giusto *)
64 definition relation_pair_setoid: basic_pair → basic_pair → setoid1.
67 [ apply (relation_pair b b1)
68 | apply relation_pair_equality
72 lemma eq_to_eq': ∀o1,o2.∀r,r': relation_pair_setoid o1 o2. r=r' → r \sub\f ∘ ⊩ = r'\sub\f ∘ ⊩.
73 intros 5 (o1 o2 r r' H); change in H with (⊩ ∘ r\sub\c = ⊩ ∘ r'\sub\c);
74 apply (.= ((commute ?? r) \sup -1));
76 apply (.= (commute ?? r'));
81 definition id_relation_pair: ∀o:basic_pair. relation_pair o o.
85 | lapply (id_neutral_right1 ? (concr o) ? (⊩)) as H;
86 lapply (id_neutral_left1 ?? (form o) (⊩)) as H1;
91 definition relation_pair_composition:
92 ∀o1,o2,o3. binary_morphism1 (relation_pair_setoid o1 o2) (relation_pair_setoid o2 o3) (relation_pair_setoid o1 o3).
97 [ apply (r1 \sub\c ∘ r \sub\c)
98 | apply (r1 \sub\f ∘ r \sub\f)
99 | lapply (commute ?? r) as H;
100 lapply (commute ?? r1) as H1;
103 apply (.= ASSOC1\sup -1);
107 change with (⊩ ∘ (b\sub\c ∘ a\sub\c) = ⊩ ∘ (b'\sub\c ∘ a'\sub\c));
108 change in H with (⊩ ∘ a \sub\c = ⊩ ∘ a' \sub\c);
109 change in H1 with (⊩ ∘ b \sub\c = ⊩ ∘ b' \sub\c);
112 apply (.= #‡(commute ?? b'));
113 apply (.= ASSOC1 \sup -1);
116 apply (.= #‡(commute ?? b')\sup -1);
117 apply (ASSOC1 \sup -1)]
120 definition BP: category1.
123 | apply relation_pair_setoid
124 | apply id_relation_pair
125 | apply relation_pair_composition
127 change with (⊩ ∘ (a34\sub\c ∘ (a23\sub\c ∘ a12\sub\c)) =
128 ⊩ ∘ ((a34\sub\c ∘ a23\sub\c) ∘ a12\sub\c));
131 change with (⊩ ∘ (a\sub\c ∘ (id_relation_pair o1)\sub\c) = ⊩ ∘ a\sub\c);
132 apply ((id_neutral_right1 ????)‡#);
134 change with (⊩ ∘ ((id_relation_pair o2)\sub\c ∘ a\sub\c) = ⊩ ∘ a\sub\c);
135 apply ((id_neutral_left1 ????)‡#);]
140 definition BPext: ∀o: BP. form o ⇒ Ω \sup (concr o).
141 intros; constructor 1;
142 [ apply (ext ? ? (rel o));
148 definition BPextS: ∀o: BP. Ω \sup (form o) ⇒ Ω \sup (concr o) ≝
153 definition fintersects: ∀o: BP. binary_morphism1 (form o) (form o) (Ω \sup (form o)).
154 intros (o); constructor 1;
155 [ apply (λa,b: form o.{c | BPext o c ⊆ BPext o a ∩ BPext o b });
156 intros; simplify; apply (.= (†H)‡#); apply refl1
157 | intros; split; simplify; intros;
158 [ apply (. #‡((†H)‡(†H1))); assumption
159 | apply (. #‡((†H\sup -1)‡(†H1\sup -1))); assumption]]
162 interpretation "fintersects" 'fintersects U V = (fun1 ___ (fintersects _) U V).
164 definition fintersectsS:
165 ∀o:BP. binary_morphism1 (Ω \sup (form o)) (Ω \sup (form o)) (Ω \sup (form o)).
166 intros (o); constructor 1;
167 [ apply (λo: basic_pair.λa,b: Ω \sup (form o).{c | BPext o c ⊆ BPextS o a ∩ BPextS o b });
168 intros; simplify; apply (.= (†H)‡#); apply refl1
169 | intros; split; simplify; intros;
170 [ apply (. #‡((†H)‡(†H1))); assumption
171 | apply (. #‡((†H\sup -1)‡(†H1\sup -1))); assumption]]
174 interpretation "fintersectsS" 'fintersects U V = (fun1 ___ (fintersectsS _) U V).
178 definition relS: ∀o: BP. binary_morphism1 (concr o) (Ω \sup (form o)) CPROP.
179 intros (o); constructor 1;
180 [ apply (λx:concr o.λS: Ω \sup (form o).∃y: form o.y ∈ S ∧ x ⊩ y);
181 | intros; split; intros; cases H2; exists [1,3: apply w]
182 [ apply (. (#‡H1)‡(H‡#)); assumption
183 | apply (. (#‡H1 \sup -1)‡(H \sup -1‡#)); assumption]]
186 interpretation "basic pair relation for subsets" 'Vdash2 x y = (fun1 (concr _) __ (relS _) x y).
187 interpretation "basic pair relation for subsets (non applied)" 'Vdash = (fun1 ___ (relS _)).