1
(************************************************************************)
2
(* v * The Coq Proof Assistant / The Coq Development Team *)
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
4
(* \VV/ **************************************************************)
5
(* // * This file is distributed under the terms of the *)
6
(* * GNU Lesser General Public License Version 2.1 *)
7
(************************************************************************)
8
(****************************************************************************)
10
(* Naive Set Theory in Coq *)
13
(* Rocquencourt Sophia-Antipolis *)
22
(* Acknowledgments: This work was started in July 1993 by F. Prost. Thanks *)
23
(* to the Newton Institute for providing an exceptional work environment *)
24
(* in Summer 1995. Several developments by E. Ledinot were an inspiration. *)
25
(****************************************************************************)
27
(*i $Id: Finite_sets_facts.v 9245 2006-10-17 12:53:34Z notin $ i*)
29
Require Export Finite_sets.
30
Require Export Constructive_sets.
31
Require Export Classical_Type.
32
Require Export Classical_sets.
33
Require Export Powerset.
34
Require Export Powerset_facts.
35
Require Export Powerset_Classical_facts.
39
Section Finite_sets_facts.
42
Lemma finite_cardinal :
43
forall X:Ensemble U, Finite U X -> exists n : nat, cardinal U X n.
45
induction 1 as [| A _ [n H]].
46
exists 0; auto with sets.
47
exists (S n); auto with sets.
50
Lemma cardinal_finite :
51
forall (X:Ensemble U) (n:nat), cardinal U X n -> Finite U X.
53
induction 1; auto with sets.
56
Theorem Add_preserves_Finite :
57
forall (X:Ensemble U) (x:U), Finite U X -> Finite U (Add U X x).
60
elim (classic (In U X x)); intro H'0; auto with sets.
61
rewrite (Non_disjoint_union U X x); auto with sets.
64
Theorem Singleton_is_finite : forall x:U, Finite U (Singleton U x).
66
intro x; rewrite <- (Empty_set_zero U (Singleton U x)).
67
change (Finite U (Add U (Empty_set U) x)) in |- *; auto with sets.
70
Theorem Union_preserves_Finite :
71
forall X Y:Ensemble U, Finite U X -> Finite U Y -> Finite U (Union U X Y).
73
intros X Y H; induction H as [|A Fin_A Hind x].
74
rewrite (Empty_set_zero U Y). trivial.
76
rewrite (Union_commutative U (Add U A x) Y).
77
rewrite <- (Union_add U Y A x).
78
rewrite (Union_commutative U Y A).
79
apply Add_preserves_Finite.
80
apply Hind. assumption.
83
Lemma Finite_downward_closed :
85
Finite U A -> forall X:Ensemble U, Included U X A -> Finite U X.
87
intros A H'; elim H'; auto with sets.
89
rewrite (less_than_empty U X H'0); auto with sets.
90
intros; elim Included_Add with U X A0 x; auto with sets.
91
destruct 1 as [A' [H5 H6]].
92
rewrite H5; auto with sets.
95
Lemma Intersection_preserves_finite :
97
Finite U A -> forall X:Ensemble U, Finite U (Intersection U X A).
99
intros A H' X; apply Finite_downward_closed with A; auto with sets.
102
Lemma cardinalO_empty :
103
forall X:Ensemble U, cardinal U X 0 -> X = Empty_set U.
105
intros X H; apply (cardinal_invert U X 0); trivial with sets.
108
Lemma inh_card_gt_O :
109
forall X:Ensemble U, Inhabited U X -> forall n:nat, cardinal U X n -> n > 0.
111
induction 1 as [x H'].
113
elim (gt_O_eq n); auto with sets.
114
intro H'1; generalize H'; generalize H'0.
115
rewrite <- H'1; intro H'2.
116
rewrite (cardinalO_empty X); auto with sets.
120
Lemma card_soustr_1 :
121
forall (X:Ensemble U) (n:nat),
123
forall x:U, In U X x -> cardinal U (Subtract U X x) (pred n).
125
intros X n H'; elim H'.
126
intros x H'0; elim H'0.
128
intros X n H' H'0 x H'1 x0 H'2.
129
elim (classic (In U X x0)).
130
intro H'4; rewrite (add_soustr_xy U X x x0).
131
elim (classic (x = x0)).
133
absurd (In U X x0); auto with sets.
134
rewrite <- H'5; auto with sets.
135
intro H'3; try assumption.
136
cut (S (pred n) = pred (S n)).
137
intro H'5; rewrite <- H'5.
138
apply card_add; auto with sets.
139
red in |- *; intro H'6; elim H'6.
140
intros H'7 H'8; try assumption.
141
elim H'1; auto with sets.
142
unfold pred at 2 in |- *; symmetry in |- *.
143
apply S_pred with (m := 0).
144
change (n > 0) in |- *.
145
apply inh_card_gt_O with (X := X); auto with sets.
146
apply Inhabited_intro with (x := x0); auto with sets.
147
red in |- *; intro H'3.
149
elim H'3; auto with sets.
150
rewrite H'3; auto with sets.
151
elim (classic (x = x0)).
152
intro H'3; rewrite <- H'3.
153
cut (Subtract U (Add U X x) x = X); auto with sets.
154
intro H'4; rewrite H'4; auto with sets.
155
intros H'3 H'4; try assumption.
156
absurd (In U (Add U X x) x0); auto with sets.
157
red in |- *; intro H'5; try exact H'5.
158
lapply (Add_inv U X x x0); tauto.
161
Lemma cardinal_is_functional :
162
forall (X:Ensemble U) (c1:nat),
164
forall (Y:Ensemble U) (c2:nat), cardinal U Y c2 -> X = Y -> c1 = c2.
166
intros X c1 H'; elim H'.
167
intros Y c2 H'0; elim H'0; auto with sets.
168
intros A n H'1 H'2 x H'3 H'5.
169
elim (not_Empty_Add U A x); auto with sets.
171
intros X n H' H'0 x H'1 Y c2 H'2.
174
elim (not_Empty_Add U X x); auto with sets.
176
intros X0 c2 H'2 H'3 x0 H'4 H'5.
177
elim (classic (In U X0 x)).
178
intro H'6; apply f_equal with nat.
179
apply H'0 with (Y := Subtract U (Add U X0 x0) x).
180
elimtype (pred (S c2) = c2); auto with sets.
181
apply card_soustr_1; auto with sets.
183
apply Sub_Add_new; auto with sets.
184
elim (classic (x = x0)).
185
intros H'6 H'7; apply f_equal with nat.
186
apply H'0 with (Y := X0); auto with sets.
187
apply Simplify_add with (x := x); auto with sets.
188
pattern x at 2 in |- *; rewrite H'6; auto with sets.
190
absurd (Add U X x = Add U X0 x0); auto with sets.
191
clear H'0 H' H'3 n H'5 H'4 H'2 H'1 c2.
192
red in |- *; intro H'.
193
lapply (Extension U (Add U X x) (Add U X0 x0)); auto with sets.
196
elim H'; intros H'0 H'1; red in H'0; clear H' H'1.
197
absurd (In U (Add U X0 x0) x); auto with sets.
198
lapply (Add_inv U X0 x0 x); [ intuition | apply (H'0 x); apply Add_intro2 ].
201
Lemma cardinal_Empty : forall m:nat, cardinal U (Empty_set U) m -> 0 = m.
203
intros m Cm; generalize (cardinal_invert U (Empty_set U) m Cm).
204
elim m; auto with sets.
205
intros; elim H0; intros; elim H1; intros; elim H2; intros.
206
elim (not_Empty_Add U x x0 H3).
209
Lemma cardinal_unicity :
210
forall (X:Ensemble U) (n:nat),
211
cardinal U X n -> forall m:nat, cardinal U X m -> n = m.
213
intros; apply cardinal_is_functional with X X; auto with sets.
217
forall (A:Ensemble U) (x:U) (n n':nat),
218
cardinal U A n -> cardinal U (Add U A x) n' -> n' <= S n.
221
elim (classic (In U A x)).
223
rewrite (Non_disjoint_union U A x H'0).
224
intro H'1; cut (n = n').
225
intro E; rewrite E; auto with sets.
226
apply cardinal_unicity with A; auto with sets.
229
intro E; rewrite E; auto with sets.
230
apply cardinal_unicity with (Add U A x); auto with sets.
233
Lemma incl_st_card_lt :
234
forall (X:Ensemble U) (c1:nat),
236
forall (Y:Ensemble U) (c2:nat),
237
cardinal U Y c2 -> Strict_Included U X Y -> c2 > c1.
239
intros X c1 H'; elim H'.
240
intros Y c2 H'0; elim H'0; auto with sets arith.
242
elim (Strict_Included_strict U (Empty_set U)); auto with sets arith.
244
intros X n H' H'0 x H'1 Y c2 H'2.
246
intro H'3; elim (not_SIncl_empty U (Add U X x)); auto with sets arith.
248
intros X0 c2 H'2 H'3 x0 H'4 H'5; elim (classic (In U X0 x)).
249
intro H'6; apply gt_n_S.
250
apply H'0 with (Y := Subtract U (Add U X0 x0) x).
251
elimtype (pred (S c2) = c2); auto with sets arith.
252
apply card_soustr_1; auto with sets arith.
253
apply incl_st_add_soustr; auto with sets arith.
254
elim (classic (x = x0)).
255
intros H'6 H'7; apply gt_n_S.
256
apply H'0 with (Y := X0); auto with sets arith.
257
apply sincl_add_x with (x := x0).
258
rewrite <- H'6; auto with sets arith.
259
pattern x0 at 1 in |- *; rewrite <- H'6; trivial with sets arith.
260
intros H'6 H'7; red in H'5.
261
elim H'5; intros H'8 H'9; try exact H'8; clear H'5.
264
intro H'5; lapply H'5; auto with sets arith.
265
intro H; elim Add_inv with U X0 x0 x; auto with sets arith.
266
intro; absurd (In U X0 x); auto with sets arith.
267
intro; absurd (x = x0); auto with sets arith.
271
forall (X Y:Ensemble U) (n m:nat),
272
cardinal U X n -> cardinal U Y m -> Included U X Y -> n <= m.
274
intros; elim Included_Strict_Included with U X Y; auto with sets arith; intro.
275
cut (m > n); auto with sets arith.
276
apply incl_st_card_lt with (X := X) (Y := Y); auto with sets arith.
277
generalize H0; rewrite <- H2; intro.
279
intro E; rewrite E; auto with sets arith.
280
apply cardinal_unicity with X; auto with sets arith.
284
forall P:Ensemble U -> Prop,
285
(forall X:Ensemble U,
287
(forall Y:Ensemble U, Strict_Included U Y X -> P Y) -> P X) ->
290
intros P H'; try assumption.
291
apply H'; auto with sets.
292
clear H'; auto with sets.
293
intros Y H'; try assumption.
295
elim H'; intros H'0 H'1; try exact H'1; clear H'.
296
lapply (less_than_empty U Y); [ intro H'3; try exact H'3 | assumption ].
297
elim H'1; auto with sets.
300
Lemma Generalized_induction_on_finite_sets :
301
forall P:Ensemble U -> Prop,
302
(forall X:Ensemble U,
304
(forall Y:Ensemble U, Strict_Included U Y X -> P Y) -> P X) ->
305
forall X:Ensemble U, Finite U X -> P X.
308
generalize P H'0; clear H'0 P.
311
apply G_aux; auto with sets.
313
intros A H' H'0 x H'1 P H'3.
314
cut (forall Y:Ensemble U, Included U Y (Add U A x) -> P Y); auto with sets.
317
intros X K H'5 L Y H'6; apply H'3; auto with sets.
318
apply Finite_downward_closed with (A := Add U X x); auto with sets.
320
elim (Strict_inclusion_is_transitive_with_inclusion U Y0 Y (Add U X x));
323
elim (Included_Add U Y0 X x);
325
| intro H'14; elim H'14; intros A' E; elim E; intros H'15 H'16; clear E H'14
326
| idtac ]; auto with sets.
327
elim (Included_Strict_Included U Y0 X); auto with sets.
328
intro H'9; apply H'5 with (Y := Y0); auto with sets.
329
intro H'9; rewrite H'9.
330
apply H'3; auto with sets.
331
intros Y1 H'8; elim H'8.
332
intros H'10 H'11; apply H'5 with (Y := Y1); auto with sets.
333
elim (Included_Strict_Included U A' X); auto with sets.
334
intro H'8; apply H'5 with (Y := A'); auto with sets.
335
rewrite <- H'15; auto with sets.
338
intros H'9 H'10; apply H'10 || elim H'10; try assumption.
341
rewrite <- H'15; auto with sets.
344
End Finite_sets_facts.