-
Notifications
You must be signed in to change notification settings - Fork 297
/
connected.lean
1620 lines (1400 loc) · 73.9 KB
/
connected.lean
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) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov
-/
import data.set.bool_indicator
import order.succ_pred.relation
import topology.subset_properties
import tactic.congrm
/-!
# Connected subsets of topological spaces
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
In this file we define connected subsets of a topological spaces and various other properties and
classes related to connectivity.
## Main definitions
We define the following properties for sets in a topological space:
* `is_connected`: a nonempty set that has no non-trivial open partition.
See also the section below in the module doc.
* `connected_component` is the connected component of an element in the space.
* `is_totally_disconnected`: all of its connected components are singletons.
* `is_totally_separated`: any two points can be separated by two disjoint opens that cover the set.
For each of these definitions, we also have a class stating that the whole space
satisfies that property:
`connected_space`, `totally_disconnected_space`, `totally_separated_space`.
## On the definition of connected sets/spaces
In informal mathematics, connected spaces are assumed to be nonempty.
We formalise the predicate without that assumption as `is_preconnected`.
In other words, the only difference is whether the empty space counts as connected.
There are good reasons to consider the empty space to be “too simple to be simple”
See also https://ncatlab.org/nlab/show/too+simple+to+be+simple,
and in particular
https://ncatlab.org/nlab/show/too+simple+to+be+simple#relationship_to_biased_definitions.
-/
open set function topological_space relation
open_locale classical topology
universes u v
variables {α : Type u} {β : Type v} {ι : Type*} {π : ι → Type*} [topological_space α]
{s t u v : set α}
section preconnected
/-- A preconnected set is one where there is no non-trivial open partition. -/
def is_preconnected (s : set α) : Prop :=
∀ (u v : set α), is_open u → is_open v → s ⊆ u ∪ v →
(s ∩ u).nonempty → (s ∩ v).nonempty → (s ∩ (u ∩ v)).nonempty
/-- A connected set is one that is nonempty and where there is no non-trivial open partition. -/
def is_connected (s : set α) : Prop :=
s.nonempty ∧ is_preconnected s
lemma is_connected.nonempty {s : set α} (h : is_connected s) :
s.nonempty := h.1
lemma is_connected.is_preconnected {s : set α} (h : is_connected s) :
is_preconnected s := h.2
theorem is_preirreducible.is_preconnected {s : set α} (H : is_preirreducible s) :
is_preconnected s :=
λ _ _ hu hv _, H _ _ hu hv
theorem is_irreducible.is_connected {s : set α} (H : is_irreducible s) : is_connected s :=
⟨H.nonempty, H.is_preirreducible.is_preconnected⟩
theorem is_preconnected_empty : is_preconnected (∅ : set α) :=
is_preirreducible_empty.is_preconnected
theorem is_connected_singleton {x} : is_connected ({x} : set α) :=
is_irreducible_singleton.is_connected
theorem is_preconnected_singleton {x} : is_preconnected ({x} : set α) :=
is_connected_singleton.is_preconnected
theorem set.subsingleton.is_preconnected {s : set α} (hs : s.subsingleton) :
is_preconnected s :=
hs.induction_on is_preconnected_empty (λ x, is_preconnected_singleton)
/-- If any point of a set is joined to a fixed point by a preconnected subset,
then the original set is preconnected as well. -/
theorem is_preconnected_of_forall {s : set α} (x : α)
(H : ∀ y ∈ s, ∃ t ⊆ s, x ∈ t ∧ y ∈ t ∧ is_preconnected t) :
is_preconnected s :=
begin
rintros u v hu hv hs ⟨z, zs, zu⟩ ⟨y, ys, yv⟩,
have xs : x ∈ s, by { rcases H y ys with ⟨t, ts, xt, yt, ht⟩, exact ts xt },
wlog xu : x ∈ u,
{ rw inter_comm u v, rw union_comm at hs,
exact this x H v u hv hu hs y ys yv z zs zu xs ((hs xs).resolve_right xu), },
rcases H y ys with ⟨t, ts, xt, yt, ht⟩,
have := ht u v hu hv(subset.trans ts hs) ⟨x, xt, xu⟩ ⟨y, yt, yv⟩,
exact this.imp (λ z hz, ⟨ts hz.1, hz.2⟩)
end
/-- If any two points of a set are contained in a preconnected subset,
then the original set is preconnected as well. -/
theorem is_preconnected_of_forall_pair {s : set α}
(H : ∀ x y ∈ s, ∃ t ⊆ s, x ∈ t ∧ y ∈ t ∧ is_preconnected t) :
is_preconnected s :=
begin
rcases eq_empty_or_nonempty s with (rfl|⟨x, hx⟩),
exacts [is_preconnected_empty, is_preconnected_of_forall x $ λ y, H x hx y],
end
/-- A union of a family of preconnected sets with a common point is preconnected as well. -/
theorem is_preconnected_sUnion (x : α) (c : set (set α)) (H1 : ∀ s ∈ c, x ∈ s)
(H2 : ∀ s ∈ c, is_preconnected s) : is_preconnected (⋃₀ c) :=
begin
apply is_preconnected_of_forall x,
rintros y ⟨s, sc, ys⟩,
exact ⟨s, subset_sUnion_of_mem sc, H1 s sc, ys, H2 s sc⟩
end
theorem is_preconnected_Union {ι : Sort*} {s : ι → set α} (h₁ : (⋂ i, s i).nonempty)
(h₂ : ∀ i, is_preconnected (s i)) :
is_preconnected (⋃ i, s i) :=
exists.elim h₁ $ λ f hf, is_preconnected_sUnion f _ hf (forall_range_iff.2 h₂)
theorem is_preconnected.union (x : α) {s t : set α} (H1 : x ∈ s) (H2 : x ∈ t)
(H3 : is_preconnected s) (H4 : is_preconnected t) : is_preconnected (s ∪ t) :=
sUnion_pair s t ▸ is_preconnected_sUnion x {s, t}
(by rintro r (rfl | rfl | h); assumption)
(by rintro r (rfl | rfl | h); assumption)
theorem is_preconnected.union' {s t : set α} (H : (s ∩ t).nonempty)
(hs : is_preconnected s) (ht : is_preconnected t) : is_preconnected (s ∪ t) :=
by { rcases H with ⟨x, hxs, hxt⟩, exact hs.union x hxs hxt ht }
theorem is_connected.union {s t : set α} (H : (s ∩ t).nonempty)
(Hs : is_connected s) (Ht : is_connected t) : is_connected (s ∪ t) :=
begin
rcases H with ⟨x, hx⟩,
refine ⟨⟨x, mem_union_left t (mem_of_mem_inter_left hx)⟩, _⟩,
exact is_preconnected.union x (mem_of_mem_inter_left hx) (mem_of_mem_inter_right hx)
Hs.is_preconnected Ht.is_preconnected
end
/-- The directed sUnion of a set S of preconnected subsets is preconnected. -/
theorem is_preconnected.sUnion_directed {S : set (set α)}
(K : directed_on (⊆) S)
(H : ∀ s ∈ S, is_preconnected s) : is_preconnected (⋃₀ S) :=
begin
rintros u v hu hv Huv ⟨a, ⟨s, hsS, has⟩, hau⟩ ⟨b, ⟨t, htS, hbt⟩, hbv⟩,
obtain ⟨r, hrS, hsr, htr⟩ : ∃ r ∈ S, s ⊆ r ∧ t ⊆ r := K s hsS t htS,
have Hnuv : (r ∩ (u ∩ v)).nonempty,
from H _ hrS u v hu hv ((subset_sUnion_of_mem hrS).trans Huv)
⟨a, hsr has, hau⟩ ⟨b, htr hbt, hbv⟩,
have Kruv : r ∩ (u ∩ v) ⊆ ⋃₀ S ∩ (u ∩ v),
from inter_subset_inter_left _ (subset_sUnion_of_mem hrS),
exact Hnuv.mono Kruv
end
/-- The bUnion of a family of preconnected sets is preconnected if the graph determined by
whether two sets intersect is preconnected. -/
theorem is_preconnected.bUnion_of_refl_trans_gen {ι : Type*} {t : set ι} {s : ι → set α}
(H : ∀ i ∈ t, is_preconnected (s i))
(K : ∀ i j ∈ t, refl_trans_gen (λ i j : ι, (s i ∩ s j).nonempty ∧ i ∈ t) i j) :
is_preconnected (⋃ n ∈ t, s n) :=
begin
let R := λ i j : ι, (s i ∩ s j).nonempty ∧ i ∈ t,
have P : ∀ (i j ∈ t), refl_trans_gen R i j →
∃ (p ⊆ t), i ∈ p ∧ j ∈ p ∧ is_preconnected (⋃ j ∈ p, s j),
{ intros i hi j hj h,
induction h,
case refl
{ refine ⟨{i}, singleton_subset_iff.mpr hi, mem_singleton i, mem_singleton i, _⟩,
rw [bUnion_singleton],
exact H i hi },
case tail : j k hij hjk ih
{ obtain ⟨p, hpt, hip, hjp, hp⟩ := ih hjk.2,
refine ⟨insert k p, insert_subset.mpr ⟨hj, hpt⟩, mem_insert_of_mem k hip, mem_insert k p, _⟩,
rw [bUnion_insert],
refine (H k hj).union' _ hp,
refine hjk.1.mono _,
rw [inter_comm],
refine inter_subset_inter subset.rfl (subset_bUnion_of_mem hjp) } },
refine is_preconnected_of_forall_pair _,
intros x hx y hy,
obtain ⟨i: ι, hi : i ∈ t, hxi : x ∈ s i⟩ := mem_Union₂.1 hx,
obtain ⟨j: ι, hj : j ∈ t, hyj : y ∈ s j⟩ := mem_Union₂.1 hy,
obtain ⟨p, hpt, hip, hjp, hp⟩ := P i hi j hj (K i hi j hj),
exact ⟨⋃ j ∈ p, s j, bUnion_subset_bUnion_left hpt, mem_bUnion hip hxi, mem_bUnion hjp hyj, hp⟩
end
/-- The bUnion of a family of preconnected sets is preconnected if the graph determined by
whether two sets intersect is preconnected. -/
theorem is_connected.bUnion_of_refl_trans_gen {ι : Type*} {t : set ι} {s : ι → set α}
(ht : t.nonempty)
(H : ∀ i ∈ t, is_connected (s i))
(K : ∀ i j ∈ t, refl_trans_gen (λ i j : ι, (s i ∩ s j).nonempty ∧ i ∈ t) i j) :
is_connected (⋃ n ∈ t, s n) :=
⟨nonempty_bUnion.2 $ ⟨ht.some, ht.some_mem, (H _ ht.some_mem).nonempty⟩,
is_preconnected.bUnion_of_refl_trans_gen (λ i hi, (H i hi).is_preconnected) K⟩
/-- Preconnectedness of the Union of a family of preconnected sets
indexed by the vertices of a preconnected graph,
where two vertices are joined when the corresponding sets intersect. -/
theorem is_preconnected.Union_of_refl_trans_gen {ι : Type*} {s : ι → set α}
(H : ∀ i, is_preconnected (s i))
(K : ∀ i j, refl_trans_gen (λ i j : ι, (s i ∩ s j).nonempty) i j) :
is_preconnected (⋃ n, s n) :=
by { rw [← bUnion_univ], exact is_preconnected.bUnion_of_refl_trans_gen (λ i _, H i)
(λ i _ j _, by simpa [mem_univ] using K i j) }
theorem is_connected.Union_of_refl_trans_gen {ι : Type*} [nonempty ι] {s : ι → set α}
(H : ∀ i, is_connected (s i))
(K : ∀ i j, refl_trans_gen (λ i j : ι, (s i ∩ s j).nonempty) i j) :
is_connected (⋃ n, s n) :=
⟨nonempty_Union.2 $ nonempty.elim ‹_› $ λ i : ι, ⟨i, (H _).nonempty⟩,
is_preconnected.Union_of_refl_trans_gen (λ i, (H i).is_preconnected) K⟩
section succ_order
open order
variables [linear_order β] [succ_order β] [is_succ_archimedean β]
/-- The Union of connected sets indexed by a type with an archimedean successor (like `ℕ` or `ℤ`)
such that any two neighboring sets meet is preconnected. -/
theorem is_preconnected.Union_of_chain {s : β → set α}
(H : ∀ n, is_preconnected (s n))
(K : ∀ n, (s n ∩ s (succ n)).nonempty) :
is_preconnected (⋃ n, s n) :=
is_preconnected.Union_of_refl_trans_gen H $
λ i j, refl_trans_gen_of_succ _ (λ i _, K i) $ λ i _, by { rw inter_comm, exact K i }
/-- The Union of connected sets indexed by a type with an archimedean successor (like `ℕ` or `ℤ`)
such that any two neighboring sets meet is connected. -/
theorem is_connected.Union_of_chain [nonempty β] {s : β → set α}
(H : ∀ n, is_connected (s n))
(K : ∀ n, (s n ∩ s (succ n)).nonempty) :
is_connected (⋃ n, s n) :=
is_connected.Union_of_refl_trans_gen H $
λ i j, refl_trans_gen_of_succ _ (λ i _, K i) $ λ i _, by { rw inter_comm, exact K i }
/-- The Union of preconnected sets indexed by a subset of a type with an archimedean successor
(like `ℕ` or `ℤ`) such that any two neighboring sets meet is preconnected. -/
theorem is_preconnected.bUnion_of_chain
{s : β → set α} {t : set β} (ht : ord_connected t)
(H : ∀ n ∈ t, is_preconnected (s n))
(K : ∀ n : β, n ∈ t → succ n ∈ t → (s n ∩ s (succ n)).nonempty) :
is_preconnected (⋃ n ∈ t, s n) :=
begin
have h1 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → k ∈ t :=
λ i j k hi hj hk, ht.out hi hj (Ico_subset_Icc_self hk),
have h2 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → succ k ∈ t := λ i j k hi hj hk,
ht.out hi hj ⟨hk.1.trans $ le_succ k, succ_le_of_lt hk.2⟩,
have h3 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → (s k ∩ s (succ k)).nonempty :=
λ i j k hi hj hk, K _ (h1 hi hj hk) (h2 hi hj hk),
refine is_preconnected.bUnion_of_refl_trans_gen H (λ i hi j hj, _),
exact refl_trans_gen_of_succ _ (λ k hk, ⟨h3 hi hj hk, h1 hi hj hk⟩)
(λ k hk, ⟨by { rw [inter_comm], exact h3 hj hi hk }, h2 hj hi hk⟩),
end
/-- The Union of connected sets indexed by a subset of a type with an archimedean successor
(like `ℕ` or `ℤ`) such that any two neighboring sets meet is preconnected. -/
theorem is_connected.bUnion_of_chain
{s : β → set α} {t : set β} (hnt : t.nonempty) (ht : ord_connected t)
(H : ∀ n ∈ t, is_connected (s n))
(K : ∀ n : β, n ∈ t → succ n ∈ t → (s n ∩ s (succ n)).nonempty) :
is_connected (⋃ n ∈ t, s n) :=
⟨nonempty_bUnion.2 $ ⟨hnt.some, hnt.some_mem, (H _ hnt.some_mem).nonempty⟩,
is_preconnected.bUnion_of_chain ht (λ i hi, (H i hi).is_preconnected) K⟩
end succ_order
/-- Theorem of bark and tree :
if a set is within a (pre)connected set and its closure,
then it is (pre)connected as well. -/
theorem is_preconnected.subset_closure {s : set α} {t : set α}
(H : is_preconnected s) (Kst : s ⊆ t) (Ktcs : t ⊆ closure s) :
is_preconnected t :=
λ u v hu hv htuv ⟨y, hyt, hyu⟩ ⟨z, hzt, hzv⟩,
let ⟨p, hpu, hps⟩ := mem_closure_iff.1 (Ktcs hyt) u hu hyu,
⟨q, hqv, hqs⟩ := mem_closure_iff.1 (Ktcs hzt) v hv hzv,
⟨r, hrs, hruv⟩ := H u v hu hv (subset.trans Kst htuv) ⟨p, hps, hpu⟩ ⟨q, hqs, hqv⟩ in
⟨r, Kst hrs, hruv⟩
theorem is_connected.subset_closure {s : set α} {t : set α}
(H : is_connected s) (Kst : s ⊆ t) (Ktcs : t ⊆ closure s): is_connected t :=
let hsne := H.left,
ht := Kst,
htne := nonempty.mono ht hsne in
⟨nonempty.mono Kst H.left, is_preconnected.subset_closure H.right Kst Ktcs ⟩
/-- The closure of a (pre)connected set is (pre)connected as well. -/
theorem is_preconnected.closure {s : set α} (H : is_preconnected s) :
is_preconnected (closure s) :=
is_preconnected.subset_closure H subset_closure $ subset.refl $ closure s
theorem is_connected.closure {s : set α} (H : is_connected s) :
is_connected (closure s) :=
is_connected.subset_closure H subset_closure $ subset.refl $ closure s
/-- The image of a (pre)connected set is (pre)connected as well. -/
theorem is_preconnected.image [topological_space β] {s : set α} (H : is_preconnected s)
(f : α → β) (hf : continuous_on f s) : is_preconnected (f '' s) :=
begin
-- Unfold/destruct definitions in hypotheses
rintros u v hu hv huv ⟨_, ⟨x, xs, rfl⟩, xu⟩ ⟨_, ⟨y, ys, rfl⟩, yv⟩,
rcases continuous_on_iff'.1 hf u hu with ⟨u', hu', u'_eq⟩,
rcases continuous_on_iff'.1 hf v hv with ⟨v', hv', v'_eq⟩,
-- Reformulate `huv : f '' s ⊆ u ∪ v` in terms of `u'` and `v'`
replace huv : s ⊆ u' ∪ v',
{ rw [image_subset_iff, preimage_union] at huv,
replace huv := subset_inter huv (subset.refl _),
rw [inter_distrib_right, u'_eq, v'_eq, ← inter_distrib_right] at huv,
exact (subset_inter_iff.1 huv).1 },
-- Now `s ⊆ u' ∪ v'`, so we can apply `‹is_preconnected s›`
obtain ⟨z, hz⟩ : (s ∩ (u' ∩ v')).nonempty,
{ refine H u' v' hu' hv' huv ⟨x, _⟩ ⟨y, _⟩; rw inter_comm,
exacts [u'_eq ▸ ⟨xu, xs⟩, v'_eq ▸ ⟨yv, ys⟩] },
rw [← inter_self s, inter_assoc, inter_left_comm s u', ← inter_assoc,
inter_comm s, inter_comm s, ← u'_eq, ← v'_eq] at hz,
exact ⟨f z, ⟨z, hz.1.2, rfl⟩, hz.1.1, hz.2.1⟩
end
theorem is_connected.image [topological_space β] {s : set α} (H : is_connected s)
(f : α → β) (hf : continuous_on f s) : is_connected (f '' s) :=
⟨nonempty_image_iff.mpr H.nonempty, H.is_preconnected.image f hf⟩
theorem is_preconnected_closed_iff {s : set α} :
is_preconnected s ↔ ∀ t t', is_closed t → is_closed t' → s ⊆ t ∪ t' →
(s ∩ t).nonempty → (s ∩ t').nonempty → (s ∩ (t ∩ t')).nonempty :=
⟨begin
rintros h t t' ht ht' htt' ⟨x, xs, xt⟩ ⟨y, ys, yt'⟩,
rw [←not_disjoint_iff_nonempty_inter, ←subset_compl_iff_disjoint_right, compl_inter],
intros h',
have xt' : x ∉ t', from (h' xs).resolve_left (absurd xt),
have yt : y ∉ t, from (h' ys).resolve_right (absurd yt'),
have := h _ _ ht.is_open_compl ht'.is_open_compl h' ⟨y, ys, yt⟩ ⟨x, xs, xt'⟩,
rw ←compl_union at this,
exact this.ne_empty htt'.disjoint_compl_right.inter_eq,
end,
begin
rintros h u v hu hv huv ⟨x, xs, xu⟩ ⟨y, ys, yv⟩,
rw [←not_disjoint_iff_nonempty_inter, ←subset_compl_iff_disjoint_right, compl_inter],
intros h',
have xv : x ∉ v, from (h' xs).elim (absurd xu) id,
have yu : y ∉ u, from (h' ys).elim id (absurd yv),
have := h _ _ hu.is_closed_compl hv.is_closed_compl h' ⟨y, ys, yu⟩ ⟨x, xs, xv⟩,
rw ←compl_union at this,
exact this.ne_empty huv.disjoint_compl_right.inter_eq,
end⟩
lemma inducing.is_preconnected_image [topological_space β] {s : set α} {f : α → β}
(hf : inducing f) : is_preconnected (f '' s) ↔ is_preconnected s :=
begin
refine ⟨λ h, _, λ h, h.image _ hf.continuous.continuous_on⟩,
rintro u v hu' hv' huv ⟨x, hxs, hxu⟩ ⟨y, hys, hyv⟩,
rcases hf.is_open_iff.1 hu' with ⟨u, hu, rfl⟩,
rcases hf.is_open_iff.1 hv' with ⟨v, hv, rfl⟩,
replace huv : f '' s ⊆ u ∪ v, by rwa image_subset_iff,
rcases h u v hu hv huv ⟨f x, mem_image_of_mem _ hxs, hxu⟩ ⟨f y, mem_image_of_mem _ hys, hyv⟩
with ⟨_, ⟨z, hzs, rfl⟩, hzuv⟩,
exact ⟨z, hzs, hzuv⟩
end
/- TODO: The following lemmas about connection of preimages hold more generally for strict maps
(the quotient and subspace topologies of the image agree) whose fibers are preconnected. -/
lemma is_preconnected.preimage_of_open_map [topological_space β] {s : set β}
(hs : is_preconnected s) {f : α → β} (hinj : function.injective f) (hf : is_open_map f)
(hsf : s ⊆ range f) :
is_preconnected (f ⁻¹' s) :=
λ u v hu hv hsuv hsu hsv,
begin
obtain ⟨b, hbs, hbu, hbv⟩ := hs (f '' u) (f '' v) (hf u hu) (hf v hv) _ _ _,
obtain ⟨a, rfl⟩ := hsf hbs,
rw hinj.mem_set_image at hbu hbv,
exact ⟨a, hbs, hbu, hbv⟩,
{ have := image_subset f hsuv,
rwa [set.image_preimage_eq_of_subset hsf, image_union] at this },
{ obtain ⟨x, hx1, hx2⟩ := hsu,
exact ⟨f x, hx1, x, hx2, rfl⟩ },
{ obtain ⟨y, hy1, hy2⟩ := hsv,
exact ⟨f y, hy1, y, hy2, rfl⟩ }
end
lemma is_preconnected.preimage_of_closed_map [topological_space β] {s : set β}
(hs : is_preconnected s) {f : α → β} (hinj : function.injective f) (hf : is_closed_map f)
(hsf : s ⊆ range f) :
is_preconnected (f ⁻¹' s) :=
is_preconnected_closed_iff.2 $ λ u v hu hv hsuv hsu hsv,
begin
obtain ⟨b, hbs, hbu, hbv⟩ :=
is_preconnected_closed_iff.1 hs (f '' u) (f '' v) (hf u hu) (hf v hv) _ _ _,
obtain ⟨a, rfl⟩ := hsf hbs,
rw hinj.mem_set_image at hbu hbv,
exact ⟨a, hbs, hbu, hbv⟩,
{ have := image_subset f hsuv,
rwa [set.image_preimage_eq_of_subset hsf, image_union] at this },
{ obtain ⟨x, hx1, hx2⟩ := hsu,
exact ⟨f x, hx1, x, hx2, rfl⟩ },
{ obtain ⟨y, hy1, hy2⟩ := hsv,
exact ⟨f y, hy1, y, hy2, rfl⟩ }
end
lemma is_connected.preimage_of_open_map [topological_space β] {s : set β} (hs : is_connected s)
{f : α → β} (hinj : function.injective f) (hf : is_open_map f) (hsf : s ⊆ range f) :
is_connected (f ⁻¹' s) :=
⟨hs.nonempty.preimage' hsf, hs.is_preconnected.preimage_of_open_map hinj hf hsf⟩
lemma is_connected.preimage_of_closed_map [topological_space β] {s : set β} (hs : is_connected s)
{f : α → β} (hinj : function.injective f) (hf : is_closed_map f) (hsf : s ⊆ range f) :
is_connected (f ⁻¹' s) :=
⟨hs.nonempty.preimage' hsf, hs.is_preconnected.preimage_of_closed_map hinj hf hsf⟩
lemma is_preconnected.subset_or_subset (hu : is_open u) (hv : is_open v) (huv : disjoint u v)
(hsuv : s ⊆ u ∪ v) (hs : is_preconnected s) :
s ⊆ u ∨ s ⊆ v :=
begin
specialize hs u v hu hv hsuv,
obtain hsu | hsu := (s ∩ u).eq_empty_or_nonempty,
{ exact or.inr ((set.disjoint_iff_inter_eq_empty.2 hsu).subset_right_of_subset_union hsuv) },
{ replace hs := mt (hs hsu),
simp_rw [set.not_nonempty_iff_eq_empty, ←set.disjoint_iff_inter_eq_empty,
disjoint_iff_inter_eq_empty.1 huv] at hs,
exact or.inl ((hs s.disjoint_empty).subset_left_of_subset_union hsuv) }
end
lemma is_preconnected.subset_left_of_subset_union (hu : is_open u) (hv : is_open v)
(huv : disjoint u v) (hsuv : s ⊆ u ∪ v) (hsu : (s ∩ u).nonempty) (hs : is_preconnected s) :
s ⊆ u :=
disjoint.subset_left_of_subset_union hsuv
begin
by_contra hsv,
rw not_disjoint_iff_nonempty_inter at hsv,
obtain ⟨x, _, hx⟩ := hs u v hu hv hsuv hsu hsv,
exact set.disjoint_iff.1 huv hx,
end
lemma is_preconnected.subset_right_of_subset_union (hu : is_open u) (hv : is_open v)
(huv : disjoint u v) (hsuv : s ⊆ u ∪ v) (hsv : (s ∩ v).nonempty) (hs : is_preconnected s) :
s ⊆ v :=
hs.subset_left_of_subset_union hv hu huv.symm (union_comm u v ▸ hsuv) hsv
/-- If a preconnected set `s` intersects an open set `u`, and limit points of `u` inside `s` are
contained in `u`, then the whole set `s` is contained in `u`. -/
lemma is_preconnected.subset_of_closure_inter_subset (hs : is_preconnected s)
(hu : is_open u) (h'u : (s ∩ u).nonempty) (h : closure u ∩ s ⊆ u) : s ⊆ u :=
begin
have A : s ⊆ u ∪ (closure u)ᶜ,
{ assume x hx,
by_cases xu : x ∈ u,
{ exact or.inl xu },
{ right,
assume h'x,
exact xu (h (mem_inter h'x hx)) } },
apply hs.subset_left_of_subset_union hu is_closed_closure.is_open_compl _ A h'u,
exact disjoint_compl_right.mono_right (compl_subset_compl.2 subset_closure),
end
theorem is_preconnected.prod [topological_space β] {s : set α} {t : set β}
(hs : is_preconnected s) (ht : is_preconnected t) :
is_preconnected (s ×ˢ t) :=
begin
apply is_preconnected_of_forall_pair,
rintro ⟨a₁, b₁⟩ ⟨ha₁, hb₁⟩ ⟨a₂, b₂⟩ ⟨ha₂, hb₂⟩,
refine ⟨prod.mk a₁ '' t ∪ flip prod.mk b₂ '' s, _,
or.inl ⟨b₁, hb₁, rfl⟩, or.inr ⟨a₂, ha₂, rfl⟩, _⟩,
{ rintro _ (⟨y, hy, rfl⟩|⟨x, hx, rfl⟩),
exacts [⟨ha₁, hy⟩, ⟨hx, hb₂⟩] },
{ exact (ht.image _ (continuous.prod.mk _).continuous_on).union (a₁, b₂) ⟨b₂, hb₂, rfl⟩
⟨a₁, ha₁, rfl⟩ (hs.image _ (continuous_id.prod_mk continuous_const).continuous_on) }
end
theorem is_connected.prod [topological_space β] {s : set α} {t : set β}
(hs : is_connected s) (ht : is_connected t) : is_connected (s ×ˢ t) :=
⟨hs.1.prod ht.1, hs.2.prod ht.2⟩
theorem is_preconnected_univ_pi [Π i, topological_space (π i)] {s : Π i, set (π i)}
(hs : ∀ i, is_preconnected (s i)) :
is_preconnected (pi univ s) :=
begin
rintros u v uo vo hsuv ⟨f, hfs, hfu⟩ ⟨g, hgs, hgv⟩,
rcases exists_finset_piecewise_mem_of_mem_nhds (uo.mem_nhds hfu) g with ⟨I, hI⟩,
induction I using finset.induction_on with i I hi ihI,
{ refine ⟨g, hgs, ⟨_, hgv⟩⟩, simpa using hI },
{ rw [finset.piecewise_insert] at hI,
have := I.piecewise_mem_set_pi hfs hgs,
refine (hsuv this).elim ihI (λ h, _),
set S := update (I.piecewise f g) i '' (s i),
have hsub : S ⊆ pi univ s,
{ refine image_subset_iff.2 (λ z hz, _),
rwa update_preimage_univ_pi,
exact λ j hj, this j trivial },
have hconn : is_preconnected S,
from (hs i).image _ (continuous_const.update i continuous_id).continuous_on,
have hSu : (S ∩ u).nonempty,
from ⟨_, mem_image_of_mem _ (hfs _ trivial), hI⟩,
have hSv : (S ∩ v).nonempty,
from ⟨_, ⟨_, this _ trivial, update_eq_self _ _⟩, h⟩,
refine (hconn u v uo vo (hsub.trans hsuv) hSu hSv).mono _,
exact inter_subset_inter_left _ hsub }
end
@[simp] theorem is_connected_univ_pi [Π i, topological_space (π i)] {s : Π i, set (π i)} :
is_connected (pi univ s) ↔ ∀ i, is_connected (s i) :=
begin
simp only [is_connected, ← univ_pi_nonempty_iff, forall_and_distrib, and.congr_right_iff],
refine λ hne, ⟨λ hc i, _, is_preconnected_univ_pi⟩,
rw [← eval_image_univ_pi hne],
exact hc.image _ (continuous_apply _).continuous_on
end
lemma sigma.is_connected_iff [Π i, topological_space (π i)] {s : set (Σ i, π i)} :
is_connected s ↔ ∃ i t, is_connected t ∧ s = sigma.mk i '' t :=
begin
refine ⟨λ hs, _, _⟩,
{ obtain ⟨⟨i, x⟩, hx⟩ := hs.nonempty,
have : s ⊆ range (sigma.mk i),
{ have h : range (sigma.mk i) = sigma.fst ⁻¹' {i}, by { ext, simp },
rw h,
exact is_preconnected.subset_left_of_subset_union
(is_open_sigma_fst_preimage _) (is_open_sigma_fst_preimage {x | x ≠ i})
(set.disjoint_iff.2 $ λ x hx, hx.2 hx.1)
(λ y hy, by simp [classical.em]) ⟨⟨i, x⟩, hx, rfl⟩ hs.2 },
exact ⟨i, sigma.mk i ⁻¹' s,
hs.preimage_of_open_map sigma_mk_injective is_open_map_sigma_mk this,
(set.image_preimage_eq_of_subset this).symm⟩ },
{ rintro ⟨i, t, ht, rfl⟩,
exact ht.image _ continuous_sigma_mk.continuous_on }
end
lemma sigma.is_preconnected_iff [hι : nonempty ι] [Π i, topological_space (π i)]
{s : set (Σ i, π i)} :
is_preconnected s ↔ ∃ i t, is_preconnected t ∧ s = sigma.mk i '' t :=
begin
refine ⟨λ hs, _, _⟩,
{ obtain rfl | h := s.eq_empty_or_nonempty,
{ exact ⟨classical.choice hι, ∅, is_preconnected_empty, (set.image_empty _).symm⟩ },
{ obtain ⟨a, t, ht, rfl⟩ := sigma.is_connected_iff.1 ⟨h, hs⟩,
refine ⟨a, t, ht.is_preconnected, rfl⟩ } },
{ rintro ⟨a, t, ht, rfl⟩,
exact ht.image _ continuous_sigma_mk.continuous_on }
end
lemma sum.is_connected_iff [topological_space β] {s : set (α ⊕ β)} :
is_connected s ↔
(∃ t, is_connected t ∧ s = sum.inl '' t) ∨ ∃ t, is_connected t ∧ s = sum.inr '' t :=
begin
refine ⟨λ hs, _, _⟩,
{ let u : set (α ⊕ β) := range sum.inl,
let v : set (α ⊕ β) := range sum.inr,
have hu : is_open u, exact is_open_range_inl,
obtain ⟨x | x, hx⟩ := hs.nonempty,
{ have h : s ⊆ range sum.inl := is_preconnected.subset_left_of_subset_union
is_open_range_inl is_open_range_inr is_compl_range_inl_range_inr.disjoint
(by simp) ⟨sum.inl x, hx, x, rfl⟩ hs.2,
refine or.inl ⟨sum.inl ⁻¹' s, _, _⟩,
{ exact hs.preimage_of_open_map sum.inl_injective open_embedding_inl.is_open_map h },
{ exact (set.image_preimage_eq_of_subset h).symm } },
{ have h : s ⊆ range sum.inr := is_preconnected.subset_right_of_subset_union
is_open_range_inl is_open_range_inr is_compl_range_inl_range_inr.disjoint
(by simp) ⟨sum.inr x, hx, x, rfl⟩ hs.2,
refine or.inr ⟨sum.inr ⁻¹' s, _, _⟩,
{ exact hs.preimage_of_open_map sum.inr_injective open_embedding_inr.is_open_map h },
{ exact (set.image_preimage_eq_of_subset h).symm } } },
{ rintro (⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩),
{ exact ht.image _ continuous_inl.continuous_on },
{ exact ht.image _ continuous_inr.continuous_on } }
end
lemma sum.is_preconnected_iff [topological_space β] {s : set (α ⊕ β)} :
is_preconnected s ↔
(∃ t, is_preconnected t ∧ s = sum.inl '' t) ∨ ∃ t, is_preconnected t ∧ s = sum.inr '' t :=
begin
refine ⟨λ hs, _, _⟩,
{ obtain rfl | h := s.eq_empty_or_nonempty,
{ exact or.inl ⟨∅, is_preconnected_empty, (set.image_empty _).symm⟩ },
obtain ⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩ := sum.is_connected_iff.1 ⟨h, hs⟩,
{ exact or.inl ⟨t, ht.is_preconnected, rfl⟩ },
{ exact or.inr ⟨t, ht.is_preconnected, rfl⟩ } },
{ rintro (⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩),
{ exact ht.image _ continuous_inl.continuous_on },
{ exact ht.image _ continuous_inr.continuous_on } }
end
/-- The connected component of a point is the maximal connected set
that contains this point. -/
def connected_component (x : α) : set α :=
⋃₀ { s : set α | is_preconnected s ∧ x ∈ s }
/-- Given a set `F` in a topological space `α` and a point `x : α`, the connected
component of `x` in `F` is the connected component of `x` in the subtype `F` seen as
a set in `α`. This definition does not make sense if `x` is not in `F` so we return the
empty set in this case. -/
def connected_component_in (F : set α) (x : α) : set α :=
if h : x ∈ F then coe '' (connected_component (⟨x, h⟩ : F)) else ∅
lemma connected_component_in_eq_image {F : set α} {x : α} (h : x ∈ F) :
connected_component_in F x = coe '' (connected_component (⟨x, h⟩ : F)) :=
dif_pos h
lemma connected_component_in_eq_empty {F : set α} {x : α} (h : x ∉ F) :
connected_component_in F x = ∅ :=
dif_neg h
theorem mem_connected_component {x : α} : x ∈ connected_component x :=
mem_sUnion_of_mem (mem_singleton x) ⟨is_connected_singleton.is_preconnected, mem_singleton x⟩
theorem mem_connected_component_in {x : α} {F : set α} (hx : x ∈ F) :
x ∈ connected_component_in F x :=
by simp [connected_component_in_eq_image hx, mem_connected_component, hx]
theorem connected_component_nonempty {x : α} :
(connected_component x).nonempty :=
⟨x, mem_connected_component⟩
theorem connected_component_in_nonempty_iff {x : α} {F : set α} :
(connected_component_in F x).nonempty ↔ x ∈ F :=
by { rw [connected_component_in], split_ifs; simp [connected_component_nonempty, h] }
theorem connected_component_in_subset (F : set α) (x : α) :
connected_component_in F x ⊆ F :=
by { rw [connected_component_in], split_ifs; simp }
theorem is_preconnected_connected_component {x : α} : is_preconnected (connected_component x) :=
is_preconnected_sUnion x _ (λ _, and.right) (λ _, and.left)
lemma is_preconnected_connected_component_in {x : α} {F : set α} :
is_preconnected (connected_component_in F x) :=
begin
rw [connected_component_in], split_ifs,
{ exact embedding_subtype_coe.to_inducing.is_preconnected_image.mpr
is_preconnected_connected_component },
{ exact is_preconnected_empty },
end
theorem is_connected_connected_component {x : α} : is_connected (connected_component x) :=
⟨⟨x, mem_connected_component⟩, is_preconnected_connected_component⟩
lemma is_connected_connected_component_in_iff {x : α} {F : set α} :
is_connected (connected_component_in F x) ↔ x ∈ F :=
by simp_rw [← connected_component_in_nonempty_iff, is_connected,
is_preconnected_connected_component_in, and_true]
theorem is_preconnected.subset_connected_component {x : α} {s : set α}
(H1 : is_preconnected s) (H2 : x ∈ s) : s ⊆ connected_component x :=
λ z hz, mem_sUnion_of_mem hz ⟨H1, H2⟩
lemma is_preconnected.subset_connected_component_in {x : α} {F : set α} (hs : is_preconnected s)
(hxs : x ∈ s) (hsF : s ⊆ F) : s ⊆ connected_component_in F x :=
begin
have : is_preconnected ((coe : F → α) ⁻¹' s),
{ refine embedding_subtype_coe.to_inducing.is_preconnected_image.mp _,
rwa [subtype.image_preimage_coe, inter_eq_left_iff_subset.mpr hsF] },
have h2xs : (⟨x, hsF hxs⟩ : F) ∈ coe ⁻¹' s := by { rw [mem_preimage], exact hxs },
have := this.subset_connected_component h2xs,
rw [connected_component_in_eq_image (hsF hxs)],
refine subset.trans _ (image_subset _ this),
rw [subtype.image_preimage_coe, inter_eq_left_iff_subset.mpr hsF]
end
theorem is_connected.subset_connected_component {x : α} {s : set α}
(H1 : is_connected s) (H2 : x ∈ s) : s ⊆ connected_component x :=
H1.2.subset_connected_component H2
lemma is_preconnected.connected_component_in {x : α} {F : set α} (h : is_preconnected F)
(hx : x ∈ F) : connected_component_in F x = F :=
(connected_component_in_subset F x).antisymm (h.subset_connected_component_in hx subset_rfl)
theorem connected_component_eq {x y : α} (h : y ∈ connected_component x) :
connected_component x = connected_component y :=
eq_of_subset_of_subset
(is_connected_connected_component.subset_connected_component h)
(is_connected_connected_component.subset_connected_component
(set.mem_of_mem_of_subset mem_connected_component
(is_connected_connected_component.subset_connected_component h)))
theorem connected_component_eq_iff_mem {x y : α} :
connected_component x = connected_component y ↔ x ∈ connected_component y :=
⟨λ h, h ▸ mem_connected_component, λ h, (connected_component_eq h).symm⟩
lemma connected_component_in_eq {x y : α} {F : set α} (h : y ∈ connected_component_in F x) :
connected_component_in F x = connected_component_in F y :=
begin
have hx : x ∈ F := connected_component_in_nonempty_iff.mp ⟨y, h⟩,
simp_rw [connected_component_in_eq_image hx] at h ⊢,
obtain ⟨⟨y, hy⟩, h2y, rfl⟩ := h,
simp_rw [subtype.coe_mk, connected_component_in_eq_image hy, connected_component_eq h2y]
end
theorem connected_component_in_univ (x : α) :
connected_component_in univ x = connected_component x :=
subset_antisymm
(is_preconnected_connected_component_in.subset_connected_component $
mem_connected_component_in trivial)
(is_preconnected_connected_component.subset_connected_component_in mem_connected_component $
subset_univ _)
lemma connected_component_disjoint {x y : α} (h : connected_component x ≠ connected_component y) :
disjoint (connected_component x) (connected_component y) :=
set.disjoint_left.2 (λ a h1 h2, h
((connected_component_eq h1).trans (connected_component_eq h2).symm))
theorem is_closed_connected_component {x : α} :
is_closed (connected_component x) :=
closure_subset_iff_is_closed.1 $
is_connected_connected_component.closure.subset_connected_component $
subset_closure mem_connected_component
lemma continuous.image_connected_component_subset [topological_space β] {f : α → β}
(h : continuous f) (a : α) : f '' connected_component a ⊆ connected_component (f a) :=
(is_connected_connected_component.image f h.continuous_on).subset_connected_component
((mem_image f (connected_component a) (f a)).2 ⟨a, mem_connected_component, rfl⟩)
lemma continuous.maps_to_connected_component [topological_space β] {f : α → β}
(h : continuous f) (a : α) : maps_to f (connected_component a) (connected_component (f a)) :=
maps_to'.2 $ h.image_connected_component_subset a
theorem irreducible_component_subset_connected_component {x : α} :
irreducible_component x ⊆ connected_component x :=
is_irreducible_irreducible_component.is_connected.subset_connected_component
mem_irreducible_component
@[mono]
lemma connected_component_in_mono (x : α) {F G : set α} (h : F ⊆ G) :
connected_component_in F x ⊆ connected_component_in G x :=
begin
by_cases hx : x ∈ F,
{ rw [connected_component_in_eq_image hx, connected_component_in_eq_image (h hx),
← show (coe : G → α) ∘ inclusion h = coe, by ext ; refl, image_comp],
exact image_subset coe ((continuous_inclusion h).image_connected_component_subset ⟨x, hx⟩) },
{ rw connected_component_in_eq_empty hx,
exact set.empty_subset _ },
end
/-- A preconnected space is one where there is no non-trivial open partition. -/
class preconnected_space (α : Type u) [topological_space α] : Prop :=
(is_preconnected_univ : is_preconnected (univ : set α))
export preconnected_space (is_preconnected_univ)
/-- A connected space is a nonempty one where there is no non-trivial open partition. -/
class connected_space (α : Type u) [topological_space α] extends preconnected_space α : Prop :=
(to_nonempty : nonempty α)
attribute [instance, priority 50] connected_space.to_nonempty -- see Note [lower instance priority]
lemma is_connected_univ [connected_space α] : is_connected (univ : set α) :=
⟨univ_nonempty, is_preconnected_univ⟩
lemma is_preconnected_range [topological_space β] [preconnected_space α] {f : α → β}
(h : continuous f) : is_preconnected (range f) :=
@image_univ _ _ f ▸ is_preconnected_univ.image _ h.continuous_on
lemma is_connected_range [topological_space β] [connected_space α] {f : α → β} (h : continuous f) :
is_connected (range f) :=
⟨range_nonempty f, is_preconnected_range h⟩
lemma dense_range.preconnected_space [topological_space β] [preconnected_space α] {f : α → β}
(hf : dense_range f) (hc : continuous f) :
preconnected_space β :=
⟨hf.closure_eq ▸ (is_preconnected_range hc).closure⟩
lemma connected_space_iff_connected_component :
connected_space α ↔ ∃ x : α, connected_component x = univ :=
begin
split,
{ rintro ⟨⟨x⟩⟩,
exactI ⟨x, eq_univ_of_univ_subset $
is_preconnected_univ.subset_connected_component (mem_univ x)⟩ },
{ rintros ⟨x, h⟩,
haveI : preconnected_space α := ⟨by { rw ← h, exact is_preconnected_connected_component }⟩,
exact ⟨⟨x⟩⟩ }
end
lemma preconnected_space_iff_connected_component :
preconnected_space α ↔ ∀ x : α, connected_component x = univ :=
begin
split,
{ intros h x,
exactI (eq_univ_of_univ_subset $
is_preconnected_univ.subset_connected_component (mem_univ x)) },
{ intros h,
casesI is_empty_or_nonempty α with hα hα,
{ exact ⟨by { rw (univ_eq_empty_iff.mpr hα), exact is_preconnected_empty }⟩ },
{ exact ⟨by { rw ← h (classical.choice hα), exact is_preconnected_connected_component }⟩ } }
end
@[simp] lemma preconnected_space.connected_component_eq_univ {X : Type*} [topological_space X]
[h : preconnected_space X] (x : X) : connected_component x = univ :=
preconnected_space_iff_connected_component.mp h x
instance [topological_space β] [preconnected_space α] [preconnected_space β] :
preconnected_space (α × β) :=
⟨by { rw ← univ_prod_univ, exact is_preconnected_univ.prod is_preconnected_univ }⟩
instance [topological_space β] [connected_space α] [connected_space β] :
connected_space (α × β) :=
⟨prod.nonempty⟩
instance [Π i, topological_space (π i)] [∀ i, preconnected_space (π i)] :
preconnected_space (Π i, π i) :=
⟨by { rw ← pi_univ univ, exact is_preconnected_univ_pi (λ i, is_preconnected_univ) }⟩
instance [Π i, topological_space (π i)] [∀ i, connected_space (π i)] : connected_space (Π i, π i) :=
⟨classical.nonempty_pi.2 $ λ i, by apply_instance⟩
@[priority 100] -- see Note [lower instance priority]
instance preirreducible_space.preconnected_space (α : Type u) [topological_space α]
[preirreducible_space α] : preconnected_space α :=
⟨(preirreducible_space.is_preirreducible_univ α).is_preconnected⟩
@[priority 100] -- see Note [lower instance priority]
instance irreducible_space.connected_space (α : Type u) [topological_space α]
[irreducible_space α] : connected_space α :=
{ to_nonempty := irreducible_space.to_nonempty α }
theorem nonempty_inter [preconnected_space α] {s t : set α} :
is_open s → is_open t → s ∪ t = univ → s.nonempty → t.nonempty → (s ∩ t).nonempty :=
by simpa only [univ_inter, univ_subset_iff] using
@preconnected_space.is_preconnected_univ α _ _ s t
theorem is_clopen_iff [preconnected_space α] {s : set α} : is_clopen s ↔ s = ∅ ∨ s = univ :=
⟨λ hs, classical.by_contradiction $ λ h,
have h1 : s ≠ ∅ ∧ sᶜ ≠ ∅, from ⟨mt or.inl h,
mt (λ h2, or.inr $ (by rw [← compl_compl s, h2, compl_empty] : s = univ)) h⟩,
let ⟨_, h2, h3⟩ := nonempty_inter hs.1 hs.2.is_open_compl (union_compl_self s)
(nonempty_iff_ne_empty.2 h1.1) (nonempty_iff_ne_empty.2 h1.2) in
h3 h2,
by rintro (rfl | rfl); [exact is_clopen_empty, exact is_clopen_univ]⟩
lemma is_clopen.eq_univ [preconnected_space α] {s : set α} (h' : is_clopen s) (h : s.nonempty) :
s = univ :=
(is_clopen_iff.mp h').resolve_left h.ne_empty
lemma frontier_eq_empty_iff [preconnected_space α] {s : set α} :
frontier s = ∅ ↔ s = ∅ ∨ s = univ :=
is_clopen_iff_frontier_eq_empty.symm.trans is_clopen_iff
lemma nonempty_frontier_iff [preconnected_space α] {s : set α} :
(frontier s).nonempty ↔ s.nonempty ∧ s ≠ univ :=
by simp only [nonempty_iff_ne_empty, ne.def, frontier_eq_empty_iff, not_or_distrib]
lemma subtype.preconnected_space {s : set α} (h : is_preconnected s) :
preconnected_space s :=
{ is_preconnected_univ := by rwa [← embedding_subtype_coe.to_inducing.is_preconnected_image,
image_univ, subtype.range_coe] }
lemma subtype.connected_space {s : set α} (h : is_connected s) :
connected_space s :=
{ to_preconnected_space := subtype.preconnected_space h.is_preconnected,
to_nonempty := h.nonempty.to_subtype }
lemma is_preconnected_iff_preconnected_space {s : set α} :
is_preconnected s ↔ preconnected_space s :=
⟨subtype.preconnected_space,
begin
introI,
simpa using is_preconnected_univ.image (coe : s → α) continuous_subtype_coe.continuous_on
end⟩
lemma is_connected_iff_connected_space {s : set α} : is_connected s ↔ connected_space s :=
⟨subtype.connected_space,
λ h, ⟨nonempty_subtype.mp h.2, is_preconnected_iff_preconnected_space.mpr h.1⟩⟩
/-- A set `s` is preconnected if and only if
for every cover by two open sets that are disjoint on `s`,
it is contained in one of the two covering sets. -/
lemma is_preconnected_iff_subset_of_disjoint {s : set α} :
is_preconnected s ↔
∀ (u v : set α) (hu : is_open u) (hv : is_open v) (hs : s ⊆ u ∪ v) (huv : s ∩ (u ∩ v) = ∅),
s ⊆ u ∨ s ⊆ v :=
begin
split; intro h,
{ intros u v hu hv hs huv,
specialize h u v hu hv hs,
contrapose! huv,
rw ←nonempty_iff_ne_empty,
simp [not_subset] at huv,
rcases huv with ⟨⟨x, hxs, hxu⟩, ⟨y, hys, hyv⟩⟩,
have hxv : x ∈ v := or_iff_not_imp_left.mp (hs hxs) hxu,
have hyu : y ∈ u := or_iff_not_imp_right.mp (hs hys) hyv,
exact h ⟨y, hys, hyu⟩ ⟨x, hxs, hxv⟩ },
{ intros u v hu hv hs hsu hsv,
rw nonempty_iff_ne_empty,
intro H,
specialize h u v hu hv hs H,
contrapose H,
apply nonempty.ne_empty,
cases h,
{ rcases hsv with ⟨x, hxs, hxv⟩, exact ⟨x, hxs, ⟨h hxs, hxv⟩⟩ },
{ rcases hsu with ⟨x, hxs, hxu⟩, exact ⟨x, hxs, ⟨hxu, h hxs⟩⟩ } }
end
/-- A set `s` is connected if and only if
for every cover by a finite collection of open sets that are pairwise disjoint on `s`,
it is contained in one of the members of the collection. -/
lemma is_connected_iff_sUnion_disjoint_open {s : set α} :
is_connected s ↔
∀ (U : finset (set α)) (H : ∀ (u v : set α), u ∈ U → v ∈ U → (s ∩ (u ∩ v)).nonempty → u = v)
(hU : ∀ u ∈ U, is_open u) (hs : s ⊆ ⋃₀ ↑U),
∃ u ∈ U, s ⊆ u :=
begin
rw [is_connected, is_preconnected_iff_subset_of_disjoint],
split; intro h,
{ intro U, apply finset.induction_on U,
{ rcases h.left,
suffices : s ⊆ ∅ → false, { simpa },
intro, solve_by_elim },
{ intros u U hu IH hs hU H,
rw [finset.coe_insert, sUnion_insert] at H,
cases h.2 u (⋃₀ ↑U) _ _ H _ with hsu hsU,
{ exact ⟨u, finset.mem_insert_self _ _, hsu⟩ },
{ rcases IH _ _ hsU with ⟨v, hvU, hsv⟩,
{ exact ⟨v, finset.mem_insert_of_mem hvU, hsv⟩ },
{ intros, apply hs; solve_by_elim [finset.mem_insert_of_mem] },
{ intros, solve_by_elim [finset.mem_insert_of_mem] } },
{ solve_by_elim [finset.mem_insert_self] },
{ apply is_open_sUnion,
intros, solve_by_elim [finset.mem_insert_of_mem] },
{ apply eq_empty_of_subset_empty,
rintro x ⟨hxs, hxu, hxU⟩,
rw mem_sUnion at hxU,
rcases hxU with ⟨v, hvU, hxv⟩,
rcases hs u v (finset.mem_insert_self _ _) (finset.mem_insert_of_mem hvU) _ with rfl,
{ contradiction },
{ exact ⟨x, hxs, hxu, hxv⟩ } } } },
{ split,
{ rw nonempty_iff_ne_empty,
by_contradiction hs, subst hs,
simpa using h ∅ _ _ _; simp },
intros u v hu hv hs hsuv,
rcases h {u, v} _ _ _ with ⟨t, ht, ht'⟩,
{ rw [finset.mem_insert, finset.mem_singleton] at ht,
rcases ht with rfl|rfl; tauto },
{ intros t₁ t₂ ht₁ ht₂ hst,
rw nonempty_iff_ne_empty at hst,
rw [finset.mem_insert, finset.mem_singleton] at ht₁ ht₂,
rcases ht₁ with rfl|rfl; rcases ht₂ with rfl|rfl,
all_goals { refl <|> contradiction <|> skip },
rw inter_comm t₁ at hst, contradiction },
{ intro t,
rw [finset.mem_insert, finset.mem_singleton],
rintro (rfl|rfl); assumption },
{ simpa using hs } }
end
/-- Preconnected sets are either contained in or disjoint to any given clopen set. -/
theorem is_preconnected.subset_clopen {s t : set α} (hs : is_preconnected s) (ht : is_clopen t)
(hne : (s ∩ t).nonempty) : s ⊆ t :=
begin
by_contra h,
have : (s ∩ tᶜ).nonempty := inter_compl_nonempty_iff.2 h,
obtain ⟨x, -, hx, hx'⟩ : (s ∩ (t ∩ tᶜ)).nonempty,
from hs t tᶜ ht.is_open ht.compl.is_open (λ x hx, em _) hne this,
exact hx' hx
end
/-- Preconnected sets are either contained in or disjoint to any given clopen set. -/
theorem disjoint_or_subset_of_clopen {s t : set α} (hs : is_preconnected s) (ht : is_clopen t) :
disjoint s t ∨ s ⊆ t :=
(disjoint_or_nonempty_inter s t).imp_right $ hs.subset_clopen ht
/-- A set `s` is preconnected if and only if
for every cover by two closed sets that are disjoint on `s`,
it is contained in one of the two covering sets. -/
theorem is_preconnected_iff_subset_of_disjoint_closed :
is_preconnected s ↔
∀ (u v : set α) (hu : is_closed u) (hv : is_closed v) (hs : s ⊆ u ∪ v) (huv : s ∩ (u ∩ v) = ∅),
s ⊆ u ∨ s ⊆ v :=
begin
split; intro h,
{ intros u v hu hv hs huv,
rw is_preconnected_closed_iff at h,
specialize h u v hu hv hs,
contrapose! huv,
rw ←nonempty_iff_ne_empty,
simp [not_subset] at huv,
rcases huv with ⟨⟨x, hxs, hxu⟩, ⟨y, hys, hyv⟩⟩,
have hxv : x ∈ v := or_iff_not_imp_left.mp (hs hxs) hxu,
have hyu : y ∈ u := or_iff_not_imp_right.mp (hs hys) hyv,
exact h ⟨y, hys, hyu⟩ ⟨x, hxs, hxv⟩ },
{ rw is_preconnected_closed_iff,
intros u v hu hv hs hsu hsv,
rw nonempty_iff_ne_empty,
intro H,
specialize h u v hu hv hs H,
contrapose H,
apply nonempty.ne_empty,
cases h,
{ rcases hsv with ⟨x, hxs, hxv⟩, exact ⟨x, hxs, ⟨h hxs, hxv⟩⟩ },
{ rcases hsu with ⟨x, hxs, hxu⟩, exact ⟨x, hxs, ⟨hxu, h hxs⟩⟩ } }
end
/-- A closed set `s` is preconnected if and only if
for every cover by two closed sets that are disjoint,
it is contained in one of the two covering sets. -/