]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/lib/basics/sets.ma
(no commit message)
[helm.git] / matita / matita / lib / basics / sets.ma
1 (*
2     ||M||  This file is part of HELM, an Hypertextual, Electronic        
3     ||A||  Library of Mathematics, developed at the Computer Science     
4     ||T||  Department of the University of Bologna, Italy.                     
5     ||I||                                                                 
6     ||T||  
7     ||A||  This file is distributed under the terms of the 
8     \   /  GNU General Public License Version 2        
9      \ /      
10       V_______________________________________________________________ *)
11
12 include "basics/logic.ma".
13
14 (**** a subset of A is just an object of type A→Prop ****)
15
16 definition empty_set ≝ λA:Type[0].λa:A.False.
17 notation "\emptyv" non associative with precedence 90 for @{'empty_set}.
18 interpretation "empty set" 'empty_set = (empty_set ?).
19
20 definition singleton ≝ λA.λx,a:A.x=a.
21 (* notation "{x}" non associative with precedence 90 for @{'sing_lang $x}. *)
22 interpretation "singleton" 'singl x = (singleton ? x).
23
24 definition union : ∀A:Type[0].∀P,Q.A → Prop ≝ λA,P,Q,a.P a ∨ Q a.
25 interpretation "union" 'union a b = (union ? a b).
26
27 definition intersection : ∀A:Type[0].∀P,Q.A→Prop ≝ λA,P,Q,a.P a ∧ Q a.
28 interpretation "intersection" 'intersects a b = (intersection ? a b).
29
30 definition complement ≝ λU:Type[0].λA:U → Prop.λw.¬ A w.
31 interpretation "complement" 'not a = (complement ? a).
32
33 definition substraction := λU:Type[0].λA,B:U → Prop.λw.A w ∧ ¬ B w.
34 interpretation "substraction" 'minus a b = (substraction ? a b).
35
36 definition subset: ∀A:Type[0].∀P,Q:A→Prop.Prop ≝ λA,P,Q.∀a:A.(P a → Q a).
37 interpretation "subset" 'subseteq a b = (subset ? a b).
38
39 (* extensional equality *)
40 definition eqP ≝ λA:Type[0].λP,Q:A → Prop.∀a:A.P a ↔ Q a.
41 (* ≐ is typed as \doteq *)
42 notation "A ≐ B" non associative with precedence 45 for @{'eqP $A $B}.
43 interpretation "extensional equality" 'eqP a b = (eqP ? a b).
44
45 lemma eqP_sym: ∀U.∀A,B:U →Prop. 
46   A ≐ B → B ≐ A.
47 #U #A #B #eqAB #a @iff_sym @eqAB qed.
48  
49 lemma eqP_trans: ∀U.∀A,B,C:U →Prop. 
50   A ≐ B → B ≐ C → A ≐ C.
51 #U #A #B #C #eqAB #eqBC #a @iff_trans // qed.
52
53 lemma eqP_union_r: ∀U.∀A,B,C:U →Prop. 
54   A ≐ C  → A ∪ B ≐ C ∪ B.
55 #U #A #B #C #eqAB #a @iff_or_r @eqAB qed.
56   
57 lemma eqP_union_l: ∀U.∀A,B,C:U →Prop. 
58   B ≐ C  → A ∪ B ≐ A ∪ C.
59 #U #A #B #C #eqBC #a @iff_or_l @eqBC qed.
60   
61 lemma eqP_intersect_r: ∀U.∀A,B,C:U →Prop. 
62   A ≐ C  → A ∩ B ≐ C ∩ B.
63 #U #A #B #C #eqAB #a @iff_and_r @eqAB qed.
64   
65 lemma eqP_intersect_l: ∀U.∀A,B,C:U →Prop. 
66   B ≐ C  → A ∩ B ≐ A ∩ C.
67 #U #A #B #C #eqBC #a @iff_and_l @eqBC qed.
68
69 lemma eqP_substract_r: ∀U.∀A,B,C:U →Prop. 
70   A ≐ C  → A - B ≐ C - B.
71 #U #A #B #C #eqAB #a @iff_and_r @eqAB qed.
72   
73 lemma eqP_substract_l: ∀U.∀A,B,C:U →Prop. 
74   B ≐ C  → A - B ≐ A - C.
75 #U #A #B #C #eqBC #a @iff_and_l /2/ qed.
76
77 (* set equalities *)
78 lemma union_empty_r: ∀U.∀A:U→Prop. 
79   A ∪ ∅ ≐ A.
80 #U #A #w % [* // normalize #abs @False_ind /2/ | /2/]
81 qed.
82
83 lemma union_comm : ∀U.∀A,B:U →Prop. 
84   A ∪ B ≐ B ∪ A.
85 #U #A #B #a % * /2/ qed. 
86
87 lemma union_assoc: ∀U.∀A,B,C:U → Prop. 
88   A ∪ B ∪ C ≐ A ∪ (B ∪ C).
89 #S #A #B #C #w % [* [* /3/ | /3/] | * [/3/ | * /3/]
90 qed.   
91
92 lemma cap_comm : ∀U.∀A,B:U →Prop. 
93   A ∩ B ≐ B ∩ A.
94 #U #A #B #a % * /2/ qed. 
95
96 lemma union_idemp: ∀U.∀A:U →Prop. 
97   A ∪ A ≐ A.
98 #U #A #a % [* // | /2/] qed. 
99
100 lemma cap_idemp: ∀U.∀A:U →Prop. 
101   A ∩ A ≐ A.
102 #U #A #a % [* // | /2/] qed. 
103
104 (*distributivities *)
105
106 lemma distribute_intersect : ∀U.∀A,B,C:U→Prop. 
107   (A ∪ B) ∩ C ≐ (A ∩ C) ∪ (B ∩ C).
108 #U #A #B #C #w % [* * /3/ | * * /3/] 
109 qed.
110   
111 lemma distribute_substract : ∀U.∀A,B,C:U→Prop. 
112   (A ∪ B) - C ≐ (A - C) ∪ (B - C).
113 #U #A #B #C #w % [* * /3/ | * * /3/] 
114 qed.
115
116 (* substraction *)
117 lemma substract_def:∀U.∀A,B:U→Prop. A-B ≐ A ∩ ¬B.
118 #U #A #B #w normalize /2/
119 qed.