-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcardinality.v
1370 lines (1271 loc) · 56.2 KB
/
cardinality.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Require Export ssreflect ssrbool ssrfun naturals Setoid.
Set Warnings "-notation-overridden".
Open Scope set_scope.
Definition equinumerous A B := ∃ f, domain f = A ∧ range f = B ∧ bijective f.
Infix "~" := equinumerous (at level 70) : set_scope.
Theorem cardinality_refl : ∀ A, A ~ A.
Proof.
move=> A.
exists (@functionify A A id).
rewrite /bijective Injective_classification Surjective_classification
functionify_domain functionify_range; (repeat split; auto) =>
[x y H H0 | y H]; [ | exists y ];
rewrite (reify H) ? (reify H0) ? functionify_action //.
Qed.
Theorem cardinality_sym : ∀ A B, A ~ B → B ~ A.
Proof.
move=> A B [f [H [H0 H1]]].
exists (inverse f).
rewrite inverse_domain ? inverse_range; auto using inverse_bijective.
Qed.
Theorem cardinality_trans : ∀ A B C, A ~ B → B ~ C → A ~ C.
Proof.
move=> A B C [f [<- [<- [? ?]]]]
[g [/[dup] ? /Composition_classification [? [? ?]] [<- [*]]]].
exists (g ∘ f).
repeat split; eauto using composition_injective, composition_surjective.
Qed.
Theorem cardinality_is_equivalence :
∀ X, is_equivalence (P X) {z in P X × P X |
proj1 (P X) (P X) z ~ proj2 (P X) (P X) z}.
Proof.
(repeat split) =>
[? ? | ? ? ? ? /Specify_classification [H1] |
? ? ? ? ? ? /Specify_classification [?] /[swap] /Specify_classification [?]];
rewrite Specify_classification ? Product_classification ? proj1_eval
? proj2_eval;
intuition eauto using cardinality_refl, cardinality_sym, cardinality_trans.
Qed.
Add Parametric Relation : set equinumerous
reflexivity proved by (cardinality_refl)
symmetry proved by (cardinality_sym)
transitivity proved by (cardinality_trans) as set_equivalence.
Theorem cardinality_eq : ∀ A B, A = B → A ~ B.
Proof.
now move=> A B ->.
Qed.
Theorem injective_into_image : ∀ f, injective f → domain f ~ image f.
Proof.
move=> f /Injective_classification H.
exists (restriction_Y (Set_is_subset (image f))).
rewrite restriction_Y_domain restriction_Y_range /bijective
Injective_classification Surjective_classification
restriction_Y_domain restriction_Y_range ? restriction_Y_action.
(repeat split; auto) =>
[x y /[dup] H0 /H /[swap] /[dup] H1 /[swap] /[apply] |
y /Specify_classification [H0 [x [H1 H2]]]]; [ | exists x ];
rewrite ? restriction_Y_action //.
Qed.
Theorem injection_restriction :
∀ f S, injective f → S ⊂ domain f → S ~ push_forward f S.
Proof.
move=> f S /Injective_classification H H0.
have: image (restriction f S) ⊂ push_forward f S =>
[y /Specify_classification /and_comm [[x]] | H1].
{ rewrite restriction_domain restriction_range => /[dup] [[?]].
rewrite -restriction_action // => [? [? ?] ?].
apply Specify_classification, conj; eauto. }
exists (restriction_Y H1).
rewrite restriction_Y_domain restriction_Y_range restriction_domain
/bijective Injective_classification Surjective_classification.
(repeat split; auto; first by apply /Intersection_subset) => [x y | y].
- rewrite restriction_Y_domain restriction_domain =>
/[dup] H2 /[dup] /Intersection_right H3 /[swap]
/[dup] H4 /[dup] /Intersection_right H5.
rewrite ? restriction_Y_action ? restriction_domain
-? restriction_action; auto.
- rewrite restriction_Y_range restriction_Y_domain restriction_domain
Specify_classification => [[H2 [x [H3 H4]]]].
exists x.
rewrite restriction_Y_action ? restriction_domain -? restriction_action //.
Qed.
Theorem cardinality_of_subsets_of_n :
∀ m (n : N), m ⊊ n → ∃ n', n' < n ∧ m ~ n'.
Proof.
move => /[swap].
elim/Induction =>
[m /proper_subset_inhab [z [/Empty_set_classification H H0]]
| n IH m /[dup] [[H H0]] /proper_subset_inhab [z [H1 H2]]] //.
elim (classic (n ∈ m)).
- elim (function_construction m n (λ x, If x = n then z else x)) =>
[f [H3 [H4 H5]] | a].
+ have: injective f.
{ apply /Injective_classification => x y H6 H7.
rewrite ? H5; repeat case excluded_middle_informative; congruence. }
elim (classic (image f = range f)) => [ | H6].
* exists n.
rewrite -H3 -H4 -H6.
auto using succ_lt, injective_into_image.
* elim (IH (image f)) =>
[n' [H7 H8] | ]; rewrite -? H3 -? H4; repeat split;
eauto 6 using lt_trans, succ_lt, injective_into_image,
cardinality_trans, image_subset_range.
+ case excluded_middle_informative => [-> | ].
* move: H1 H2 => /in_S_succ /Pairwise_union_classification =>
[[H1 | /Singleton_classification ->]] //.
* move: H =>
/[swap] H3 /[apply] /in_S_succ /Pairwise_union_classification
[ | /Singleton_classification] //.
- elim (classic (m = n)) =>
[-> | H3 H4]; eauto using lt_trans, succ_lt, cardinality_refl.
suff: m ⊊ n => [/IH [n' [H5 H6]] | ]; eauto using lt_trans, succ_lt.
split; auto =>
x /[dup] /[swap] /H /in_S_succ /Pairwise_union_classification
[ | /Singleton_classification ->] //.
Qed.
Lemma equivalence_minus_element_singular : ∀ A x y,
x ∈ A → y ∈ A → A \ {x,x} ~ A \ {y,y}.
Proof.
move=> A x y H H0.
case (classic (x = y)) => [-> | H1]; auto using cardinality_refl.
elim (function_construction (A \ {x,x}) (A \ {y,y})
(λ z, If z = y then x else z))
=> [f' [H2 [H3 H4]] | a0 /Complement_classification H2].
- exists f'.
rewrite /bijective Injective_classification Surjective_classification H2 H3.
(repeat split; auto) =>
[x0 y0 /Complement_classification [H5 /Singleton_classification H6]
/Complement_classification [H7 /Singleton_classification H8] |
y0 /Complement_classification [H5 /Singleton_classification H6]].
+ rewrite ? H4 ? Complement_classification ? Singleton_classification //.
case (classic (x = x0)), (classic (x = y0));
repeat case excluded_middle_informative; congruence.
+ case (classic (x = y0)) =>
[<- | ]; [ exists y | exists y0 ];
rewrite H4 Complement_classification Singleton_classification;
repeat split; try case excluded_middle_informative; intuition.
- rewrite Complement_classification Singleton_classification.
case excluded_middle_informative => *; intuition.
Qed.
Theorem equivalence_minus_element : ∀ A B x y,
A ~ B → x ∈ A → y ∈ B → A \ {x,x} ~ B \ {y,y}.
Proof.
move=> A B x y [f [<- [<- [/Injective_classification ?
/Surjective_classification H]]]] ? ?.
enough ((domain f) \ {x,x} ~ (range f) \ {f x, f x});
eauto using cardinality_trans, equivalence_minus_element_singular,
function_maps_domain_to_range.
elim (function_construction ((domain f) \ {x,x})
((range f) \ {f x, f x}) (λ x, f x)) =>
[f' [H0 [H1 H2]] | a /Complement_classification
[H5 /Singleton_classification H6]].
- exists f'.
rewrite /bijective Injective_classification Surjective_classification H0 H1.
(repeat split; auto) =>
[x0 y0 /[dup] ? /Complement_classification [? /Singleton_classification ?]
/[dup] ? /Complement_classification [? /Singleton_classification ?] |
y0 /[dup] ? /Complement_classification
[/[dup] ? /H ? /Singleton_classification H8]]; try rewrite ? H2; auto.
elim (H y0) => [x0 [? ?] | ] //.
exists x0.
rewrite H2 Complement_classification Singleton_classification;
repeat split; auto; move: H8 => /[swap] <- /neq_sym //.
- rewrite Complement_classification Singleton_classification;
auto using function_maps_domain_to_range.
Qed.
Lemma two_sided_inverse_bijective : ∀ A B,
(∃ (f : elts A → elts B) (g : elts B → elts A),
((∀ a : elts A, g (f a) = a) ∧ (∀ b : elts B, f (g b) = b))) → A ~ B.
Proof.
move=> A B [f [g [H H0]]].
exists (functionify f).
rewrite /bijective Injective_classification Surjective_classification
functionify_range functionify_domain.
(repeat split; auto) => [x y H1 H2 | y H1].
- rewrite (reify H1) (reify H2) ? functionify_action
=> /set_proj_injective H3.
f_equal.
rewrite <-H, <-H3, H => //.
- exists (g (mkSet H1)).
rewrite functionify_action H0.
auto using elts_in_set.
Qed.
Theorem two_sided_inverse_bijective_set:
∀ A B, (∃ f g, (∀ a, a ∈ A → (f a ∈ B ∧ g (f a) = a)) ∧
(∀ b, b ∈ B → (g b ∈ A ∧ f (g b) = b))) → A ~ B.
Proof.
move=> A B [f [g [/[dup] H /[swap] /[dup] H0]]].
elim (function_construction A B f) => [f' [<- [<- H1 H2 H3]] | a /H [H1]] //.
exists f'.
rewrite /bijective Injective_classification Surjective_classification.
(repeat split; auto) =>
[x y /[dup] H4 /H3 [H5 H6] /[dup] H7 /H3 [H8 H9] | y /[dup] H4 /H2 [H5 H6]];
[ | exists (g y) ]; rewrite ? H1 // -{2} H6 -{2} H9 => -> //.
Qed.
Theorem proper_subsets_of_natural_numbers : ∀ m (n : N), m ⊊ n → ¬ n ~ m.
Proof.
move /[swap].
elim/Induction => [m /proper_subset_inhab [z [/Empty_set_classification]] |
n IH m /[dup] H [H0 H1] [f [H2 [H3 /[dup] ? [? ?]]]]] //.
have H4: S n \ {n,n} = n.
{ rewrite -S_is_succ /succ complement_disjoint_union ? disjoint_succ //. }
elim (classic (n ∈ m)) => [? | ?].
- (apply /(IH (m \ {n,n})); repeat split) =>
[x /Complement_classification
[/H0 /in_S_succ /Pairwise_union_classification [H5 | H5] ?] | H5 | ] //.
+ contradict H1.
apply Subset_equality_iff, conj; auto =>
x /in_S_succ /Pairwise_union_classification
[ | /Singleton_classification ->] //.
rewrite -H5 => /complement_subset //.
+ rewrite -{1}H4.
apply equivalence_minus_element; rewrite /equinumerous; eauto.
- apply /(IH (m \ {f n, f n})).
+ (apply /(subsetneq_subset_trans _ m); repeat split) =>
[x /Complement_classification [H5 ?] | H5 |
x /[dup] /H0 /in_S_succ /Pairwise_union_classification
[H5 | /Singleton_classification -> ] ] //.
move: (function_maps_domain_to_range f n) (in_succ n).
rewrite H2 in_S_succ H3 -H5 => /[apply].
rewrite Complement_classification Singleton_classification => [[?]] //.
+ rewrite -{1}H4.
apply /equivalence_minus_element; try apply /in_S_succ /in_succ.
* rewrite /equinumerous; eauto.
* move: (function_maps_domain_to_range f n) (in_succ n).
rewrite H2 in_S_succ H3 => /[apply] //.
Qed.
Theorem equiv_proper_subset_ω : ∃ S, S ⊊ ω ∧ S ~ ω.
Proof.
exists (ω \ {0,0}).
(repeat split) =>
[x /Complement_classification [?] | | ]
//; first by move: (elts_in_set 0) =>
/[swap] {2}<- /Complement_classification [_] /Singleton_classification //.
symmetry.
set (f := functionify (λ x, x + 1)).
elim (function_construction ω (ω \ {0,0}) (λ x, f x)) =>
[f' [H [H0 H1]] | a H].
- exists f'.
(repeat split; auto;
rewrite ? Injective_classification ? Surjective_classification) =>
[x y H2 H3 | y H2].
+ move: H H2 H3 -> => H2 H3.
(rewrite ? H1 ? (reify H2) ? (reify H3)
? functionify_action -? (add_comm 1); auto) =>
/set_proj_injective /cancellation_add -> //.
+ move: H0 H2 -> =>
/Complement_classification [H0] /Singleton_classification H2.
exists (mkSet H0 - 1).
(have: (mkSet H0) ≠ 0 by (contradict H2; now inversion H2)) =>
/succ_0 => [[m /[dup] H3]].
rewrite H H1 /f ? functionify_action 1? add_comm ? sub_abab H3;
repeat split; eauto using elts_in_set, one_le_succ.
rewrite -H3 //.
- rewrite /f (reify H) functionify_action Complement_classification
Singleton_classification add_1_r.
split; eauto using elts_in_set => /set_proj_injective /(@eq_sym N) /PA4 //.
Qed.
Definition finite S := ∃ n : N, S ~ n.
Definition infinite S := ¬ finite S.
Theorem naturals_are_finite : ∀ n : N, finite n.
Proof.
rewrite /finite.
eauto using cardinality_refl.
Qed.
Theorem infinite_ω : infinite ω.
Proof.
move: equiv_proper_subset_ω =>
[S [/[dup] /[dup] H [H0 H1] /proper_subset_inhab [z [H2 H3]] H4]]
[n /[dup] H5 [f [H6 [H7 [/Injective_classification H8
/Surjective_classification H9]]]]].
(contradiction
(proper_subsets_of_natural_numbers {x in n | ∃ s, s ∈ S ∧ x = f s} n);
repeat split) => [x /Specify_classification [H10] | H10 | ] //.
- absurd (f z ∈ n).
+ rewrite -H10 Specify_classification => [[H11 [s [H12 /H8]]]] H13.
move: H6 H13 H2 (H12) (H12) -> =>
/[apply] /[swap] /H0 /[swap] /[apply] <- //.
+ move: H6 H7 H2 (function_maps_domain_to_range f z) -> =>
-> /[swap] /[apply] //.
- rewrite -{1}H5 -{1}H4.
elim (function_construction
S {x in n | ∃ s : set, s ∈ S ∧ x = f s} (λ x, f x))
=> [f' [H10 [H11 H12]] | a /[dup] H10].
+ exists f'.
rewrite /bijective Injective_classification Surjective_classification.
(repeat split; auto) => [x y | y].
* move: H10 (H12) -> => /[swap] H13 /[dup] -> // /[swap] H14 -> // /H8.
move: H6 H13 H14 -> => /H0 /[swap] /H0; tauto.
* rewrite H11 => /Specify_classification => [[H13 [s] /[dup] [[H14]] _]].
rewrite -H10 => [[H15 ->]]; eauto.
+ move: H6 H7 (function_maps_domain_to_range f a) -> =>
-> /[swap] /H0 /[swap] /[apply] H11.
apply /Specify_classification /conj; eauto.
Qed.
Theorem natural_cardinality_uniqueness : ∀ m n : N, m ~ n → m = n.
Proof.
move=> m n.
wlog: m n / n < m =>
[x H | /lt_is_subsetneq /proper_subsets_of_natural_numbers] //.
elim (lt_trichotomy m n) => [ | []]; auto using eq_sym, cardinality_sym.
Qed.
Theorem finite_cardinality_uniqueness : ∀ S, finite S → exists ! n : N, S ~ n.
Proof.
move=> S [n H].
exists n.
split; eauto using natural_cardinality_uniqueness,
cardinality_trans, cardinality_sym.
Qed.
Definition finite_cardinality (S : set) : N.
Proof.
elim (excluded_middle_informative (finite S)) =>
[/finite_cardinality_uniqueness
/constructive_definite_description [n H] | H].
- exact n.
- exact 0.
Defined.
Notation " # E " := (finite_cardinality E) (at level 45) : set_scope.
Theorem card_equiv : ∀ x, finite x → x ~ # x.
Proof.
rewrite /finite_cardinality => x H.
(case excluded_middle_informative => /=; try tauto) => H0.
elim constructive_definite_description => //.
Qed.
Theorem card_equiv_l : ∀ S, finite S → # S ~ S.
Proof.
move=> S /card_equiv /cardinality_sym //.
Qed.
Add Morphism finite with signature equinumerous ==> iff as finiteness_equiv.
Proof.
split => [[n]|[n]]; exists n; eauto using cardinality_sym, cardinality_trans.
Qed.
Theorem card_of_natural : ∀ n : N, # n = n.
Proof.
eauto using eq_sym, natural_cardinality_uniqueness, card_equiv,
naturals_are_finite.
Qed.
Add Morphism finite_cardinality with signature
equinumerous ==> eq as finite_cardinality_equiv.
Proof.
rewrite /finite_cardinality => x y H.
(repeat case excluded_middle_informative => /=; auto) =>
[* | ? /[dup] | ? /[dup]]; try rewrite {1}H //.
repeat elim constructive_definite_description.
eauto using natural_cardinality_uniqueness, cardinality_trans,
cardinality_sym.
Qed.
Theorem equivalence_to_card : ∀ S (n : N), S ~ n → # S = n.
Proof.
move=> S n ->.
auto using card_of_natural.
Qed.
Theorem equivalence_to_bijection : ∀ S (n : N),
finite S → # S = n → ∃ f, domain f = S ∧ range f = n ∧ bijective f.
Proof.
move=> S n /card_equiv /[swap] -> [f H].
eauto.
Qed.
Lemma subset_equinumerosity :
∀ A B C D, A ~ B → B ⊂ C → C ~ D → ∃ E, E ⊂ D ∧ A ~ E.
Proof.
move=> A B C D [f [<- [<- [/Injective_classification H
/Surjective_classification H0]]]]
/[swap] [[g [<- [<- [/Injective_classification H1
/Surjective_classification H2]]]]] H3.
exists ({d in range g | ∃ a, a ∈ domain f ∧ g (f a) = d}).
split => [d /Specify_classification [H4] | ] //.
elim (function_construction
(domain f) {d in range g |
∃ a : set, a ∈ domain f ∧ g (f a) = d} (λ x, g (f x)))
=> [h [H4 [H5 H6]] | a H4].
- exists h.
rewrite /bijective Injective_classification Surjective_classification.
(repeat split; auto) => [x y | y].
+ move: H4 H6 -> => /[swap] H6 /[swap] H7 /[dup] -> // -> // /H1 /H H8.
apply /H8; eauto using function_maps_domain_to_range.
+ rewrite H5 Specify_classification H4 => [[H7 [a [H8 <-]]]].
eauto.
- apply Specify_classification, conj;
eauto using function_maps_domain_to_range.
Qed.
Theorem card_empty : # ∅ = 0.
Proof.
rewrite -(card_of_natural 0) //.
Qed.
Theorem empty_card : ∀ S, S ~ 0 → S = ∅.
Proof.
move=> S /cardinality_sym [f] [H [<- [H0 /Surjective_classification]]].
move: H -> => H.
(apply Subset_equality_iff, conj; auto using Empty_set_is_subset) =>
x /H [y [/Empty_set_classification]] //.
Qed.
Lemma finite_subsets_precursor :
∀ E F, finite F → E ⊂ F → ∃ n : N, E ~ n ∧ n ≤ # F.
Proof.
move=>
E F /[dup]
[[n /[dup] /equivalence_to_card /[swap]
[[f [<- [H /[dup] H0 [/Injective_classification H1
/Surjective_classification H2]]]]] H3 H4 H5]].
elim (classic (E = (domain f))) =>
[-> | H6]; eauto using cardinality_sym, card_equiv, le_refl.
(elim (proper_subset_inhab E (domain f)); try split; eauto) => [z [H7 H8]].
elim (cardinality_of_subsets_of_n
{y in # (domain f) | ∃ x, x ∈ E ∧ f x = y} (# domain f)) =>
[n' [H9 [g [H10 [H11 H12]]]] | ].
- exists n'.
split; last by eapply lt_le_trans; eauto using le_refl.
apply /(cardinality_trans _ (domain g)); try now (exists g).
move: (H5) (H10).
elim (function_construction E (domain g) (λ x, f x)) =>
[f' [<- [H13 H14 H15]] | y].
+ exists f'.
rewrite /bijective Injective_classification Surjective_classification.
(repeat split; auto) =>
[x y H17 H18 | y]; try rewrite ? H14 // => /H1 ?; auto.
move: H13 H16 H14 -> =>
-> /[swap] /Specify_classification [?] [?] [?] /[swap] <-; eauto.
+ move: H10 H3 H -> => -> <- H.
apply Specify_classification, conj; eauto.
apply /function_maps_domain_to_range; auto.
- split => [y /Specify_classification [H9 [x [H10]]] | H9] //.
contradict H8.
move: (H7) H H3 H9 =>
/function_maps_domain_to_range /[swap] ->
/[swap] <- /[swap] <-
/Specify_classification [H] [x] /and_comm [/H1] /[swap] ? <-; auto.
Qed.
Theorem subsets_of_finites_are_finite : ∀ E F, finite F → E ⊂ F → finite E.
Proof.
move=> E F H /finite_subsets_precursor [| n [H0 H1]] //.
apply /ex_intro /H0.
Qed.
Theorem infinite_subset : ∀ E F, infinite E → E ⊂ F → infinite F.
Proof.
move=> E F H /subsets_of_finites_are_finite /[apply] //.
Qed.
Theorem finite_subsets : ∀ E F, finite F → E ⊂ F → # E ≤ # F.
Proof.
move=> E F /[swap] /finite_subsets_precursor /[apply]
[[n [/equivalence_to_card <-]]] //.
Qed.
Theorem naturals_sum_diff : ∀ n m, (m + n) \ m ~ n.
Proof.
elim/Induction =>
[m | n /[swap] m /(_ m) [f [H [H0 [/Injective_classification H1
/Surjective_classification H2]]]]];
rewrite ? add_0_r ? add_succ_r -? S_is_succ;
first by apply cardinality_eq, Complement_subset, Set_is_subset.
have H3: ∀ z, z ∈ succ (m + n) \ m → z ≠ m + n → z ∈ domain f => [z | ].
{ rewrite H ? Complement_classification =>
[[/Pairwise_union_classification
[H3 | /Singleton_classification] H4] H5] //. }
elim (function_construction
(succ (m + n) \ m) (succ n) (λ x, If x = m + n then n else f x))
=> [f' [H4 [H5 H6]] | a H4].
- exists f'.
move: (H4) (H3) <- => H7.
rewrite /bijective Injective_classification Surjective_classification H5.
(repeat split; auto) => [x y H8 H9 | y /Pairwise_union_classification
[ | /Singleton_classification ->]].
+ rewrite ? H6; try congruence.
repeat case excluded_middle_informative; try congruence; auto
=> H10 H11 H12; contradiction (no_quines n);
[ rewrite {1}H12 -H0 | rewrite -{1}H12 -H0 ];
auto using function_maps_domain_to_range.
+ rewrite -H0 => /H2 [x].
rewrite H H4 =>
[[/Complement_classification [/[dup] H8 /subset_succ H9] H10 H11]].
exists x.
rewrite ? H6 ? Complement_classification //.
repeat split => //.
case excluded_middle_informative => //.
move: H8 => /[swap] -> /no_quines //.
+ exists (m+n).
have H8: m+n ∈ domain f'.
{ rewrite H4 Complement_classification.
split.
- apply /Pairwise_union_classification /or_intror.
rewrite Singleton_classification //.
- elim (classic (n = 0)) =>
[-> | ]; rewrite ? add_0_r -? lt_is_in -? le_not_gt 1 ? add_comm;
auto using le_refl, le_add_l. }
rewrite H6 -? H4; (repeat split) => //.
case excluded_middle_informative => //.
- case excluded_middle_informative; auto using in_succ => H5.
rewrite -H0.
apply /subset_succ /function_maps_domain_to_range /H3 => //.
Qed.
Theorem finite_union_equinumerosity : ∀ E F,
finite E → finite F → E ∩ F = ∅ → (E ∪ F) ~ # E + # F.
Proof.
move=> E F [n /[dup] /equivalence_to_card -> /cardinality_sym]
/[swap] [[m /[dup] /equivalence_to_card -> /cardinality_sym]].
move: (naturals_sum_diff m n)
=> /[dup] H1 [h [H11 [H12 [/Injective_classification
H13 /Surjective_classification H14]]]]
/[dup] H0 [g [H7 [H8 [/Injective_classification
H9 /Surjective_classification H10]]]]
/[dup] H [f [H3 [H4 [/Injective_classification H5
/Surjective_classification H6]]]] H2.
elim (function_construction
(n + m) (E ∪ F) (λ x, If x ∈ n then f x else g (h x))) =>
[f' [/[dup] H15 <- [H16 H17]] | a].
- symmetry.
exists f'.
rewrite /bijective Injective_classification Surjective_classification.
(repeat split; auto) => [x y H18 H19 | y].
+ rewrite ? H17 //.
wlog: x y H17 H18 H19 / x ∈ n ∧ y ∉ n => [x0 | ].
* (repeat case excluded_middle_informative)
=> *; [ apply H5 | apply x0 | apply eq_sym, x0 | ];
repeat case excluded_middle_informative; intuition try congruence.
apply H13; try rewrite H11 Complement_classification -H15 //.
apply H9; auto; rewrite H7 -H12 ; apply function_maps_domain_to_range;
rewrite H11 Complement_classification -H15 //.
* (repeat case excluded_middle_informative; try tauto) => H20 H21 _ H22.
contradiction (Empty_set_classification (f x)).
rewrite -H2 -H4 -H8 Pairwise_intersection_classification.
move: H3 H21 <- => /function_maps_domain_to_range.
(have: y ∈ domain h by rewrite H11 -H15 Complement_classification //)
=> /function_maps_domain_to_range.
move: H12 H7 H22 -> => <- {3}-> /function_maps_domain_to_range //.
+ rewrite H16 -H4 -H8 Pairwise_union_classification =>
[[/H6 [x] /and_comm [<-] /[dup] /[dup] | /H10 [z [H18 H19]]]].
* have: n ⊂ n + m by apply le_is_subset, le_add.
move: H3 H15 H17 => {1 2}-> => -> H17 /[apply].
repeat esplit; eauto.
rewrite H17 //.
case excluded_middle_informative => //.
* move: H7 H12 H18 H11 H15 H17 -> => <- /H14 /[swap] -> /[swap] -> =>
[[x [/[dup] H20 /Complement_classification [H21 H22] H23]] H17].
repeat esplit; eauto.
rewrite H17 //.
case excluded_middle_informative; intuition congruence.
- case excluded_middle_informative =>
H15 H16; apply /Pairwise_union_classification.
+ move: H3 H15 H4 <- => /function_maps_domain_to_range /[swap] ->; auto.
+ (have: a ∈ domain h by rewrite H11 Complement_classification) =>
/function_maps_domain_to_range.
move: H12 H7 H8 -> =>
<- /[swap] /function_maps_domain_to_range /[swap] ->; auto.
Qed.
Theorem finite_union_cardinality : ∀ E F,
finite E → finite F → E ∩ F = ∅ → # (E ∪ F) = # E + # F.
Proof.
eauto using equivalence_to_card, finite_union_equinumerosity.
Qed.
Theorem finite_disjoint_unions_are_finite : ∀ E F,
finite E → finite F → E ∩ F = ∅ → finite (E ∪ F).
Proof.
move=> E F H H0 H1.
apply /ex_intro /finite_union_equinumerosity => //.
Qed.
Theorem singleton_card_1 : ∀ x, {x,x} ~ 1.
Proof.
move=> x.
elim (function_construction {x,x} 1 (λ x, 0)) =>
[f [H [H0 H1]] | a H]; last by apply /in_succ.
(eapply ex_intro, conj, conj, conj; eauto;
rewrite ? Injective_classification ? Surjective_classification) => [a b | y].
- move: H -> => /Singleton_classification -> /Singleton_classification -> //.
- rewrite H H0 /one -in_S_succ => /Pairwise_union_classification =>
[[/Empty_set_classification | /Singleton_classification ->]] //.
(have: x ∈ {x,x} by apply /Singleton_classification); eauto.
Qed.
Theorem singletons_are_finite : ∀ x, finite {x,x}.
Proof.
move=> x.
apply /ex_intro /singleton_card_1.
Qed.
Lemma singleton_times_natural_equiv_natural : ∀ n m : N, ({n,n} × m ~ m).
Proof.
move=> n m.
symmetry.
elim (function_construction m ({n,n} × m) (λ x, (n,x))) =>
[f [H [H0 H1]] | a H].
2: { apply /Product_classification.
repeat esplit; rewrite ? Singleton_classification //. }
exists f.
rewrite /bijective ? Injective_classification ? Surjective_classification.
(repeat split; auto) => [x y | y].
- move: H (H1) -> =>
/[swap] ? /[dup] -> // /[swap] ? -> // /Ordered_pair_iff [?] //.
- move: H H0 -> =>
-> /Product_classification
[a [b [/Singleton_classification -> [/[dup] H /H1 H0 ->]]]]; eauto.
Qed.
Lemma singleton_times_natural_is_finite : ∀ n m : N, finite ({n,n} × m).
Proof.
move=> n m.
apply /ex_intro /singleton_times_natural_equiv_natural.
Qed.
Lemma singleton_times_m_card : ∀ n m : N, # ({n,n} × m) = m.
Proof.
move=> n m.
auto using equivalence_to_card, singleton_times_natural_equiv_natural.
Qed.
Theorem natural_products_are_finite : ∀ n m : N, finite (n × m).
Proof.
elim/Induction => [m | n IH m].
- exists 0.
now rewrite Empty_product_left /=.
- rewrite -S_is_succ /succ Product_union_distr_l.
apply /finite_disjoint_unions_are_finite;
auto using singleton_times_natural_is_finite.
rewrite -Product_intersection disjoint_succ Empty_product_left //.
Qed.
Theorem finite_empty : ∀ S, finite S → # S = 0 → S = ∅.
Proof.
move=> S /card_equiv /[swap] -> /empty_card H //.
Qed.
Theorem singleton_card : ∀ n, # {n,n} = 1.
Proof.
move=> n.
apply /equivalence_to_card /singleton_card_1.
Qed.
Theorem natural_prod_card : ∀ n m : N, # (n × m) = (# n) * (# m).
Proof.
elim/Induction =>
[m | n IH m];
rewrite ? Empty_product_left ? card_empty ? card_of_natural ? mul_0_l //
- S_is_succ /succ Product_union_distr_l ? finite_union_cardinality ? IH
-? add_1_r ? mul_distr_r ? singleton_times_m_card
? card_of_natural ? mul_1_l -? Product_intersection
? disjoint_succ ? Empty_product_left;
auto using naturals_are_finite, natural_products_are_finite,
singletons_are_finite, singleton_times_natural_is_finite, disjoint_succ.
Qed.
Theorem Inclusion_Exclusion : ∀ E F,
finite E → finite F → # (E ∪ F) + # (E ∩ F) = # E + # F.
Proof.
move=> E F H H0.
rewrite disjoint_union_complement finite_union_cardinality // -? add_assoc
-1 ? finite_union_cardinality ? complement_union_intersection;
eauto using disjoint_intersection_complement, subsets_of_finites_are_finite,
complement_disjoint_intersection, complement_subset, Intersection_left.
Qed.
Theorem finite_unions_are_finite : ∀ E F, finite E → finite F → finite (E ∪ F).
Proof.
move=> E F H H0.
rewrite disjoint_union_complement.
apply finite_disjoint_unions_are_finite;
eauto using disjoint_intersection_complement, complement_subset,
subsets_of_finites_are_finite.
Qed.
Theorem finite_union_card_bound : ∀ E F, # (E ∪ F) ≤ # E + # F.
Proof.
move=> E F.
case (classic (finite E)), (classic (finite F));
try (by rewrite -Inclusion_Exclusion /le; eauto);
rewrite {1}/finite_cardinality; case excluded_middle_informative
=> *; auto using zero_le; exfalso;
eauto using subsets_of_finites_are_finite, Union_right, Union_left.
Qed.
Add Morphism product with signature
equinumerous ==> equinumerous ==> equinumerous as product_equiv.
Proof.
move=>
E n [f [<- [<- [/Injective_classification H /Surjective_classification H0]]]]
F m [g [<- [<- [/Injective_classification H1
/Surjective_classification H2]]]].
elim (function_construction
(domain f × domain g) (range f × range g)
(λ z, (f (proj1 (domain f) (domain g) z),
g (proj2 (domain f) (domain g) z)))) =>
[h [H3 [H4 H5]] | z /Product_classification [a [b [H3 [H4 ->]]]]].
- exists h.
rewrite /bijective Injective_classification Surjective_classification.
(repeat split; auto) => [x y /[dup] H6 /[swap] /[dup] H7 | z].
+ rewrite ? H5 -? H3 // ? H3 =>
/[swap] /Product_classification [a [b [H8 [H9 ->]]]]
/Product_classification [c [d [H10 [H11 ->]]]].
rewrite ? pro1j_eval ? proj2_eval ? proj1_eval // =>
/Ordered_pair_iff [/H] /[swap] /H1; intuition congruence.
+ rewrite H3 H4 => /Product_classification
[a [b [/H0 [x [H6 <-]] [/H2 [y [H7 <-]]] ->]]].
exists (x,y).
rewrite ? H5 ? Product_classification ? proj1_eval ? proj2_eval;
repeat split; eauto.
- rewrite proj1_eval ? proj2_eval ? Product_classification //.
repeat esplit; eauto using function_maps_domain_to_range.
Qed.
Theorem product_card_comm : ∀ E F, E × F ~ F × E.
Proof.
move=> E F.
eexists; auto using swap_domain, swap_range, swap_bijective.
Qed.
Theorem finite_products_are_finite :
∀ E F, finite E → finite F → finite (E × F).
Proof.
move=> E F [n ->] [m ->].
auto using natural_products_are_finite.
Qed.
Theorem infinite_products_are_infinite :
∀ E F, E ≠ ∅ → infinite F →infinite (E × F).
Proof.
move=> E F /Nonempty_classification [e] /mkSet {}e H.
have /injective_into_image H0: injective (functionify (embed E F e)).
{ rewrite Injective_classification functionify_domain => ? ? H0 H1.
rewrite (reify H0) (reify H1) ? functionify_action /= =>
/Ordered_pair_iff [] //. }
rewrite -(functionify_range (embed E F e)).
eapply infinite_subset, image_subset_range.
rewrite /infinite -H0 functionify_domain //.
Qed.
Theorem infinite_product_card_right :
∀ E F, infinite F → # (E × F) = (# E) * (# F).
Proof.
move=> E F H.
(case (classic (E = ∅)) => [-> | /infinite_products_are_infinite /(_ H)]);
rewrite ? Empty_product_left ? card_empty ? {1 3}/finite_cardinality;
repeat case excluded_middle_informative => //= *; ring.
Qed.
Theorem infinite_product_card_left :
∀ E F, infinite E → # (E × F) = (# E) * (# F).
Proof.
move=> E F H.
rewrite product_card_comm infinite_product_card_right; intuition ring.
Qed.
Theorem product_card : ∀ E F, # (E × F) = (# E) * (# F).
Proof.
move=> E F.
case (classic (finite F)) => [ | /infinite_product_card_right] //.
case (classic (finite E)) => [[n ->] [m ->] | /infinite_product_card_left];
auto using natural_prod_card.
Qed.
Theorem power_union_r : ∀ A B C, B ∩ C = ∅ → A ^ (B ∪ C) ~ A ^ B × A ^ C.
Proof.
have Z:
∀ A B C z, z ∈ A ^ (B ∪ C) → {x in z | proj1 (B ∪ C) A x ∈ B} ∈ A ^ B
=> [A B C z /Specify_classification [H [H0 H1]] | A B C H].
{ rewrite Specify_classification Powerset_classification.
have: {x in z | proj1 (B ∪ C) A x ∈ B} ⊂ B × A =>
[x /Specify_classification
[/H0 /Product_classification [b [a [H2 [H3 ->]]]]] | ];
first by rewrite proj1_eval ? Product_classification; eauto.
(repeat split; auto) => a /[dup] H3 /Union_left =>
/(_ C) /H1 [y [[H4 H5] H6]].
exists y.
repeat split => // =>
[ | x' [H7]]; rewrite Specify_classification ? rewrite proj1_eval;
try apply Union_left; intuition. }
elim (function_construction
(A ^ (B ∪ C)) (A ^ B × A ^ C)
(λ z, ({x in z | proj1 (B ∪ C) A x ∈ B},
{x in z | proj1 (B ∪ C) A x ∈ C}))) =>
[f [/[dup] H0 <- [H1 H2]] | z /[dup]].
2: { rewrite {2 4}Union_comm => *.
eapply Product_classification, ex_intro, ex_intro, conj, conj; eauto. }
(do 2 esplit; repeat split; eauto;
rewrite ? Injective_classification ? Surjective_classification) => [u v | y].
- move: H0 => /[swap] /[dup] H3 /[swap] /[dup] {2}->
/[swap] /Specify_classification [/Powerset_classification H4 _]
/[swap] /[dup] H5 /[swap] -> /Specify_classification
[/Powerset_classification H6 _].
rewrite ? H2 // => /Ordered_pair_iff [H7 H8].
apply Extensionality.
move=> z; wlog: u v z H3 H4 H5 H6 H7 H8 / z ∈ u => [H0 | ].
{ split => *; [ apply (H0 u v z) | apply (H0 v u z) ]; auto. }
(split; try tauto) =>
/H4 /Product_classification
[y [x [/Pairwise_union_classification H9 [H10 H11]]]] =>
{Z H H1 H2 H3 H4 H5 H6}.
wlog: B C y H7 H8 H9 H10 H11 / y ∈ B => [ | /[dup] H /(Union_left _ C) H1].
{ elim H9 => *; [ | rewrite Union_comm in H7 H8 ]; eauto. }
have: z ∈ {x in v | proj1 (B ∪ C) A x ∈ B} =>
[ | /Specify_classification]; last by tauto.
move: H11 H0 H7 -> => H0 <-.
apply Specify_classification.
rewrite proj1_eval //.
- move: H1 -> => /Product_classification
[u [v [/Specify_classification [H3 [H4 H5]]
[/Specify_classification [H6 [H7 H8]] H9]]]].
exists (u ∪ v).
have: u ∪ v ∈ A ^ (B ∪ C).
{ rewrite Specify_classification Powerset_classification.
have: u ∪ v ⊂ (B ∪ C) × A => [z /Pairwise_union_classification H10 | H1].
{ rewrite Product_union_distr_l Pairwise_union_classification.
intuition eauto. }
repeat split; auto => a /Pairwise_union_classification H10.
clear Z f H0 H2 H3 H6 H9 H1.
wlog: A B C a u v H H4 H5 H7 H8 H10 y / a ∈ B =>
[ | {H10} /[dup] H10 /H5 [z [[H0 /[dup] /H4 /Product_in_left
H1 /(Union_left _ v) H2] H3]]].
{ elim H10; [ | rewrite ? (Union_comm B C) ? (Union_comm u v)
1 ? Intersection_comm in H y |-* ]; eauto. }
exists z.
repeat split; auto =>
x' [H6 /Pairwise_union_classification [H9 | /H7 /Product_in_left H9]];
apply H3 => //.
contradiction (Empty_set_classification a).
rewrite -H Pairwise_intersection_classification //. }
move: H0 => /[swap] /[dup] H0 /[swap] <- H1.
split; auto.
rewrite H2 //.
suff H10: (∀ X Y W a b : set, Y ∩ W = ∅ → a ⊂ Y × X → b ⊂ W × X →
a = {x in a ∪ b | proj1 (Y ∪ W) X x ∈ Y}).
{ suff <- : u = {x in u ∪ v | proj1 (B ∪ C) A x ∈ B}; auto.
suff <- : v = {x in u ∪ v | proj1 (B ∪ C) A x ∈ C};
rewrite (Union_comm B C) Union_comm
Intersection_comm in H0 H |-*; auto. }
clear => X Y W a b H H0 H1.
apply Extensionality => z.
split =>
[/[dup] /H0 /Product_classification
[x [y [/[dup] H2 /(Union_left _ W) H3 [H4 ->]]]] /(Union_left _ b) H5 |
/Specify_classification
[/Pairwise_union_classification
[H2 | /H1 /Product_classification
[x [y [/[dup] H2 /(Union_right Y) H3 [H4 ->]]]]] H5]]; auto.
+ rewrite Specify_classification proj1_eval //.
+ contradiction (Empty_set_classification (proj1 (Y ∪ W) X (x, y))).
rewrite -H Pairwise_intersection_classification {2}proj1_eval //.
Qed.
Theorem power_1_r : ∀ m n, m^{n,n} ~ m.
Proof.
move=> m n.
symmetry.
elim (function_construction m (m^{n,n}) (λ x, {(n,x),(n,x)}))
=> [f [H [H0 H1]] | a H].
- exists f.
rewrite /bijective Injective_classification Surjective_classification.
(repeat split; auto) => [x y | y].
+ move: H H1 -> => /[swap] H2 /[swap] H3 /[dup] -> // -> //.
move: (in_singleton (n,x)) =>
/[swap] -> /Singleton_classification /Ordered_pair_iff [] //.
+ move: (H) H0 (in_singleton n) -> => -> =>
/[swap] /Specify_classification [? [H2 /(_ n)]] /[apply] [[a [[? ?] H3]]].
exists a.
rewrite H1; repeat split; auto.
apply Extensionality => z.
split => [/Singleton_classification -> |
/[dup] /H2 /Product_classification
[c [d [/Singleton_classification -> [? ->] ?]]]] //.
apply Singleton_classification, Ordered_pair_iff,
conj, eq_sym, H3, conj => //.
- rewrite Specify_classification Powerset_classification.
have H0: {(n,a),(n,a)} ⊂ {n,n} × m => [x | ].
{ rewrite Singleton_classification Product_classification.
exists n, a.
rewrite Singleton_classification //. }
(repeat split; auto) => a' /Singleton_classification ->.
exists a.
((repeat split; auto) => [ | x']);
rewrite ? Singleton_classification // ? Ordered_pair_iff => [[]] _ [] //.
Qed.
Theorem natural_powers_are_finite : ∀ m n : N, finite (m^n).
Proof.
move /[swap].
elim/Induction
=> *; rewrite ? power_0_r -? S_is_succ /succ ? power_union_r ? power_1_r;
auto using finite_products_are_finite, naturals_are_finite,
disjoint_succ, (naturals_are_finite 1).
Qed.
Theorem natural_powers_card : ∀ m n : N, # (m^n) = ((# m)^(# n))%N.
Proof.
move /[swap].
elim/Induction => [m | n IH m].
- rewrite ? card_of_natural power_0_r pow_0_r -(card_of_natural 1) //.
- rewrite
-S_is_succ /succ power_union_r ? disjoint_succ // finite_union_cardinality
? disjoint_succ // ? singleton_card ? pow_add_r ? pow_1_r
? power_1_r ? product_card ? IH //;
auto using naturals_are_finite, singletons_are_finite,
natural_powers_are_finite.
Qed.
Add Morphism power with signature
equinumerous ==> equinumerous ==> equinumerous as power_equiv.
Proof.
move=> A C [f [<- [<- [/Injective_classification H
/Surjective_classification H0]]]] B D
[g [<- [<- [/Injective_classification H1
/Surjective_classification H2]]]].
elim (function_construction
((domain f)^(domain g)) ((range f)^(range g))
(λ S, {z in (range g) × (range f) |
∃ x, x ∈ S ∧ g (proj1 (domain g) (domain f) x) =
proj1 (range g) (range f) z ∧
f (proj2 (domain g) (domain f) x) =
proj2 (range g) (range f) z})) =>
[h [H3 [H4 H5]] | φ /Specify_classification [H3 [H4 H5]]].
- exists h.
rewrite /bijective Injective_classification Surjective_classification.
(repeat split; auto) => [x y H6 H7 | y].
+ move: H3 H6 H7 H5 (H5) -> =>
/[dup] H3 /Specify_classification [_ [H6 H7]] /[dup] H8
/Specify_classification [_ [H9 H10]] -> // -> // H11.
apply Extensionality => z {A B C D H0 H2 h H3 H4 H8}.
wlog: x y z H H1 H6 H7 H9 H10 H11 / z ∈ x => [H0 | ].
* split => *; [ apply (H0 x y z) | apply (H0 y x z) ]; auto.
* split => [/[dup] /[swap] /H6 /Product_classification
[a [b [H2 [H3 ->]]] H4 {z H0}] | H2] //.
have: (g a, f b) ∈ {z in range g × range f | ∃ x0 : set,
x0 ∈ x ∧ g (proj1 (domain g) (domain f) x0) =
proj1 (range g) (range f) z
∧ f (proj2 (domain g) (domain f) x0) =
proj2 (range g) (range f) z}.
{ apply Specify_classification, conj.
- apply Product_classification.
exists (g a), (f b).
repeat split; auto; now apply function_maps_domain_to_range.
- exists (a, b).
rewrite ? proj1_eval ? proj2_eval;
auto using function_maps_domain_to_range. }
rewrite H11 Specify_classification =>
[[H0 [z [/[dup] /H9 /Product_classification [a' [b' [? [? ->] ?]]]]]]].
rewrite ? proj1_eval ? proj2_eval;
auto using function_maps_domain_to_range =>
[[]] /H1 /[swap] /H; intuition congruence.
+ move: (H3) (H4) -> => -> => /Specify_classification [_ [H6 H7]].
exists {z in domain g × domain f |
(g (proj1 (domain g) (domain f) z),
f (proj2 (domain g) (domain f) z)) ∈ y}.
have H8: {z in domain g × domain f |
(g (proj1 (domain g) (domain f) z),
f (proj2 (domain g) (domain f) z)) ∈ y} ∈ domain f ^ domain g.
{ (apply Specify_classification, conj, conj;
rewrite ? Powerset_classification) =>
[z /Specify_classification [] | z /Specify_classification [] |
z /[dup] H8 /function_maps_domain_to_range /H7
[x [[/H0 [w [] /[swap] <- H9] H11] H12]]] //.
exists w.
(repeat split; auto;
first by rewrite Specify_classification Product_classification
proj1_eval ? proj2_eval; intuition eauto)
=> x' [H13 /Specify_classification [H14]].
rewrite proj1_eval ? proj2_eval //.
auto using function_maps_domain_to_range. }
split; rewrite ? H5; auto.
apply Extensionality => z.
split => [/Specify_classification
[/Product_classification [a [b [H9 [H10 ->]]]]