-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplotkin.v
1662 lines (1590 loc) · 58.5 KB
/
plotkin.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
(* Copyright (c) 2014, Robert Dockins *)
Require Import List.
Require Import basics.
Require Import preord.
Require Import categories.
Require Import sets.
Require Import finsets.
Require Import esets.
Require Import effective.
Require Import directed.
(** * Plotkin orders and normal sets.
A plotkin order is a preorder where every conditionally-inhabited,
bounded finite set has a minimal upper bound; and where every
finite set has a finite MUB closure.
The Plotkin orders are alternately characterized has having
finite normal sets. A set X is normal if, for every z,
the set { x | x ∈ X ∧ x ≤ z } is h-directed. A preorder is
Plotkin iff every conditionally-inhabted finite set has an
enclosing finite normal set.
Demonstrating the existence of normal sets is generally easier
than producing finite MUB closures, so that is our preferred
method for demonstrating that an order is Plotkin.
It might be better (following Gunter) to simply take the normal
set definition as primary and drop the MUB closure definition
altogether. That might make other things more complicated,
I'm not sure. Anyway, it would mean major changes to difficult
proofs, like those in joinable.v.
*)
(** A preorder is MUB complete if every bounded, h-inhabited finite
set has a least upper bound below the given bound.
*)
Definition is_mub_complete hf (A:preord) :=
forall (M:finset A) (x:A), inh hf M -> upper_bound x M ->
exists mub:A, minimal_upper_bound mub M /\ mub ≤ x.
(** A set is MUB closed if it contains every MUB of every
h-inhabited finite subset.
*)
Definition mub_closed hf (A:preord) (X:finset A) :=
forall M:finset A, inh hf M -> M ⊆ X ->
forall x:A, minimal_upper_bound x M -> x ∈ X.
(** A Plotkin order is MUB complete and has a finite MUB closure
operation. Note, we explicitly require mub_closure to be
the smallest MUB closure operation. It is thus uniquely
determined. In fact, this requirement is not strictly necessary;
given an arbitrary MUB closure operation, we can compute the
minimal one.
*)
Record plotkin_order (hf:bool) (A:preord) :=
PlotkinOrder
{ mub_complete : is_mub_complete hf A
; mub_closure : finset A -> finset A
; mub_clos_incl : forall M:finset A, M ⊆ mub_closure M
; mub_clos_mub : forall (M:finset A), mub_closed hf A (mub_closure M)
; mub_clos_smallest : forall (M X:finset A),
M ⊆ X ->
mub_closed hf A X ->
mub_closure M ⊆ X
}.
Arguments mub_closure [hf] [A] p _.
Arguments mub_complete [hf] [A] p _ _ _ _.
Arguments mub_clos_incl [hf] [A] p _ _ _.
Arguments mub_clos_mub [hf] [A] p _ _ _ _ _ _.
Arguments mub_clos_smallest [hf] [A] p _ _ _ _ _ _.
(** MUB-closure is actually a closure operation: it is
monotone, inclusive and idempotent.
*)
Lemma mub_clos_mono : forall hf A (H:plotkin_order hf A),
forall (M N:finset A),
M ⊆ N -> mub_closure H M ⊆ mub_closure H N.
Proof.
intros.
apply mub_clos_smallest; auto.
- apply incl_trans with finset_theory N; auto.
apply mub_clos_incl.
- apply mub_clos_mub; eauto.
Qed.
Lemma mub_clos_idem : forall hf A (H:plotkin_order hf A),
forall (M:finset A),
mub_closure H M ≈ mub_closure H (mub_closure H M).
Proof.
intros. split.
- apply mub_clos_incl.
- apply mub_clos_smallest; auto.
+ red; auto.
+ apply mub_clos_mub; auto.
Qed.
(** The empty preorder is Plotkin.
*)
Program Definition empty_plotkin hf : plotkin_order hf emptypo :=
PlotkinOrder hf emptypo _ (fun _ => nil) _ _ _.
Solve Obligations of empty_plotkin with (repeat intro; simpl in *; intuition).
(** The unit preorder is Plotkin.
*)
Program Definition unit_plotkin hf : plotkin_order hf unitpo :=
PlotkinOrder hf _ _ (fun M => if hf then M else (tt::nil)) _ _ _.
Solve Obligations of unit_plotkin with (repeat intro; hnf; auto).
Next Obligation.
repeat intro. exists tt.
split; hnf; auto.
Qed.
Next Obligation.
repeat intro.
destruct hf; auto.
destruct a. apply cons_elem; auto.
Qed.
Next Obligation.
repeat intro.
destruct hf.
- hnf in H. destruct H.
destruct x0. destruct x. apply H0. auto.
- destruct x. apply cons_elem; auto.
Qed.
Next Obligation.
repeat intro.
destruct hf; [ apply H; auto |].
apply (H0 M); auto.
- red; auto.
- split; hnf; auto.
repeat intro. hnf. auto.
Qed.
(** When a preorder is effective Plotkin, it is decidable if an
element is an upper bound or a minimal upper bound of a finite set.
*)
Section dec_lemmas.
Variable hf:bool.
Variable A:preord.
Variable Heff : effective_order A.
Variable Hplt : plotkin_order hf A.
Lemma upper_bound_dec : forall (M:finset A) (x:A),
{ upper_bound x M } + { ~upper_bound x M }.
Proof.
induction M; intros.
- left. red. intros. destruct H as [q [??]]. elim H.
- destruct (IHM x).
+ destruct (eff_ord_dec A Heff a x).
* left.
red. simpl; intros.
destruct H as [q [??]].
simpl in H. destruct H; subst.
** rewrite H0; auto.
** apply u. exists q; split; auto.
* right.
intro. apply n.
apply H.
exists a. split; simpl; auto.
+ right. intro.
apply n.
red; intros.
apply H.
destruct H0 as [q[??]].
exists q; split; simpl; auto.
Qed.
Lemma mub_finset_dec : forall (M:finset A) (x:A) (Hinh:inh hf M),
{ minimal_upper_bound x M } + { ~minimal_upper_bound x M }.
Proof.
intros M x.
destruct (upper_bound_dec M x).
- destruct (eff_in_dec Heff (mub_closure Hplt M) x).
+ set (P b := upper_bound b M -> b ≤ x -> x ≤ b).
destruct (finset_find_dec' A P) with (mub_closure Hplt M).
* subst P; simpl; intuition.
rewrite <- H. apply H0.
** red; intros. rewrite H. apply H1. auto.
** rewrite H; auto.
* unfold P. simpl.
intro b.
destruct (upper_bound_dec M b).
** destruct (eff_ord_dec A Heff x b); auto.
*** destruct (eff_ord_dec A Heff b x); auto.
left; intros. contradiction.
** left; intros. contradiction.
* destruct s.
destruct a.
red in H0.
subst P. simpl in H0.
right. intro.
destruct H1.
apply H0.
intros.
apply H2; auto.
* left.
split; auto.
intros.
destruct (mub_complete Hplt M b) as [b0 [??]]; auto.
transitivity b0; auto.
apply p; auto.
** apply mub_clos_mub with M; auto.
apply mub_clos_incl; auto.
** destruct H1; auto.
** transitivity b; auto.
+ right. intro.
apply n.
apply mub_clos_mub with M; auto.
apply mub_clos_incl; auto.
- right.
intro. destruct H.
apply n; auto.
Qed.
End dec_lemmas.
Lemma upper_bound_ok : forall A (G:finset A) (x y:A),
x ≈ y -> upper_bound x G -> upper_bound y G.
Proof.
unfold upper_bound; intros.
rewrite <- H. apply H0; auto.
Qed.
Lemma minimal_upper_bound_ok : forall A (G:finset A) (x y:A),
x ≈ y -> minimal_upper_bound x G -> minimal_upper_bound y G.
Proof.
unfold minimal_upper_bound. intros.
destruct H0; split.
- eapply upper_bound_ok; eauto.
- intros. rewrite <- H. apply H1; auto.
rewrite H; auto.
Qed.
(** We introduce the alternate characterization of Plotkin orders
and preorders posessing enough normal sets. The Plotkin->normal
direction of equivalance is easy, but the other direction is rather
involved.
*)
Section normal_sets.
Variable A:preord.
Variable Heff: effective_order A.
Variable hf:bool.
(** A set X is normal if it is h-inhabited and, for abitrary z,
the intersection of X with { x | x ≤ z } is directed.
*)
Definition normal_set (X:finset A) :=
(inh hf X) /\
forall z, directed hf
(finsubset A
(fun x => x ≤ z)
(fun x => eff_ord_dec A Heff x z)
X).
(** A preorder "has" normal sets if every h-inhabited set is inclosed in
some finite normal set.
*)
Definition has_normals :=
forall (X:finset A) (Hinh:inh hf X),
{ Z:finset A | X ⊆ Z /\ normal_set Z }.
(** Plotkin orders have normal sets.
*)
Section plt_normal.
Hypothesis Hplt : plotkin_order hf A.
Lemma plt_has_normals : has_normals.
Proof.
red. intros X Xinh.
exists (mub_closure Hplt X).
split.
- apply mub_clos_incl.
- red; intros.
split.
+ apply inh_sub with X; auto.
apply mub_clos_incl.
+ red; simpl; intros.
destruct (mub_complete Hplt M z); auto.
* red; intros.
apply H in H0.
apply finsubset_elem in H0.
** destruct H0; auto.
** intros. rewrite <- H2; auto.
* destruct H0.
exists x. split; auto.
** destruct H0; auto.
** apply finsubset_elem.
*** intros. rewrite <- H2; auto.
*** split; auto.
apply (mub_clos_mub Hplt X) with M; auto.
red; intros.
apply H in H2.
apply finsubset_elem in H2.
**** destruct H2; auto.
**** intros. rewrite <- H4; auto.
Qed.
End plt_normal.
(** Given a finite subset X of a normal set Q, we can compute the (finite) set of
all upper bounds of X that lie in Q. Furthermore, for each upper bound of X,
there is some upper bound of X below it in Q.
*)
Lemma normal_has_ubs Q :
normal_set Q ->
forall (X:finset A) (Hinh:inh hf X), X ⊆ Q ->
{ Y:finset A | Y ⊆ Q /\
(forall y, y ∈ Y -> upper_bound y X) /\
(forall z, upper_bound z X -> exists m, m ≤ z /\ m ∈ Y /\ upper_bound m X) }.
Proof.
intros. red in H.
set (Y := finsubset A (fun x => upper_bound x X) (fun x => upper_bound_dec A Heff X x) Q).
exists Y. split.
- unfold Y.
red. intros.
apply finsubset_elem in H1.
+ destruct H1; auto.
+ apply upper_bound_ok.
- split.
+ intros.
unfold Y in H1.
apply finsubset_elem in H1.
* destruct H1; auto.
* apply upper_bound_ok.
+ intros z Hz.
destruct H as [HQ H].
destruct (H z X); auto.
* red; intros.
apply finsubset_elem.
** intros. rewrite <- H2; auto.
** split.
*** apply H0; auto.
*** apply Hz. auto.
* destruct H1.
apply finsubset_elem in H2.
** destruct H2.
exists x. intuition.
unfold Y.
apply finsubset_elem.
*** apply upper_bound_ok.
*** split; auto.
** intros. rewrite <- H4. auto.
Qed.
(** Moreover, under the same conditions, we can calculate the set
of minimal upper bounds of X.
*)
Section normal_mubs.
Variable Q:finset A.
Hypothesis H : normal_set Q.
Variable X:finset A.
Variable Hinh : inh hf X.
Hypothesis H0 : X ⊆ Q.
Let Y := proj1_sig (normal_has_ubs Q H X Hinh H0).
Let H1 := proj1 (proj2_sig (normal_has_ubs Q H X Hinh H0)).
Let H2 := proj2 (proj2_sig (normal_has_ubs Q H X Hinh H0)).
Let P (x y:A) := (y ≤ x /\ x ≰ y).
Lemma normal_mubs' : forall x, { z | z ∈ Y /\ P x z } + { forall z, z ∈ Y -> ~P x z }.
Proof.
intro x.
apply (finset_find_dec A (P x)).
- clear; unfold P; intros.
rewrite <- H. auto.
- unfold P.
intro y.
destruct (eff_ord_dec A Heff y x).
+ destruct (eff_ord_dec A Heff x y).
* right. intros [??]. apply H4; auto.
* left. split; auto.
+ right. intros [??]. apply n; auto.
Qed.
Lemma normal_sub_mub_dec : forall x, { minimal_upper_bound x X }+{~minimal_upper_bound x X}.
Proof.
intro x.
destruct (normal_mubs' x).
- destruct s as [m [??]].
red in H4.
right. intro.
destruct H4.
apply H6.
apply H5; auto.
destruct H2.
+ apply H2. auto.
- destruct (upper_bound_dec A Heff X x).
+ left. red; intros.
split; auto.
intros.
destruct H2.
destruct (H6 b) as [m [?[??]]]; auto.
destruct (eff_ord_dec A Heff x b); auto.
elim (n m); auto.
red. split; auto.
transitivity b; auto.
red; intros.
apply n0.
transitivity m; auto.
+ right. intros [??]. contradiction.
Qed.
Lemma normal_has_mubs :
{ Y:finset A | Y ⊆ Q /\
(forall y, y ∈ Y -> minimal_upper_bound y X) /\
forall z, upper_bound z X -> exists m, m ≤ z /\ m ∈ Y /\ minimal_upper_bound m X }.
Proof.
exists (finsubset A (fun x => minimal_upper_bound x X) normal_sub_mub_dec Y).
split.
- red; intros.
apply finsubset_elem in H3.
+ destruct H3.
apply H1; auto.
+ apply minimal_upper_bound_ok.
- split; intros.
+ apply finsubset_elem in H3.
* destruct H3; auto.
* apply minimal_upper_bound_ok.
+ destruct H2.
destruct (H5 z) as [m [?[??]]]; auto.
cut (forall (Y1 Y2:finset A), (Y1++Y2)%list = Y -> forall m,
(forall y, y ∈ Y1 -> y ≤ m -> m ≤ y) ->
m ∈ Y2 -> m ≤ z -> exists m', m' ∈ Y2 /\ m' ≤ z /\ minimal_upper_bound m' X).
{ intros.
destruct (H9 nil Y) with m; auto.
intros. destruct H10 as [?[??]]. elim H10.
exists x. intuition.
apply finsubset_elem.
apply minimal_upper_bound_ok.
split; auto.
}
clear m H6 H7 H8.
intros Y1 Y2. revert Y1. induction Y2; simpl; intros.
* rewrite <- List.app_nil_end in H6.
destruct H8 as [?[??]].
elim H8.
* destruct (eff_ord_dec A Heff a m).
** destruct (normal_mubs' a).
*** destruct s as [m' [??]].
destruct H11.
assert (m' ∈ (Y2:finset A)).
{ destruct H10 as [q [??]].
rewrite <- H6 in H10.
apply List.in_app_or in H10.
destruct H10.
- elim H12.
transitivity m; auto.
apply H7; auto.
exists q; split; auto.
transitivity a; auto.
- destruct H10.
subst q.
elim H12. rewrite H13. auto.
exists q; split; auto.
}
destruct (IHY2 (Y1 ++ a::nil)%list) with m'.
**** rewrite List.app_ass.
simpl. auto.
**** intros.
destruct H14 as [p [??]].
apply List.in_app_or in H14.
destruct H14.
***** transitivity a; auto.
transitivity m; auto.
apply H7; auto.
****** exists p; split; auto.
****** transitivity m'; auto.
transitivity a; auto.
***** simpl in H14. intuition subst.
rewrite H16; auto.
**** auto.
**** transitivity m; auto.
transitivity a; auto.
**** exists x.
intuition.
destruct H2 as [p [??]].
exists p; split; simpl; auto.
*** exists a. split.
exists a; split; simpl; auto. split; auto.
transitivity m; auto.
split.
**** apply H2.
fold Y.
rewrite <- H6.
exists a; split; simpl; auto.
apply List.in_or_app; auto.
right; simpl; auto.
**** intros.
destruct (eff_ord_dec A Heff a b); auto.
destruct (H5 b) as [q [??]]; auto.
destruct H13.
elim (n q); auto.
split; auto.
***** transitivity b; auto.
***** intro.
apply n0.
transitivity q; auto.
** destruct (IHY2 (Y1++(a::nil))%list) with m.
*** rewrite <- H6.
rewrite List.app_ass; auto.
*** intros.
destruct H10 as [p [??]].
apply List.in_app_or in H10.
destruct H10.
**** apply H7; auto.
exists p; split; auto.
**** simpl in H10; intuition subst.
elim n. rewrite <- H12. auto.
*** destruct H8 as [?[??]].
destruct H8. subst a.
elim n. destruct H10; auto.
exists x; split; auto.
*** auto.
*** exists x; intuition.
destruct H2 as [p [??]].
exists p; split; simpl; auto.
Qed.
End normal_mubs.
(** We can decide if a finite subset of a normal set is MUB closed.
*)
Lemma normal_sub_mub_closed_dec Q : normal_set Q ->
forall (M:finset A), M ⊆ Q -> { mub_closed hf A M }+{ ~mub_closed hf A M }.
Proof.
intros HQ M HM.
unfold mub_closed.
set (P' (N:finset A) := inh hf N -> N ⊆ M -> forall x, minimal_upper_bound x N -> x ∈ M).
assert (forall x y, x ≈ y -> P' x -> P' y).
{ clear. unfold P'. intros.
apply H0.
- apply inh_eq with y; auto.
- rewrite H. auto.
- destruct H3. split.
+ red; intros. apply H3.
rewrite <- H; auto.
+ intros. apply H4.
* red; intros. apply H5.
rewrite H; auto.
* auto.
}
destruct (finsubset_dec' A (OrdDec A (eff_ord_dec A Heff)) P') with M; auto.
- intro x.
unfold P'.
destruct (inh_dec A hf x).
+ destruct (finset_find_dec' A
(fun p:A => p ∈ M)) with x; simpl.
* intros. rewrite <- H0; auto.
* intros. apply finset_in_dec.
constructor. apply eff_ord_dec. auto.
* left. intros Hx ?.
destruct s.
destruct a.
apply H0 in H1. elim H2; auto.
* destruct (normal_has_mubs Q HQ x) as [MUBS [?[??]]]; auto.
** red; intros. apply HM. apply m. auto.
** destruct (finset_find_dec' A (fun p => p ∈ M)) with MUBS; simpl.
*** intros. rewrite <- H3; auto.
*** intros. apply finset_in_dec.
constructor. apply eff_ord_dec. auto.
*** right. intro.
destruct s. destruct a. apply H5.
apply H3; auto.
*** left. intros _. intros.
apply m0.
destruct (H2 x0) as [x0' [?[??]]].
**** destruct H4; auto.
**** apply member_eq with x0'; auto.
split; auto.
destruct H4.
apply H8; auto.
destruct H7; auto.
+ left; intro. contradiction.
- left.
intros.
unfold P' in p.
apply p with M0; auto.
- right. intro.
destruct e as [X [??]].
apply H2.
red. intros.
apply H0 with X; auto.
Qed.
(** We can caluclate the (finite) set of all MUB closed finite subsets
of a normal set.
*)
Lemma normal_set_mub_closed_sets Q : normal_set Q ->
{ CLS : finset (finset A) |
forall X, X ∈ CLS <-> (inh hf X /\ X ⊆ Q /\ mub_closed hf A X) }.
Proof.
intros.
set (SUBS := list_finsubsets Q).
assert (forall X, X ∈ SUBS -> X ⊆ Q).
{ intros.
unfold SUBS in H0.
apply list_finsubsets_correct; auto.
}
assert { XS:finset (finset A) | XS ⊆ SUBS /\
forall X, X ∈ XS <-> (inh hf X /\ X ∈ SUBS /\ mub_closed hf A X) }.
{
revert H0.
generalize SUBS.
clear SUBS.
induction SUBS; intros.
- exists nil. split.
+ red; auto.
+ intuition.
* destruct H1 as [?[??]]. elim H1.
* destruct H1 as [?[??]]. elim H1.
- destruct IHSUBS as [XS [??]].
+ intros. apply H0.
destruct H1 as [q [??]]. exists q; split; simpl; auto.
+ destruct (inh_dec A hf a).
* destruct (normal_sub_mub_closed_dec Q H a); auto.
** apply H0. exists a; split; simpl; auto.
** exists (a::XS)%list.
split.
*** red; intros.
destruct H3 as [q [??]].
destruct H3.
**** subst q.
exists a; split; simpl; auto.
**** destruct (H1 a0).
***** exists q; split; simpl; auto.
***** destruct H5. exists x; split; simpl; auto.
*** split; intros.
**** destruct H3 as [q [??]].
destruct H3.
***** subst q.
split; [ apply inh_eq with a; auto |].
split.
****** exists a; split; simpl; auto.
****** red. intros.
rewrite H4.
apply (m M); auto.
rewrite <- H4; auto.
***** assert (X ∈ XS).
{ exists q; split; simpl; auto. }
apply H2 in H5.
destruct H5; split; auto.
destruct H6; split; auto.
destruct H6 as [q' [??]].
exists q'; split; simpl; auto.
**** destruct H3 as [HQ [??]].
destruct H3 as [q [??]].
destruct H3.
***** subst q.
exists a; split; simpl; auto.
***** assert (X ∈ XS).
{ apply H2.
split; auto.
split; auto.
exists q; split; simpl; auto.
}
destruct H6 as [q' [??]].
exists q'; split; simpl; auto.
** exists XS.
split.
*** red; intros.
apply H1 in H3.
destruct H3 as [q [??]]. exists q; split; simpl; auto.
*** split; intros.
**** rewrite H2 in H3.
destruct H3 as [HQ [??]]; split; auto. split; auto.
destruct H3 as [q [??]]. exists q; split; simpl; auto.
**** destruct H3 as [HQ [??]].
destruct H3 as [q [??]].
destruct H3.
***** subst q.
elim n; auto.
red; intros.
red in H4.
rewrite <- H5.
apply (H4 M); auto.
rewrite H5; auto.
***** rewrite H2. split; auto.
split; auto.
exists q; split; simpl; auto.
* exists XS.
split.
** red; intros.
apply H1 in H3.
destruct H3 as [q [??]].
exists q; split; simpl; auto.
** split; intros.
*** rewrite H2 in H3.
destruct H3 as [HQ [??]]; split; auto. split; auto.
destruct H3 as [q [??]]. exists q; split; simpl; auto.
*** destruct H3 as [HQ [??]].
destruct H3 as [q [??]].
destruct H3.
**** subst q.
elim n; auto.
apply inh_eq with X; auto.
**** rewrite H2. split; auto.
split; auto.
exists q; split; simpl; auto.
}
destruct X as [XS [??]].
exists XS.
intro X; split; intros.
apply H2 in H3.
destruct H3. split; auto.
destruct H4; split; auto.
destruct H3 as [?[??]].
apply H2; split; auto. split; auto.
apply list_finsubsets_complete; auto.
constructor. apply (eff_ord_dec A Heff).
Qed.
Let OD := (OrdDec A (eff_ord_dec A Heff)).
(** The intersection of any two MUB closed sets is itself MUB closed.
*)
Lemma mub_closed_intersect : forall (X Y:finset A),
mub_closed hf A X -> mub_closed hf A Y ->
mub_closed hf A (fin_intersect A OD X Y).
Proof.
repeat intro.
apply fin_intersect_elem.
split.
- apply (H M); auto.
red; intros.
apply H2 in H4.
apply fin_intersect_elem in H4.
destruct H4; auto.
- apply (H0 M); auto.
red; intros.
apply H2 in H4.
apply fin_intersect_elem in H4.
destruct H4; auto.
Qed.
(** Any normal set is mub closed.
*)
Lemma normal_set_mub_closed Q : normal_set Q -> mub_closed hf A Q.
Proof.
repeat intro.
destruct (normal_has_mubs Q H M H0) as [MUBS [?[??]]]; auto.
destruct (H5 x) as [m [?[??]]].
- destruct H2; auto.
- apply H3.
apply member_eq with m; auto.
split; auto.
destruct H2. apply H9; auto.
destruct H8; auto.
Qed.
(** Given an h-inhabited finite subset of a normal set, we can compute
the smallest MUB-closed superset. This is done by taking the
intersection of all the MUB-closed subsetsets of X that lie in Q.
*)
Lemma normal_set_mub_closure Q : normal_set Q ->
forall (M:finset A) (Minh : inh hf M), M ⊆ Q ->
{ CL:finset A | M ⊆ CL /\ mub_closed hf A CL /\
forall CL':finset A, M ⊆ CL' -> mub_closed hf A CL' -> CL ⊆ CL' }.
Proof.
intros.
destruct (normal_set_mub_closed_sets Q H) as [CLS ?]; auto.
assert (Hsubdec : forall X:finset A, {M⊆X}+{~(M ⊆ X)}).
{ intros.
destruct (finset_find_dec' A (fun z => z ∈ X)) with M; simpl.
+ intros. rewrite <- H1; auto.
+ apply finset_in_dec.
constructor. apply eff_ord_dec; auto.
+ destruct s as [z [??]].
right. intro. apply H3 in H1.
contradiction.
+ left. red; auto.
}
set (CLS' := finsubset (finset A) (fun X => M ⊆ X) Hsubdec CLS).
exists (fin_list_intersect A OD CLS' Q).
split.
- red; intros.
apply fin_list_intersect_elem.
split.
+ apply H0; auto.
+ intros.
unfold CLS' in H2.
apply finsubset_elem in H2.
* destruct H2. apply H3; auto.
* intros. rewrite <- H4; auto.
- split.
+ cut (forall x, x ∈ CLS' -> mub_closed hf A x).
{ generalize CLS'. clear -H.
induction CLS'; intros.
- simpl.
apply normal_set_mub_closed; auto.
- simpl.
apply mub_closed_intersect.
+ apply H0.
exists a; split; simpl; auto.
+ apply IHCLS'.
intros. apply H0.
destruct H1 as [q [??]]. exists q; split; simpl; auto.
}
intros.
unfold CLS' in H1.
apply finsubset_elem in H1.
* destruct H1.
apply i in H1.
destruct H1 as [Hx [??]]; auto.
* intros. rewrite <- H3; auto.
+ intros.
red; intros.
apply fin_list_intersect_elem in H3.
destruct H3.
assert (fin_intersect A OD CL' Q ∈ CLS').
{ unfold CLS'.
apply finsubset_elem.
- intros. rewrite <- H5; auto.
- split; auto.
+ apply i.
split.
* destruct hf; auto.
red in Minh. simpl.
destruct Minh as [x ?].
exists x.
apply fin_intersect_elem. split; auto.
* split; auto.
** red; intros.
apply fin_intersect_elem in H5.
destruct H5; auto.
** apply mub_closed_intersect; auto.
apply normal_set_mub_closed; auto.
+ red; intros.
apply fin_intersect_elem.
split; auto.
}
apply H4 in H5.
apply fin_intersect_elem in H5.
destruct H5; auto.
Qed.
(** In a MUB complete preorder, every MUB closed set is normal.
*)
Lemma mub_closed_normal_set : forall Q (HQ:inh hf Q),
is_mub_complete hf A ->
mub_closed hf A Q ->
normal_set Q.
Proof.
intros. split; auto. repeat intro.
set (Q' := finsubset A (fun x => x ≤ z) (fun x => eff_ord_dec A Heff x z) Q).
destruct (H Q' z).
- apply inh_sub with M; auto.
- red; intros.
unfold Q' in H2.
apply finsubset_elem in H2.
+ destruct H2; auto.
+ intros. rewrite <- H4; auto.
- destruct H2.
assert (x ∈ Q).
{ apply (H0 Q'); auto.
- apply inh_sub with M; auto.
- unfold Q'; red; intros.
apply finsubset_elem in H4.
+ destruct H4; auto.
+ intros. rewrite <- H6; auto.
}
exists x. split; auto.
+ red; intros.
destruct H2.
apply H2.
unfold Q'.
apply finsubset_elem.
* intros. rewrite <- H7; auto.
* split; auto.
** apply H1 in H5.
apply finsubset_elem in H5.
*** destruct H5; auto.
*** intros. rewrite <- H8; auto.
** apply H1 in H5.
apply finsubset_elem in H5.
*** destruct H5; auto.
*** intros. rewrite <- H8; auto.
+ unfold Q'.
apply finsubset_elem.
* intros. rewrite <- H5; auto.
* split; auto.
Qed.
Hypothesis Hnorm : has_normals.
Lemma check_inh (X:finset A) : { X = nil /\ hf = true }+{ inh hf X }.
Proof.
destruct hf.
- simpl.
destruct X. left; auto.
right. exists c. apply cons_elem; auto.
- right. red. auto.
Qed.
(** Define the MUB closure operation in a preorder with normal sets.
Some slightly funny games are played here to ensure that the MUB
closure operation is a total function even when hf = true. In this
case, the MUB closure of nil is nil; this works because nil is
(vacuously) MUB closed when h = true.
*)
Definition norm_closure X :=
match check_inh X with
| left _ => nil
| right Xinh =>
match Hnorm X Xinh with
| exist _ Q (conj HQ1 HQ2) => proj1_sig (normal_set_mub_closure Q HQ2 X Xinh HQ1)
end
end.
(** A preorder is Plotkin whenever it has normal sets.
*)
Program Definition norm_plt : plotkin_order hf A :=
PlotkinOrder hf A _ norm_closure _ _ _.
Next Obligation.
red; intros.
destruct (Hnorm M) as [Q [??]]; auto.
destruct (normal_has_mubs Q H2 M H H1) as [MUBS [?[??]]].
destruct (H5 x) as [m [?[??]]]; auto.
exists m; split; auto.
Qed.
Next Obligation.
repeat intro.
unfold norm_closure.
destruct (check_inh M).
- destruct a0. subst M; auto.
- destruct (Hnorm M i) as [Q [??]].
destruct (normal_set_mub_closure Q n M i i0).
simpl.
destruct a0.
apply H0. auto.
Qed.
Next Obligation.
repeat intro.
unfold norm_closure in *.
destruct (check_inh M).
- destruct a. subst. rewrite H3 in H.
destruct H. apply H0 in H.
apply nil_elem in H. elim H.
- destruct (Hnorm M i) as [Q [??]].
destruct (normal_set_mub_closure Q n M i i0).
simpl in *.
destruct a.
destruct H3.
apply H3 with M0; auto.
Qed.
Next Obligation.
repeat intro.
unfold norm_closure in *.
destruct (check_inh M).
- apply nil_elem in H1. elim H1.
- destruct (Hnorm M i) as [Q [??]].
destruct (normal_set_mub_closure Q n M i i0).
simpl in *.
destruct a0 as [?[??]].
apply H4; auto.
Qed.
End normal_sets.
(** The product of two effective Plotkin orders has normal sets. *)
Lemma prod_has_normals hf (A B:preord)
(HAeff:effective_order A)
(HBeff:effective_order B)
(HA:plotkin_order hf A)
(HB:plotkin_order hf B) :
has_normals (A×B) (effective_prod HAeff HBeff) hf.
Proof.
red; intros.
exists (finprod (mub_closure HA (image π₁ X))
(mub_closure HB (image π₂ X))).
split.
- red; intros.
destruct a.
apply finprod_elem.
split.
+ apply mub_clos_incl.
change c with (π₁#((c,c0):(A×B))).
apply image_axiom1. auto.
+ apply mub_clos_incl.
change c0 with (π₂#((c,c0):(A×B))).
apply image_axiom1. auto.
- apply mub_closed_normal_set.
+ destruct hf; auto.
destruct Hinh as [x ?].
exists x.
destruct x as [a b].
apply finprod_elem.
split; apply mub_clos_incl; auto.
* change a with (π₁#((a,b):A×B)).
apply image_axiom1. auto.
* change b with (π₂#((a,b):A×B)).
apply image_axiom1. auto.
+ red. intros M x HMinh. intro.
destruct x as [a b].
destruct (mub_complete HA (image π₁ M) a).