1-- Connectedness: a space with no splitting into two disjoint nonempty open2-- sets, connected subsets through open separations, the clopen3-- characterisation, examples, continuous images, closures, unions through4-- a common point, and connected components5-- Part of Cumulus, the Grace17 mathematics library.6-- Copyright (c) 2026 Grant Passmore.7-- Released under the Apache License 2.0. See LICENSE in the repository root.8-- Authors: Grant Passmore910module Grace.Cumulus.Topology.Connected11import Separation1213-- A disconnection of the space; an open separation of a subset A uses two14-- open sets whose traces on A are disjoint, nonempty, and cover A.15predicate Disconnection (X T U V : Set) :=16 U ∈ T ∧ V ∈ T ∧ Nonempty(U) ∧ Nonempty(V) ∧ Disjoint(U, V) ∧ U ∪ V = X1718predicate OpenSeparation (T A U V : Set) :=19 U ∈ T ∧ V ∈ T ∧ A ⊆ U ∪ V ∧ Disjoint(U ∩ A, V ∩ A) ∧20 Nonempty(U ∩ A) ∧ Nonempty(V ∩ A)2122predicate IsConnected (X T : Set) :=¬(∃ U, ∃ V, Disconnection(X, T, U, V))2324predicate IsConnectedSubset (X T A : Set) :=25 A ⊆ X ∧¬(∃ U, ∃ V, OpenSeparation(T, A, U, V))2627theorem IsConnectedSubset.subset (X T A : Set)28requires connected : IsConnectedSubset(X, T, A)29shows A ⊆ X30proof31exact connected.left3233theorem IsConnectedSubset.no_separation (X T A U V : Set)34requires connected : IsConnectedSubset(X, T, A)35requires separation : OpenSeparation(T, A, U, V)36shows⊥37proof38apply connected.right39exact⟨U, V, separation⟩4041theorem OpenSeparation.symmetric (T A U V : Set)42requires separation : OpenSeparation(T, A, U, V)43shows OpenSeparation(T, A, V, U)44proof45obtain⟨hU, hV, covers, disjoint, inhabitedU, inhabitedV⟩:= separation46have swapped : A ⊆ V ∪ U47rw union2.commutative48exact covers49exact⟨hV, hU, swapped, (Disjoint.symmetric with disjoint), inhabitedV, inhabitedU⟩5051-- The clopen characterisation.5253theorem IsConnected.clopen (X T U : Set)54requires topology : IsTopology(X, T)55requires connected : IsConnected(X, T)56requires isOpen : U ∈ T57requires closed : IsClosed(X, T, U)58shows U =∅∨ U = X59proof60have hUX := closed.left61by_contra neither62have notEmpty : U ≠∅63intro equal64apply neither65left66exact equal67have notWhole : U ≠ X68intro equal69apply neither70right71exact equal72have negation : ¬(∃ U, ∃ V, Disconnection(X, T, U, V)) := connected73apply negation74witness U75witness complement(X, U)76refine⟨isOpen, closed.right, (Nonempty.of_ne_empty with notEmpty), ?_, ?_, (complement.union2 with hUX)⟩77 . by_contra none78apply notWhole79apply Subset.antisymmetric80 . exact hUX81 . intros x hx82by_contra outside83apply none84witness x85exact complement.membership.backward with⟨hx, outside⟩86 . have same := complement.intersection at X, U87exact same8889theorem IsConnected.of_clopen (X T : Set)90requires topology : IsTopology(X, T)91requires trivial : ∀ U ∈ T, IsClosed(X, T, U) → U =∅∨ U = X92shows IsConnected(X, T)93proof94unfold IsConnected95introsplit96obtain⟨U, V, hU, hV, inhabitedU, inhabitedV, disjoint, whole⟩:=split97have hUX := IsTopology.subset with topology, hU98have hVX := IsTopology.subset with topology, hV99have separated := Disjoint.iff.forward with disjoint100have complementV : complement(X, U) = V101ext x102constructor103 . intro hx104have parts := complement.membership.forward with hx105have hxX := parts.left106rw← whole at hxX107have split2 := union2.membership.forward with hxX108cases split2 with inU | inV109 . exfalso110exact parts.right with inU111 . exact inV112 . intro hx113apply complement.membership.backward114refine⟨(hVX with x, hx), ?_⟩115intro inU116exact separated with x, inU, hx117have closedU : IsClosed(X, T, U)118constructor119 . exact hUX120 . rw complementV121exact hV122havecases:= trivial with U, hU, closedU123casescaseswith isEmpty | isWhole124 . obtain⟨x, hx⟩:= inhabitedU125rw isEmpty at hx126exact empty.membership with x, hx127 . obtain⟨y, hy⟩:= inhabitedV128have hyU : y ∈ U129rw isWhole130exact hVX with y, hy131exact separated with y, hyU, hy132133theorem IsConnected.iff_clopen (X T : Set)134requires topology : IsTopology(X, T)135shows IsConnected(X, T) ↔∀ U ∈ T, IsClosed(X, T, U) → U =∅∨ U = X136proof137constructor138 . intros connected U hU closed139exact IsConnected.clopen with topology, connected, hU, closed140 . intro trivial141exact IsConnected.of_clopen with topology, trivial142143-- Examples: the indiscrete space is connected; a discrete two-point space144-- is not.145146theorem IsConnected.indiscrete (X : Set)147shows IsConnected(X, {∅, X})148proof149unfold IsConnected150introsplit151obtain⟨U, V, hU, hV, inhabitedU, inhabitedV, disjoint, whole⟩:=split152have separated := Disjoint.iff.forward with disjoint153obtain⟨x, hx⟩:= inhabitedU154obtain⟨y, hy⟩:= inhabitedV155have splitU := pair.membership.forward with hU156have splitV := pair.membership.forward with hV157cases splitU with emptyU | wholeU158 . rw emptyU at hx159exact empty.membership with x, hx160 . cases splitV with emptyV | wholeV161 . rw emptyV at hy162exact empty.membership with y, hy163 . have hxV : x ∈ V164rw [wholeV, ← wholeU]165exact hx166exact separated with x, hx, hxV167168theorem IsConnected.not_discrete_pair (a b : Set)169requires distinct : a ≠ b170shows¬IsConnected({a, b}, 𝒫({a, b}))171proof172intro connected173have negation : ¬(∃ U, ∃ V, Disconnection({a, b}, 𝒫({a, b}), U, V)) := connected174apply negation175have singletonA : {a} ⊆ {a, b} := singleton.subset_pair at a, b176have singletonB : {b} ⊆ {a, b}177intros z hz178have same := singleton.membership.forward with hz179rw same180exact pair.right at a, b181witness {a}182witness {b}183refine⟨(powerset.membership_iff.backward with singletonA), (powerset.membership_iff.backward with singletonB), (Nonempty.singleton at a), (Nonempty.singleton at b), ?_, ?_⟩184 . apply Disjoint.iff.backward185intros z hz hz2186have sameA := singleton.membership.forward with hz187have sameB := singleton.membership.forward with hz2188apply distinct189rw [← sameA, ← sameB]190rfl191 . symm192exact pair.eq_union2 at a, b193194-- The whole space is a connected subset exactly when the space is195-- connected.196197theorem IsConnectedSubset.whole_iff (X T : Set)198requires topology : IsTopology(X, T)199shows IsConnectedSubset(X, T, X) ↔ IsConnected(X, T)200proof201constructor202 . intros connected split203obtain⟨U, V, hU, hV, inhabitedU, inhabitedV, disjoint, whole⟩:=split204have hUX := IsTopology.subset with topology, hU205have hVX := IsTopology.subset with topology, hV206have traceU := intersection.eq_left_of_subset with hUX207have traceV := intersection.eq_left_of_subset with hVX208apply connected.right209witness U210witness V211refine⟨hU, hV, ?_, ?_, ?_, ?_⟩212 . rw whole213exact Subset.reflexive at X214 . rw [traceU, traceV]215exact disjoint216 . rw traceU217exact inhabitedU218 . rw traceV219exact inhabitedV220 . intro connected221constructor222 . exact Subset.reflexive at X223 . introsplit224obtain⟨U, V, hU, hV, covers, disjoint, inhabitedU, inhabitedV⟩:=split225have hUX := IsTopology.subset with topology, hU226have hVX := IsTopology.subset with topology, hV227have traceU := intersection.eq_left_of_subset with hUX228have traceV := intersection.eq_left_of_subset with hVX229rw [traceU, traceV] at disjoint230rw traceU at inhabitedU231rw traceV at inhabitedV232have negation : ¬(∃ U, ∃ V, Disconnection(X, T, U, V)) := connected233apply negation234witness U235witness V236refine⟨hU, hV, inhabitedU, inhabitedV, disjoint, ?_⟩237exact Subset.antisymmetric with (union2.subset with hUX, hVX), covers238239theorem IsConnectedSubset.empty (X T : Set)240shows IsConnectedSubset(X, T, ∅)241proof242constructor243 . exact empty.subset at X244 . introsplit245obtain⟨U, V, hU, hV, covers, disjoint, inhabitedU, inhabitedV⟩:=split246obtain⟨x, hx⟩:= inhabitedU247have parts := intersection.membership.forward with hx248exact empty.membership with x, parts.right249250theorem IsConnectedSubset.singleton (X T x : Set)251requires hx : x ∈ X252shows IsConnectedSubset(X, T, {x})253proof254constructor255 . exact singleton.subset_iff.backward with hx256 . introsplit257obtain⟨U, V, hU, hV, covers, disjoint, inhabitedU, inhabitedV⟩:=split258have separated := Disjoint.iff.forward with disjoint259obtain⟨y, hy⟩:= inhabitedU260obtain⟨z, hz⟩:= inhabitedV261have partsY := intersection.membership.forward with hy262have partsZ := intersection.membership.forward with hz263have sameY := singleton.membership.forward with partsY.right264have sameZ := singleton.membership.forward with partsZ.right265rw sameY at hy266rw sameZ at hz267exact separated with x, hy, hz268269-- A connected subset meeting one side of a would-be separation lies in it.270theorem IsConnectedSubset.absorbed (X T A U V x : Set)271requires connected : IsConnectedSubset(X, T, A)272requires hU : U ∈ T273requires hV : V ∈ T274requires covers : A ⊆ U ∪ V275requires disjoint : Disjoint(U ∩ A, V ∩ A)276requires hxA : x ∈ A277requires hxU : x ∈ U278shows A ⊆ U279proof280intros a ha281by_contra outside282have inUnion := covers with a, ha283havesplit:= union2.membership.forward with inUnion284casessplitwith inU | inV285 . exact outside with inU286 . apply connected.right287have inhabitedU : Nonempty(U ∩ A) :=⟨x, (intersection.membership.backward with⟨hxU, hxA⟩)⟩288have inhabitedV : Nonempty(V ∩ A) :=⟨a, (intersection.membership.backward with⟨inV, ha⟩)⟩289witness U290witness V291exact⟨hU, hV, covers, disjoint, inhabitedU, inhabitedV⟩292293-- The continuous image of a connected subset is connected.294theorem IsConnectedSubset.image (f X T Y S A : Set)295requires continuous : ContinuousMap(f, X, T, Y, S)296requires connected : IsConnectedSubset(X, T, A)297shows IsConnectedSubset(Y, S, functionImage(f, A, Y))298proof299have function := continuous.left300have hAX := connected.left301constructor302 . exact functionImage.subset at f, A, Y303 . introsplit304obtain⟨U, V, hU, hV, covers, disjoint, inhabitedU, inhabitedV⟩:=split305have separated := Disjoint.iff.forward with disjoint306have openU := continuous.right with U, hU307have openV := continuous.right with V, hV308apply connected.right309witness functionPreimage(f, X, U)310witness functionPreimage(f, X, V)311refine⟨openU, openV, ?_, ?_, ?_, ?_⟩312 . intros a ha313have haX := hAX with a, ha314have valueY := FunctionBetween.apply_closed with function, haX315have imageMember : f(a) ∈ functionImage(f, A, Y) bysimp [functionImage.membership]316have inUnion := covers with f(a), imageMember317have split2 := union2.membership.forward with inUnion318apply union2.membership.backward319cases split2 with inU | inV320 . left321exact functionPreimage.membership.backward with⟨haX, inU⟩322 . right323exact functionPreimage.membership.backward with⟨haX, inV⟩324 . apply Disjoint.iff.backward325intros a haU haV326have partsU := intersection.membership.forward with haU327have partsV := intersection.membership.forward with haV328have valueU := functionPreimage.membership.forward with partsU.left329have valueV := functionPreimage.membership.forward with partsV.left330have haX := hAX with a, partsU.right331have valueY := FunctionBetween.apply_closed with function, haX332have imageMember : f(a) ∈ functionImage(f, A, Y) bysimp [functionImage.membership]333have inTraceU : f(a) ∈ U ∩ functionImage(f, A, Y) := intersection.membership.backward with⟨valueU.right, imageMember⟩334have inTraceV : f(a) ∈ V ∩ functionImage(f, A, Y) := intersection.membership.backward with⟨valueV.right, imageMember⟩335exact separated with f(a), inTraceU, inTraceV336 . obtain⟨y, hy⟩:= inhabitedU337have parts := intersection.membership.forward with hy338have hyU := parts.left339have imageParts := functionImage.membership.forward with parts.right340obtain⟨hyY, a, ha, shape⟩:= imageParts341have haX := hAX with a, ha342rw shape at hyU343witness a344exact intersection.membership.backward with⟨(functionPreimage.membership.backward with⟨haX, hyU⟩), ha⟩345 . obtain⟨y, hy⟩:= inhabitedV346have parts := intersection.membership.forward with hy347have hyV := parts.left348have imageParts := functionImage.membership.forward with parts.right349obtain⟨hyY, a, ha, shape⟩:= imageParts350have haX := hAX with a, ha351rw shape at hyV352witness a353exact intersection.membership.backward with⟨(functionPreimage.membership.backward with⟨haX, hyV⟩), ha⟩354355theorem IsConnected.image (f X T Y S : Set)356requires topology : IsTopology(X, T)357requires continuous : ContinuousMap(f, X, T, Y, S)358requires connected : IsConnected(X, T)359shows IsConnectedSubset(Y, S, functionImage(f, X, Y))360proof361have whole := IsConnectedSubset.whole_iff.backward with topology, connected362exact IsConnectedSubset.image with continuous, whole363364-- A continuous surjection carries connectedness to the codomain.365theorem IsConnected.of_surjection (f X T Y S : Set)366requires topologyX : IsTopology(X, T)367requires topologyY : IsTopology(Y, S)368requires continuous : ContinuousMap(f, X, T, Y, S)369requires surjective : SurjectiveBetween(f, X, Y)370requires connected : IsConnected(X, T)371shows IsConnected(Y, S)372proof373have function := continuous.left374have image := IsConnected.image with topologyX, continuous, connected375have whole : functionImage(f, X, Y) = Y376apply Subset.antisymmetric377 . exact functionImage.subset at f, X, Y378 . intros y hy379obtain⟨x, hx, edge⟩:= surjective.right with y, hy380have value := FunctionBetween.apply_value with function, hx, edge381rw← value382exact functionImage.value with function, hx383rw whole at image384exact IsConnectedSubset.whole_iff.forward with topologyY, image385386theorem IsConnected.of_homeomorphism (f X T Y S : Set)387requires topologyX : IsTopology(X, T)388requires topologyY : IsTopology(Y, S)389requires homeomorphism : IsHomeomorphism(f, X, T, Y, S)390requires connected : IsConnected(X, T)391shows IsConnected(Y, S)392proof393obtain⟨bijective, continuous, inverse⟩:= homeomorphism394have surjective := Bijective.surjective with bijective395exact IsConnected.of_surjection with topologyX, topologyY, continuous, surjective, connected396397theorem IsConnected.homeomorphic_iff (f X T Y S : Set)398requires topologyX : IsTopology(X, T)399requires topologyY : IsTopology(Y, S)400requires homeomorphism : IsHomeomorphism(f, X, T, Y, S)401shows IsConnected(X, T) ↔ IsConnected(Y, S)402proof403have inverse := IsHomeomorphism.inverse with homeomorphism404constructor405 . intro connected406exact IsConnected.of_homeomorphism with topologyX, topologyY, homeomorphism, connected407 . intro connected408exact IsConnected.of_homeomorphism with topologyY, topologyX, inverse, connected409410-- Anything between a connected set and its closure is connected.411theorem IsConnectedSubset.between (X T A B : Set)412requires topology : IsTopology(X, T)413requires connected : IsConnectedSubset(X, T, A)414requires hAB : A ⊆ B415requires hB : B ⊆ closure(X, T, A)416shows IsConnectedSubset(X, T, B)417proof418have hAX := connected.left419have closureInside := closure.subset with topology, hAX420constructor421 . exact Subset.transitive with hB, closureInside422 . introsplit423obtain⟨U, V, hU, hV, covers, disjoint, inhabitedU, inhabitedV⟩:=split424have separated := Disjoint.iff.forward with disjoint425apply connected.right426have meetsU : Nonempty(U ∩ A)427obtain⟨b, hb⟩:= inhabitedU428have parts := intersection.membership.forward with hb429have inClosure := hB with b, parts.right430have touches := closure.membership.forward with topology, hAX, inClosure431exact touches.right with U, hU, parts.left432have meetsV : Nonempty(V ∩ A)433obtain⟨b, hb⟩:= inhabitedV434have parts := intersection.membership.forward with hb435have inClosure := hB with b, parts.right436have touches := closure.membership.forward with topology, hAX, inClosure437exact touches.right with V, hV, parts.left438witness U439witness V440refine⟨hU, hV, (Subset.transitive with hAB, covers), ?_, meetsU, meetsV⟩441apply Disjoint.iff.backward442intros a haU haV443have partsU := intersection.membership.forward with haU444have partsV := intersection.membership.forward with haV445have inB := hAB with a, partsU.right446have inTraceU : a ∈ U ∩ B := intersection.membership.backward with⟨partsU.left, inB⟩447have inTraceV : a ∈ V ∩ B := intersection.membership.backward with⟨partsV.left, inB⟩448exact separated with a, inTraceU, inTraceV449450theorem IsConnectedSubset.closure (X T A : Set)451requires topology : IsTopology(X, T)452requires connected : IsConnectedSubset(X, T, A)453shows IsConnectedSubset(X, T, closure(X, T, A))454proof455have contains := Space.closure.contains with topology, connected.left456exact IsConnectedSubset.between with topology, connected, contains, (Subset.reflexive at closure(X, T, A))457458-- Unions of connected subsets through a common point are connected.459460theorem IsConnectedSubset.union_family (X T F p : Set)461requires connected : ∀ A ∈ F, IsConnectedSubset(X, T, A)462requires common : ∀ A ∈ F, p ∈ A463shows IsConnectedSubset(X, T, ⋃(F))464proof465constructor466 . apply union.subset467intros A hA468have connectedA := connected with A, hA469exact connectedA.left470 . introsplit471obtain⟨U, V, hU, hV, covers, disjoint, inhabitedU, inhabitedV⟩:=split472have separated := Disjoint.iff.forward with disjoint473have memberDisjoint : ∀ A ∈ F, Disjoint(U ∩ A, V ∩ A)474intros A hA475have below := union.subset_of_member with hA476have leftBelow := intersection.monotone_right at A, ⋃(F), U with below477have rightBelow := intersection.monotone_right at A, ⋃(F), V with below478have first := Disjoint.of_subset_left with disjoint, leftBelow479exact Disjoint.of_subset_right with first, rightBelow480have memberCovers : ∀ A ∈ F, A ⊆ U ∪ V481intros A hA482exact Subset.transitive with (union.subset_of_member with hA), covers483obtain⟨x, hx⟩:= inhabitedU484have partsX := intersection.membership.forward with hx485obtain⟨A0, hA0, hxA0⟩:= union.membership.forward with partsX.right486have hpA0 := common with A0, hA0487have hpUnion := union.contains with hA0, hpA0488have hpUnionV := union.contains with hA0, hpA0489have splitP := union2.membership.forward with (covers with p, hpUnion)490cases splitP with inU | inV491 . have inside : ⋃(F) ⊆ U492apply union.subset493intros A hA494exact IsConnectedSubset.absorbed with (connected with A, hA), hU, hV, (memberCovers with A, hA), (memberDisjoint with A, hA), (common with A, hA), inU495obtain⟨y, hy⟩:= inhabitedV496have partsY := intersection.membership.forward with hy497have hyU := inside with y, partsY.right498have inTraceU : y ∈ U ∩⋃(F) := intersection.membership.backward with⟨hyU, partsY.right⟩499exact separated with y, inTraceU, hy500 . have inside : ⋃(F) ⊆ V501apply union.subset502intros A hA503have swappedCovers : A ⊆ V ∪ U504rw union2.commutative505exact memberCovers with A, hA506have swappedDisjoint := Disjoint.symmetric with (memberDisjoint with A, hA)507exact IsConnectedSubset.absorbed with (connected with A, hA), hV, hU, swappedCovers, swappedDisjoint, (common with A, hA), inV508have hxV := inside with x, partsX.right509have inTraceV : x ∈ V ∩⋃(F) := intersection.membership.backward with⟨hxV, partsX.right⟩510exact separated with x, hx, inTraceV511512theorem IsConnectedSubset.union2 (X T A B : Set)513requires connectedA : IsConnectedSubset(X, T, A)514requires connectedB : IsConnectedSubset(X, T, B)515requires meets : Nonempty(A ∩ B)516shows IsConnectedSubset(X, T, A ∪ B)517proof518obtain⟨p, hp⟩:= meets519have parts := intersection.membership.forward with hp520have connected : ∀ C ∈ {A, B}, IsConnectedSubset(X, T, C)521intros C hC522havesplit:= pair.membership.forward with hC523casessplitwith isA | isB524 . rw isA525exact connectedA526 . rw isB527exact connectedB528have common : ∀ C ∈ {A, B}, p ∈ C529intros C hC530havesplit:= pair.membership.forward with hC531casessplitwith isA | isB532 . rw isA533exact parts.left534 . rw isB535exact parts.right536have joined := IsConnectedSubset.union_family with connected, common537 rwa union.pair at joined538539-- Connected components: the union of the connected subsets through a540-- point.541542def connectedThrough (X T x : Set) : Set:=543 { A ∈𝒫(X) | IsConnectedSubset(X, T, A) ∧ x ∈ A }544545def component (X T x : Set) : Set:=⋃(connectedThrough(X, T, x))546547theorem component.connected (X T x : Set)548shows IsConnectedSubset(X, T, component(X, T, x))549proof550unfold component551apply IsConnectedSubset.union_family at X, T, connectedThrough(X, T, x), x552 . intros A hA553have parts := connectedThrough.membership.forward with hA554exact parts.right.left555 . intros A hA556have parts := connectedThrough.membership.forward with hA557exact parts.right.right558559theorem component.subset (X T x : Set)560shows component(X, T, x) ⊆ X561proof562have connected := component.connected at X, T, x563exact connected.left564565theorem component.maximal (X T x A : Set)566requires connected : IsConnectedSubset(X, T, A)567requires hx : x ∈ A568shows A ⊆ component(X, T, x)569proof570have found : A ∈ connectedThrough(X, T, x)571apply connectedThrough.membership.backward572exact⟨(powerset.membership_iff.backward with connected.left), connected, hx⟩573unfold component574exact union.subset_of_member with found575576theorem component.contains (X T x : Set)577requires hx : x ∈ X578shows x ∈ component(X, T, x)579proof580have connected := IsConnectedSubset.singleton at X, T, x with hx581haveself : x ∈ {x} bysimp [singleton.membership]582have below := component.maximal with connected, self583exact below with x, self584585theorem component.closed (X T x : Set)586requires topology : IsTopology(X, T)587requires hx : x ∈ X588shows IsClosed(X, T, component(X, T, x))589proof590have connected := component.connected at X, T, x591have closureConnected := IsConnectedSubset.closure with topology, connected592have contains := Space.closure.contains with topology, connected.left593have hxClosure := contains with x, (component.contains with hx)594have below := component.maximal with closureConnected, hxClosure595apply IsClosed.iff_closure.backward with topology, connected.left596exact Subset.antisymmetric with below, contains597598theorem component.eq_of_member (X T x y : Set)599requires hx : x ∈ X600requires hy : y ∈ component(X, T, x)601shows component(X, T, y) = component(X, T, x)602proof603have connectedX := component.connected at X, T, x604have connectedY := component.connected at X, T, y605have hyX := component.subset at X, T, x with y, hy606have first := component.maximal with connectedX, hy607have hxY := first with x, (component.contains with hx)608have second := component.maximal with connectedY, hxY609exact Subset.antisymmetric with second, first610611-- Connected subsets agree with connectedness of the subspace.612theorem IsConnectedSubset.iff_subspace (X T A : Set)613requires topology : IsTopology(X, T)614requires hA : A ⊆ X615shows IsConnectedSubset(X, T, A) ↔ IsConnected(A, subspaceTopology(T, A))616proof617constructor618 . intro connected619unfold IsConnected620introsplit621obtain⟨U1, V1, hU1, hV1, inhabitedU, inhabitedV, disjoint, whole⟩:=split622obtain⟨U, hU, shapeU⟩:= subspaceTopology.membership.forward with hU1623obtain⟨V, hV, shapeV⟩:= subspaceTopology.membership.forward with hV1624rw← shapeU at inhabitedU625rw← shapeV at inhabitedV626rw [← shapeU, ← shapeV] at disjoint627rw [← shapeU, ← shapeV] at whole628apply connected.right629witness U630witness V631refine⟨hU, hV, ?_, disjoint, inhabitedU, inhabitedV⟩632intros a ha633have inWhole : a ∈ U ∩ A ∪ V ∩ A634rw whole635exact ha636have split2 := union2.membership.forward with inWhole637apply union2.membership.backward638cases split2 with inU | inV639 . left640have parts := intersection.membership.forward with inU641exact parts.left642 . right643have parts := intersection.membership.forward with inV644exact parts.left645 . intro connected646constructor647 . exact hA648 . introsplit649obtain⟨U, V, hU, hV, covers, disjoint, inhabitedU, inhabitedV⟩:=split650have tracedU : U ∩ A ∈ subspaceTopology(T, A) := subspaceTopology.membership.backward with⟨U, hU, rfl⟩651have tracedV : V ∩ A ∈ subspaceTopology(T, A) := subspaceTopology.membership.backward with⟨V, hV, rfl⟩652have negation : ¬(∃ U, ∃ V, Disconnection(A, subspaceTopology(T, A), U, V)) := connected653apply negation654witness U ∩ A655witness V ∩ A656refine⟨tracedU, tracedV, inhabitedU, inhabitedV, disjoint, ?_⟩657apply Subset.antisymmetric658 . exact union2.subset with (intersection.subset_right at U, A), (intersection.subset_right at V, A)659 . intros a ha660have split2 := union2.membership.forward with (covers with a, ha)661apply union2.membership.backward662cases split2 with inU | inV663 . left664exact intersection.membership.backward with⟨inU, ha⟩665 . right666exact intersection.membership.backward with⟨inV, ha⟩667