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 "logic/cprop_connectives.ma".
16 include "datatypes/categories.ma".
18 record powerset_carrier (A: setoid) : Type ≝ { mem_operator: A ⇒ CPROP }.
20 definition subseteq_operator ≝
21 λA:setoid.λU,V.∀a:A. mem_operator ? U a → mem_operator ? V a.
23 theorem transitive_subseteq_operator: ∀A. transitive ? (subseteq_operator A).
31 definition powerset_setoid: setoid → setoid1.
34 [ apply (powerset_carrier T)
36 [ apply (λU,V. subseteq_operator ? U V ∧ subseteq_operator ? V U)
37 | simplify; intros; split; intros 2; assumption
38 | simplify; intros (x y H); cases H; split; assumption
39 | simplify; intros (x y z H H1); cases H; cases H1; split;
40 apply transitive_subseteq_operator; [1,4: apply y ]
44 interpretation "powerset" 'powerset A = (powerset_setoid A).
46 interpretation "subset construction" 'subset \eta.x =
47 (mk_powerset_carrier _ (mk_unary_morphism _ CPROP x _)).
49 definition mem: ∀A. binary_morphism1 A (Ω \sup A) CPROP.
52 [ apply (λx,S. mem_operator ? S x)
54 cases b; clear b; cases b'; clear b'; simplify; intros;
55 apply (trans1 ????? (prop_1 ?? u ?? H));
56 cases H1; whd in s s1;
59 | apply s1; assumption]]
62 interpretation "mem" 'mem a S = (fun1 ??? (mem ?) a S).
64 definition subseteq: ∀A. binary_morphism1 (Ω \sup A) (Ω \sup A) CPROP.
67 [ apply (λU,V. subseteq_operator ? U V)
71 [ apply (transitive_subseteq_operator ????? s2);
72 apply (transitive_subseteq_operator ???? s1 s4)
73 | apply (transitive_subseteq_operator ????? s3);
74 apply (transitive_subseteq_operator ???? s s4) ]]
77 interpretation "subseteq" 'subseteq U V = (fun1 ??? (subseteq ?) U V).
79 theorem subseteq_refl: ∀A.∀S:Ω \sup A.S ⊆ S.
83 theorem subseteq_trans: ∀A.∀S1,S2,S3: Ω \sup A. S1 ⊆ S2 → S2 ⊆ S3 → S1 ⊆ S3.
84 intros; apply transitive_subseteq_operator; [apply S2] assumption.
87 definition overlaps: ∀A. binary_morphism1 (Ω \sup A) (Ω \sup A) CPROP.
90 [ apply (λA.λU,V:Ω \sup A.exT2 ? (λx:A.x ∈ U) (λx:A.x ∈ V))
92 constructor 1; intro; cases H2; exists; [1,4: apply w]
93 [ apply (. #‡H); assumption
94 | apply (. #‡H1); assumption
95 | apply (. #‡(H \sup -1)); assumption;
96 | apply (. #‡(H1 \sup -1)); assumption]]
99 interpretation "overlaps" 'overlaps U V = (fun1 ??? (overlaps ?) U V).
101 definition intersects:
102 ∀A. binary_morphism1 (powerset_setoid A) (powerset_setoid A) (powerset_setoid A).
105 [ apply (λU,V. {x | x ∈ U ∧ x ∈ V });
106 intros; simplify; apply (.= (H‡#)‡(H‡#)); apply refl1;
108 split; intros 2; simplify in f ⊢ %;
109 [ apply (. (#‡H)‡(#‡H1)); assumption
110 | apply (. (#‡(H \sup -1))‡(#‡(H1 \sup -1))); assumption]]
113 interpretation "intersects" 'intersects U V = (fun1 ??? (intersects ?) U V).
116 ∀A. binary_morphism1 (powerset_setoid A) (powerset_setoid A) (powerset_setoid A).
119 [ apply (λU,V. {x | x ∈ U ∨ x ∈ V });
120 intros; simplify; apply (.= (H‡#)‡(H‡#)); apply refl1
122 split; intros 2; simplify in f ⊢ %;
123 [ apply (. (#‡H)‡(#‡H1)); assumption
124 | apply (. (#‡(H \sup -1))‡(#‡(H1 \sup -1))); assumption]]
127 interpretation "union" 'union U V = (fun1 ??? (union ?) U V).
129 definition singleton: ∀A:setoid. unary_morphism A (Ω \sup A).
130 intros; constructor 1;
131 [ apply (λA:setoid.λa:A.{b | a=b});
135 [ apply H | apply (H \sup -1) ]
136 | intros; split; intros 2; simplify in f ⊢ %; apply trans;
137 [ apply a |4: apply a'] try assumption; apply sym; assumption]
140 interpretation "singleton" 'singl a = (fun_1 ?? (singleton ?) a).