1-- Surjective images preserve finite generation of algebras (ZF).2-- Part of Cumulus, the Grace17 mathematics library.3-- Copyright (c) 2026 Grant Passmore.4-- Released under the Apache License 2.0. See LICENSE in the repository root.5-- Authors: Grant Passmore67module Grace.Cumulus.Algebra.Image8import Adjoin9import Cardinal.FiniteImage1011def subringComap (g B T : Set) : Set:= {x ∈ B | g(x) ∈ T}1213section Maps14variable (B plus z minus times unit C sum o inverse product e g : Set)15notationring S := (B, plus, z, minus, times, unit)16notationring U := (C, sum, o, inverse, product, e)17hypothesis source : IsCommRing(S)18hypothesis target : IsCommRing(U)19hypothesis hom : IsRingHom(g, S, U)2021theorem subringComap.subring (T : Set)22requires subring : IsSubring(U, T)23shows IsSubring(S, subringComap(g, B, T))24proof25have ordinary := IsCommRing.ring with source26have zeroIn := IsRing.zero_in_carrier with ordinary27have multiplicative := IsRing.multiplicative with ordinary28have oneIn := IsMonoid.unit_in_carrier with multiplicative29have zeroMem := IsSubring.zero_closed with subring30have oneMem := IsSubring.one_closed with subring31have negClosed := IsSubring.neg_closed with subring32have addClosed := IsSubring.add_closed with subring33have mulClosed := IsSubring.mul_closed with subring34have zeroValue := IsRingHom.zero with hom35have oneValue := IsRingHom.one with hom36have subset : subringComap(g, B, T) ⊆ B37intros x hx38have data := subringComap.membership.forward with hx39exact data.left40unfold IsSubring41refine⟨subset, ⟨?_, ⟨?_, ⟨?_, ⟨?_, ?_⟩⟩⟩⟩⟩42 . apply subringComap.membership.backward at g, B, T, z43rw zeroValue44refine⟨zeroIn, zeroMem⟩45 . apply subringComap.membership.backward at g, B, T, unit46rw oneValue47refine⟨oneIn, oneMem⟩48intros x hx49obtain⟨member, value⟩:= subringComap.membership.forward with hx50have closed := IsRing.neg_closed with ordinary, member51have mapped := IsRingHom.neg with hom, member52have output := ClosedUnary.mem with negClosed, value53apply subringComap.membership.backward54rw mapped55refine⟨closed, output⟩56intros x hx y hy57obtain⟨memberX, valueX⟩:= subringComap.membership.forward with hx58obtain⟨memberY, valueY⟩:= subringComap.membership.forward with hy59have closed := IsRing.add_closed with ordinary, memberX, memberY60have mapped := IsRingHom.add with hom, memberX, memberY61have output := ClosedBinary.mem with addClosed, valueX, valueY62apply subringComap.membership.backward63rw mapped64refine⟨closed, output⟩65intros x hx y hy66obtain⟨memberX, valueX⟩:= subringComap.membership.forward with hx67obtain⟨memberY, valueY⟩:= subringComap.membership.forward with hy68have closed := IsRing.mul_closed with ordinary, memberX, memberY69have mapped := IsRingHom.mul with hom, memberX, memberY70have output := ClosedBinary.mem with mulClosed, valueX, valueY71apply subringComap.membership.backward72rw mapped73refine⟨closed, output⟩7475end Maps7677section Algebras78variable (A add zero neg mul one B plus z minus times unit C sum o inverse product e f g : Set)79notationring R := (A, add, zero, neg, mul, one)80notationring S := (B, plus, z, minus, times, unit)81notationring U := (C, sum, o, inverse, product, e)82hypothesis coefficients : IsCommRing(R)83hypothesis source : IsCommRing(S)84hypothesis target : IsCommRing(U)85hypothesis coefficientMap : IsRingHom(f, R, S)86hypothesis hom : IsRingHom(g, S, U)8788theorem Subalgebra.comap (T : Set)89requires subalgebra : Subalgebra(compose(g, f, A, B, C), R, U, T)90shows Subalgebra(f, R, S, subringComap(g, B, T))91proof92have functionF := IsRingHom.function with coefficientMap93have functionG := IsRingHom.function with hom94have composite := compose.function at g, f, A, B, C with*95havestructure:= subalgebra96have subring := subringComap.subring with source, target, hom, structure.left97have included :=structure.right98have image : functionImage(f, A, B) ⊆ subringComap(g, B, T)99intros b hb100obtain⟨memberB, a, ha, value⟩:= functionImage.membership.forward with hb101have compositeValue := compose.apply at g, f, A, B, C, a with*102have imageValue := functionImage.value at compose(g, f, A, B, C), A, C, a with*103have member := included with compose(g, f, A, B, C)(a), imageValue104apply subringComap.membership.backward105constructor106 . exact memberB107 . rw [value, ← compositeValue]108exact member109unfold Subalgebra110refine⟨subring, image⟩111112theorem algebraAdjoin.map_into (G : Set)113requires bounded : G ⊆ S114shows algebraAdjoin(f, R, S, G) ⊆ subringComap(g, B, algebraAdjoin(compose(g, f, A, B, C), R, U, functionImage(g, G, C)))115proof116have composite := IsRingHom.compose with coefficients, coefficientMap, hom117have function := IsRingHom.function with hom118have imageBound := functionImage.subset at g, G, C119have generated := algebraAdjoin.subalgebra with coefficients, target, composite, imageBound120have contains := algebraAdjoin.contains with coefficients, target, composite, imageBound121have preimage := Subalgebra.comap with coefficients, source, target, coefficientMap, hom, generated122have generators : G ⊆ subringComap(g, B, algebraAdjoin(compose(g, f, A, B, C), R, U, functionImage(g, G, C)))123intros x hx124have member := bounded with x, hx125have value := FunctionBetween.apply_closed with function, member126have image : g(x) ∈ functionImage(g, G, C)127apply functionImage.membership.backward128refine⟨value, x, hx, ?_⟩129rfl130have generatedValue := contains with g(x), image131exact subringComap.membership.backward with⟨member, generatedValue⟩132exact algebraAdjoin.least with coefficients, source, coefficientMap, preimage, generators133134theorem algebraAdjoin.surjective_image (G : Set)135requires onto : SurjectiveBetween(g, B, C)136requires bounded : G ⊆ S137requires generates : algebraAdjoin(f, R, S, G) = S138shows algebraAdjoin(compose(g, f, A, B, C), R, U, functionImage(g, G, C)) = U139proof140have composite := IsRingHom.compose with coefficients, coefficientMap, hom141have subset := algebraAdjoin.subset at A, add, zero, neg, mul, one, C, sum, o, inverse, product, e, compose(g, f, A, B, C), functionImage(g, G, C) with*142have mapped := algebraAdjoin.map_into with coefficients, source, target, coefficientMap, hom, bounded143rw generates at mapped144have surjection := onto145apply Subset.antisymmetric with subset146intros y hy147obtain⟨x, hx, edge⟩:= surjection.right with y, hy148have value := FunctionBetween.apply_value with surjection.left, hx, edge149have member := mapped with x, hx150have data := subringComap.membership.forward with member151rw value at data152exact data.right153154theorem FinitelyGeneratedAlgebra.surjective_image155requires finiteGeneration : FinitelyGeneratedAlgebra(f, R, S)156requires onto : SurjectiveBetween(g, B, C)157shows FinitelyGeneratedAlgebra(compose(g, f, A, B, C), R, U)158proof159obtain⟨G, finite, bounded, generates⟩:= finiteGeneration160have function := IsRingHom.function with hom161have imageFinite := Finite.function_image with function, finite, bounded162have imageBound := functionImage.subset at g, G, C163have imageGenerates := algebraAdjoin.surjective_image with coefficients, source, target, coefficientMap, hom, onto, bounded, generates164unfold FinitelyGeneratedAlgebra165refine⟨functionImage(g, G, C), imageFinite, imageBound, imageGenerates⟩166167end Algebras168section Quotients169variable (A add zero neg mul one B plus z minus times unit f J : Set)170notationring R := (A, add, zero, neg, mul, one)171notationring S := (B, plus, z, minus, times, unit)172notationring Q := S ⧸ J173hypothesis coefficients : IsCommRing(R)174hypothesis source : IsCommRing(S)175hypothesis hom : IsRingHom(f, R, S)176hypothesis ideal : IsIdeal(S, J)177178theorem FinitelyGeneratedAlgebra.quotient179requires finiteGeneration : FinitelyGeneratedAlgebra(f, R, S)180shows FinitelyGeneratedAlgebra(compose(quotientProjection(B, idealRelation(B, plus, minus, J)), f, A, B, Q), R, Q)181proof182have target := idealQuotient.comm_ring with*183have projection := idealQuotient.projection_hom with*184have equivalence := idealRelation.equivalence with*185have onto := quotientProjection.surjective with*186exact FinitelyGeneratedAlgebra.surjective_image with coefficients, source, target, hom, projection, finiteGeneration, onto187188end Quotients189