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 definition relation_pair_setoid: basic_pair → basic_pair → setoid1.
66 [ apply (relation_pair b b1)
67 | apply relation_pair_equality
71 lemma eq_to_eq': ∀o1,o2.∀r,r': relation_pair_setoid o1 o2. r=r' → r \sub\f ∘ ⊩ = r'\sub\f ∘ ⊩.
72 intros 5 (o1 o2 r r' H); change in H with (⊩ ∘ r\sub\c = ⊩ ∘ r'\sub\c);
73 apply (.= (commute ?? r \sup -1));
75 apply (.= (commute ?? r'));
80 definition id_relation_pair: ∀o:basic_pair. relation_pair o o.
84 | lapply (id_neutral_right1 ? (concr o) ? (⊩)) as H;
85 lapply (id_neutral_left1 ?? (form o) (⊩)) as H1;
90 definition relation_pair_composition:
91 ∀o1,o2,o3. binary_morphism1 (relation_pair_setoid o1 o2) (relation_pair_setoid o2 o3) (relation_pair_setoid o1 o3).
96 [ apply (r1 \sub\c ∘ r \sub\c)
97 | apply (r1 \sub\f ∘ r \sub\f)
98 | lapply (commute ?? r) as H;
99 lapply (commute ?? r1) as H1;
102 apply (.= ASSOC1\sup -1);
106 change with (⊩ ∘ (b\sub\c ∘ a\sub\c) = ⊩ ∘ (b'\sub\c ∘ a'\sub\c));
107 change in H with (⊩ ∘ a \sub\c = ⊩ ∘ a' \sub\c);
108 change in H1 with (⊩ ∘ b \sub\c = ⊩ ∘ b' \sub\c);
111 apply (.= #‡(commute ?? b'));
112 apply (.= ASSOC1 \sup -1);
115 apply (.= #‡(commute ?? b')\sup -1);
116 apply (ASSOC1 \sup -1)]
119 definition BP: category1.
122 | apply relation_pair_setoid
123 | apply id_relation_pair
124 | apply relation_pair_composition
126 change with (⊩ ∘ (a34\sub\c ∘ (a23\sub\c ∘ a12\sub\c)) =
127 ⊩ ∘ ((a34\sub\c ∘ a23\sub\c) ∘ a12\sub\c));
130 change with (⊩ ∘ (a\sub\c ∘ (id_relation_pair o1)\sub\c) = ⊩ ∘ a\sub\c);
131 apply ((id_neutral_right1 ????)‡#);
133 change with (⊩ ∘ ((id_relation_pair o2)\sub\c ∘ a\sub\c) = ⊩ ∘ a\sub\c);
134 apply ((id_neutral_left1 ????)‡#);]
139 definition BPext: ∀o: BP. form o ⇒ Ω \sup (concr o).
140 intros; constructor 1;
141 [ apply (ext ? ? (rel o));
147 definition BPextS: ∀o: BP. Ω \sup (form o) ⇒ Ω \sup (concr o) ≝
152 definition fintersects: ∀o: BP. binary_morphism1 (form o) (form o) (Ω \sup (form o)).
153 intros (o); constructor 1;
154 [ apply (λa,b: form o.{c | BPext o c ⊆ BPext o a ∩ BPext o b });
155 intros; simplify; apply (.= (†H)‡#); apply refl1
156 | intros; split; simplify; intros;
157 [ apply (. #‡((†H)‡(†H1))); assumption
158 | apply (. #‡((†H\sup -1)‡(†H1\sup -1))); assumption]]
161 interpretation "fintersects" 'fintersects U V = (fun1 ___ (fintersects _) U V).
163 definition fintersectsS:
164 ∀o:BP. binary_morphism1 (Ω \sup (form o)) (Ω \sup (form o)) (Ω \sup (form o)).
165 intros (o); constructor 1;
166 [ apply (λo: basic_pair.λa,b: Ω \sup (form o).{c | BPext o c ⊆ BPextS o a ∩ BPextS o b });
167 intros; simplify; apply (.= (†H)‡#); apply refl1
168 | intros; split; simplify; intros;
169 [ apply (. #‡((†H)‡(†H1))); assumption
170 | apply (. #‡((†H\sup -1)‡(†H1\sup -1))); assumption]]
173 interpretation "fintersectsS" 'fintersects U V = (fun1 ___ (fintersectsS _) U V).
177 definition relS: ∀o: BP. binary_morphism1 (concr o) (Ω \sup (form o)) CPROP.
178 intros (o); constructor 1;
179 [ apply (λx:concr o.λS: Ω \sup (form o).∃y: form o.y ∈ S ∧ x ⊩ y);
180 | intros; split; intros; cases H2; exists [1,3: apply w]
181 [ apply (. (#‡H1)‡(H‡#)); assumption
182 | apply (. (#‡H1 \sup -1)‡(H \sup -1‡#)); assumption]]
185 interpretation "basic pair relation for subsets" 'Vdash2 x y = (fun1 (concr _) __ (relS _) x y).
186 interpretation "basic pair relation for subsets (non applied)" 'Vdash = (fun1 ___ (relS _)).