1-- The continuous image of a compact set is compact: pull a cover back,2-- take a finite subcover, and push each member forward through a chosen3-- original. The choice of originals is the one use of choice in the4-- compactness development5-- 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.CompactImage11import Compact12import Set.Choice1314defgraph originalMap (f X C F : Set) (U ∈ F) : C := choose(originals(f, X, C, U))15requires inside : F ⊆ preimages(f, X, C)16proof17have hU := inside with U, assumption18obtain⟨V, hV, shape⟩:= preimages.membership.forward with hU19have original : V ∈ originals(f, X, C, U) := originals.membership.backward with⟨hV, shape⟩20have inhabited : Nonempty(originals(f, X, C, U)) :=⟨V, original⟩21have chosen := choose.member with inhabited22have parts := originals.membership.forward with chosen23exact parts.left2425theorem IsCompact.image (f X T Y S A : Set)26requires continuous : ContinuousMap(f, X, T, Y, S)27requires compact : IsCompact(X, T, A)28shows IsCompact(Y, S, functionImage(f, A, Y))29proof30have function := continuous.left31constructor32 . exact functionImage.subset at f, A, Y33 . intros D cover34have pulledOpen : preimages(f, X, D) ⊆ T35intros U hU36obtain⟨V, hV, shape⟩:= preimages.membership.forward with hU37rw← shape38exact continuous.right with V, (cover.left with V, hV)39have pulledCover : A ⊆⋃(preimages(f, X, D))40intros a ha41have haX := compact.left with a, ha42have value := FunctionBetween.apply_closed with function, haX43have imageMember : f(a) ∈ functionImage(f, A, Y) bysimp [functionImage.membership]44have covered := cover.right with f(a), imageMember45obtain⟨V, hV, inV⟩:= union.membership.forward with covered46have member : functionPreimage(f, X, V) ∈ preimages(f, X, D) := preimages.membership.backward with⟨V, hV, rfl⟩47have inPreimage : a ∈ functionPreimage(f, X, V) := functionPreimage.membership.backward with⟨haX, inV⟩48exact union.contains with member, inPreimage49obtain⟨F, hF, finiteF, coveredA⟩:= compact.right with preimages(f, X, D), ⟨pulledOpen, pulledCover⟩50have graph := originalMap.function with hF51witness functionImage(originalMap(f, X, D, F), F, D)52refine⟨(functionImage.subset at originalMap(f, X, D, F), F, D), (Finite.function_image with graph, finiteF, (Subset.reflexive at F)), ?_⟩53intros y hy54simp [functionImage.membership] at hy55obtain⟨hyY, a, ha, shape⟩:= hy56have covered := coveredA with a, ha57obtain⟨U, hU, haU⟩:= union.membership.forward with covered58have value := originalMap.value with hF59have hUP := hF with U, hU60obtain⟨V, hV, preimageShape⟩:= preimages.membership.forward with hUP61have member : V ∈ originals(f, X, D, U) := originals.membership.backward with⟨hV, preimageShape⟩62have inhabited : Nonempty(originals(f, X, D, U)) :=⟨V, member⟩63have chosen := choose.member with inhabited64have chosenParts := originals.membership.forward with chosen65rw← value at chosenParts66have inChosen : a ∈ functionPreimage(f, X, originalMap(f, X, D, F)(U)) by rwa chosenParts.right67have hit := functionPreimage.membership.forward with inChosen68have chosenMember : originalMap(f, X, D, F)(U) ∈ functionImage(originalMap(f, X, D, F), F, D)69have closed := FunctionBetween.apply_closed with graph, hU70simp [functionImage.membership]71constructor72 . exact closed73 . witness U74constructor75 . exact hU76 . rfl77rw shape78exact union.contains with chosenMember, hit.right79