1-- Transport of relative linear spans along algebra homomorphisms (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.LinearSpanMap8import SpanProduct9import Image1011section Algebras12variable (A add zero neg mul one B plus z minus times unit C sum o inverse product e f g : Set)13notationring R := (A, add, zero, neg, mul, one)14notationring S := (B, plus, z, minus, times, unit)15notationring U := (C, sum, o, inverse, product, e)16hypothesis coefficients : IsCommRing(R)17hypothesis source : IsCommRing(S)18hypothesis target : IsCommRing(U)19hypothesis coefficientMap : IsRingHom(f, R, S)20hypothesis hom : IsRingHom(g, S, U)2122theorem Submodule.comap (T : Set)23requires submodule : Submodule(compose(g, f, A, B, C), R, U, T)24shows Submodule(f, R, S, subringComap(g, B, T))25proof26have ordinary := IsCommRing.ring with source27have functionF := IsRingHom.function with coefficientMap28have functionG := IsRingHom.function with hom29have composite := IsRingHom.compose with coefficients, coefficientMap, hom30have zeroIn := IsRing.zero_in_carrier with ordinary31have zeroMem := Submodule.zero_mem with coefficients, target, composite, submodule32have negClosed := Submodule.neg_closed with coefficients, target, composite, submodule33have addClosed := Submodule.add_closed with coefficients, target, composite, submodule34have zeroValue := IsRingHom.zero with hom35have bounded : subringComap(g, B, T) ⊆ B bysimp [Subset, subringComap.membership]36have zeroMember : S[0] ∈ subringComap(g, B, T)37apply subringComap.membership.backward38rw zeroValue39refine⟨zeroIn, zeroMem⟩40have negative : ClosedUnary(subringComap(g, B, T), minus)41intros x hx42obtain⟨inB, member⟩:= subringComap.membership.forward with hx43have closed := IsRing.neg_closed with ordinary, inB44have mapped := IsRingHom.neg with hom, inB45have result := ClosedUnary.mem with negClosed, member46apply subringComap.membership.backward47rw mapped48refine⟨closed, result⟩49have addition : ClosedBinary(subringComap(g, B, T), plus)50intros x hx y hy51obtain⟨inX, memberX⟩:= subringComap.membership.forward with hx52obtain⟨inY, memberY⟩:= subringComap.membership.forward with hy53have closed := IsRing.add_closed with ordinary, inX, inY54have mapped := IsRingHom.add with hom, inX, inY55have result := ClosedBinary.mem with addClosed, memberX, memberY56apply subringComap.membership.backward57rw mapped58refine⟨closed, result⟩59have scalars : ∀ a ∈ R, ∀ x ∈ subringComap(g, B, T), S[f(a) * x] ∈ subringComap(g, B, T)60intros a ha x hx61obtain⟨inB, member⟩:= subringComap.membership.forward with hx62have image := IsRingHom.closed with coefficientMap, ha63have closed := IsRing.mul_closed with ordinary, image, inB64have mapped := IsRingHom.mul with hom, image, inB65have compositeValue := compose.apply with ha66have result := Submodule.scalar_mul_mem with coefficients, target, composite, submodule, ha, member67rw compositeValue at result68apply subringComap.membership.backward69rw mapped70refine⟨closed, result⟩71unfold Submodule72refine⟨bounded, zeroMember, negative, addition, scalars⟩7374theorem linearSpan.map_mem (G x : Set)75requires bounded : G ⊆ S76requires member : x ∈ linearSpan(f, R, S, G)77shows g(x) ∈ linearSpan(compose(g, f, A, B, C), R, U, functionImage(g, G, C))78proof79have composite := IsRingHom.compose with coefficients, coefficientMap, hom80have span := linearSpan.submodule at A, add, zero, neg, mul, one, C, sum, o, inverse, product, e, compose(g, f, A, B, C), functionImage(g, G, C) with*81have preimage := Submodule.comap with coefficients, source, target, coefficientMap, hom, span82have imageBound : functionImage(g, G, C) ⊆ C byexact functionImage.subset at g, G, C83have contains := linearSpan.contains with coefficients, target, composite, imageBound84have generators : G ⊆ subringComap(g, B, linearSpan(compose(g, f, A, B, C), R, U, functionImage(g, G, C)))85intros u hu86have inB : u ∈ B bysimp [Subset]87have closed := IsRingHom.closed with hom, inB88have image : g(u) ∈ functionImage(g, G, C) := functionImage.membership.backward with⟨closed, u, hu, rfl⟩89have inSpan : g(u) ∈ linearSpan(compose(g, f, A, B, C), R, U, functionImage(g, G, C)) bysimp [Subset]90exact subringComap.membership.backward with⟨inB, inSpan⟩91have included := linearSpan.least with coefficients, source, coefficientMap, preimage, generators92have inPreimage := included with x, member93have data := subringComap.membership.forward with inPreimage94exact data.right9596end Algebras97