]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/formal_topology/overlap/relations_to_o-algebra.ma
SUBSETS_full up to universe inconsistency
[helm.git] / helm / software / matita / contribs / formal_topology / overlap / relations_to_o-algebra.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "relations.ma".
16 include "o-algebra.ma".
17
18 definition SUBSETS: objs1 SET → OAlgebra.
19  intro A; constructor 1;
20   [ apply (Ω \sup A);
21   | apply subseteq;
22   | apply overlaps;
23   | apply big_intersects;
24   | apply big_union;
25   | apply ({x | True});
26     simplify; intros; apply (refl1 ? (eq1 CPROP));
27   | apply ({x | False});
28     simplify; intros; apply (refl1 ? (eq1 CPROP));
29   | intros; whd; intros; assumption
30   | intros; whd; split; assumption
31   | intros; apply transitive_subseteq_operator; [2: apply f; | skip | assumption]
32   | intros; cases f; exists [apply w] assumption
33   | intros; split; [ intros 4; apply (f ? f1 i); | intros 3; intro; apply (f i ? f1); ]
34   | intros; split;
35      [ intros 4; apply f; exists; [apply i] assumption;
36      | intros 3; intros; cases f1; apply (f w a x); ]
37   | intros 3; cases f;
38   | intros 3; constructor 1;
39   | intros; cases f; exists; [apply w]
40      [ assumption
41      | whd; intros; cases i; simplify; assumption]
42   | intros; split; intro;
43      [ cases f; cases x1; exists [apply w1] exists [apply w] assumption;
44      | cases e; cases x; exists; [apply w1] [ assumption | exists; [apply w] assumption]]
45   | intros; intros 2; cases (f (singleton ? a) ?);
46      [ exists; [apply a] [assumption | change with (a = a); apply refl1;]
47      | change in x1 with (a = w); change with (mem A a q); apply (. (x1‡#));
48        assumption]]
49 qed.
50
51 definition powerset_of_SUBSETS: ∀A.oa_P (SUBSETS A) → Ω \sup A ≝ λA,x.x.
52 coercion powerset_of_SUBSETS.
53
54 definition orelation_of_relation: ∀o1,o2:REL. arrows1 ? o1 o2 → arrows2 OA (SUBSETS o1) (SUBSETS o2).
55  intros;
56  constructor 1;
57   [ constructor 1; 
58      [ apply (λU.image ?? c U);
59      | intros; apply (#‡e); ]
60   | constructor 1;
61      [ apply (λU.minus_star_image ?? c U);
62      | intros; apply (#‡e); ]
63   | constructor 1;
64      [ apply (λU.star_image ?? c U);
65      | intros; apply (#‡e); ]
66   | constructor 1;
67      [ apply (λU.minus_image ?? c U);
68      | intros; apply (#‡e); ]
69   | intros; split; intro;
70      [ change in f with (∀a. a ∈ image ?? c p → a ∈ q);
71        change with (∀a:o1. a ∈ p → a ∈ star_image ?? c q);
72        intros 4; apply f; exists; [apply a] split; assumption;
73      | change in f with (∀a:o1. a ∈ p → a ∈ star_image ?? c q);
74        change with (∀a. a ∈ image ?? c p → a ∈ q);
75        intros; cases f1; cases x; clear f1 x; apply (f ? f3); assumption; ]
76   | intros; split; intro;
77      [ change in f with (∀a. a ∈ minus_image ?? c p → a ∈ q);
78        change with (∀a:o2. a ∈ p → a ∈ minus_star_image ?? c q);
79        intros 4; apply f; exists; [apply a] split; assumption;
80      | change in f with (∀a:o2. a ∈ p → a ∈ minus_star_image ?? c q);
81        change with (∀a. a ∈ minus_image ?? c p → a ∈ q);
82        intros; cases f1; cases x; clear f1 x; apply (f ? f3); assumption; ]
83   | intros; split; intro; cases f; clear f;
84      [ cases x; cases x2; clear x x2; exists; [apply w1]
85         [ assumption;
86         | exists; [apply w] split; assumption]
87      | cases x1; cases x2; clear x1 x2; exists; [apply w1]
88         [ exists; [apply w] split; assumption;
89         | assumption; ]]]
90 qed.
91
92 lemma orelation_of_relation_preserves_equality:
93  ∀o1,o2:REL.∀t,t': arrows1 ? o1 o2. t = t' → eq2 ? (orelation_of_relation ?? t) (orelation_of_relation ?? t').
94  intros; split; unfold orelation_of_relation; simplify; intro; split; intro;
95  simplify; whd in o1 o2;
96   [ change with (a1 ∈ minus_star_image ?? t a → a1 ∈ minus_star_image ?? t' a);
97     apply (. #‡(e^-1‡#));
98   | change with (a1 ∈ minus_star_image ?? t' a → a1 ∈ minus_star_image ?? t a);
99     apply (. #‡(e‡#));
100   | change with (a1 ∈ minus_image ?? t a → a1 ∈ minus_image ?? t' a);
101     apply (. #‡(e ^ -1‡#));
102   | change with (a1 ∈ minus_image ?? t' a → a1 ∈ minus_image ?? t a);
103     apply (. #‡(e‡#));
104   | change with (a1 ∈ image ?? t a → a1 ∈ image ?? t' a);
105     apply (. #‡(e ^ -1‡#));
106   | change with (a1 ∈ image ?? t' a → a1 ∈ image ?? t a);
107     apply (. #‡(e‡#));
108   | change with (a1 ∈ star_image ?? t a → a1 ∈ star_image ?? t' a);
109     apply (. #‡(e ^ -1‡#));
110   | change with (a1 ∈ star_image ?? t' a → a1 ∈ star_image ?? t a);
111     apply (. #‡(e‡#)); ]
112 qed.
113
114 lemma orelation_of_relation_preserves_identity:
115  ∀o1:REL. eq2 ? (orelation_of_relation ?? (id1 ? o1)) (id2 OA (SUBSETS o1)).
116  intros; split; intro; split; whd; intro; 
117   [ change with ((∀x. x ♮(id1 REL o1) a1→x∈a) → a1 ∈ a); intros;
118     apply (f a1); change with (a1 = a1); apply refl1;
119   | change with (a1 ∈ a → ∀x. x ♮(id1 REL o1) a1→x∈a); intros;
120     change in f1 with (x = a1); apply (. f1‡#); apply f;
121   | alias symbol "and" = "and_morphism".
122     change with ((∃y:o1.a1 ♮(id1 REL o1) y ∧ y∈a) → a1 ∈ a);
123     intro; cases e; clear e; cases x; clear x; change in f with (a1=w);
124     apply (. f‡#); apply f1;
125   | change with (a1 ∈ a → ∃y:o1.a1 ♮(id1 REL o1) y ∧ y∈a);
126     intro; exists; [apply a1]; split; [ change with (a1=a1); apply refl1; | apply f]
127   | change with ((∃x:o1.x ♮(id1 REL o1) a1∧x∈a) → a1 ∈ a);
128     intro; cases e; clear e; cases x; clear x; change in f with (w=a1);
129     apply (. f^-1‡#); apply f1;
130   | change with (a1 ∈ a → ∃x:o1.x ♮(id1 REL o1) a1∧x∈a);
131     intro; exists; [apply a1]; split; [ change with (a1=a1); apply refl1; | apply f]
132   | change with ((∀y.a1 ♮(id1 REL o1) y→y∈a) → a1 ∈ a); intros;
133     apply (f a1); change with (a1 = a1); apply refl1;
134   | change with (a1 ∈ a → ∀y.a1 ♮(id1 REL o1) y→y∈a); intros;
135     change in f1 with (a1 = y); apply (. f1^-1‡#); apply f;]
136 qed.
137
138 (* CSC: ???? forse un uncertain mancato *)
139 alias symbol "eq" = "setoid2 eq".
140 alias symbol "compose" = "category1 composition".
141 lemma orelation_of_relation_preserves_composition:
142  ∀o1,o2,o3:REL.∀F: arrows1 ? o1 o2.∀G: arrows1 ? o2 o3.
143   orelation_of_relation ?? (G ∘ F) =
144    comp2 OA (SUBSETS o1) (SUBSETS o2) (SUBSETS o3)
145     ?? (*(orelation_of_relation ?? F) (orelation_of_relation ?? G)*).
146  [ apply (orelation_of_relation ?? F); | apply (orelation_of_relation ?? G); ]
147  intros; split; intro; split; whd; intro; whd in ⊢ (% → %); intros;
148   [ whd; intros; apply f; exists; [ apply x] split; assumption; 
149   | cases f1; clear f1; cases x1; clear x1; apply (f w); assumption;
150   | cases e; cases x; cases f; cases x1; clear e x f x1; exists; [ apply w1 ]
151     split; [ assumption | exists; [apply w] split; assumption ]
152   | cases e; cases x; cases f1; cases x1; clear e x f1 x1; exists; [apply w1 ]
153     split; [ exists; [apply w] split; assumption | assumption ]
154   | unfold arrows1_of_ORelation_setoid; 
155     cases e; cases x; cases f; cases x1; clear e x f x1; exists; [ apply w1 ]
156     split; [ assumption | exists; [apply w] split; assumption ]
157   | unfold arrows1_of_ORelation_setoid in e; 
158     cases e; cases x; cases f1; cases x1; clear e x f1 x1; exists; [apply w1 ]
159     split; [ exists; [apply w] split; assumption | assumption ]
160   | whd; intros; apply f; exists; [ apply y] split; assumption;
161   | cases f1; clear f1; cases x; clear x; apply (f w); assumption;]
162 qed.
163
164 definition SUBSETS': carr3 (arrows3 CAT2 (category2_of_category1 REL) OA).
165  constructor 1;
166   [ apply SUBSETS;
167   | intros; constructor 1;
168      [ apply (orelation_of_relation S T);
169      | intros; apply (orelation_of_relation_preserves_equality S T a a' e); ]
170   | apply orelation_of_relation_preserves_identity;
171   | simplify; intros;
172     apply (.= (orelation_of_relation_preserves_composition o1 o2 o4 f1 (f3∘f2)));
173     apply (#‡(orelation_of_relation_preserves_composition o2 o3 o4 f2 f3)); ]
174 qed.
175
176 theorem SUBSETS_faithful:
177  ∀S,T.∀f,g:arrows2 (category2_of_category1 REL) S T.
178   map_arrows2 ?? SUBSETS' ?? f = map_arrows2 ?? SUBSETS' ?? g → f=g.
179  intros; unfold SUBSETS' in e; simplify in e; cases e;
180  unfold orelation_of_relation in e3; simplify in e3; clear e e1 e2 e4;
181  intros 2; lapply (e3 (singleton ? x)); cases Hletin;
182  split; intro; [ lapply (s y); | lapply (s1 y); ]
183   [2,4: exists; [1,3:apply x] split; [1,3: assumption |*: change with (x=x); apply rule #]
184   |*: cases Hletin1; cases x1; change in f3 with (eq1 ? x w); apply (. f3‡#); assumption;]
185 qed.
186
187 theorem SUBSETS_full: ∀S,T.∀f.∃g. map_arrows2 ?? SUBSETS' S T g = f.
188  intros; exists;
189   [ constructor 1; constructor 1;
190      [ apply (λx.λy. y ∈ f (singleton S x));
191      | intros; unfold FunClass_1_OF_carr2; lapply (.= e1‡#);
192         [4: apply mem; |6: apply Hletin;|1,2,3,5: skip]
193        lapply (#‡prop11 ?? f ?? (†e)); [6: apply Hletin; |*:skip ]]
194      | whd; split; whd; intro; simplify; unfold map_arrows2; simplify;
195         [ split;
196            [ change with (∀a1.(∀x. a1 ∈ f (singleton S x) → x ∈ a) → a1 ∈ f⎻* a);
197            | change with (∀a1.a1 ∈ f⎻* a → (∀x.a1 ∈ f (singleton S x) → x ∈ a)); ]
198         | split;
199            [ change with (∀a1.(∃y. y ∈ f (singleton S a1) ∧ y ∈ a) → a1 ∈ f⎻ a);
200            | change with (∀a1.a1 ∈ f⎻ a → (∃y.y ∈ f (singleton S a1) ∧ y ∈ a)); ]
201         | split;
202            [ change with (∀a1.(∃x. a1 ∈ f (singleton S x) ∧ x ∈ a) → a1 ∈ f a);
203            | change with (∀a1.a1 ∈ f a → (∃x. a1 ∈ f (singleton S x) ∧ x ∈ a)); ]
204         | split;
205            [ change with (∀a1.(∀y. y ∈ f (singleton S a1) → y ∈ a) → a1 ∈ f* a);
206            | change with (∀a1.a1 ∈ f* a → (∀y. y ∈ f (singleton S a1) → y ∈ a)); ]]
207         [ intros; apply ((. (or_prop2 ?? f (singleton ? a1) a)^-1) ? a1);
208            [ intros 2; apply (f1 a2); change in f2 with (a2 ∈ f⎻ (singleton ? a1));
209              lapply (. (or_prop3 ?? f (singleton ? a2) (singleton ? a1)));
210               [ cases Hletin; change in x1 with (eq1 ? a1 w);
211                 apply (. x1‡#); assumption;
212               | exists; [apply a2] [change with (a2=a2); apply rule #; | assumption]]
213            | change with (a1 = a1); apply rule #; ]
214         | intros; apply ((. (or_prop2 ?? f (singleton ? a1) a)) ? x);
215            [ intros 2; change in f3 with (eq1 ? a1 a2); change with (a2 ∈ f⎻* a); apply (. f3^-1‡#);
216              assumption;
217            | lapply (. (or_prop3 ?? f (singleton ? x) (singleton ? a1))^-1);
218               [ cases Hletin; change in x1 with (eq1 ? x w);
219                 change with (x ∈ f⎻ (singleton ? a1)); apply (. x1‡#); assumption;
220               | exists; [apply a1] [assumption | change with (a1=a1); apply rule #; ]]]
221         | intros; cases e; cases x; clear e x;
222           lapply (. (or_prop3 ?? f (singleton ? a1) a)^-1);
223            [ cases Hletin; change in x with (eq1 ? a1 w1); apply (. x‡#); assumption;
224            | exists; [apply w] assumption ]
225         | intros; lapply (. (or_prop3 ?? f (singleton ? a1) a));
226            [ cases Hletin; exists; [apply w] split; assumption;
227            | exists; [apply a1] [change with (a1=a1); apply rule #; | assumption ]] 
228         | intros; cases e; cases x; clear e x;
229           apply (f_image_monotone ?? f (singleton ? w) a ? a1);
230            [ intros 2; change in f3 with (eq1 ? w a2); change with (a2 ∈ a);
231              apply (. f3^-1‡#); assumption;
232            | assumption; ]
233         | intros; lapply (. (or_prop3 ?? f a (singleton ? a1))^-1);
234            [ cases Hletin; exists; [apply w] split;
235               [ lapply (. (or_prop3 ?? f (singleton ? w) (singleton ? a1)));
236                  [ cases Hletin1; change in x3 with (eq1 ? a1 w1); apply (. x3‡#); assumption;
237                  | exists; [apply w] [change with (w=w); apply rule #; | assumption ]]
238               | assumption ]
239            | exists; [apply a1] [ assumption; | change with (a1=a1); apply rule #;]]
240         | intros; apply ((. (or_prop1 ?? f (singleton ? a1) a)^-1) ? a1);
241            [ apply f1; | change with (a1=a1); apply rule #; ]
242         | intros; apply ((. (or_prop1 ?? f (singleton ? a1) a)) ? y);
243            [ intros 2; change in f3 with (eq1 ? a1 a2); change with (a2 ∈ f* a);
244              apply (. f3^-1‡#); assumption;
245            | assumption ]]]
246 qed.