-
Notifications
You must be signed in to change notification settings - Fork 1
/
ordinals.v
1856 lines (1676 loc) · 50.9 KB
/
ordinals.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 functions.
Module Ordinal.
Export Order. Import Map.
Definition is_transitive_set x := forall y, inc y x -> sub y x.
Definition is_ordinal o :=
A (is_transitive_set o)
(A (is_strict_order inc o)
(forall x, sub x o -> nonempty x -> ex (is_min o (leq_of inc) x))).
Lemma ordinal_in_ordinal : forall o, is_ordinal o -> forall x, inc x o ->
is_ordinal x.
Proof.
ir.
uh H;uhg;ee.
uhg;uhg;ir.
assert (inc y o). apply H with x. am. am.
assert (inc a o). apply H with y;am.
apply H1 with y. am. am. am.
am. am.
uhg;ee. uhg;ir. ap H1. apply H with x. am. am.
uhg;ir. apply H1 with y. apply H with x;am.
apply H with x;am. am. apply H with x;am. am.
ir.
apply H2 in H4.
nin H4. exists x1.
uhg;ee. uhg;ee;ir.
ap H3. am.
ap H4. am. am.
apply sub_trans with x;au.
Qed.
Lemma ordinal_well_order : forall o, is_ordinal o -> is_well_order (leq_of inc) o.
Proof.
ir;uhg;ee. ap order_of_strict. am.
am.
Qed.
Lemma ordinal_not_inc_self : forall o, is_ordinal o -> ~ inc o o.
Proof.
ir;uhg;ir.
eapply H. am. am.
Qed.
Lemma emptyset_ordinal : is_ordinal emptyset.
Proof.
uhg;ee.
uhg;ir.
apply emptyset_empty in H;nin H.
uhg;ee;uhg;ir.
apply emptyset_empty in H;nin H.
apply emptyset_empty in H;nin H.
ir.
nin H0. apply H in H0. apply emptyset_empty in H0;nin H0.
Qed.
Lemma ordinal_segment : forall a b, is_ordinal a -> is_ordinal b ->
is_initial_segment inc a (inter2 a b).
Proof.
uhg. ir.
ee. uhg;ir;eapply inter2_l;am.
ir.
apply inter2_and in H2;ee.
ap inter2_inc.
uh H;ee. eapply H. am. am.
uh H0;ee. eapply H0. am. am.
Qed.
Lemma ordinal_inc_sub : forall a b, is_ordinal b -> inc a b -> sub a b.
Proof.
intros a b H.
ap H.
Qed.
Lemma transitive_set_union : forall x, (forall y, inc y x -> is_transitive_set y) ->
is_transitive_set (union x).
Proof.
ir. uhg;ir.
uhg;ir.
ap union_inc.
apply union_ex in H0;nin H0;ee.
cp H0. apply H in H3.
uh H3. cp H2. apply H3 in H4.
cp H1. apply H4 in H5.
exists x0;ee. am. am.
Qed.
Lemma ordinal_inc_inc_not : forall a b, is_ordinal a -> inc a b -> inc b a -> False.
Proof.
ir.
assert (is_ordinal b).
eapply ordinal_in_ordinal. am. am.
uh H;ee.
eapply H3. am.
uh H2;ee. eapply H2. am. am.
Qed.
Lemma ordinal_inter2_ordinal : forall a b, is_ordinal a -> is_ordinal b -> is_ordinal (inter2 a b).
Proof.
ir. uhg. ee;try uhg;ir.
uhg;ir. ap inter2_inc. uh H;ee;eapply H. eapply inter2_l. am. am.
uh H0;ee;eapply H0. eapply inter2_r. am. am.
ee. uhg;ir.
ap H. apply inter2_l with b;am.
uhg;ir. uh H;ee.
uh H6;ee. eapply H8.
eapply H. eapply inter2_l. ap H2. am.
Focus 2. ap H3. eapply inter2_l. am.
eapply inter2_l. am.
am.
uh H;ee.
apply H4 in H2.
nin H2. exists x0. uhg;ee.
uhg;ee. ap H1. am.
ir. ap H2. am. am.
uhg;ir;eapply inter2_l;au.
Qed.
Lemma ordinal_inc_lt_of : forall a b, is_ordinal a -> is_ordinal b -> (lt_of sub a b) = inc a b.
Proof.
ir;ap iff_eq;ir.
uh H1;ee.
Focus 2.
uhg;ee. ap H0. am.
uhg;ir;subst. eapply H. am. am.
pose (x := complement b a).
assert (nonempty x). ap excluded_middle;uhg;ir.
ap H2. ap extensionality;au;uhg;ir.
ap excluded_middle;uhg;ir. ap H3. econstructor. uf x;ap Z_inc. am. am.
assert (sub x b). uf x. ap Z_sub.
uh H0;ee.
destruct H6 with x as [y H7]. am. am.
assert (inc y x). am. apply Z_all in H8;ee.
assert (y = a).
ap extensionality;uhg;ir.
assert (~ inc a0 x). uhg;ir.
uh H7;ee;uh H7;ee. destruct H13 with a0. am.
apply ordinal_inc_inc_not with y a0. eapply ordinal_in_ordinal. Focus 2. ap H8.
uhg;ee;am. am. am. subst.
eapply ordinal_not_inc_self. eapply ordinal_in_ordinal. uhg;ee;am. am. am.
eapply use_complement. Focus 2. am.
eapply H0. ap H8. am.
assert (inc a0 b). au.
destruct well_order_total with (leq_of inc) b y a0;au.
uhg;ee. ap order_of_strict. am. am.
nin H12.
ap False_rect. ap H9.
uh H;ee. eapply H. am. am.
subst. ap False_rect.
au.
nin H12;subst;au.
ap False_rect. au.
subst. am.
Qed.
Lemma ordinal_sub_leq_of : forall a b, is_ordinal a -> is_ordinal b -> sub a b = leq_of inc a b.
Proof.
ir.
ap iff_eq;ir. uhg.
apply by_cases with (a=b);ir;au.
wr ordinal_inc_lt_of. uf lt_of. left;ee;am.
am. am.
nin H1. ap H0. am.
subst;ap sub_refl.
Qed.
Lemma ordinal_inc_eq_inc : forall a b, is_ordinal a -> is_ordinal b ->
(inc a b \/ (a=b \/ inc b a)).
Proof.
ir.
pose (d := inter2 a b).
assert (sub d a). uhg;ir;eapply inter2_l;am.
assert (sub d b). uhg;ir;eapply inter2_r;am.
assert (is_ordinal d). uf d. ap ordinal_inter2_ordinal;am.
rwi ordinal_sub_leq_of H1;au.
rwi ordinal_sub_leq_of H2;au.
nin H1;nin H2;subst.
ap False_rect. apply ordinal_not_inc_self with d;au. ap inter2_inc. am. am.
right;right. wr H2. am.
left;wr H1;am.
right;left. wr H1. am.
Qed.
Lemma ordinal_inc_S_all : forall o, is_ordinal o -> inc emptyset (oS o).
Proof.
ir. uf oS;rw tack_on_inc. destruct (ordinal_inc_eq_inc emptyset_ordinal H);au.
nin H0;subst;au.
edestruct emptyset_empty;am.
Qed.
Lemma ordinal_inc_neq : forall o, is_ordinal o -> forall x, inc x o -> x<>o.
Proof.
uhg;ir. subst.
eapply ordinal_not_inc_self;am.
Qed.
Lemma ordinal_sub_sub : forall a b, is_ordinal a -> is_ordinal b ->
(sub a b \/ sub b a).
Proof.
ir.
cp (ordinal_inc_eq_inc H H0). nin H1.
left. ap H0;am.
nin H1;subst. left;ap sub_refl.
right;ap H;am.
Qed.
Lemma ordinal_sub_total_order : forall o, is_ordinal o -> is_total_order sub o.
Proof.
ir. uhg;ee. uhg;ee. uhg;ir;ap sub_refl.
uhg;ir;ap extensionality;am.
uhg;ir;apply sub_trans with y;am.
uhg;ir. ap ordinal_sub_sub;apply ordinal_in_ordinal with o;am.
Qed.
Lemma ordinal_inc_wf : forall x, (forall y, inc y x -> is_ordinal y) -> nonempty x ->
ex (is_min x (leq_of inc) x).
Proof.
ir.
nin H0.
apply by_cases with (inter2 x0 x = emptyset);ir.
exists x0;uhg;ee. uhg;ee.
am. ir. cp (H x0 H0). cp (H x1 H2).
destruct (ordinal_inc_eq_inc H3 H4).
uhg. au. nin H5;subst;au.
uhg;au. uhg. ap False_rect.
eapply emptyset_empty.
wr H1. ap inter2_inc. am. am.
am.
assert (nonempty (inter2 x0 x)).
ap excluded_middle;uhg;ir;ap H1. ap empty_emptyset.
ir. ap H2;econstructor;am.
assert (is_ordinal x0). au.
uh H3;ee. destruct H5 with (inter2 x0 x).
uhg;ir;eapply inter2_l;am. am.
exists x1;uhg;ee. uhg;ee.
eapply inter2_r;am. ir.
uhg;apply by_cases with (x1=x2);ir;au.
left.
destruct ordinal_inc_eq_inc with x0 x2.
au. au.
assert (is_ordinal x2). au.
uh H10;ee. eapply H10.
am. am.
nin H9;subst.
am.
uh H6;ee;uh H6;ee. destruct H11 with x2.
ap inter2_inc;am. am. subst. ap False_rect;au.
eapply inter2_r;am.
Qed.
Lemma ordinal_inc_trans : forall a b c, inc a b -> inc b c -> is_ordinal c -> inc a c.
Proof.
ir.
assert (is_ordinal b).
apply ordinal_in_ordinal with c;am.
assert (is_ordinal a).
apply ordinal_in_ordinal with b;am.
wr ordinal_inc_lt_of;au.
uhg;ee.
wri ordinal_inc_lt_of H;au;wri ordinal_inc_lt_of H0;au.
uh H;uh H0;ee.
apply sub_trans with b;au.
uhg;ir;subst.
apply ordinal_inc_inc_not with b c;au.
Qed.
Lemma transitive_union_ordinal : forall x, is_transitive_set x ->
(forall o, inc o x -> is_ordinal o) -> is_ordinal (union x).
Proof.
ir. uhg;ee.
uhg;ir. uhg;ir.
ap union_inc. apply union_ex in H1;nin H1;ee.
econstructor. ee. am. destruct H0 with x0. am.
ee. eapply H4. am. am.
uhg;ee. uhg;ir.
apply union_ex in H1;nin H1;ee.
destruct H0 with x1;au;ee.
ap H4. am.
uhg;ir. apply union_ex in H1;apply union_ex in H2;apply union_ex in H4.
nin H1;nin H2;nin H4;ee.
assert (is_ordinal x1 & is_ordinal x2 & is_ordinal x3). ee;au. ee.
cp (ordinal_sub_sub H9 H10).
cp (ordinal_sub_sub H9 H11).
cp (ordinal_sub_sub H11 H10).
destruct H12.
destruct H14.
apply H10 with y;au. apply H11 with y;au.
destruct H13. apply H11 with y;au. apply H9 with y;au.
ir.
destruct ordinal_inc_wf with x0.
ir. cp (H1 y H3).
apply union_ex in H4;nin H4;ee.
apply ordinal_in_ordinal with x1;au.
am.
exists x1. uhg;ee.
uhg;ee. ap H1;am.
ir. ap H3. am.
am.
Qed.
Lemma ordinal_S : forall o, is_ordinal o -> is_ordinal (oS o).
Proof.
ir. uf oS.
uhg;ee.
uhg;ir. ufi oS H0. rwi tack_on_inc H0. nin H0.
uf oS. uhg;ir;rw tack_on_inc. left. uh H;ee;eapply H. am. am.
subst. uhg;ir;uf oS;rw tack_on_inc. au.
uhg;ee;uhg;ir. rwi tack_on_inc H0;nin H0;subst.
ap H;am. ap ordinal_not_inc_self;am.
rwi tack_on_inc H0;rwi tack_on_inc H1;rwi tack_on_inc H3.
nin H0;nin H1;nin H3;subst.
apply H with y;am.
am. ap False_rect.
apply ordinal_not_inc_self with o. am.
apply ordinal_inc_trans with z. am. am. am. am.
ap False_rect.
apply ordinal_not_inc_self with o. am.
apply ordinal_inc_trans with y. am. am. am.
apply ordinal_inc_trans with y. am. am. am.
am. am.
ir.
uh H;ee.
apply by_cases with (nonempty (inter2 o x));ir.
apply H3 in H4.
nin H4. exists x0;uhg;ee. uhg;ee.
rw tack_on_inc. left;am.
ir.
cp (H0 x1 H5). rwi tack_on_inc H6;nin H6;subst.
ap H4. ap inter2_inc;am.
uhg. left. am.
eapply inter2_r;am.
ap inter2_l.
assert (x = singleton o).
ap extensionality;uhg;ir.
apply by_cases with (a=o);ir.
subst. ap singleton_inc.
destruct H4. exists a. ap inter2_inc.
apply H0 in H5. rwi tack_on_inc H5;nin H5. am.
destruct H6;am.
am.
apply singleton_eq in H5;subst.
ap excluded_middle;uhg;ir.
nin H1. ap H4. exists x0. ap inter2_inc;au.
cp H1. apply H0 in H1. rwi tack_on_inc H1. nin H1.
am. subst. destruct H5;am.
subst.
exists o. uhg;ee.
uhg;ee. rw tack_on_inc;au.
ir. uhg;right. symmetry;ap singleton_eq;am.
ap singleton_inc.
Qed.
Lemma ordinal_oS_inj : forall a, is_ordinal a -> forall b, oS a = oS b -> a=b.
Proof.
assert (forall a, is_ordinal a -> forall b, is_ordinal b -> oS a = oS b -> sub a b).
ir.
destruct ordinal_inc_eq_inc with a b;try am.
rw ordinal_sub_leq_of;au. left;am.
nin H2. subst. ap sub_refl.
assert (inc a (oS b)). wr H1;rw oS_inc;au.
rwi oS_inc H3;nin H3.
ap False_rect;eapply ordinal_inc_inc_not. Focus 2. am.
am. am.
subst. ap sub_refl.
ir.
assert (is_ordinal b).
apply ordinal_in_ordinal with (oS a).
ap ordinal_S;am.
rw H1;rw oS_inc;au.
ap extensionality;ap H;au.
Qed.
Lemma nNum_ordinal : forall n, inc n nNum -> is_ordinal n.
Proof.
ap nNum_rect.
ap emptyset_ordinal.
ir. ap ordinal_S;am.
Qed.
Notation ω := nNum.
Lemma omega_transitiveT : is_transitive_set nNum.
Proof.
uhg. ap nNum_rect.
ap emptyset_sub_all.
ir.
uhg;ir. ufi oS H1;rwi tack_on_inc H1;nin H1.
ap H0;am. subst. am.
Qed.
Lemma omega_union : nNum = union nNum.
Proof.
ap extensionality;uhg;ir.
Focus 2. apply union_ex in H;nin H;ee. eapply omega_transitiveT.
am. am.
ap union_inc. econstructor. ee.
eapply oS_nNum. am.
uf oS;rw tack_on_inc;au.
Qed.
Lemma omega_ordinal : is_ordinal nNum.
Proof.
rw omega_union.
ap transitive_union_ordinal. ap omega_transitiveT.
ap nNum_ordinal.
Qed.
Lemma ordinal_ind : forall (p : EP), (forall o, is_ordinal o -> (forall a, inc a o -> p a) -> p o) ->
forall o, is_ordinal o -> p o.
Proof.
ir. ap excluded_middle;uhg;ir.
pose (z := Z o (fun x => ~ p x)).
destruct ordinal_inc_wf with z. ir.
apply Z_all in H2. ee. apply ordinal_in_ordinal with o;am.
ap excluded_middle;uhg;ir;ap H1;ap H;try am.
ir. ap excluded_middle;uhg;ir. ap H2;exists a;ap Z_inc;am.
uh H2;ee. apply Z_all in H3.
ee.
ap H4. ap H. apply ordinal_in_ordinal with o;am.
ir. ap excluded_middle;uhg;ir.
uh H2;ee. destruct H7 with a. ap Z_inc.
uh H0;ee. eapply H0. am. am.
am.
eapply ordinal_inc_inc_not. apply ordinal_in_ordinal with o;am. am. am.
subst. apply ordinal_not_inc_self with a. apply ordinal_in_ordinal with o;am.
am.
Qed.
Lemma nNum_wo_ind : forall (p : EP), (forall n, inc n nNum -> (forall a, inc a n -> p a) -> p n) ->
forall n, inc n nNum -> p n.
Proof.
intros p IH.
pose (p' := fun o => inc o nNum -> p o).
assert (forall n, is_ordinal n -> p' n).
ap ordinal_ind;uf p';ir.
ap IH. am. ir. ap H0. am. eapply omega_transitiveT. am. am.
ir. ap H. ap nNum_ordinal;am. am.
Qed.
Definition successor_ordinal x := exists o, is_ordinal o & x = oS o.
Lemma successor_is_ordinal : forall x, successor_ordinal x -> is_ordinal x.
Proof.
ir;nin H;ee;subst;ap ordinal_S;am.
Qed.
Definition limit_ordinal x := A (is_ordinal x) (A (nonempty x) (~ successor_ordinal x)).
Lemma limit_is_ordinal : forall x, limit_ordinal x -> is_ordinal x.
Proof.
ir;am.
Qed.
Definition finite_ordinal x := A (is_ordinal x) (forall y, is_ordinal y -> sub y x -> (y=emptyset \/ successor_ordinal y)).
Lemma finite_ordinal_in_finite_ordinal : forall x, finite_ordinal x ->
forall y, inc y x -> finite_ordinal y.
Proof.
uhg;ir;ee. apply ordinal_in_ordinal with x;am.
ir. ap H. am. wri ordinal_inc_lt_of H0.
eapply sub_trans;am. apply ordinal_in_ordinal with x;am.
am.
Qed.
Lemma finite_S : forall o, finite_ordinal o -> finite_ordinal (oS o).
Proof.
ir. uhg;ee. ap ordinal_S. am.
ir. rwi ordinal_sub_leq_of H1. nin H1. ufi oS H1. rwi tack_on_inc H1.
nin H1. ap H. am. rw ordinal_sub_leq_of. left;am. am. am.
subst. ap H. am. ap sub_refl. subst. right. exists o;ee. am. tv.
am. ap ordinal_S;am.
Qed.
Lemma nNum_finite_ordinals : forall n, inc n nNum -> finite_ordinal n.
Proof.
ap nNum_rect.
uhg;ee. ap emptyset_ordinal.
ir. left. ap extensionality;au;ap emptyset_sub_all.
intros n H. ap finite_S.
Qed.
Lemma finite_ordinal_nNum : forall o, finite_ordinal o -> inc o nNum.
Proof.
ir. ap excluded_middle;uhg;ir.
pose (y := complement (oS o) nNum).
assert (nonempty y). exists o. ap Z_inc. uf oS;rw tack_on_inc;au.
am.
assert (is_ordinal (oS o)). ap ordinal_S;am.
uh H2;ee. clear H3;clear H2. apply H4 in H1.
nin H1. clear H4.
assert (finite_ordinal x).
apply finite_ordinal_in_finite_ordinal with (oS o).
ap finite_S. am. am.
uh H2. ee. destruct H3 with x.
am. ap sub_refl.
subst. uh H1;ee. apply Z_all in H4. ee.
ap H5. ap emptyset_N.
nin H4. ee. subst.
uh H1;ee. apply Z_all in H5. ee.
ap H6. ap oS_nNum.
ap excluded_middle;uhg;ir.
assert (inc x0 y). ap Z_inc. assert (is_ordinal (oS o)).
ap ordinal_S. am. uh H8;ee;eapply H8.
am. uf oS;rw tack_on_inc;au.
am.
apply H1 in H8.
wri ordinal_sub_leq_of H8. apply ordinal_not_inc_self with x0.
am. ap H8. uf oS;rw tack_on_inc;au.
ap ordinal_S;am. am.
ap Z_sub.
Qed.
Lemma class_initial_is_ordinal : forall x, (forall y, inc y x -> is_ordinal y) ->
(forall b, inc b x -> forall c, inc c b -> inc c x) ->
is_ordinal x.
Proof.
ir;uhg;ee. uhg. uhg;ir;eapply H0;am.
uhg;ee. uhg;ir.
ap ordinal_not_inc_self. ap H;am.
uhg. ir. eapply ordinal_inc_trans. am. am. ap H.
am.
ir. destruct ordinal_inc_wf with x0.
ir;ap H;au.
am.
exists x1. erewrite <-sub_min. am. am.
ap sub_refl.
Qed.
Lemma omega_least_limit : forall o, limit_ordinal o -> sub nNum o.
Proof.
ir. destruct ordinal_inc_eq_inc with o nNum.
am. ap omega_ordinal.
apply nNum_finite_ordinals in H0. uh H;ee.
nin H2. uh H0;ee. destruct H2 with o.
am. ap sub_refl. subst. nin H1. apply emptyset_empty in H1;nin H1.
am.
nin H0. subst. ap sub_refl. ap H. am.
Qed.
Lemma omega_is_limit : limit_ordinal nNum.
Proof.
uhg;ee. ap omega_ordinal.
exists emptyset. ap emptyset_N.
uhg;ir. nin H.
ee.
assert(inc x nNum). rw H0. uf oS;rw tack_on_inc;au.
assert (inc (oS x) nNum). ap oS_nNum. am.
wri H0 H2. destruct ordinal_not_inc_self with nNum.
ap omega_ordinal. am.
Qed.
Lemma ordinal_ind_cases : forall (p : EP), p emptyset ->
(forall o, is_ordinal o -> p o -> p (oS o)) ->
(forall o, limit_ordinal o -> (forall x, inc x o -> p x) -> p o) ->
forall o, is_ordinal o -> p o.
Proof.
intros p H H0 H1. ap ordinal_ind.
ir. apply by_cases with (successor_ordinal o). ir.
nin H4. ee. subst.
ap H0. am. ap H3. uf oS. rw tack_on_inc;au.
ir. apply by_cases with (o=emptyset);ir.
subst. am.
ap H1. uhg. ee. am. ap excluded_middle;uhg;ir;ap H5;ap extensionality;uhg;ir.
nin H6;exists a;am. apply emptyset_empty in H7;nin H7.
am. am.
Qed.
Lemma ordinal_sub_ind : forall (p : E2P) (a : E), is_ordinal a ->
p a a ->
(forall b, is_ordinal b -> sub a b -> p a b -> p a (oS b)) ->
(forall b, limit_ordinal b -> inc a b -> (forall x, inc x b -> sub a x -> p a x) -> p a b) ->
forall b, is_ordinal b -> sub a b -> p a b.
Proof.
intros p a Hoa Hpaa HS HL.
pose (p' := fun b => sub a b -> p a b).
assert (forall b, is_ordinal b -> p' b).
ap ordinal_ind_cases;try am;uf p';ir.
assert (a = emptyset). ap emptyset_sub_is.
am.
subst. am.
rwi ordinal_sub_leq_of H1. nin H1.
assert (sub a o). rwi oS_inc H1;nin H1. ap H. am.
subst;ap sub_refl. ap HS. am. am. ap H0. am.
subst. am.
am. ap ordinal_S;am.
rwi ordinal_sub_leq_of H1;try am. nin H1.
ap HL. am. am. am. subst. am.
am.
Qed.
Lemma ordinal_inc_sub_trans : forall a,
forall b, is_ordinal b -> inc a b ->
forall c, is_ordinal c -> sub b c ->
inc a c.
Proof.
ir.
assert (is_ordinal a). apply ordinal_in_ordinal with b;am.
rwi ordinal_sub_leq_of H2;au.
nin H2. apply ordinal_inc_trans with b;am. subst.
am.
Qed.
Lemma ordinal_sub_inc_trans : forall a, is_ordinal a ->
forall b, sub a b ->
forall c, is_ordinal c -> inc b c ->
inc a c.
Proof.
ir. assert (is_ordinal b).
apply ordinal_in_ordinal with c;am.
rwi ordinal_sub_leq_of H0;au. nin H0.
apply ordinal_inc_trans with b;am.
subst;am.
Qed.
Import Function.
Definition approx g d h := A (is_ordinal d)
(A (Function.axioms h)
(A (domain h = d)
(forall x, inc x d -> ev h x = g (restr h x)))).
Lemma approx_restr : forall g, forall d h, approx g d h -> forall o, inc o d -> approx g o (restr h o).
Proof.
ir. uh H;ee;uhg;ee. apply ordinal_in_ordinal with d;am.
ap restr_axioms. am. rw restr_domain. ap extensionality;uhg;ir.
eapply inter2_r;am. ap inter2_inc. rw H2. uh H;ee;eapply H. am. am.
am.
am. ir.
rw restr_ev. rw H3.
ap uneq. ap extensionality;uhg;ir.
apply Z_all in H5. ee.
ap Z_inc. ap Z_inc. am. assert (is_ordinal o). apply ordinal_in_ordinal with d;am.
uh H7;ee;eapply H7. am. am. am.
apply Z_all in H5;ee;apply Z_all in H5;ee;ap Z_inc. am.
am. uh H;ee;eapply H. am. am. am. am.
rw H2. uh H;ee;eapply H;am.
Qed.
Lemma approx_unicity : forall g d, unicity (approx g d).
Proof.
intros g. pose (fun d => forall h h' : E, approx g d h -> approx g d h' -> h = h').
assert (forall d, is_ordinal d -> P d).
cp (approx_restr (g:=g)).
ap ordinal_ind;uf P;ir.
uh H2;ee;uh H3;ee.
ap function_extensionality;eauto.
rw H8;am. rw H5;ir.
rw H6;try am;rw H9;try am.
ap uneq. apply H1 with x. am.
apply approx_restr with o. uhg;ee;am. am.
apply approx_restr with o. uhg;ee;am. am.
uhg;ufi P H;ir;eapply H;am.
Qed.
Lemma approx_sub : forall g, forall d d', sub d d' ->
forall h h', approx g d h -> approx g d' h' -> sub h h'.
Proof.
intros g.
ir.
rwi ordinal_sub_leq_of H. nin H.
assert (h = restr h' d).
eapply approx_unicity. am.
eapply approx_restr. am. am.
subst. ap Z_sub.
subst. assert (h = h').
eapply approx_unicity. am.
am. rw H;ap sub_refl.
am. am.
Qed.
Lemma approx_ex : forall g d, is_ordinal d -> ex (approx g d).
Proof.
intros g. ap ordinal_ind_cases;ir.
exists emptyset. uhg;ee.
ap emptyset_ordinal.
uhg. ee. uhg. ir. emptyset_auto.
uhg;uhg;ir. emptyset_auto.
ap empty_emptyset;ir.
ufi domain H. apply Z_pr in H. nin H.
eapply emptyset_empty;au.
ir;ap False_rect;eapply emptyset_empty;au.
nin H0.
pose (h := tack_on x (J o (g x))).
ufi tack_on h.
assert (axioms x). am. assert (domain x = o). am.
set (h0 := singleton (J o (g x))) in *.
assert (axioms h0). uf h0. ap singleton_axioms.
assert (domain h0 = singleton o). ap singleton_domain.
assert (inter2 (domain x) (domain h0) = emptyset). ap empty_emptyset;ir.
apply inter2_and in H5;ee. rwi H4 H6. apply singleton_eq in H6.
rwi H6 H5;rwi H2 H5;eapply H. am. am.
assert (axioms h). uf h.
ap union2_axioms;am.
assert (domain h = (oS o)). uf h. rw union2_domain;try am.
rw H2;rw H4. uf oS. reflexivity.
exists h. uhg;ee;try am.
ap ordinal_S;am.
ir. ufi oS H8;rwi tack_on_inc H8;nin H8.
assert (restr h x0 = restr x x0).
ap extensionality;uhg;ir;apply Z_all in H9;ee.
ap Z_inc. ufi h H9. apply union2_or in H9;nin H9.
am. apply singleton_eq in H9. rwi H9 H10;clpri H10.
ap False_rect;eapply ordinal_inc_inc_not. am. am. am. am.
ap Z_inc;try am. uf h. ap union2_l. am.
rw H9. transitivity (ev x x0).
uf h. ap union2_ev_l;try am. rw H2;am.
ap H0. am. rw H8.
assert (restr h o = x). uf h;ap extensionality;uhg;ir.
apply Z_all in H9;ee. apply union2_or in H9;nin H9.
am. apply singleton_eq in H9. rwi H9 H10. clpri H10.
edestruct ordinal_not_inc_self. am. am.
ap Z_inc. ap union2_l;am. wr H2.
ap domain_P_in. am. am.
rw H9.
uf h. rw union2_ev_r. uf h0.
symmetry. ap fun_show_ev;au. ap singleton_inc. am. am.
am. uf h0;rw singleton_domain;ap singleton_inc.
assert (o = union o).
ap extensionality;uhg;ir.
ap union_inc. ap excluded_middle;uhg;ir.
assert (forall y, inc y o -> sub y a).
ir. assert (is_ordinal y). apply ordinal_in_ordinal with o;am.
assert (is_ordinal a). apply ordinal_in_ordinal with o;am.
nin (ordinal_sub_sub H4 H5). am. rwi ordinal_sub_leq_of H6.
nin H6. nin H2. exists y;ee;am.
subst. ap sub_refl.
am. am.
ap H. uhg. exists a.
ee. apply ordinal_in_ordinal with o;am.
assert (is_ordinal a). apply ordinal_in_ordinal with o;am.
ap extensionality;uhg;ir.
uf oS;rw tack_on_inc.
cp H5. apply H3 in H6. rwi ordinal_sub_leq_of H6.
au. apply ordinal_in_ordinal with o;am.
am. ufi oS H5;rwi tack_on_inc H5. nin H5.
uh H;ee. uh H;ee. eapply H. am. am.
subst. am.
apply union_ex in H1;nin H1;ee.
uh H;ee;uh H;ee;eapply H;am.
pose (z := (Im (fun x => unique_choose (approx g x)) o)).
assert (forall y, inc y z -> exists x, inc x o & approx g x y).
ir.
apply Im_ex in H2;nin H2;ee. exists x;ee. am. rw H3. ap unique_choose_pr.
ap H0;am. uhg;ir;eapply approx_unicity;am.
assert (forall x y, inc x o -> approx g x y -> inc y z).
ir. uf z. ap Im_show_inc. exists x;ee. am.
eapply approx_unicity. am. ap unique_choose_pr;au. ap approx_unicity.
assert (forall f, inc f z -> axioms f). ir. apply H2 in H4;nin H4;ee;am.
assert (union_cond z). uhg.
ir. apply H2 in H5;apply H2 in H6.
nin H5;nin H6;ee.
assert (domain f = x0). am. assert (domain g0 = x1). am.
rwi H11 H7. rwi H12 H8.
assert (is_ordinal x0 & is_ordinal x1). ee;am.
ee.
nin (ordinal_sub_sub H13 H14).
eapply sub_ev_eq. am. eapply approx_sub. am.
am. am. rw H11;am.
symmetry.
eapply sub_ev_eq. am. eapply approx_sub. am.
am. am. rw H12;am.
pose (h := union z).
assert (axioms h). ap union_compatible_axioms;am.
assert (domain h = o). uf h. rw union_compatible_domain.
rw H1. ap uneq.
ap extensionality;uhg;ir. apply Im_ex in H7;nin H7. ee.
rw H8;clear H8;clear a. apply H2 in H7.
nin H7;ee. uh H8;ee. rw H10.
am.
ap Im_show_inc. cp H7.
apply H0 in H8. nin H8.
cp H8. apply H3 in H9.
exists x;ee. am. symmetry;am.
am.
am. am.
exists h;uhg;ee. am. am. am.
ir.
assert (inc (oS x) o).
assert (is_ordinal (oS x)). ap ordinal_S;apply ordinal_in_ordinal with o;am.
destruct ordinal_inc_eq_inc with o (oS x). am. am.
ufi oS H10. rwi tack_on_inc H10. nin H10.
destruct ordinal_inc_inc_not with o x;am.
destruct ordinal_not_inc_self with o. am. wri H10 H8. am.
nin H10. uh H;ee. nin H12.
exists x. ee. apply ordinal_in_ordinal with o;am.
am.
am.
cp H9. apply H0 in H10;nin H10;cp H10. apply H3 in H11.
Focus 2. am.
transitivity (ev x0 x). uf h. eapply union_compatible_ev.
am. am. am. uh H10;ee. rw H13.
uf oS;rw tack_on_inc;au.
uh H10;ee.
rw H14. ap uneq.
ap extensionality;uhg;ir; apply Z_all in H15;ee.
assert (approx g (oS x) x0). uhg;ee;am.
ap Z_inc. uf h. ap union_inc. exists x0. ee. am. am.
am.
ufi h H15;apply union_ex in H15;nin H15;ee.
cp H15. apply H2 in H18.
nin H18;ee.
assert (approx g (oS x) x0). uhg;ee;am.
assert (approx g x (restr x0 x)). eapply approx_restr. am.
uf oS;rw tack_on_inc;au.
assert (is_ordinal x). am. assert (is_ordinal x2). apply ordinal_in_ordinal with o;am.
destruct (ordinal_sub_sub) with x x2;try am.
assert (sub (restr x0 x) x1). eapply approx_sub. am. am. am.
assert (inc (P a) (domain (restr x0 x))).
rw restr_domain;try am. ap inter2_inc.
rw H13. uf oS;rw tack_on_inc;au. am.
apply domain_ev_inc in H26;try am.
cp H26. apply H25 in H27.
assert (a = J (P a) (ev (restr x0 x) (P a))).
assert (is_pair a). eapply H19. am.
nin H28. clpr;clpri H27. ap uneq.
eapply H19. Focus 2. am.
ap H17.
rw H28. ap domain_ev_inc. ap restr_axioms.
am. rw restr_domain;try am. ap inter2_inc. rw H13.
uf oS;rw tack_on_inc;au. am.
assert (sub x1 (restr x0 x)). eapply approx_sub.
am. am. am.
ap H25. am.
uf oS. rw tack_on_inc. au.
Qed.
Lemma ordinal_rec_ex : forall g : E1, exists f : E1, forall o, is_ordinal o ->
f o = g (Function.create o f).
Proof.
ir.
set (f0 := (fun o => unique_choose (approx g (oS o)))).
assert (forall o, is_ordinal o -> approx g (oS o) (f0 o)).
ir;uf f0. ap unique_choose_pr. ap approx_ex. ap ordinal_S;am.
ap approx_unicity.
assert (forall a b, is_ordinal a -> is_ordinal b -> sub a b -> sub (f0 a) (f0 b)).
ir. assert (sub (oS a) (oS b)).
uhg;ir. ufi oS H3;rwi tack_on_inc H3. nin H3;
uf oS;rw tack_on_inc.
au. subst. rwi ordinal_sub_leq_of H2;au.
eapply approx_sub. am. ap H;am. ap H;am.
assert (forall o, is_ordinal o -> approx g o (L o (fun a => ev (f0 a) a))).
ap ordinal_ind.
ir.
uhg;ee. am. ap create_axioms. ap create_domain.
ir. rw create_ev.
assert (is_ordinal x). apply ordinal_in_ordinal with o;am.
apply H in H4.
uh H4;ee. rw H7.
ap uneq. ap extensionality;uhg;ir;apply Z_all in H8;ee.
ap Z_inc. uf L. ap Im_show_inc.
cp H8. apply H5 in H10.
nin H10.
clpri H9.
exists a;ee. uh H1;ee;eapply H1. am. am.
ap uneq. eapply H5. am.
assert (is_ordinal x). apply ordinal_in_ordinal with o;am.
assert (is_ordinal a). apply ordinal_in_ordinal with x;am.
assert (sub a x). rw ordinal_sub_leq_of;au. uhg;au.
apply H0 in H12;try am.
ap H12.
cp H11;apply H in H13.
ap domain_ev_inc. am. uh H13;ee. rw H15.
uf oS;rw tack_on_inc;au.
am.
cp H8.
apply Im_ex in H10. nin H10;ee;subst.
clpri H9.
assert (is_ordinal x0). apply ordinal_in_ordinal with o;am.
assert (is_ordinal x). apply ordinal_in_ordinal with o;am.
assert (sub x0 x). rw ordinal_sub_leq_of;au. uhg;au.
cp H12;apply H in H14.
cp H11;apply H in H15.
assert (sub (oS x0) (oS x)).
uf oS;uhg;ir. rwi tack_on_inc H16;rw tack_on_inc.
nin H16. left;au. subst.
rwi ordinal_sub_leq_of H13;au.
assert (sub (f0 x0) (f0 x)). eapply approx_sub;try am.
assert (ev (f0 x0) x0 = ev (f0 x) x0).
eapply sub_ev_eq. am. am. uh H15;ee. rw H19. uf oS;rw tack_on_inc;au.
rw H18.
assert (ev (f0 x) x0 = ev (restr (f0 x) x) x0).
symmetry. ap restr_ev. am. am.
uh H14;ee. rw H20. ap H16. uf oS;rw tack_on_inc;au.
rw H19. ap domain_ev_inc.
ap restr_axioms. am.
rw restr_domain;au. ap inter2_inc.
uh H14;ee. rw H21. ap H16;uf oS;rw tack_on_inc;au.
am. uf oS;rw tack_on_inc;au. am.
exists (fun o => ev (f0 o) o).
ir.
cp H2; apply H in H3. uh H3;ee.
rw H6. ap uneq.
eapply approx_unicity.
Focus 2. ap H1. am.
uhg;ee. am. ap restr_axioms;am.
rw restr_domain. rw H5. uf oS. ap extensionality;uhg;ir.
apply inter2_and in H7;am.
ap inter2_inc. rw tack_on_inc;au. am.
am.
ir. rw restr_ev. rw H6.
ap uneq. ap extensionality;uhg;ir.
apply Z_all in H8;ee. ap Z_inc. ap Z_inc. am.
uh H2;ee;eapply H2. am. am. am.
apply Z_all in H8;ee;apply Z_all in H8;ee.
ap Z_inc;am.
uf oS;rw tack_on_inc;au. am. am.
rw H5. uf oS;rw tack_on_inc;au.
uf oS;rw tack_on_inc;au.
Qed.
Definition ordinal_rec : E1 -> E1.
intros g o.
ap ev. ap unique_choose.
ap approx. ap g.
ap oS. ap o. ap o.
Defined.
Lemma approx_unique_choose : forall g o, is_ordinal o ->
approx g o (unique_choose (approx g o)).
Proof.
ir;ap unique_choose_pr.
ap approx_ex. am.
ap approx_unicity.
Qed.
Lemma ordinal_rec_pr : forall g, forall o, is_ordinal o -> ordinal_rec g o =
g (Function.create o (ordinal_rec g)).
Proof.
intro g. ap ordinal_ind;ir.
assert (forall a, inc a o -> approx g a (L a (ordinal_rec g))).
ir. uhg;ee. eapply ordinal_in_ordinal;am.
ap create_axioms. ap create_domain.
ir. rw create_ev;au. rw H0;au.
ap uneq. assert (sub x a). rw ordinal_sub_leq_of.
uhg;au. apply ordinal_in_ordinal with a.
apply ordinal_in_ordinal with o;am.
am.
apply ordinal_in_ordinal with o;am.
ap function_extensionality;ir.
ap create_axioms. ap restr_axioms. ap create_axioms.
rw create_domain. rw restr_sub_domain. tv.
ap create_axioms. rw create_domain. am.
rwi create_domain H4. rw create_ev;au. rw restr_ev;au. rw create_ev;au.
ap create_axioms. rw create_domain. au.
uh H;ee;eapply H. am. am.
cp (approx_unique_choose g (ordinal_S H)).
uh H2. ee.
etransitivity. uf ordinal_rec. reflexivity.
rw H5.
ap uneq. eapply approx_unicity.
eapply approx_restr. uhg;ee;am.
rw oS_inc;au.
uhg;ee. am. ap create_axioms. ap create_domain.
ir. rw create_ev;au.
rw H0;au. ap uneq.
etransitivity.
symmetry. ap restr_eq. ap create_axioms.
Focus 2. rw create_domain.
rw create_domain. ap H. am.
ap create_axioms.
ir. rwi create_domain H7. rw create_ev;au. rw create_ev;au.