-
Notifications
You must be signed in to change notification settings - Fork 1
/
ordinal_arith.v
1484 lines (1302 loc) · 43.1 KB
/
ordinal_arith.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
Set Implicit Arguments.
Unset Strict Implicit.
Require Export cardinal.
Require Export lci.
Require Export ring.
Module Cardinal_arith.
Export Cardinal.
Lemma singleton_product_l : forall x y, product (singleton x) y = Im (J x) y.
Proof.
ir;ap extensionality;uhg;ir.
apply product_pr in H;ee;nin H.
clpri H0;clpri H1;apply singleton_eq in H0;subst.
ap Im_inc. am.
Im_nin H;subst;ap product_pair_inc;au.
ap singleton_inc.
Qed.
Lemma singleton_product_r : forall x y, product x (singleton y) = Im (fun a => J a y) x.
Proof.
ir;ap extensionality;uhg;ir.
apply product_pr in H;ee;nin H.
clpri H0;clpri H1;apply singleton_eq in H1;subst.
ap Im_show_inc. exists a;ee;au.
Im_nin H;subst;ap product_pair_inc;au.
ap singleton_inc.
Qed.
Definition caPlus c d := card (union2 (product (singleton emptyset) c)
(product (singleton (singleton emptyset)) d)).
Definition caMult c d := card (product c d).
Section NotaSection.
Infix "+" := caPlus.
Infix "*" := caMult.
Lemma caPlus_0eq : forall a b, caPlus a b = emptyset -> (a=emptyset & b=emptyset).
Proof.
ir.
ufi caPlus H.
cp (card_equipotent ((union2 (product (singleton ∅) a) (product (singleton (singleton ∅)) b)))).
rwi H H0. clear H.
nin H0. ee;
ap excluded_middle;uhg;ir;
apply not_empty_nonempty in H0;
nin H0.
apply emptyset_empty with (ev x (J emptyset x0)).
eapply trans_of_map;try am.
ap union2_l;ap product_pair_inc;au.
ap singleton_inc.
apply emptyset_empty with (ev x (J (singleton emptyset) x0)).
eapply trans_of_map;try am.
ap union2_r;ap product_pair_inc;au.
ap singleton_inc.
Qed.
Lemma caPlus_card_proper : forall a a', are_equipotent a a' ->
forall b b', are_equipotent b b' ->
caPlus a b = caPlus a' b'.
Proof.
ir.
ap card_invariant.
ap Equipotent.union2_equipotent;try ap Equipotent.product_equipotent;
try ap are_equipotent_refl;au.
ap empty_emptyset;ir.
apply inter2_and in H1;ee. apply product_pr in H1;apply product_pr in H2;ee.
apply singleton_eq in H5;apply singleton_eq in H3.
apply emptyset_empty with emptyset. eapply eq_ind.
ap singleton_inc.
wr H3;au.
ap empty_emptyset;ir.
apply inter2_and in H1;ee. apply product_pr in H1;apply product_pr in H2;ee.
apply singleton_eq in H5;apply singleton_eq in H3.
apply emptyset_empty with emptyset. eapply eq_ind.
ap singleton_inc.
wr H3;au.
Qed.
Lemma caPlus_strict_union : forall x y, inter2 x y = emptyset ->
caPlus x y = card (union2 x y).
Proof.
ir. ap card_invariant.
ap Equipotent.union2_equipotent.
ap empty_emptyset;ir.
apply inter2_and in H0;ee.
apply product_pr in H0;ee;nin H0.
clpri H2;clpri H3.
apply singleton_eq in H2;subst.
apply product_pair_pr in H1;ee.
apply singleton_eq in H0.
apply emptyset_empty with emptyset. eapply eq_ind.
ap singleton_inc. au.
am.
ap are_equipotent_sym. ap trans_equipotent.
exists (J emptyset). uhg;ee;uhg;ir.
ap product_pair_inc;au. ap singleton_inc.
apply pair_eq in H2;au.
apply product_pr in H0;ee;nin H0.
clpri H1;clpri H2;apply singleton_eq in H1;subst.
exists b;ee;au.
ap are_equipotent_sym. ap trans_equipotent.
exists (J (singleton emptyset)). uhg;ee;uhg;ir.
ap product_pair_inc;au. ap singleton_inc.
apply pair_eq in H2;au.
apply product_pr in H0;ee;nin H0.
clpri H1;clpri H2;apply singleton_eq in H1;subst.
exists b;ee;au.
Qed.
Lemma caMult_card_proper : forall a a', are_equipotent a a' ->
forall b b', are_equipotent b b' ->
caMult a b = caMult a' b'.
Proof.
ir. ap card_invariant. ap Equipotent.product_equipotent;am.
Qed.
Lemma caMult_singleton_l : forall x y, caMult (singleton x) y = card y.
Proof.
ir;ap card_invariant.
ap are_equipotent_sym. ap trans_equipotent.
exists (J x). uhg;ee;uhg;ir.
ap product_pair_inc;au. ap singleton_inc.
apply pair_eq in H1;am.
apply product_pr in H;ee;nin H;clpri H0;clpri H1.
apply singleton_eq in H0;subst.
exists b;ee;au.
Qed.
Lemma caPlus_comm : forall c d, c + d = d + c.
Proof.
ir;uf caPlus.
ap card_invariant.
rw are_equipotent_transformation.
exists (fun x => let a := P x in let b := Q x in if eq_dec a (emptyset) then
J ((singleton emptyset)) b else
J (emptyset) b).
assert (Hs : singleton emptyset <> emptyset).
uhg;ir. apply emptyset_empty with emptyset. eapply eq_ind.
ap singleton_inc. am.
uhg;ee;uhg;ir.
apply union2_or in H. nin H; apply product_pr in H;ee;nin H;
clpri H0;clpri H1;clpr.
apply singleton_eq in H0;subst.
rw eq_dec_if. ap union2_r. ap product_pair_inc. ap singleton_inc.
am.
apply singleton_eq in H0;subst.
rw eq_dec_if_not.
ap union2_l. ap product_pair_inc. ap singleton_inc. am.
am.
apply union2_or in H;apply union2_or in H0.
nin H;nin H0;apply product_pr in H;apply product_pr in H0;ee;nin H;nin H0;
clpri H1;clpri H2;clpri H3;clpri H4;clpri H5;clpr;
apply singleton_eq in H4;apply singleton_eq in H2;
subst;repeat rwi eq_dec_if H1.
apply pair_eq in H1. ap uneq. am.
rwi eq_dec_if_not H1. cp Hs;nin H.
apply pair_eq in H1. au.
cp Hs;nin H. rwi eq_dec_if_not H1. apply pair_eq in H1. am.
am.
rwi eq_dec_if_not H1;au. apply pair_eq in H1.
nin Hs;ee;au.
rwi eq_dec_if_not H1;au;rwi eq_dec_if_not H1;au.
apply pair_eq in H1. ee;subst. tv.
apply union2_or in H. nin H;apply product_pr in H;ee;nin H;clpri H0;clpri H1;clpr;
apply singleton_eq in H0;subst.
econstructor. ee. ap union2_r. ap product_pair_inc. ap singleton_inc.
am.
clpr. rw eq_dec_if_not;au.
econstructor. ee. ap union2_l. ap product_pair_inc. ap singleton_inc. am.
clpr. rw eq_dec_if. tv.
Qed.
Lemma caMult_comm : forall c d, c*d=d*c.
Proof.
ir;uf caMult;ap card_invariant.
rw are_equipotent_transformation.
exists (fun x => J (Q x) (P x)).
uhg;ee;uhg;ir.
apply product_pr in H;ee;nin H. clpri H0;clpri H1;clpr.
ap product_pair_inc;au.
apply product_pr in H;ee;nin H. clpri H1;clpri H2;clpri H3.
apply product_pr in H0;ee; nin H. clpri H1.
apply pair_eq in H1. ee;subst;tv.
apply product_pr in H;ee;nin H. clpri H0;clpri H1;clpr.
econstructor;ee. ap product_pair_inc. am. am.
clpr. tv.
Qed.
Lemma caPlus_assoc : forall x y z, caPlus x (caPlus y z) = caPlus (caPlus x y) z.
Proof.
ir. uf caPlus.
assert (Hs : singleton emptyset <> emptyset).
uhg;ir. apply emptyset_empty with emptyset. eapply eq_ind.
ap singleton_inc. am.
ap card_invariant.
rw are_equipotent_transformation.
set (t1:= singleton emptyset). set (t2 := singleton t1).
cp (card_equipotent (union2 (product t1 y) (product t2 z))).
cp (card_equipotent (union2 (product t1 x) (product t2 y))).
apply are_equipotent_sym in H. rwi are_equipotent_transformation H.
rwi are_equipotent_transformation H0.
destruct H as [f H]. destruct H0 as [g H0].
exists (fun p => let a := P p in let b := Q p in
if eq_dec a emptyset then (*b in x -> g (emptyset, b) in card ...*)
J emptyset (g p )
else let c := f b in
if eq_dec (P c) emptyset then J emptyset (g (J (t1) (Q c)))
else c).
uhg;ee;uhg;ir.
apply union2_or in H1;nin H1;apply product_pr in H1;ee;
nin H1;clpri H2;clpri H3;clpr;apply singleton_eq in H2;subst.
rw eq_dec_if.
ap union2_l. ap product_pair_inc. ap singleton_inc.
ap H0. ap union2_l. ap product_pair_inc. ap singleton_inc. am.
rw eq_dec_if_not;au.
apply H in H3. apply union2_or in H3;nin H3;apply product_pr in H1;ee;
nin H1;clpri H2;clpri H3;clpr;apply singleton_eq in H2;subst.
rw eq_dec_if. ap union2_l. ap product_pair_inc. ap singleton_inc. ap H0.
ap union2_r. ap product_pair_inc. ap singleton_inc. am.
rw eq_dec_if_not;au. ap union2_r. ap product_pair_inc. ap singleton_inc.
am.
apply union2_or in H1;nin H1;apply product_pr in H1;ee;
nin H1;clpri H4;clpri H5;apply singleton_eq in H4;subst;
apply union2_or in H2;nin H2;apply product_pr in H1;ee;nin H1;
clpri H4;clpri H2;apply singleton_eq in H2;subst;clpri H3;repeat rwi eq_dec_if H3.
apply pair_eq in H3;ee.
ap H0. ap union2_l. ap product_pair_inc. ap singleton_inc.
am. ap union2_l. ap product_pair_inc. ap singleton_inc.
am.
am.
apply H in H4. apply union2_or in H4;nin H4; apply product_pr in H1;ee;
nin H1;clpri H2;clpri H4.
rwi eq_dec_if_not H3;au.
clpri H3.
apply singleton_eq in H2;subst. rwi eq_dec_if H3.
apply pair_eq in H3;ee.
apply H0 in H2. apply pair_eq in H2;ee. nin Hs;au.
ap union2_l. ap product_pair_inc. ap singleton_inc.
am.
ap union2_r. ap product_pair_inc. ap singleton_inc.
am.
rwi eq_dec_if_not H3;au.
clpri H3. apply singleton_eq in H2;subst.
rwi eq_dec_if_not H3;au. apply pair_eq in H3;ee;nin Hs;au.
rwi eq_dec_if_not H3;au.
apply H in H5.
apply union2_or in H5;nin H5;apply product_pr in H1;ee;nin H1;
clpri H2;clpri H5;apply singleton_eq in H2;subst;clpri H3.
rwi eq_dec_if H3.
apply pair_eq in H3;ee.
apply H0 in H2. apply pair_eq in H2;ee;nin Hs;au.
ap union2_r. ap product_pair_inc. ap singleton_inc.
am. ap union2_l. ap product_pair_inc. ap singleton_inc.
am.
rwi eq_dec_if_not H3;au. apply pair_eq in H3;ee;nin Hs;au.
ap uneq. ap H. am. am.
apply H in H5;apply H in H4.
apply union2_or in H5;nin H5;apply product_pr in H1;ee;nin H1;
clpri H2;clpri H5;apply singleton_eq in H2;subst;
apply union2_or in H4;nin H4;apply product_pr in H1;ee;nin H1;
clpri H2;clpri H4;apply singleton_eq in H2;subst;clpri H3;
repeat rwi eq_dec_if H3.
rwi eq_dec_if_not H3;au. rwi eq_dec_if_not H3;au.
apply pair_eq in H3. ee.
apply H0 in H2;try (ap union2_r;ap product_pair_inc;try (ap singleton_inc);am).
apply pair_eq in H2;ee.
subst. tv.
rwi eq_dec_if_not H3;au. rwi eq_dec_if_not H3;au.
rwi eq_dec_if_not H3;au. apply pair_eq in H3;ee;nin Hs;au.
rwi eq_dec_if_not H3;au. rwi eq_dec_if_not H3;au. rwi eq_dec_if_not H3;au.
apply pair_eq in H3;ee;nin Hs;au.
rwi eq_dec_if_not H3;au. rwi eq_dec_if_not H3;au. rwi eq_dec_if_not H3;au.
rwi eq_dec_if_not H3;au.
apply union2_or in H1;nin H1;apply product_pr in H1;ee;nin H1;
clpri H2;clpri H3;clpr;apply singleton_eq in H2;subst.
apply H0 in H3. nin H3;ee.
subst. apply union2_or in H1;nin H1;apply product_pr in H1;ee;
nin H1;clpri H2;clpri H3;apply singleton_eq in H2;subst;clpr.
exists (J emptyset b). ee.
ap union2_l. ap product_pair_inc. ap singleton_inc.
am.
clpr. rw eq_dec_if. tv.
assert (inc (J emptyset b) (union2 (product t1 y) (product t2 z))).
ap union2_l. ap product_pair_inc. ap singleton_inc.
am.
apply H in H1. nin H1;ee;subst.
exists (J t1 x0);ee.
ap union2_r. ap product_pair_inc. ap singleton_inc.
am.
clpr. rw eq_dec_if_not;au. rw H2;clpr. rw eq_dec_if. tv.
assert (inc (J t1 b) (union2 (product t1 y) (product t2 z))).
ap union2_r. ap product_pair_inc. ap singleton_inc.
am.
apply H in H1;nin H1;ee;subst.
econstructor. ee. ap union2_r. ap product_pair_inc.
ap singleton_inc. am. clpr. rw eq_dec_if_not;au.
rw H2;clpr. rw eq_dec_if_not;au.
Qed.
Lemma caMult_assoc : forall x y z, caMult x (caMult y z) = caMult (caMult x y) z.
Proof.
ir. transitivity (card (product x (product y z))).
ap card_invariant.
ap Equipotent.product_equipotent.
ap are_equipotent_refl.
ap are_equipotent_sym. ap card_equipotent.
etransitivity. ap card_invariant. ap Equipotent.product_equipotent_assoc.
ap card_invariant.
ap Equipotent.product_equipotent.
ap card_equipotent.
ap are_equipotent_refl.
Qed.
Lemma caPlus_cardinal_0_r : forall x, is_cardinal x -> caPlus x emptyset = x.
Proof.
ir. transitivity (card x).
ap card_invariant. rw product_emptyset_r.
ap trans_equipotent.
exists Q. uhg;ee;uhg;ir.
apply union2_or in H0;nin H0. apply product_pr in H0;ee. am.
edestruct emptyset_empty;am.
apply union2_or in H0;apply union2_or in H1.
nin H0;nin H1;try (edestruct emptyset_empty;am).
apply product_pr in H0;apply product_pr in H1. ee.
nin H0;nin H1. clpri H3;clpri H4;clpri H5;clpri H6.
clpri H2. apply singleton_eq in H5;apply singleton_eq in H3;subst;tv.
exists (J emptyset y). ee.
ap union2_l. ap product_pair_inc. ap singleton_inc. am.
clpr;tv.
symmetry;ap cardinal_eq_card. am.
ap are_equipotent_refl.
Qed.
Lemma caPlus_N_0_r : forall x, inc x nNum -> caPlus x emptyset = x.
Proof.
ir. ap caPlus_cardinal_0_r. wr nNum_card. ap card_is_cardinal. am.
Qed.
Lemma caPlus_N_S : forall x, inc x nNum -> forall y, inc y nNum ->
caPlus x (oS y) = oS (caPlus x y).
Proof.
pose (p := fun x y => inc (caPlus x y) nNum -> caPlus x (oS y) = oS (caPlus x y)).
assert (forall x n, inc x nNum -> inc n nNum -> p x n).
uf p;ir.
symmetry. ap cardinal_eq_card. eapply eq_ind. ap card_is_cardinal.
ap nNum_card. ap oS_nNum;am.
ap are_equipotent_sym. ap trans_equipotent.
cp (card_equipotent (union2 (product (singleton ∅) x)
(product (singleton (singleton ∅)) n))).
apply are_equipotent_sym in H2.
rwi are_equipotent_transformation H2.
destruct H2 as [f H2].
cp product_pair_inc;cp singleton_inc.
assert (singleton emptyset <> emptyset).
uhg;ir;apply emptyset_empty with emptyset.
eapply eq_ind. ap singleton_inc. am.
assert (forall a, inc a (x+n) -> a<>x+n).
ir. ap ordinal_inc_neq. ap card_ordinal. am.
assert (forall a, a=x+n -> ~ inc a (x+n)).
uhg;ir;subst. eapply H6. am. tv.
exists (fun a => if eq_dec a (x+n) then J (singleton emptyset) n
else f a).
uhg;ee;uhg;ir.
rwi oS_inc H8;nin H8.
rw eq_dec_if_not. apply H2 in H8.
apply union2_or in H8. nin H8.
ap union2_l;am. ap union2_r. apply product_pr in H8.
ee. ap product_inc. am. am. rw oS_inc;au.
ap ordinal_inc_neq. ap card_ordinal. am.
subst. rw eq_dec_if. ap union2_r.
ap product_pair_inc;au. rw oS_inc;au.
rwi oS_inc H8;rwi oS_inc H9.
nin H8;nin H9;subst;repeat rwi eq_dec_if H10.
rwi eq_dec_if_not H10;au. rwi eq_dec_if_not H10;au.
ap H2;au.
subst. rwi eq_dec_if_not H10;au.
apply H2 in H8.
apply union2_or in H8. rwi H10 H8.
nin H8;apply product_pair_pr in H8;ee.
apply singleton_eq in H8. nin H5;am.
edestruct ordinal_inc_neq. ap nNum_ordinal.
ap H0. am. tv.
rwi eq_dec_if_not H10;au.
apply H2 in H9. apply union2_or in H9.
wri H10 H9. nin H9;apply product_pair_pr in H8;ee.
nin H5;ap singleton_eq;am.
edestruct ordinal_inc_neq. ap nNum_ordinal.
ap H0. am. tv.
tv.
apply union2_or in H8. nin H8;apply product_pr in H8;ee;
nin H8;clpri H9;clpri H10;apply singleton_eq in H9;subst.
assert (inc (J emptyset b) (union2 (product (singleton ∅) x)
(product (singleton (singleton ∅)) n))).
ap union2_l;au.
apply H2 in H8.
nin H8. ee.
exists x0;ee.
rw oS_inc. left;am.
rw eq_dec_if_not;au.
rwi oS_inc H10. nin H10.
assert (inc (J (singleton emptyset) b) (union2 (product (singleton ∅) x)
(product (singleton (singleton ∅)) n))).
ap union2_r;au.
apply H2 in H9.
nin H9. ee.
exists x0;ee.
rw oS_inc. left;am.
rw eq_dec_if_not;au.
subst.
exists (x+n). ee. rw oS_inc;au.
rw eq_dec_if;au.
pose (p' x n := inc (x+n) nNum).
assert (forall x, inc x nNum -> forall n, inc n nNum -> p' x n).
intros x Hx. ap nNum_rect;uf p';ir.
rw caPlus_N_0_r;am.
ufi p H. rw H. ap oS_nNum. am.
am. am. am.
ir;ap H;try am.
ap H0;am.
Qed.
Lemma caPlus_N_lci : is_lci caPlus nNum.
Proof.
uhg. intros x Hx.
ap nNum_rect.
rw caPlus_N_0_r;am.
ir. rw caPlus_N_S;au. ap oS_nNum;am.
Qed.
Lemma caPlus_N_comm : commutative caPlus nNum.
Proof.
uhg;ir;ap caPlus_comm.
Qed.
Lemma caPlus_N_assoc : associative caPlus nNum.
Proof.
uhg;ir;ap caPlus_assoc.
Qed.
Lemma caPlus_N_0_l : forall x, inc x nNum -> caPlus emptyset x = x.
Proof.
ir;etransitivity. ap caPlus_comm.
ap caPlus_N_0_r;am.
Qed.
Lemma caPlus_0_N_neutre : is_neutre caPlus nNum emptyset.
Proof.
uhg;ee. ap emptyset_N. ap caPlus_N_0_r. ap caPlus_N_0_l.
Qed.
Lemma caPlus_N_monoid : is_monoid caPlus nNum emptyset.
Proof.
uhg;ee. ap caPlus_N_lci. ap caPlus_0_N_neutre.
ap caPlus_N_assoc.
Qed.
Lemma caMult_0_r : forall x, caMult x emptyset = emptyset.
Proof.
ir. ap empty_emptyset;ir.
cp (card_equipotent (product x emptyset)).
nin H0. apply H0 in H. nin H;ee.
apply product_pr in H;ee;eapply emptyset_empty;am.
Qed.
Lemma caMult_0_l : forall x, caMult emptyset x = emptyset.
Proof.
ir. rw caMult_comm. ap caMult_0_r.
Qed.
Lemma caMult_singleton_r : forall a x, caMult a (singleton x) = card a.
Proof.
ir. ap card_invariant. ap are_equipotent_sym. ap trans_equipotent.
exists (fun y => J y x).
uhg;ee;uhg;ir. ap product_pair_inc. am. ap singleton_inc.
apply pair_eq in H1;ee;au.
apply product_pr in H;ee;nin H;clpri H0;clpri H1.
apply singleton_eq in H1;subst.
exists a0;ee. am. tv.
Qed.
Lemma caMult_N_o1_r : forall n, inc n nNum -> caMult n o1 = n.
Proof.
ir. rw o1_rw. rw caMult_singleton_r. ap nNum_card. am.
Qed.
Lemma caMult_N_S : forall a, inc a nNum -> forall b, inc b nNum ->
caMult a (oS b) = caPlus (caMult a b) a.
Proof.
pose (p := fun x y => inc (caMult x y) nNum -> caMult x (oS y) = caPlus (caMult x y) x).
assert (forall a, inc a nNum -> forall b, inc b nNum -> p a b).
uf p;ir.
ap card_invariant.
ap trans_equipotent.
cp (card_equipotent (product a b)).
rwi are_equipotent_transformation H2.
destruct H2 as [f H2].
assert (singleton emptyset <> emptyset).
uhg;ir;apply emptyset_empty with emptyset.
eapply eq_ind. ap singleton_inc. am.
exists (fun p => let pb := Q p in
if eq_dec pb b then J (singleton emptyset) (P p)
else J emptyset (f p)).
uhg;ee;uhg;ir.
apply product_pr in H4;ee;nin H4.
clpri H5;clpri H6. rwi oS_inc H6.
clpr. nin H6.
rw eq_dec_if_not. ap union2_l. ap product_pair_inc.
ap singleton_inc. ap H2. ap product_pair_inc;am.
ap ordinal_inc_neq;try am. ap nNum_ordinal;am.
subst. rw eq_dec_if. ap union2_r.
ap product_pair_inc. ap singleton_inc. am.
apply product_pr in H4;apply product_pr in H5;ee;nin H4;nin H5.
clpri H9;clpri H10;clpri H7;clpri H8.
clpri H6.
rwi oS_inc H10;rwi oS_inc H8;nin H10;nin H8;subst;repeat rwi eq_dec_if H6.
rwi eq_dec_if_not H6. rwi eq_dec_if_not H6. apply pair_eq in H6;ee.
apply H2;au. ap product_pair_inc;am. ap product_pair_inc;am.
ap ordinal_inc_neq;au. ap nNum_ordinal;am.
ap ordinal_inc_neq;au. ap nNum_ordinal;am.
rwi eq_dec_if_not H6. apply pair_eq in H6;ee.
nin H3;au.
ap ordinal_inc_neq;au. ap nNum_ordinal;am.
rwi eq_dec_if_not H6. apply pair_eq in H6;ee. nin H3;au.
ap ordinal_inc_neq;au. ap nNum_ordinal;am.
apply pair_eq in H6;ee.
subst. tv.
apply union2_or in H4;nin H4;
apply product_pr in H4;ee;nin H4;
clpri H5;clpri H6;apply singleton_eq in H5;subst.
cp H6. apply H2 in H4. nin H4;ee.
subst. apply product_pr in H4;ee;nin H4.
clpri H5;clpri H7.
exists (J a0 b0);ee. ap product_pair_inc. am. rw oS_inc;au.
clpr. rw eq_dec_if_not. tv.
ap ordinal_inc_neq;au. ap nNum_ordinal;am.
exists (J b0 b);ee. ap product_pair_inc;au.
rw oS_inc;au. clpr. rw eq_dec_if;au.
assert (forall a, inc a nNum -> forall b, inc b nNum -> inc (caMult a b) nNum).
intros a Ha. ap nNum_rect;ir.
rw caMult_0_r. ap emptyset_N.
rw H. ap caPlus_N_lci. am. am. am. am. am.
ir;ap H;au.
Qed.
Lemma caMult_N_lci : is_lci caMult nNum.
Proof.
uhg;intros a Ha;ap nNum_rect;ir.
rw caMult_0_r. ap emptyset_N.
rw caMult_N_S. ap caPlus_N_lci. am. am. am. am.
Qed.
Lemma caMult_N_comm : commutative caMult nNum.
Proof.
uhg;ir;ap caMult_comm.
Qed.
Lemma caMult_N_assoc : associative caMult nNum.
Proof.
uhg;ir;ap caMult_assoc.
Qed.
Lemma caMult_1_neutre : is_neutre caMult nNum o1.
Proof.
uhg;ee. ap o1_N. ap caMult_N_o1_r.
ir. rw caMult_comm. ap caMult_N_o1_r;am.
Qed.
Lemma caMult_N_monoid : is_monoid caMult nNum o1.
Proof.
uhg;ee. ap caMult_N_lci.
ap caMult_1_neutre. ap caMult_N_assoc.
Qed.
Lemma caMult_distrib_l : forall a b c, caMult a (caPlus b c) = caPlus
(caMult a b) (caMult a c).
Proof.
ir. transitivity (caPlus (product a b) (product a c)). ap card_invariant.
ap trans_equipotent.
assert (singleton emptyset <> emptyset).
uhg;ir;apply emptyset_empty with emptyset.
eapply eq_ind. ap singleton_inc. am.
cp (card_equipotent (union2 (product (singleton emptyset) b)
(product (singleton (singleton emptyset)) c))).
replace ((card
(union2 (product (singleton ∅) b)
(product (singleton (singleton ∅)) c)))) with (b+c) in H0.
Focus 2. tv.
apply are_equipotent_sym in H0.
rwi are_equipotent_transformation H0.
destruct H0 as [f H0].
pose (g := fun p => let pfp := P (f (Q p)) in let qfp := Q (f (Q p)) in
if eq_dec pfp emptyset then J emptyset (J (P p) (qfp))
else J (singleton emptyset) (J (P p) (qfp))).
assert (forall p, inc p (product a (b+c)) -> (Q (g p) = J (P p) (Q (f (Q p))) &
inc (g p) (union2 (product (singleton ∅) (product a b))
(product (singleton (singleton ∅)) (product a c))))).
ir.
ap PropGuard_use. uf g;ee. apply product_pr in H1;ee;nin H1. clpri H2;clpri H3.
clpr. apply H0 in H3. apply union2_or in H3;nin H3;
apply product_pr in H1;ee;nin H1;clpri H3;clpri H4;apply singleton_eq in H3;
ap Pguard;ee;subst;clpr.
rw eq_dec_if. clpr. tv.
rw eq_dec_if. ap union2_l. ap product_pair_inc.
ap singleton_inc. ap product_pair_inc;am.
rw eq_dec_if_not. clpr. tv.
am.
rw eq_dec_if_not;au. ap union2_r.
repeat ap product_pair_inc;au. ap singleton_inc.
exists g.
uhg;ee;uhg;ir.
ap H1. am.
cp (uneq Q H4). rwi (and_P (H1 x H2)) H5.
rwi (and_P (H1 y H3)) H5.
apply pair_eq in H5. ee.
apply product_pr in H2;ee;apply product_pr in H3;ee;nin H2;nin H3;
clpri H7;clpri H8;clpri H9;clpri H10;clpri H4;clpri H5;clpri H6.
cp H8;cp H10;apply H0 in H8. apply H0 in H10.
subst.
ap uneq. apply union2_or in H8;apply union2_or in H10.
clear H1. ufi g H4;clpri H4.
ap H0. am. am.
nin H8;nin H10;apply product_pr in H1;apply product_pr in H5;ee;
nin H1;nin H5;clpri H11;clpri H12;clpri H6;clpri H10;clpri H8;
apply singleton_eq in H11;apply singleton_eq in H8;subst;clpri H4
;repeat rwi eq_dec_if H4;au.
rwi eq_dec_if_not H4;au. apply pair_eq in H4;ee;nin H;au.
rwi eq_dec_if_not H4;au. apply pair_eq in H4;ee;nin H;au.
clear H1.
apply union2_or in H2;nin H2;apply product_pr in H1;ee;nin H1;
clpri H2;clpri H3;apply singleton_eq in H2;subst;clpr.
assert (inc (J emptyset (Q b0)) (union2 (product (singleton ∅) b)
(product (singleton (singleton ∅)) c))).
ap union2_l;ap product_pair_inc. ap singleton_inc. eapply product_pr. am.
apply H0 in H1. nin H1;ee;subst.
uf g. apply product_pr in H3;ee;nin H3.
clpri H4;clpri H5;clpri H2. exists (J a0 x).
ee. ap product_pair_inc;am.
clpr. rw H2;clpr. rw eq_dec_if. tv.
assert (inc (J (singleton emptyset) (Q b0)) (union2 (product (singleton ∅) b)
(product (singleton (singleton ∅)) c))).
ap union2_r;ap product_pair_inc. ap singleton_inc. eapply product_pr. am.
apply H0 in H1. nin H1;ee;subst.
uf g. apply product_pr in H3;ee;nin H3.
clpri H4;clpri H5;clpri H2. exists (J a0 x).
ee. ap product_pair_inc;am.
clpr. rw H2;clpr. rw eq_dec_if_not;au.
(*other part of transitivity from very beginning*)
ap caPlus_card_proper; ap card_equipotent.
Qed.
Lemma caMult_distrib_r : forall a b c, caMult (caPlus b c) a = caPlus
(caMult b a) (caMult c a).
Proof.
ir. rw caMult_comm. rw caMult_distrib_l. rw caMult_comm. ap uneq.
ap caMult_comm.
Qed.
Lemma caMult_N_distrib : distributes caPlus caMult nNum.
Proof.
uhg. ee. uhg. ir.
ap caMult_distrib_l.
uhg;ir;ap caMult_distrib_r.
Qed.
Lemma ca_N_quasiring : is_quasiring caPlus caMult nNum emptyset o1.
Proof.
uhg;ee.
ap caPlus_N_monoid.
ap caMult_N_monoid.
ap caMult_N_distrib.
ir;ap caMult_0_l.
ir;ap caMult_0_r.
Qed.
Lemma caMult_integral : forall a b, caMult a b = emptyset -> (a=emptyset \/ b=emptyset).
Proof.
ir;apply by_cases with (a=emptyset);ir;au.
right. ap empty_emptyset;ir.
cp (card_equipotent (product a b)).
ufi caMult H. rwi H H2.
nin H2. assert (nonempty a).
ap not_empty_nonempty.
am.
nin H3.
cp (product_pair_inc H3 H1).
apply (bijective_of_map H2) in H4.
eapply emptyset_empty;am.
Qed.
End NotaSection.
End Cardinal_arith.
Module Ordinal_arith.
Export Ordinal. Export Function.
Export Map.
Import Cardinal_arith.
Definition oPlus b := ordinal_rec_cases b (fun o fo => oS fo)
(fun h => union (range h)).
Lemma oPlus_0_r : forall b, oPlus b emptyset = b.
Proof.
ir. uf oPlus.
rw ordinal_rec_case_0. tv.
Qed.
Lemma oPlus_S : forall b, forall a, is_ordinal a ->
oPlus b (oS a) = oS (oPlus b a).
Proof.
ir. uf oPlus.
rw ordinal_rec_case_S. tv. am.
Qed.
Lemma oPlus_limit : forall a, limit_ordinal a -> forall b,
oPlus b a = union (Im (oPlus b) a).
Proof.
ir.
uf oPlus. rw ordinal_rec_case_limit.
rw range_Im_rw. rw create_domain.
ap uneq. fold (oPlus b).
ap Im_ev_create. ap create_axioms.
am.
Qed.
Lemma oPlus_1_r : forall a, oPlus a (oS emptyset) = oS a.
Proof.
ir. rw oPlus_S. rw oPlus_0_r. tv. ap emptyset_ordinal.
Qed.
Lemma oPlus_inc_compat_r : forall a, forall b c, is_ordinal c -> inc b c ->
inc (oPlus a b) (oPlus a c).
Proof.
intros a b. pose (H := emptyset). (*dummy value*)
pose (p := fun c => inc b c -> inc (oPlus a b) (oPlus a c)).
assert (forall c, is_ordinal c -> p c).
ap ordinal_ind_cases;uf p;ir.
apply emptyset_empty in H0;nin H0.
ufi oS H2. rwi tack_on_inc H2. nin H2.
rw oPlus_S. uf oS;rw tack_on_inc;au. am.
subst. rw oPlus_S;au.
uf oS;rw tack_on_inc;au.
rw (oPlus_limit H0).
cp H2. wri (ordinal_limit_union_self H0) H3. apply union_ex in H3;nin H3;ee.
cp (H1 x H3 H4).
ap union_inc. exists (oPlus a x). ee.
ap Im_inc. am. am.
ap H0.
Qed.
Lemma oPlus_ordinal : forall b, is_ordinal b -> forall a, is_ordinal a ->
is_ordinal (oPlus b a).
Proof.
intros b H. ap ordinal_ind_cases.
rw oPlus_0_r;am.
ir. rw oPlus_S;au. ap ordinal_S;am.
ir. rw oPlus_limit;au.
ap ordinal_union.
ir. apply Im_ex in H2;nin H2;ee;subst;au.
Qed.
Lemma oPlus_sub_compat_l : forall b c, is_ordinal c -> inc b c -> forall a, is_ordinal a ->
sub (oPlus b a) (oPlus c a).
Proof.
intros b c H H0. assert (is_ordinal b).
apply ordinal_in_ordinal with c;am.
ap ordinal_ind_cases.
rw oPlus_0_r. rw oPlus_0_r.
rw ordinal_sub_leq_of;au;uhg;au.
ir.
repeat rw oPlus_S;au.
cp oPlus_ordinal.
uf oS;uhg;intro;repeat rw tack_on_inc;ir.
nin H5. left. au.
subst.
rwi ordinal_sub_leq_of H3;au.
ir. rw oPlus_limit;au.
rw oPlus_limit;au.
uhg;ir.
apply union_ex in H4;nin H4;ee.
apply Im_ex in H4;nin H4;ee;subst.
ap union_inc. exists (oPlus c x0). ee.
ap Im_inc;am.
ap H3. am. am.
Qed.
Lemma oPlus_sub_compat_r : forall a, is_ordinal a -> forall b, is_ordinal b ->
forall c, is_ordinal c -> sub b c ->
sub (oPlus a b) (oPlus a c).
Proof.
ir. rwi ordinal_sub_leq_of H2;au.
rw ordinal_sub_leq_of.
nin H2. left.
ap oPlus_inc_compat_r. am. am.
subst. right;tv.
ap oPlus_ordinal;am. ap oPlus_ordinal;am.
Qed.
Lemma oPlus_reg_r : forall a, is_ordinal a -> forall b c, is_ordinal b -> is_ordinal c ->
oPlus a b = oPlus a c -> b=c.
Proof.
ir.
cp (oPlus_ordinal).
destruct ordinal_inc_eq_inc with b c;au.
destruct ordinal_not_inc_self with (oPlus a b).
au. assert (inc (oPlus a b) (oPlus a c)).
ap oPlus_inc_compat_r;au. wri H2 H5;am.
nin H4. am.
destruct ordinal_not_inc_self with (oPlus a c).
au. assert (inc (oPlus a c) (oPlus a b)).
ap oPlus_inc_compat_r;au. rwi H2 H5;am.
Qed.
Lemma oPlus_assoc : forall a, is_ordinal a -> forall b, is_ordinal b -> forall c, is_ordinal c -> oPlus (oPlus a b) c = oPlus a (oPlus b c).
Proof.
intros a Ha b H. ap ordinal_ind_cases.
rw oPlus_0_r. rw oPlus_0_r. tv.
ir. rw oPlus_S. rw oPlus_S. rw oPlus_S.
rw H1. tv. ap oPlus_ordinal;am. am. am.
ir. rw (oPlus_limit H0).
rw (oPlus_limit H0).
assert (limit_ordinal (⋃ (Im (oPlus b) o))).
uhg;ee. ap ordinal_union.
ir. apply Im_ex in H2;nin H2;ee;subst. ap oPlus_ordinal.
am. apply ordinal_in_ordinal with o;am.
assert (sub (oS emptyset) o).
uhg;ir. ufi oS H2;rwi tack_on_inc H2. nin H2.
apply emptyset_empty in H2;nin H2. subst.
destruct (ordinal_inc_eq_inc) with emptyset o;try am.
ap emptyset_ordinal. nin H2. subst. ap False_rect.
uh H0;ee. nin H2. apply emptyset_empty with x;am.
apply emptyset_empty in H2;nin H2.
exists (oPlus b emptyset).
assert (union o = o). ap ordinal_limit_union_self;am.
assert (inc emptyset o). ap H2;uf oS;rw tack_on_inc;au.
wri H3 H4. apply union_ex in H4;nin H4.
ee.
ap union_inc. econstructor.
ee. ap Im_inc. am. ap oPlus_inc_compat_r. apply ordinal_in_ordinal with o;am.
am.
uhg;ir. nin H2.
ee. assert (inc x (oS x)). uf oS;rw tack_on_inc;au.
wri H3 H4.
apply union_ex in H4. nin H4;ee.
apply Im_ex in H4. nin H4;ee.
subst.
eapply H0. exists x1. assert (is_ordinal x1). apply ordinal_in_ordinal with o;am.
ee. am.
destruct (ordinal_inc_eq_inc) with o (oS x1).
am. ap ordinal_S;am.
ufi oS H7;rwi tack_on_inc H7;nin H7. destruct ordinal_inc_inc_not with o x1;au.
subst. destruct ordinal_not_inc_self with x1;au.
nin H7. am.
assert (inc (oS x) (union (Im (oPlus b) o))).
ap union_inc. econstructor. ee.
ap Im_inc. am. rw oPlus_S;au.
ap ordinal_S_inc_inc. am. ap oPlus_ordinal;au.
am.
rwi H3 H8. destruct ordinal_not_inc_self with (oS x);au.
ap ordinal_S;am.
assert (oPlus b o = union (Im (oPlus b) o)).
ap oPlus_limit. am.
wr oPlus_limit;au. wr oPlus_limit;au.
assert (oPlus (oPlus a b) o = union (Im (oPlus (oPlus a b)) o)).
ap oPlus_limit;au. rw H4.
assert (⋃ (Im (oPlus (oPlus a b)) o) = (union (Im (fun d => oPlus a (oPlus b d)) o))).
ap uneq. ap Im_uneq. ir. au. rw H5.
transitivity (union (Im (oPlus a) (oPlus b o))).
Focus 2. symmetry. ap oPlus_limit. rw H3;am.
assert (forall y, inc y ((Im (fun d : E => oPlus a (oPlus b d)) o)) -> is_ordinal y).
ir. apply Im_ex in H6. nin H6. ee. subst. ap oPlus_ordinal;try am.
ap oPlus_ordinal;try am. apply ordinal_in_ordinal with o;am.
assert (forall y, inc y ( (Im (oPlus a) (oPlus b o))) -> is_ordinal y).
ir. apply Im_ex in H7;nin H7;ee;subst. ap oPlus_ordinal. am.
eapply ordinal_in_ordinal. Focus 2. am. ap oPlus_ordinal;try am. ap H0.
ap extensionality;[idtac | ap ordinal_union_sub;try am;ir].
uhg;ir. apply union_ex in H8;ee;nin H8;ee.
ap union_inc;exists x;ee;try am.
apply Im_ex in H8. nin H8;ee;subst.
ap Im_inc.
rw H3. assert (inc (oS x0) o). ap ordinal_limit_gt. am. am.
ap union_inc;econstructor;ee. ap Im_inc. am. rw oPlus_S. uf oS;rw tack_on_inc;au.
apply ordinal_in_ordinal with o;try am. ap H0.
apply Im_ex in H8. nin H8;ee;subst.
rwi H3 H8. apply union_ex in H8;nin H8;ee.
apply Im_ex in H8;nin H8;ee;subst.
assert (inc (oPlus a x) (oPlus a (oPlus b x1))).
ap oPlus_inc_compat_r. ap oPlus_ordinal. am. apply ordinal_in_ordinal with o.
ap H0. am.
am.
exists (oPlus a (oPlus b x1)). ee.
ap Im_show_inc. exists x1;ee. am. tv.
assert (is_ordinal a). am. assert (is_ordinal b). am.
assert (is_ordinal o). ap H0. assert (is_ordinal x1).
apply ordinal_in_ordinal with o;am.
assert (is_ordinal (oPlus b x1)). ap oPlus_ordinal. am. am.
assert (is_ordinal x). apply ordinal_in_ordinal with (oPlus b x1);am.
cp (oPlus_ordinal). rw ordinal_sub_leq_of;au.
uhg. au.
Qed.
Lemma oPlus_sub_l : forall a, is_ordinal a -> forall b, is_ordinal b ->
sub a (oPlus a b).
Proof.
intros a H. ap ordinal_ind_cases.
rw oPlus_0_r. ap sub_refl.
ir. uhg;ir. rw oPlus_S;au. uf oS;rw tack_on_inc;au.
ir.
rw (oPlus_limit H0).
uhg;ir. ap union_inc.
uh H0;ee. nin H3.
cp (H1 x H3).
cp ( H5 a0 H2).
econstructor. ee. ap Im_inc. am. am.
Qed.
Lemma oPlus_sub_r : forall a, is_ordinal a -> forall b, is_ordinal b ->
sub b (oPlus a b).
Proof.
intros a H. ap ordinal_ind_cases.
ap emptyset_sub_all.
ir.
rw oPlus_S;au. uf oS;uhg;ir. rwi tack_on_inc H2. nin H2.
rw tack_on_inc. left. au.
rw tack_on_inc;subst. rwi ordinal_sub_leq_of H1;au.
ap oPlus_ordinal;au.
ir.
uhg;ir.
assert (inc (oS a0) o). ap ordinal_limit_gt;am.
apply H1 in H3.