forked from inQWIRE/QuantumLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCtopology.v
2105 lines (1885 loc) · 70.2 KB
/
Ctopology.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Require Export Polynomial.
Require Import Setoid.
(************************************)
(* First, we define a topology on C *)
(************************************)
Declare Scope topology_scope.
Delimit Scope topology_scope with T.
Open Scope topology_scope.
(* we define a subset of C as a function from C to {True, False} *)
(* so c is in A if A(c) = True *)
Definition Cset := C -> Prop.
Definition union (A B : Cset) : Cset :=
fun c => A c \/ B c.
Definition intersection (A B : Cset) : Cset :=
fun c => A c /\ B c.
Definition complement (A : Cset) : Cset :=
fun c => not (A c).
Definition setminus (A B : Cset) : Cset :=
intersection A (complement B).
Definition is_in (a : C) (A : Cset) : Prop := A a.
Definition subset (A B : Cset) : Prop :=
forall c, A c -> B c.
Definition eq_set (A B : Cset) : Prop :=
forall c, A c <-> B c.
Definition ϵ_disk (a : C) (ϵ : R) : Cset :=
fun c => Cmod (c - a) < ϵ.
Definition open_square (cen : C) (s : R) : Cset :=
fun c => Rabs (fst c - fst cen) < s /\ Rabs (snd c - snd cen) < s.
Definition open_rect (cen : C) (s1 s2 : R) : Cset :=
fun c => Rabs (fst c - fst cen) < s1 /\ Rabs (snd c - snd cen) < s2.
Definition bounded (A : Cset) : Prop :=
exists ϵ, subset A (ϵ_disk C0 ϵ).
Definition image (f : C -> C) (A : Cset) : Cset :=
fun c => (exists c', A c' /\ f c' = c).
Definition preimage (f : C -> C) (B : Cset) : Cset :=
fun c => B (f c).
Definition continuous_on (f : C -> C) (A : Cset) : Prop :=
forall c, A c -> continuous_at f c.
Infix "∪" := union (at level 50, left associativity) : topology_scope.
Infix "∩" := intersection (at level 40, left associativity) : topology_scope.
Infix "⊂" := subset (at level 0) : topology_scope.
Infix "⩦" := eq_set (at level 0) : topology_scope.
Infix "\" := setminus (at level 0) : topology_scope.
Infix "@" := image (at level 0) : topology_scope.
Notation "f *{ A }" := (preimage f A) (at level 0) : topology_scope.
Notation "A `" := (complement A) (at level 0) : topology_scope.
Infix "∈" := is_in (at level 0) : topology_scope.
Notation "B( a , ϵ )" := (ϵ_disk a ϵ) (at level 30, no associativity) : topology_scope.
Definition open (A : Cset) : Prop :=
forall c, A c -> exists ϵ, ϵ > 0 /\ B(c,ϵ) ⊂ A.
Definition closed (A : Cset) : Prop :=
open (A`).
Definition empty_set : Cset :=
fun _ => False.
Definition C_ : Cset :=
fun _ => True.
(** showing that all the above def's are preserved by eq_set *)
Lemma eq_set_refl : forall (A : Cset), A ⩦ A.
Proof. easy. Qed.
Lemma eq_set_symm : forall (A B : Cset), A ⩦ B -> B ⩦ A.
Proof. easy. Qed.
Lemma eq_set_trans : forall (A B C : Cset),
A ⩦ B -> B ⩦ C -> A ⩦ C.
Proof. intros.
unfold eq_set in *; intros.
split; intros.
apply H0; apply H; easy.
apply H; apply H0; easy.
Qed.
Add Parametric Relation : Cset eq_set
reflexivity proved by eq_set_refl
symmetry proved by eq_set_symm
transitivity proved by eq_set_trans
as eq_set_equiv_rel.
Add Parametric Morphism : subset
with signature eq_set ==> eq_set ==> iff as subset_mor.
Proof. unfold subset, eq_set; split; intros;
apply H0; apply H1; apply H; easy.
Qed.
Add Parametric Morphism : union
with signature eq_set ==> eq_set ==> eq_set as union_mor.
Proof. unfold union, eq_set; split; intros; destruct H1;
try (left; apply H; easy); right; apply H0; easy.
Qed.
Add Parametric Morphism : intersection
with signature eq_set ==> eq_set ==> eq_set as intersection_mor.
Proof. unfold intersection, eq_set; split; intros; split;
try (apply H; apply H1); apply H0; apply H1.
Qed.
Add Parametric Morphism : bounded
with signature eq_set ==> iff as bounded_mor.
Proof. unfold bounded; split; intros;
destruct H0; exists x0.
rewrite <- H; easy.
rewrite H; easy.
Qed.
Add Parametric Morphism : open
with signature eq_set ==> iff as open_mor.
Proof. unfold open; split; intros;
apply H in H1; apply H0 in H1; destruct H1 as [e [H2 H3] ];
exists e; split; auto.
rewrite <- H; easy.
rewrite H; easy.
Qed.
(* one quick helper *)
Lemma Cmod_lt_helper : forall (c : C) (ϵ : R),
Cmod c < ϵ -> Rabs (fst c) < ϵ /\ Rabs (snd c) < ϵ.
Proof. intros.
assert (H' := Rmax_Cmod c).
split.
- eapply Rle_lt_trans.
eapply Rle_trans.
apply Rmax_l.
apply H'.
easy.
- eapply Rle_lt_trans.
eapply Rle_trans.
apply Rmax_r.
apply H'.
easy.
Qed.
(** Subset lemmas *)
Lemma subset_cup_l : forall (A B : Cset),
A ⊂ (A ∪ B).
Proof. unfold subset, union; left; easy. Qed.
Lemma subset_cup_r : forall (A B : Cset),
B ⊂ (A ∪ B).
Proof. unfold subset, union; right; easy. Qed.
Lemma subset_cap_l : forall (A B : Cset),
(A ∩ B) ⊂ A.
Proof. unfold subset, intersection; easy. Qed.
Lemma subset_cap_r : forall (A B : Cset),
(A ∩ B) ⊂ B.
Proof. unfold subset, intersection; easy. Qed.
Lemma subset_self : forall (A : Cset),
A ⊂ A.
Proof. easy. Qed.
Lemma subset_transitive : forall (A B C : Cset),
A ⊂ B -> B ⊂ C -> A ⊂ C.
Proof. unfold subset; intros.
apply H0; apply H; easy.
Qed.
#[global] Hint Resolve subset_cup_l subset_cup_r subset_cap_l subset_cap_r subset_self subset_transitive : Csub_db.
Lemma subset_cup_reduce : forall (A B C : Cset),
A ⊂ B \/ A ⊂ C -> A ⊂ (B ∪ C).
Proof. unfold subset, union; intros.
destruct H.
- left; apply H; easy.
- right; apply H; easy.
Qed.
Lemma subset_cap_reduce : forall (A B C : Cset),
A ⊂ B /\ A ⊂ C -> A ⊂ (B ∩ C).
Proof. unfold subset, intersection; intros.
destruct H; split.
apply H; easy.
apply H1; easy.
Qed.
Lemma subset_ball_l : forall (a : C) (ϵ1 ϵ2 : R),
B(a, Rmin ϵ1 ϵ2) ⊂ B(a, ϵ1).
Proof. unfold subset, ϵ_disk; intros.
eapply Rlt_le_trans; eauto.
apply Rmin_l.
Qed.
Lemma subset_ball_r : forall (a : C) (ϵ1 ϵ2 : R),
B(a, Rmin ϵ1 ϵ2) ⊂ B(a, ϵ2).
Proof. unfold subset, ϵ_disk; intros.
eapply Rlt_le_trans; eauto.
apply Rmin_r.
Qed.
Lemma subset_C_ : forall (A : Cset),
A ⊂ C_.
Proof. unfold subset; easy. Qed.
#[global] Hint Resolve subset_cup_reduce subset_cap_reduce subset_ball_l subset_ball_r subset_C_ : Csub_db.
Lemma subset_equal : forall (A B : Cset),
A ⊂ B -> B ⊂ A -> A ⩦ B.
Proof. unfold subset, eq_set; intros.
split; try apply H; apply H0.
Qed.
Lemma subset_not : forall (A B : Cset),
~ (A ⊂ B) -> (exists a, A a /\ B` a).
Proof. intros.
destruct (Classical_Prop.classic (exists a : C, A a /\ (B) ` a)); auto.
assert (H1 : forall a, ~ (A a /\ (B) ` a)).
{ unfold not; intros.
apply H0; exists a; easy. }
assert (H2 : A ⊂ B).
{ unfold subset; intros.
assert (H' := H1 c).
apply Classical_Prop.not_and_or in H'.
destruct H'; try easy.
unfold not, complement in H3.
apply Decidable.dec_not_not; auto.
unfold Decidable.decidable.
apply Classical_Prop.classic. }
easy.
Qed.
(* some image and preimage relationships with subsets *)
Lemma subset_image : forall (A B : Cset) (f : C -> C),
A ⊂ B -> (f @ A) ⊂ (f @ B).
Proof. unfold subset; intros.
destruct H0 as [x [H0 H1] ].
apply H in H0.
exists x; easy.
Qed.
(* showing subset relationships between squares, circles, and rectangles *)
Lemma circle_in_square : forall (cen : C) (s : R),
(ϵ_disk cen s) ⊂ (open_square cen s).
Proof. unfold subset, ϵ_disk, open_square; intros.
apply Cmod_lt_helper in H.
easy.
Qed.
Lemma square_in_circle : forall (cen : C) (ϵ : R),
(open_square cen (ϵ / √ 2)) ⊂ (ϵ_disk cen ϵ).
Proof. unfold subset, ϵ_disk, open_square; intros.
destruct H.
destruct (Rle_lt_dec ϵ 0).
- assert (H' : ϵ / √ 2 <= 0).
{ unfold Rdiv.
rewrite <- (Rmult_0_r ϵ).
apply Rmult_le_compat_neg_l; auto; left.
apply Rinv_0_lt_compat; apply Rlt_sqrt2_0. }
assert (H1 := Rabs_pos ((fst c - fst cen))).
lra.
- assert (H' : 0 < ϵ / √ 2).
unfold Rdiv; apply Rmult_lt_0_compat; auto.
apply Rinv_0_lt_compat; apply Rlt_sqrt2_0.
assert (H1 : (ϵ / √ 2 = Rabs (ϵ / √ 2))%R).
{ unfold Rabs.
destruct (Rcase_abs (ϵ / √ 2)); lra. }
rewrite H1 in *.
apply Rsqr_lt_abs_1 in H; apply Rsqr_lt_abs_1 in H0.
assert (H2 : ((ϵ / √ 2)² = ϵ² / 2)%R).
{ unfold Rsqr, Rdiv.
R_field_simplify; try easy.
apply sqrt2_neq_0. }
rewrite H2 in *.
unfold Cmod.
rewrite <- sqrt_Rsqr; try lra.
apply sqrt_lt_1_alt. split.
apply Rplus_le_le_0_compat; apply pow2_ge_0.
rewrite double_var.
apply Rplus_lt_compat;
unfold Rsqr in *; simpl; lra.
Qed.
Lemma square_is_rectangle : forall (cen : C) (s : R),
(open_square cen s) ⩦ (open_rect cen s s).
Proof. intros; easy. Qed.
Lemma square_in_rect_at_point : forall (cen c : C) (s1 s2 : R),
s1 > 0 -> s2 > 0 ->
(open_rect cen s1 s2) c ->
exists s, s > 0 /\ (open_square c s) ⊂ (open_rect cen s1 s2).
Proof. intros.
exists (Rmin (s1 - (Rabs (fst c - fst cen))) (s2 - (Rabs (snd c - snd cen)))).
destruct H1 as [H1 H2].
repeat split.
apply Rmin_pos; try lra.
all : destruct H3.
- eapply Rlt_le_trans in H3; try apply Rmin_l.
replace (fst c0 - fst cen)%R with ((fst c0 - fst c) + (fst c - fst cen))%R by lra.
eapply Rle_lt_trans; try apply Rabs_triang; lra.
- eapply Rlt_le_trans in H4; try apply Rmin_r.
replace (snd c0 - snd cen)%R with ((snd c0 - snd c) + (snd c - snd cen))%R by lra.
eapply Rle_lt_trans; try apply Rabs_triang; lra.
Qed.
Lemma square_contains_center : forall (cen : C) (s : R),
s > 0 -> open_square cen s cen.
Proof. intros.
unfold open_square.
do 2 rewrite Rminus_eq_0, Rabs_R0; easy.
Qed.
(** some lemmas about open/closed sets *)
Lemma emptyset_open : open empty_set.
Proof. easy. Qed.
Lemma C_open : open C_.
Proof. unfold open, C_, is_in; intros.
exists 1; split; try lra.
easy.
Qed.
Lemma ball_open : forall (a : C) (ϵ : R),
ϵ > 0 -> open (B(a,ϵ)).
Proof. unfold open; intros.
unfold ϵ_disk in H0.
exists (ϵ - Cmod (c - a))%R.
split; try lra.
unfold subset; intros.
unfold ϵ_disk in *.
assert (H2 : Cmod (c0 - c) + Cmod (c - a) < ϵ). { lra. }
apply Cmod_triangle_diff in H2.
easy.
Qed.
Lemma closed_ball_complement_open : forall (c : C) (r : R),
open (fun c' => Cmod (c' - c) > r).
Proof. unfold open; intros.
exists (Cmod (c0 - c) - r)%R.
split; try lra.
unfold subset, ϵ_disk; intros.
assert (H' := Cmod_triangle (c1 - c) (c0 - c1)).
replace (c1 - c + (c0 - c1)) with (c0 - c) in H' by lca.
rewrite Cmod_switch in H0; lra.
Qed.
Lemma closed_ball_closed : forall (a : C) (ϵ : R),
closed (fun c' => Cmod (c' - a) <= ϵ).
Proof. intros; unfold closed.
assert (H' : (fun c' : C => Cmod (c' - a) <= ϵ) ` ⩦ (fun c' : C => Cmod (c' - a) > ϵ)).
{ apply subset_equal; unfold subset, complement; intros; lra. }
rewrite H'.
apply closed_ball_complement_open.
Qed.
Lemma rect_open : forall (cen : C) (s1 s2 : R),
s1 > 0 -> s2 > 0 -> open (open_rect cen s1 s2).
Proof. unfold open; intros.
apply square_in_rect_at_point in H1; auto.
destruct H1 as [s [H1 H2] ].
exists s; split; auto.
eapply subset_transitive; try apply H2.
apply circle_in_square.
Qed.
Lemma cup_open : forall (A B : Cset),
open A -> open B -> open (A ∪ B).
Proof. unfold open; intros.
unfold union in H1.
destruct H1.
- destruct ((H c) H1) as [ϵ [H2 H3] ].
exists ϵ.
split; eauto with Csub_db.
- destruct ((H0 c) H1) as [ϵ [H2 H3] ].
exists ϵ.
split; eauto with Csub_db.
Qed.
Lemma cap_open : forall (A B : Cset),
open A -> open B -> open (A ∩ B).
Proof. unfold open; intros.
unfold intersection in H1.
destruct H1.
destruct ((H c) H1) as [ϵ1 [H3 H4] ].
destruct ((H0 c) H2) as [ϵ2 [H5 H6] ].
exists (Rmin ϵ1 ϵ2).
split.
apply Rmin_Rgt_r; easy.
eauto with Csub_db.
Qed.
(** lemmas about preimage *)
(** some lemmas showing basic properties *)
Lemma complement_involutive : forall (A : Cset),
(A`)` ⩦ A.
Proof. unfold complement; intros.
apply subset_equal.
- unfold subset; intros.
apply Classical_Prop.NNPP; easy.
- unfold subset; intros.
unfold not. intros.
easy.
Qed.
Lemma bounded_cup : forall (A B : Cset),
bounded A -> bounded B -> bounded (A ∪ B).
Proof. intros.
destruct H as [ϵ1 H].
destruct H0 as [ϵ2 H0].
exists (Rmax ϵ1 ϵ2).
unfold subset, ϵ_disk in *; intros.
destruct H1.
- apply H in H1.
eapply Rlt_le_trans; eauto.
apply Rmax_l.
- apply H0 in H1.
eapply Rlt_le_trans; eauto.
apply Rmax_r.
Qed.
(************************)
(* Defining compactness *)
(************************)
Definition Ccover := Cset -> Prop.
Definition WF_cover (G : Ccover) : Prop :=
forall A A', (A ⩦ A' /\ G A) -> G A'.
Definition WFify_cover (G : Ccover) : Ccover :=
fun A => exists A', A ⩦ A' /\ G A'.
Definition open_cover (G : Ccover) : Prop :=
forall A, G A -> open A.
Definition subcover (G1 G2 : Ccover) : Prop :=
forall A, G1 A -> G2 A.
Definition eq_cover (G1 G2 : Ccover) : Prop :=
forall A, G1 A <-> G2 A.
(* used in list_to_cover *)
Fixpoint In' (A : Cset) (l : list Cset) : Prop :=
match l with
| [] => False
| (A' :: l) => A ⩦ A' \/ In' A l
end.
Definition list_to_cover (l : list Cset) : Ccover :=
fun A => In' A l.
Definition finite_cover (G : Ccover) : Prop :=
exists l, eq_cover G (list_to_cover l).
Definition big_cup (G : Ccover) : Cset :=
fun c => (exists A, G A /\ A c).
Definition big_cap (G : Ccover) : Cset :=
fun c => (forall A, G A -> A c).
(* the star of the show! *)
Definition compact (A : Cset) : Prop :=
forall G, open_cover G -> WF_cover G -> A ⊂ (big_cup G) ->
(exists G', finite_cover G' /\ subcover G' G /\ A ⊂ (big_cup G')).
(* showing some basic wf lemmas *)
Lemma WF_WFify : forall (G : Ccover),
WF_cover (WFify_cover G).
Proof. intros. unfold WF_cover, WFify_cover. intros.
destruct H as [H [A0 [H0 H1 ] ] ].
exists A0; split; try easy.
symmetry in H.
eapply eq_set_trans;
try apply H; easy.
Qed.
Lemma WF_finitecover : forall (l : list Cset),
WF_cover (list_to_cover l).
Proof. induction l as [| A].
- unfold WF_cover, list_to_cover; intros.
destruct H.
easy.
- unfold WF_cover, list_to_cover in *; intros.
destruct H; destruct H0.
left; rewrite <- H, <- H0; easy.
right; apply (IHl A0); easy.
Qed.
Lemma WFify_is_projection : forall (G : Ccover),
WF_cover G ->
eq_cover G (WFify_cover G).
Proof. unfold eq_cover; intros; split; intros.
exists A; easy.
destruct H0 as [A0 [H0 H1] ].
apply (H A0 A); easy.
Qed.
(* showing that all the def's are preserved by eq_cover *)
Lemma eq_cover_refl : forall (G : Ccover), eq_cover G G.
Proof. easy. Qed.
Lemma eq_cover_symm : forall (G1 G2 : Ccover), eq_cover G1 G2 -> eq_cover G2 G1.
Proof. easy. Qed.
Lemma eq_cover_trans : forall (G1 G2 G3 : Ccover),
eq_cover G1 G2 -> eq_cover G2 G3 -> eq_cover G1 G3.
Proof. intros.
unfold eq_cover in *; intros.
split; intros.
apply H0; apply H; easy.
apply H; apply H0; easy.
Qed.
Add Parametric Relation : Ccover eq_cover
reflexivity proved by eq_cover_refl
symmetry proved by eq_cover_symm
transitivity proved by eq_cover_trans
as eq_cover_equiv_rel.
Add Parametric Morphism : subcover
with signature eq_cover ==> eq_cover ==> iff as subcover_mor.
Proof. intros. unfold subcover, eq_cover; split; intros;
apply H0; apply H1; apply H; easy.
Qed.
Add Parametric Morphism : open_cover
with signature eq_cover ==> iff as opencover_mor.
Proof. unfold eq_cover, open_cover; split; intros;
apply H0; apply H; easy.
Qed.
Add Parametric Morphism : big_cup
with signature eq_cover ==> eq_set as bigcup_mor.
Proof. unfold eq_cover, big_cup; split; intros;
destruct H0 as [A [H0 H1] ]; exists A; split; auto; apply H; auto.
Qed.
Add Parametric Morphism : big_cap
with signature eq_cover ==> eq_set as bigcap_mor.
Proof. unfold eq_cover, big_cap; split; intros;
apply H0; apply H; apply H1.
Qed.
(* must also show that compactness is preserved by eq_set *)
Add Parametric Morphism : compact
with signature eq_set ==> iff as compact_mor.
Proof. intros. unfold compact; split; intros.
- rewrite <- H in *.
apply H0 in H3; try easy.
destruct H3 as [G' [H3 [H4 H5] ] ].
rewrite H in H5.
exists G'; easy.
- rewrite H in *.
apply H0 in H3; try easy.
destruct H3 as [G' [H3 [H4 H5] ] ].
rewrite <- H in H5.
exists G'; easy.
Qed.
(** now some lemmas *)
Lemma list_to_cover_reduce : forall (A A0 : Cset) (l : list Cset),
list_to_cover (A :: l) A0 <->
A ⩦ A0 \/ list_to_cover l A0.
Proof. intros; split; intros;
destruct H; try (left; easy); right; easy.
Qed.
Lemma open_cover_reduce : forall (l : list Cset) (A : Cset),
open_cover (list_to_cover (A :: l)) ->
open A /\ open_cover (list_to_cover l).
Proof. intros; split; unfold open_cover in H.
apply H.
apply list_to_cover_reduce; left; easy.
unfold open_cover; intros.
apply H.
apply list_to_cover_reduce; right; easy.
Qed.
Lemma subcover_reduce : forall (l : list Cset) (A : Cset) (G : Ccover),
subcover (list_to_cover (A :: l)) G ->
G A /\ subcover (list_to_cover l) G.
Proof. intros; split.
apply H.
apply list_to_cover_reduce; left; easy.
unfold subcover; intros.
apply H.
apply list_to_cover_reduce; right; easy.
Qed.
Lemma finite_cover_subset : forall (l : list Cset) (G : Ccover),
WF_cover G -> subcover G (list_to_cover l) ->
finite_cover G.
Proof. induction l as [| A].
- intros.
exists []; split; intros; auto; easy.
- intros.
destruct (IHl (fun A' => G A' /\ ~ (eq_set A' A))).
+ unfold WF_cover in *; intros; split;
destruct H1 as [H1 [H2 H3] ].
apply (H A0 A'); easy.
unfold not; intros; apply H3.
rewrite H1; easy.
+ unfold subcover in *; intros.
destruct H1.
apply H0 in H1.
apply list_to_cover_reduce in H1.
destruct H1; try easy.
unfold not in H2.
symmetry in H1.
apply H2 in H1; easy.
+ destruct (Classical_Prop.classic (G A)).
* exists (A :: x).
unfold eq_cover; split; intros; simpl.
destruct (Classical_Prop.classic (A ⩦ A0)); try (left; easy).
right; apply H1; split; auto.
unfold not; intros; apply H4; easy.
apply list_to_cover_reduce in H3.
destruct H3.
apply (H A A0); easy.
apply H1 in H3; easy.
* exists x.
unfold eq_cover; intros; split; intros.
apply H1; split; auto.
unfold not; intros; apply H2.
apply (H A0 A); easy.
apply H1 in H3; easy.
Qed.
Lemma big_cup_extend_l : forall (l : list Cset) (A : Cset),
(A ∪ (big_cup (list_to_cover l))) ⩦ (big_cup (list_to_cover (A :: l))).
Proof. intros.
unfold union, big_cup, list_to_cover; intros.
apply subset_equal.
- unfold subset; intros.
destruct H.
+ exists A; split; try left; easy.
+ destruct H as [A0 [H H0] ].
exists A0. split; try right; easy.
- unfold subset; intros.
destruct H as [A0 [ [H | H] H0] ]; subst.
left; apply H; easy.
right; exists A0; split; easy.
Qed.
Lemma big_cap_extend_l : forall (l : list Cset) (A : Cset),
(A ∩ (big_cap (list_to_cover l))) ⩦ (big_cap (list_to_cover (A :: l))).
Proof. intros.
unfold intersection, big_cap, list_to_cover; intros.
apply subset_equal.
- unfold subset; intros.
destruct H; destruct H0; subst; try easy.
apply H0; easy.
apply H1; apply H0.
- unfold subset; intros.
split.
apply H; left; easy.
intros; apply H; right; apply H0.
Qed.
Lemma app_union : forall (l1 l2 : list Cset),
(big_cup (list_to_cover (l1 ++ l2))) ⩦
((big_cup (list_to_cover l1)) ∪ (big_cup (list_to_cover l2))).
Proof. induction l1 as [| A].
- intros; simpl.
apply subset_equal; auto with Csub_db.
unfold subset; intros.
destruct H; try easy.
destruct H; easy.
- intros.
rewrite <- app_comm_cons.
rewrite <- big_cup_extend_l.
rewrite IHl1.
rewrite <- big_cup_extend_l.
split; intros.
+ destruct H.
left; left; easy.
destruct H. left; right; easy.
right; easy.
+ destruct H. destruct H.
left; easy.
right; left; easy.
right; right; easy.
Qed.
Lemma In'_app_or : forall (l1 l2 : list Cset) (A : Cset),
In' A (l1 ++ l2) -> In' A l1 \/ In' A l2.
Proof. induction l1 as [| A0].
- intros; right; easy.
- intros.
rewrite <- app_comm_cons in H.
destruct H.
left; left; easy.
apply IHl1 in H.
destruct H.
left; right; easy.
right; easy.
Qed.
Lemma In'_map : forall {X} (l : list X) (f : X -> Cset) (A : Cset),
In' A (map f l) -> exists (x : X), (f x) ⩦ A /\ In x l.
Proof. induction l; firstorder (subst; auto).
Qed.
Lemma arb_cup_open : forall (G : Ccover),
open_cover G -> open (big_cup G).
Proof. unfold open_cover, open, big_cup in *; intros.
destruct H0 as [A [H0 H1] ].
destruct (H A H0 c) as [ϵ [H2 H3] ]; auto.
exists ϵ.
split; auto.
eapply subset_transitive; eauto.
unfold subset; intros.
exists A; split; easy.
Qed.
Lemma ltc_open : forall (l : list Cset),
open_cover (list_to_cover l) -> open (big_cap (list_to_cover l)).
Proof. induction l as [| h].
- intros.
unfold list_to_cover, big_cap, open; intros.
exists 1; split; try easy; lra.
- intros.
apply open_cover_reduce in H.
rewrite <- big_cap_extend_l.
apply cap_open; try easy.
apply IHl; easy.
Qed.
Lemma fin_cap_open : forall (G : Ccover),
open_cover G -> finite_cover G -> open (big_cap G).
Proof. intros.
unfold finite_cover in H0.
destruct H0 as [l H0].
rewrite H0.
apply ltc_open.
rewrite <- H0; easy.
Qed.
(* we have not yet defined enough setup to define preimage for functions whose domains differ
from C_. This is fine when proving FTA, since polynomials are continuous everywhere.
Could be expanded if we want to make a general topology library *)
Lemma continuous_preimage_open : forall (f : C -> C),
continuous_on f C_ -> (forall A, open A -> open f*{A}).
Proof. intros.
unfold open in *; intros.
unfold preimage in H1.
destruct (H0 (f c) H1) as [ϵ [H2 H3] ].
assert (H' : C_ c). easy.
destruct (H c H' ϵ) as [δ [H4 H5] ]; auto.
exists δ; split; auto.
unfold subset, preimage, ϵ_disk in *; intros.
destruct (Ceq_dec c0 c); subst; try easy.
apply H3; apply H5; try easy.
Qed.
Lemma preimage_open_continuous : forall (f : C -> C),
(forall A, open A -> open f*{A}) -> continuous_on f C_.
Proof. unfold continuous_on; intros.
unfold continuous_at, limit_at_point; intros.
assert (H2 := (H ( B(f c,ϵ) ) (ball_open (f c) ϵ H1))).
unfold open in H2.
destruct (H2 c) as [δ [H3 H4] ].
unfold preimage, ϵ_disk.
replace (f c - f c)%C with C0 by lca.
rewrite Cmod_0; lra.
exists δ; split; auto; intros.
unfold preimage, subset, ϵ_disk in H4.
apply H4; easy.
Qed.
(* we define the preimage of a cover *)
Definition preimage_cover (f : C -> C) (G : Ccover) : Ccover :=
fun A => (exists A', G A' /\ A ⩦ (f*{A'})).
Lemma open_cover_preimage_open : forall (f : C -> C) (G : Ccover),
open_cover G -> continuous_on f C_ ->
open_cover (preimage_cover f G).
Proof. intros.
unfold open_cover, preimage_cover; intros.
destruct H1 as [A' [H1 H2] ]; subst.
apply H in H1.
rewrite H2.
apply (continuous_preimage_open _ H0); easy.
Qed.
Lemma WF_preimage_cover : forall (f : C -> C) (G : Ccover),
WF_cover (preimage_cover f G).
Proof. unfold WF_cover, preimage_cover; intros.
destruct H as [H [A0 [H0 H1] ] ].
exists A0; split; auto.
rewrite <- H; easy.
Qed.
Lemma subset_preimage_pres : forall (f : C -> C) (A : Cset) (G : Ccover),
((f) @ (A)) ⊂ (big_cup G) ->
A ⊂ (big_cup (preimage_cover f G)).
Proof. unfold subset; intros.
unfold big_cup, preimage_cover.
assert (H' : big_cup G (f c)).
{ apply H.
exists c; split; easy. }
unfold big_cup in H'.
destruct H' as [A0 [H1 H2] ].
exists (f*{A0}); split; try easy.
exists A0; split; easy.
Qed.
Lemma extract_finite_image : forall (f : C -> C) (l : list Cset) (A : Cset) (G : Ccover),
WF_cover G ->
subcover (list_to_cover l) (preimage_cover f G) ->
A ⊂ (big_cup (list_to_cover l)) ->
exists l', subcover (list_to_cover l') G /\ (f @ A) ⊂ (big_cup (list_to_cover l')).
Proof. induction l as [| A0].
- intros.
exists []; split; auto.
unfold subcover; easy.
unfold subset in *; intros.
destruct H2 as [c0 [H2 H3] ].
apply H1 in H2.
unfold list_to_cover, big_cup in H2.
destruct H2; easy.
- intros.
apply subcover_reduce in H0.
destruct H0.
apply (IHl (A \ A0)) in H2; auto.
destruct H0 as [A'0 [H0 H3] ].
destruct H2 as [l' [H2 H4] ].
exists (A'0 :: l'); split.
unfold subcover, list_to_cover; intros.
destruct H5; try (apply (H A'0 A1); easy).
apply H2; easy.
unfold subset in *; intros.
apply big_cup_extend_l.
destruct (Classical_Prop.classic (A'0 c)).
left; easy.
right; apply H4.
destruct H5 as [c' [H5 H7] ].
exists c'; repeat split; auto.
unfold complement, not; intros.
apply H6; apply H3 in H8.
unfold preimage in H8; subst; easy.
unfold subset in *; intros.
destruct H3; apply H1 in H3.
apply big_cup_extend_l in H3.
destruct H3; easy.
Qed.
Lemma continuous_image_compact : forall (f : C -> C) (A : Cset),
continuous_on f C_ -> compact A ->
compact (f @ A).
Proof. intros.
unfold compact; intros.
assert (H4 := (subset_preimage_pres _ _ _ H3)).
apply H0 in H4.
destruct H4 as [G' [H4 [H5 H6] ] ].
destruct H4 as [l H4]; subst.
destruct (extract_finite_image f l A G) as [l' [H7 H8] ]; auto.
all : try (rewrite <- H4; easy).
exists (list_to_cover l'); repeat split; try easy.
exists l'; easy.
apply open_cover_preimage_open; easy.
apply WF_preimage_cover.
Qed.
(*************************************************************************)
(* We now introduce cube_compact and show that is is the same as compact *)
(*************************************************************************)
Definition cube_cover (G : Ccover) : Prop :=
forall A, G A -> exists s cen, s > 0 /\ A ⩦ (open_square cen s).
Definition cube_compact (A : Cset) : Prop :=
forall G, cube_cover G -> WF_cover G -> A ⊂ (big_cup G) ->
(exists G', finite_cover G' /\ subcover G' G /\ A ⊂ (big_cup G')).
(* we use this to turn covers to cube_covers *)
Definition cover_to_cube_cover (G : Ccover) : Ccover :=
fun A => (exists s cen A', s > 0 /\ (A ⩦ (open_square cen s)) /\ G A' /\ (open_square cen s) ⊂ A').
Lemma cube_cover_open_cover : forall (G : Ccover),
cube_cover G -> open_cover G.
Proof. unfold open_cover, cube_cover; intros.
apply H in H0.
destruct H0 as [s [cen [H0 H1] ] ].
rewrite H1, square_is_rectangle.
apply rect_open; easy.
Qed.
Lemma WF_ctcc : forall (G : Ccover),
WF_cover (cover_to_cube_cover G).
Proof. unfold WF_cover; intros.
destruct H.
destruct H0 as [s [cen [A0 [H0 [H1 [H2 H3] ] ] ] ] ].
exists s, cen, A0; split; auto.
split; try easy.
rewrite <- H1; easy.
Qed.
Lemma cube_cover_ctcc : forall (G : Ccover),
cube_cover (cover_to_cube_cover G).
Proof. unfold cube_cover; intros.
destruct H as [s [cen [A0 [H0 [H1 [H2 H3] ] ] ] ] ].
exists s, cen.
split; easy.
Qed.
Lemma ctcc_in_cover : forall (G : Ccover),
open_cover G -> (big_cup G) ⩦ (big_cup (cover_to_cube_cover G)).
Proof. intros; split; intros.
- destruct H0 as [A [H0 H1] ].
assert (H0' := H0).
apply H in H0.
assert (H2 := H1); apply H0 in H1.
destruct H1 as [ϵ [H1 H3] ].
exists (open_square c (ϵ / √ 2)).
split.
unfold cover_to_cube_cover.
exists (ϵ / √ 2)%R, c, A; split.
apply lt_ep_helper in H1; easy.
split; try easy.
split; try easy.
eapply subset_transitive; try apply H3.
apply square_in_circle.
apply square_contains_center.
apply (lt_ep_helper ϵ); easy.
- destruct H0 as [A [H0 H1] ].
destruct H0 as [s [cen [A0 [H0 [H2 [H3 H4] ] ] ] ] ].
exists A0; split; auto.
apply H4; apply H2; easy.
Qed.
Lemma fin_cubecover_gives_fin_cover : forall (l : list Cset) (G : Ccover),
WF_cover G ->
subcover (list_to_cover l) (cover_to_cube_cover G) ->
exists l', subcover (list_to_cover l') G /\
(big_cup (list_to_cover l)) ⊂ (big_cup (list_to_cover l')).
Proof. induction l as [| A].
- intros. exists []; split; try easy.
- intros.
apply subcover_reduce in H0; destruct H0.
apply IHl in H1; auto.
destruct H1 as [l' [H1 H2] ].
destruct H0 as [s [cen [A0 [H0 [H3 [H4 H5] ] ] ] ] ].
exists (A0 :: l').
split.
unfold subcover, list_to_cover; intros.
destruct H6.
apply (H A0 A1); easy.
apply H1; easy.
do 2 rewrite <- big_cup_extend_l.
unfold subset; intros.
destruct H6.
left; apply H5; apply H3; easy.
right; apply H2; easy.
Qed.
Lemma compact_is_cube_compact : forall (A : Cset),
compact A <-> cube_compact A.
Proof. split; intros.
- unfold cube_compact; intros.
apply cube_cover_open_cover in H0.
apply H in H2; easy.
- unfold compact, cube_compact in *; intros.
destruct (H (cover_to_cube_cover G)) as [G' [H3 [H4 H5] ] ].
apply cube_cover_ctcc.
apply WF_ctcc.