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).
29 definition powerset_setoid: setoid → setoid1.
32 [ apply (powerset_carrier T)
34 [ apply (λU,V. subseteq_operator ? U V ∧ subseteq_operator ? V U)
35 | simplify; intros; split; intros 2; assumption
36 | simplify; intros (x y H); cases H; split; assumption
37 | simplify; intros (x y z H H1); cases H; cases H1; split;
38 apply transitive_subseteq_operator; [1,4: apply y ]
42 interpretation "powerset" 'powerset A = (powerset_setoid A).
44 interpretation "subset construction" 'subset \eta.x =
45 (mk_powerset_carrier _ (mk_unary_morphism _ CPROP x _)).
47 definition mem: ∀A. binary_morphism1 A (Ω \sup A) CPROP.
50 [ apply (λx,S. mem_operator ? S x)
52 cases b; clear b; cases b'; clear b'; simplify; intros;
53 apply (trans1 ????? (prop_1 ?? u ?? H));
54 cases H1; whd in s s1;
57 | apply s1; assumption]]
60 interpretation "mem" 'mem a S = (fun1 ___ (mem _) a S).
62 definition subseteq: ∀A. binary_morphism1 (Ω \sup A) (Ω \sup A) CPROP.
65 [ apply (λU,V. subseteq_operator ? U V)
69 [ apply (transitive_subseteq_operator ????? s2);
70 apply (transitive_subseteq_operator ???? s1 s4)
71 | apply (transitive_subseteq_operator ????? s3);
72 apply (transitive_subseteq_operator ???? s s4) ]]
75 interpretation "subseteq" 'subseteq U V = (fun1 ___ (subseteq _) U V).
77 definition overlaps: ∀A. binary_morphism1 (Ω \sup A) (Ω \sup A) CPROP.
80 [ apply (λA.λU,V:Ω \sup A.exT2 ? (λx:A.x ∈ U) (λx:A.x ∈ V))
82 constructor 1; intro; cases H2; exists; [1,4: apply w]
83 [ apply (. #‡H); assumption
84 | apply (. #‡H1); assumption
85 | apply (. #‡(H \sup -1)); assumption;
86 | apply (. #‡(H1 \sup -1)); assumption]]
89 interpretation "overlaps" 'overlaps U V = (fun1 ___ (overlaps _) U V).
91 definition intersects:
92 ∀A. binary_morphism1 (powerset_setoid A) (powerset_setoid A) (powerset_setoid A).
95 [ apply (λU,V. {x | x ∈ U ∧ x ∈ V });
96 intros; simplify; apply (.= (H‡#)‡(H‡#)); apply refl1;
98 split; intros 2; simplify in f ⊢ %;
99 [ apply (. (#‡H)‡(#‡H1)); assumption
100 | apply (. (#‡(H \sup -1))‡(#‡(H1 \sup -1))); assumption]]
103 interpretation "intersects" 'intersects U V = (fun1 ___ (intersects _) U V).
106 ∀A. binary_morphism1 (powerset_setoid A) (powerset_setoid A) (powerset_setoid A).
109 [ apply (λU,V. {x | x ∈ U ∨ x ∈ V });
110 intros; simplify; apply (.= (H‡#)‡(H‡#)); apply refl1
112 split; intros 2; simplify in f ⊢ %;
113 [ apply (. (#‡H)‡(#‡H1)); assumption
114 | apply (. (#‡(H \sup -1))‡(#‡(H1 \sup -1))); assumption]]
117 interpretation "union" 'union U V = (fun1 ___ (union _) U V).
119 definition singleton: ∀A:setoid. A → Ω \sup A.
120 apply (λA:setoid.λa:A.{b | a=b});
124 [ apply H | apply (H \sup -1) ]
127 interpretation "singleton" 'singl a = (singleton _ a).