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 "datatypes/subsets.ma".
17 record binary_relation (A,B: setoid) : Type ≝
18 { satisfy:> binary_morphism1 A B CPROP }.
20 notation < "hvbox (x \nbsp \natur term 90 r \nbsp y)" with precedence 45 for @{'satisfy $r $x $y}.
21 notation > "hvbox (x \natur term 90 r y)" with precedence 45 for @{'satisfy $r $x $y}.
22 interpretation "relation applied" 'satisfy r x y = (fun1 ___ (satisfy __ r) x y).
24 definition binary_relation_setoid: setoid → setoid → setoid1.
27 [ apply (binary_relation A B)
29 [ apply (λA,B.λr,r': binary_relation A B. ∀x,y. r x y ↔ r' x y)
30 | simplify; intros 3; split; intro; assumption
31 | simplify; intros 5; split; intro;
32 [ apply (fi ?? (H ??)) | apply (if ?? (H ??))] assumption
33 | simplify; intros 7; split; intro;
34 [ apply (if ?? (H1 ??)) | apply (fi ?? (H ??)) ]
35 [ apply (if ?? (H ??)) | apply (fi ?? (H1 ??)) ]
39 definition composition:
41 binary_morphism1 (binary_relation_setoid A B) (binary_relation_setoid B C) (binary_relation_setoid A C).
47 [ apply (λs1:A.λs3:C.∃s2:B. s1 ♮R12 s2 ∧ s2 ♮R23 s3);
49 split; intro; cases H2 (w H3); clear H2; exists; [1,3: apply w ]
50 [ apply (. (H‡#)‡(#‡H1)); assumption
51 | apply (. ((H \sup -1)‡#)‡(#‡(H1 \sup -1))); assumption]]
52 | intros 8; split; intro H2; simplify in H2 ⊢ %;
53 cases H2 (w H3); clear H2; exists [1,3: apply w] cases H3 (H2 H4); clear H3;
54 [ lapply (if ?? (H x w) H2) | lapply (fi ?? (H x w) H2) ]
55 [ lapply (if ?? (H1 w y) H4)| lapply (fi ?? (H1 w y) H4) ]
56 exists; try assumption;
60 definition REL: category1.
63 | intros (T T1); apply (binary_relation_setoid T T1)
64 | intros; constructor 1;
65 constructor 1; unfold setoid1_of_setoid; simplify;
66 [ intros; apply (c = c1)
67 | intros; split; intro;
68 [ apply (trans ????? (H \sup -1));
69 apply (trans ????? H2);
71 | apply (trans ????? H);
72 apply (trans ????? H2);
77 cases f (w H); clear f; cases H; clear H;
78 [cases f (w1 H); clear f | cases f1 (w1 H); clear f1]
80 exists; try assumption;
81 split; try assumption;
82 exists; try assumption;
84 |6,7: intros 5; unfold composition; simplify; split; intro;
85 unfold setoid1_of_setoid in x y; simplify in x y;
86 [1,3: cases H (w H1); clear H; cases H1; clear H1; unfold;
87 [ apply (. (H \sup -1 : eq1 ? w x)‡#); assumption
88 | apply (. #‡(H : eq1 ? w y)); assumption]
89 |2,4: exists; try assumption; split; first [apply refl | assumption]]]
92 definition full_subset: ∀s:REL. Ω \sup s.
93 apply (λs.{x | True});
94 intros; simplify; split; intro; assumption.
99 definition setoid1_of_REL: REL → setoid ≝ λS. S.
101 coercion setoid1_of_REL.