1-- Monotone maps between ordered sets, Galois connections, and closure2-- operators3-- Part of Cumulus, the Grace17 mathematics library.4-- Copyright (c) 2026 Grant Passmore.5-- Released under the Apache License 2.0. See LICENSE in the repository root.6-- Authors: Grant Passmore78module Grace.Cumulus.Lattice.Monotone9import Complete1011predicate IsMonotoneMap (f A r B s : Set) :=12 FunctionBetween(f, A, B) ∧13 (∀ x ∈ A, ∀ y ∈ A, relates(r, x, y) → relates(s, f(x), f(y)))1415predicate IsAntitoneMap (f A r B s : Set) :=16 FunctionBetween(f, A, B) ∧17 (∀ x ∈ A, ∀ y ∈ A, relates(r, x, y) → relates(s, f(y), f(x)))1819-- A Galois connection: f is left adjoint to g.20predicate IsGaloisConnection (f A r g B s : Set) :=21 FunctionBetween(f, A, B) ∧ FunctionBetween(g, B, A) ∧22 (∀ x ∈ A, ∀ y ∈ B, (relates(s, f(x), y) ↔ relates(r, x, g(y))))2324predicate IsClosureOperator (c A r : Set) :=25 FunctionBetween(c, A, A) ∧26 (∀ x ∈ A, relates(r, x, c(x))) ∧27 (∀ x ∈ A, ∀ y ∈ A, relates(r, x, y) → relates(r, c(x), c(y))) ∧28 (∀ x ∈ A, c(c(x)) = c(x))2930-- Monotone maps3132theorem IsMonotoneMap.function (f A r B s : Set)33requires h : IsMonotoneMap(f, A, r, B, s)34shows f : A → B35proof36simp [IsMonotoneMap]3738theorem IsMonotoneMap.preserves (f A r B s x y : Set)39requires h : IsMonotoneMap(f, A, r, B, s)40requires hx : x ∈ A41requires hy : y ∈ A42requires hxy : relates(r, x, y)43shows relates(s, f(x), f(y))44proof45rcases h with⟨function, monotone⟩46exact monotone with x, hx, y, hy, hxy4748theorem IsMonotoneMap.apply_member (f A r B s x : Set)49requires h : IsMonotoneMap(f, A, r, B, s)50requires hx : x ∈ A51shows f(x) ∈ B52proof53exact FunctionBetween.apply_closed with (IsMonotoneMap.function with h), hx5455theorem IsAntitoneMap.function (f A r B s : Set)56requires h : IsAntitoneMap(f, A, r, B, s)57shows f : A → B58proof59simp [IsAntitoneMap]6061theorem IsAntitoneMap.reverses (f A r B s x y : Set)62requires h : IsAntitoneMap(f, A, r, B, s)63requires hx : x ∈ A64requires hy : y ∈ A65requires hxy : relates(r, x, y)66shows relates(s, f(y), f(x))67proof68rcases h with⟨function, antitone⟩69exact antitone with x, hx, y, hy, hxy7071theorem IsMonotoneMap.identity (A r : Set)72shows IsMonotoneMap(identity(A), A, r, A, r)73proof74constructor75 . exact identity.function at A76 . intros x hx y hy hxy77have valueX := identity.apply with hx78have valueY := identity.apply with hy79rw [valueX, valueY]80exact hxy8182theorem IsMonotoneMap.compose (f g A r B s C t : Set)83requires hf : IsMonotoneMap(f, A, r, B, s)84requires hg : IsMonotoneMap(g, B, s, C, t)85shows IsMonotoneMap(compose(g, f, A, B, C), A, r, C, t)86proof87have fFunction := IsMonotoneMap.function with hf88have gFunction := IsMonotoneMap.function with hg89constructor90 . exact compose.function with fFunction, gFunction91 . intros x hx y hy hxy92have valueX := compose.apply with fFunction, gFunction, hx93have valueY := compose.apply with fFunction, gFunction, hy94rw [valueX, valueY]95have fxB := FunctionBetween.apply_closed with fFunction, hx96have fyB := FunctionBetween.apply_closed with fFunction, hy97have mapped := IsMonotoneMap.preserves with hf, hx, hy, hxy98exact IsMonotoneMap.preserves with hg, fxB, fyB, mapped99100theorem IsMonotoneMap.converse (f A r B s : Set)101requires h : IsMonotoneMap(f, A, r, B, s)102shows IsMonotoneMap(f, A, converse(r, A, A), B, converse(s, B, B))103proof104have function := IsMonotoneMap.function with h105constructor106 . exact function107 . intros x hx y hy hxy108have yx := converse.reflects with hxy109have mapped := IsMonotoneMap.preserves with h, hy, hx, yx110have fxB := FunctionBetween.apply_closed with function, hx111have fyB := FunctionBetween.apply_closed with function, hy112exact converse.relates with fyB, fxB, mapped113114theorem IsAntitoneMap.monotone_converse (f A r B s : Set)115requires h : IsAntitoneMap(f, A, r, B, s)116shows IsMonotoneMap(f, A, r, B, converse(s, B, B))117proof118have function := IsAntitoneMap.function with h119constructor120 . exact function121 . intros x hx y hy hxy122have reversed := IsAntitoneMap.reverses with h, hx, hy, hxy123have fxB := FunctionBetween.apply_closed with function, hx124have fyB := FunctionBetween.apply_closed with function, hy125exact converse.relates with fyB, fxB, reversed126127theorem OrderEmbedding.monotone (f A r B s : Set)128requires h : OrderEmbedding(f, A, r, B, s)129shows IsMonotoneMap(f, A, r, B, s)130proof131rcases h with⟨injective, ordered⟩132have function := Injective.function with injective133constructor134 . exact function135 . intros x hx y hy hxy136have fxB := FunctionBetween.apply_closed with function, hx137have fyB := FunctionBetween.apply_closed with function, hy138have mapX := FunctionBetween.relates_apply with function, hx139have mapY := FunctionBetween.relates_apply with function, hy140have preserved :=orderedwith x, hx, y, hy, f(x), fxB, f(y), fyB, mapX,141 mapY142exact preserved.forward with hxy143144theorem OrderEmbedding.reflects (f A r B s x y : Set)145requires h : OrderEmbedding(f, A, r, B, s)146requires hx : x ∈ A147requires hy : y ∈ A148requires hxy : relates(s, f(x), f(y))149shows relates(r, x, y)150proof151rcases h with⟨injective, ordered⟩152have function := Injective.function with injective153have fxB := FunctionBetween.apply_closed with function, hx154have fyB := FunctionBetween.apply_closed with function, hy155have mapX := FunctionBetween.relates_apply with function, hx156have mapY := FunctionBetween.relates_apply with function, hy157have preserved :=orderedwith x, hx, y, hy, f(x), fxB, f(y), fyB, mapX, mapY158exact preserved.backward with hxy159160theorem OrderIsomorphism.monotone (f A r B s : Set)161requires h : OrderIsomorphism(f, A, r, B, s)162shows IsMonotoneMap(f, A, r, B, s)163proof164exact OrderEmbedding.monotone with (OrderIsomorphism.embedding with h)165166-- Chains and bounds under a monotone map167168theorem IsMonotoneMap.chain (f A r B s C : Set)169requires h : IsMonotoneMap(f, A, r, B, s)170requires chain : Chain(A, r, C)171shows Chain(B, s, functionImage(f, C, B))172proof173rcases chain with⟨bounded, comparable⟩174constructor175 . exact functionImage.subset at f, C, B176 . intros u hu v hv177obtain⟨uB, x, hx, rfl⟩:= functionImage.membership.forward with hu178obtain⟨vB, y, hy, rfl⟩:= functionImage.membership.forward with hv179have xA := bounded with x, hx180have yA := bounded with y, hy181havecases:= comparable with x, hx, y, hy182casescaseswith xy | yx183 . left184exact IsMonotoneMap.preserves with h, xA, yA, xy185 . right186exact IsMonotoneMap.preserves with h, yA, xA, yx187188theorem IsMonotoneMap.image_upper (f A r B s S u : Set)189requires h : IsMonotoneMap(f, A, r, B, s)190requires bound : UpperBound(A, r, S, u)191shows UpperBound(B, s, functionImage(f, S, B), f(u))192proof193have uA := UpperBound.member with bound194have bounded := UpperBound.subset with bound195refine⟨(IsMonotoneMap.apply_member with h, uA), (functionImage.subset at f,196 S, B), ?_⟩197intros v hv198obtain⟨vB, x, hx, rfl⟩:= functionImage.membership.forward with hv199have above := UpperBound.above with bound, hx200exact IsMonotoneMap.preserves with h, (bounded with x, hx), uA, above201202theorem IsMonotoneMap.image_lower (f A r B s S l : Set)203requires h : IsMonotoneMap(f, A, r, B, s)204requires bound : LowerBound(A, r, S, l)205shows LowerBound(B, s, functionImage(f, S, B), f(l))206proof207have lA := LowerBound.member with bound208have bounded := LowerBound.subset with bound209refine⟨(IsMonotoneMap.apply_member with h, lA), (functionImage.subset at f,210 S, B), ?_⟩211intros v hv212obtain⟨vB, x, hx, rfl⟩:= functionImage.membership.forward with hv213have below := LowerBound.below with bound, hx214exact IsMonotoneMap.preserves with h, lA, (bounded with x, hx), below215216theorem IsMonotoneMap.image_supremum_le (f A r B s S u v : Set)217requires h : IsMonotoneMap(f, A, r, B, s)218requires hu : Supremum(A, r, S, u)219requires hv : Supremum(B, s, functionImage(f, S, B), v)220shows relates(s, v, f(u))221proof222have uA := Supremum.member with hu223have bound := IsMonotoneMap.image_upper with h, (Supremum.upper with hu)224exact Supremum.least with hv, (IsMonotoneMap.apply_member with h, uA), bound225226theorem IsMonotoneMap.image_infimum_ge (f A r B s S l m : Set)227requires h : IsMonotoneMap(f, A, r, B, s)228requires hl : Infimum(A, r, S, l)229requires hm : Infimum(B, s, functionImage(f, S, B), m)230shows relates(s, f(l), m)231proof232have lA := Infimum.member with hl233have bound := IsMonotoneMap.image_lower with h, (Infimum.lower with hl)234exact Infimum.greatest with hm, (IsMonotoneMap.apply_member with h, lA), bound235236theorem IsMonotoneMap.join_le (f A r B s x y : Set)237requires h : IsMonotoneMap(f, A, r, B, s)238requires source : IsLattice(A, r)239requires target : IsLattice(B, s)240requires hx : x ∈ A241requires hy : y ∈ A242shows relates(s, join(B, s, f(x), f(y)), f(join(A, r, x, y)))243proof244have joinA := join.member with source, hx, hy245have fxB := IsMonotoneMap.apply_member with h, hx246have fyB := IsMonotoneMap.apply_member with h, hy247have fJ := IsMonotoneMap.apply_member with h, joinA248have xJ := IsMonotoneMap.preserves with h, hx, joinA,249 (join.upper_left with source, hx, hy)250have yJ := IsMonotoneMap.preserves with h, hy, joinA,251 (join.upper_right with source, hx, hy)252exact join.least with target, fxB, fyB, fJ, xJ, yJ253254theorem IsMonotoneMap.meet_ge (f A r B s x y : Set)255requires h : IsMonotoneMap(f, A, r, B, s)256requires source : IsLattice(A, r)257requires target : IsLattice(B, s)258requires hx : x ∈ A259requires hy : y ∈ A260shows relates(s, f(meet(A, r, x, y)), meet(B, s, f(x), f(y)))261proof262have meetA := meet.member with source, hx, hy263have fxB := IsMonotoneMap.apply_member with h, hx264have fyB := IsMonotoneMap.apply_member with h, hy265have fM := IsMonotoneMap.apply_member with h, meetA266have mX := IsMonotoneMap.preserves with h, meetA, hx,267 (meet.lower_left with source, hx, hy)268have mY := IsMonotoneMap.preserves with h, meetA, hy,269 (meet.lower_right with source, hx, hy)270exact meet.greatest with target, fxB, fyB, fM, mX, mY271272-- Galois connections273274theorem IsGaloisConnection.lower_function (f A r g B s : Set)275requires h : IsGaloisConnection(f, A, r, g, B, s)276shows f : A → B277proof278simp [IsGaloisConnection]279280theorem IsGaloisConnection.upper_function (f A r g B s : Set)281requires h : IsGaloisConnection(f, A, r, g, B, s)282shows g : B → A283proof284simp [IsGaloisConnection]285286theorem IsGaloisConnection.adjunction (f A r g B s x y : Set)287requires h : IsGaloisConnection(f, A, r, g, B, s)288requires hx : x ∈ A289requires hy : y ∈ B290shows relates(s, f(x), y) ↔ relates(r, x, g(y))291proof292rcases h with⟨fFunction, gFunction, adjoint⟩293exact adjoint with x, hx, y, hy294295theorem IsGaloisConnection.unit (f A r g B s x : Set)296requires h : IsGaloisConnection(f, A, r, g, B, s)297requires target : IsPartialOrder(B, s)298requires hx : x ∈ A299shows relates(r, x, g(f(x)))300proof301have reflexive := IsPartialOrder.reflexive with target302have fxB := FunctionBetween.apply_closed with303 (IsGaloisConnection.lower_function with h), hx304have adjoint := IsGaloisConnection.adjunction with h, hx, fxB305exact adjoint.forward with (reflexive with f(x), fxB)306307theorem IsGaloisConnection.counit (f A r g B s y : Set)308requires h : IsGaloisConnection(f, A, r, g, B, s)309requires source : IsPartialOrder(A, r)310requires hy : y ∈ B311shows relates(s, f(g(y)), y)312proof313have reflexive := IsPartialOrder.reflexive with source314have gyA := FunctionBetween.apply_closed with315 (IsGaloisConnection.upper_function with h), hy316have adjoint := IsGaloisConnection.adjunction with h, gyA, hy317exact adjoint.backward with (reflexive with g(y), gyA)318319theorem IsGaloisConnection.lower_monotone (f A r g B s : Set)320requires h : IsGaloisConnection(f, A, r, g, B, s)321requires source : IsPartialOrder(A, r)322requires target : IsPartialOrder(B, s)323shows IsMonotoneMap(f, A, r, B, s)324proof325have transitive := IsPartialOrder.transitive with source326have fFunction := IsGaloisConnection.lower_function with h327have gFunction := IsGaloisConnection.upper_function with h328constructor329 . exact fFunction330 . intros x hx y hy hxy331have fyB := FunctionBetween.apply_closed with fFunction, hy332have gfyA := FunctionBetween.apply_closed with gFunction, fyB333have unit := IsGaloisConnection.unit with h, target, hy334have below := transitive with x, hx, y, hy, g(f(y)), gfyA, hxy, unit335have adjoint := IsGaloisConnection.adjunction with h, hx, fyB336exact adjoint.backward with below337338theorem IsGaloisConnection.upper_monotone (f A r g B s : Set)339requires h : IsGaloisConnection(f, A, r, g, B, s)340requires source : IsPartialOrder(A, r)341requires target : IsPartialOrder(B, s)342shows IsMonotoneMap(g, B, s, A, r)343proof344have transitive := IsPartialOrder.transitive with target345have fFunction := IsGaloisConnection.lower_function with h346have gFunction := IsGaloisConnection.upper_function with h347constructor348 . exact gFunction349 . intros x hx y hy hxy350have gxA := FunctionBetween.apply_closed with gFunction, hx351have fgxB := FunctionBetween.apply_closed with fFunction, gxA352have counit := IsGaloisConnection.counit with h, source, hx353have below := transitive with f(g(x)), fgxB, x, hx, y, hy, counit, hxy354have adjoint := IsGaloisConnection.adjunction with h, gxA, hy355exact adjoint.forward with below356357theorem IsGaloisConnection.lower_upper_lower (f A r g B s x : Set)358requires h : IsGaloisConnection(f, A, r, g, B, s)359requires source : IsPartialOrder(A, r)360requires target : IsPartialOrder(B, s)361requires hx : x ∈ A362shows f(g(f(x))) = f(x)363proof364have antisymmetric := IsPartialOrder.antisymmetric with target365have fFunction := IsGaloisConnection.lower_function with h366have gFunction := IsGaloisConnection.upper_function with h367have fxB := FunctionBetween.apply_closed with fFunction, hx368have gfxA := FunctionBetween.apply_closed with gFunction, fxB369have fgfxB := FunctionBetween.apply_closed with fFunction, gfxA370have below := IsGaloisConnection.counit with h, source, fxB371have unit := IsGaloisConnection.unit with h, target, hx372have monotone := IsGaloisConnection.lower_monotone with h, source, target373have above := IsMonotoneMap.preserves with monotone, hx, gfxA, unit374exact antisymmetric with f(g(f(x))), fgfxB, f(x), fxB, below, above375376theorem IsGaloisConnection.upper_lower_upper (f A r g B s y : Set)377requires h : IsGaloisConnection(f, A, r, g, B, s)378requires source : IsPartialOrder(A, r)379requires target : IsPartialOrder(B, s)380requires hy : y ∈ B381shows g(f(g(y))) = g(y)382proof383have antisymmetric := IsPartialOrder.antisymmetric with source384have fFunction := IsGaloisConnection.lower_function with h385have gFunction := IsGaloisConnection.upper_function with h386have gyA := FunctionBetween.apply_closed with gFunction, hy387have fgyB := FunctionBetween.apply_closed with fFunction, gyA388have gfgyA := FunctionBetween.apply_closed with gFunction, fgyB389have above := IsGaloisConnection.unit with h, target, gyA390have counit := IsGaloisConnection.counit with h, source, hy391have monotone := IsGaloisConnection.upper_monotone with h, source, target392have below := IsMonotoneMap.preserves with monotone, fgyB, hy, counit393exact antisymmetric with g(f(g(y))), gfgyA, g(y), gyA, below, above394395theorem IsGaloisConnection.identity (A r : Set)396shows IsGaloisConnection(identity(A), A, r, identity(A), A, r)397proof398refine⟨identity.function at A, identity.function at A, ?_⟩399intros x hx y hy400have valueX := identity.apply with hx401have valueY := identity.apply with hy402rw [valueX, valueY]403constructor404 . intro related405exact related406 . intro related407exact related408409theorem IsGaloisConnection.compose (f A r g B s k C t l : Set)410requires first : IsGaloisConnection(f, A, r, g, B, s)411requires second : IsGaloisConnection(k, B, s, l, C, t)412shows413 IsGaloisConnection(compose(k, f, A, B, C), A, r, compose(g, l, C, B, A), C, t)414proof415have fFunction := IsGaloisConnection.lower_function with first416have gFunction := IsGaloisConnection.upper_function with first417have kFunction := IsGaloisConnection.lower_function with second418have lFunction := IsGaloisConnection.upper_function with second419refine⟨(compose.function with fFunction, kFunction),420 (compose.function with lFunction, gFunction), ?_⟩421intros x hx z hz422have valueX := compose.apply with fFunction, kFunction, hx423have valueZ := compose.apply with lFunction, gFunction, hz424rw [valueX, valueZ]425have fxB := FunctionBetween.apply_closed with fFunction, hx426have lzB := FunctionBetween.apply_closed with lFunction, hz427have outer := IsGaloisConnection.adjunction with second, fxB, hz428have inner := IsGaloisConnection.adjunction with first, hx, lzB429constructor430 . intro related431exact inner.forward with (outer.forward with related)432 . intro related433exact outer.backward with (inner.backward with related)434435-- The left adjoint preserves suprema and the right adjoint preserves infima.436437theorem IsGaloisConnection.lower_supremum (f A r g B s S u : Set)438requires h : IsGaloisConnection(f, A, r, g, B, s)439requires source : IsPartialOrder(A, r)440requires target : IsPartialOrder(B, s)441requires hu : Supremum(A, r, S, u)442shows Supremum(B, s, functionImage(f, S, B), f(u))443proof444have monotone := IsGaloisConnection.lower_monotone with h, source, target445have gFunction := IsGaloisConnection.upper_function with h446have uA := Supremum.member with hu447have bounded := Supremum.subset with hu448constructor449 . exact IsMonotoneMap.image_upper with monotone, (Supremum.upper with hu)450 . intros b hb bound451have gbA := FunctionBetween.apply_closed with gFunction, hb452have lifted : UpperBound(A, r, S, g(b))453refine⟨gbA, bounded, ?_⟩454intros x hx455have xA := bounded with x, hx456have fxB := IsMonotoneMap.apply_member with monotone, xA457have imageMember : f(x) ∈ functionImage(f, S, B) :=458 functionImage.membership.backward with⟨fxB, x, hx, rfl⟩459have above := UpperBound.above with bound, imageMember460have adjoint := IsGaloisConnection.adjunction with h, xA, hb461exact adjoint.forward with above462have below := Supremum.least with hu, gbA, lifted463have adjoint := IsGaloisConnection.adjunction with h, uA, hb464exact adjoint.backward with below465466theorem IsGaloisConnection.upper_infimum (f A r g B s T v : Set)467requires h : IsGaloisConnection(f, A, r, g, B, s)468requires source : IsPartialOrder(A, r)469requires target : IsPartialOrder(B, s)470requires hv : Infimum(B, s, T, v)471shows Infimum(A, r, functionImage(g, T, A), g(v))472proof473have monotone := IsGaloisConnection.upper_monotone with h, source, target474have fFunction := IsGaloisConnection.lower_function with h475have vB := Infimum.member with hv476have bounded := Infimum.subset with hv477constructor478 . exact IsMonotoneMap.image_lower with monotone, (Infimum.lower with hv)479 . intros a ha bound480have faB := FunctionBetween.apply_closed with fFunction, ha481have lifted : LowerBound(B, s, T, f(a))482refine⟨faB, bounded, ?_⟩483intros y hy484have yB := bounded with y, hy485have gyA := IsMonotoneMap.apply_member with monotone, yB486have imageMember : g(y) ∈ functionImage(g, T, A) :=487 functionImage.membership.backward with⟨gyA, y, hy, rfl⟩488have below := LowerBound.below with bound, imageMember489have adjoint := IsGaloisConnection.adjunction with h, ha, yB490exact adjoint.backward with below491have above := Infimum.greatest with hv, faB, lifted492have adjoint := IsGaloisConnection.adjunction with h, ha, vB493exact adjoint.forward with above494495-- Closure operators496497theorem IsClosureOperator.function (c A r : Set)498requires h : IsClosureOperator(c, A, r)499shows c : A → A500proof501simp [IsClosureOperator]502503theorem IsClosureOperator.extensive (c A r x : Set)504requires h : IsClosureOperator(c, A, r)505requires hx : x ∈ A506shows relates(r, x, c(x))507proof508rcases h with⟨function, extensive, monotone, idempotent⟩509exact extensive with x, hx510511theorem IsClosureOperator.monotone (c A r : Set)512requires h : IsClosureOperator(c, A, r)513shows IsMonotoneMap(c, A, r, A, r)514proof515rcases h with⟨function, extensive, monotone, idempotent⟩516refine⟨function, monotone⟩517518theorem IsClosureOperator.idempotent (c A r x : Set)519requires h : IsClosureOperator(c, A, r)520requires hx : x ∈ A521shows c(c(x)) = c(x)522proof523rcases h with⟨function, extensive, monotone, idempotent⟩524exact idempotent with x, hx525526theorem IsClosureOperator.apply_member (c A r x : Set)527requires h : IsClosureOperator(c, A, r)528requires hx : x ∈ A529shows c(x) ∈ A530proof531exact FunctionBetween.apply_closed with (IsClosureOperator.function with h),532 hx533534theorem IsClosureOperator.identity (A r : Set)535requires order : IsPartialOrder(A, r)536shows IsClosureOperator(identity(A), A, r)537proof538have reflexive := IsPartialOrder.reflexive with order539refine⟨identity.function at A, ?_, ?_, ?_⟩540 . intros x hx541have valueX := identity.apply with hx542rw valueX543exact reflexive with x, hx544 . intros x hx y hy hxy545have valueX := identity.apply with hx546have valueY := identity.apply with hy547rw [valueX, valueY]548exact hxy549 . intros x hx550have valueX := identity.apply with hx551rw valueX552rw valueX553rfl554555theorem IsClosureOperator.le_iff (c A r x y : Set)556requires h : IsClosureOperator(c, A, r)557requires order : IsPartialOrder(A, r)558requires hx : x ∈ A559requires hy : y ∈ A560shows relates(r, x, c(y)) ↔ relates(r, c(x), c(y))561proof562have transitive := IsPartialOrder.transitive with order563have monotone := IsClosureOperator.monotone with h564have cxA := IsClosureOperator.apply_member with h, hx565have cyA := IsClosureOperator.apply_member with h, hy566constructor567 . intro below568have mapped := IsMonotoneMap.preserves with monotone, hx, cyA, below569have twice := IsClosureOperator.idempotent with h, hy570rw twice at mapped571exact mapped572 . intro below573have extensive := IsClosureOperator.extensive with h, hx574exact transitive with x, hx, c(x), cxA, c(y), cyA, extensive, below575576theorem IsGaloisConnection.closure (f A r g B s : Set)577requires h : IsGaloisConnection(f, A, r, g, B, s)578requires source : IsPartialOrder(A, r)579requires target : IsPartialOrder(B, s)580shows IsClosureOperator(compose(g, f, A, B, A), A, r)581proof582have fFunction := IsGaloisConnection.lower_function with h583have gFunction := IsGaloisConnection.upper_function with h584have lower := IsGaloisConnection.lower_monotone with h, source, target585have upper := IsGaloisConnection.upper_monotone with h, source, target586have composite := IsMonotoneMap.compose with lower, upper587refine⟨(compose.function with fFunction, gFunction), ?_, ?_, ?_⟩588 . intros x hx589have valueX := compose.apply with fFunction, gFunction, hx590rw valueX591exact IsGaloisConnection.unit with h, target, hx592 . intros x hx y hy hxy593exact IsMonotoneMap.preserves with composite, hx, hy, hxy594 . intros x hx595have fxB := FunctionBetween.apply_closed with fFunction, hx596have gfxA := FunctionBetween.apply_closed with gFunction, fxB597have valueX := compose.apply with fFunction, gFunction, hx598have valueTwice := compose.apply with fFunction, gFunction, gfxA599rw valueX600rw valueTwice601exact IsGaloisConnection.upper_lower_upper with h, source, target, fxB602