1-- One common denominator for finite sets and finitely spanned submodules (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.ClearDenominators8import Localization9import FiniteSpan1011section Rings12variable (B plus z minus times unit T D : Set)13notationring S := (B, plus, z, minus, times, unit)14hypothesisring : IsCommRing(S)15hypothesis subring : IsSubring(S, T)16hypothesis denominators : Denominators(S, T, D)1718theorem localizationWithin.clear_list (K : Set) (xs : List(K))19requires included : K ⊆ localizationWithin(S, T, D)20shows∃ d ∈ D, ∀ x ∈ listSupport{K}(xs), S[d * x] ∈ T21proof22induction xs23| List.nil =>24have one := Denominators.one_mem withring, subring, denominators25refine⟨unit, one, ?_⟩26intros x hx27rw listSupport at hx28exfalso29exactset.empty with hx30| List.cons(x, tail) using ih =>31have bounded := IsSubring.subset_carrier with subring32have denomBound := Denominators.subset withring, subring, denominators33have denomAmbient := Subset.transitive with denomBound, bounded34have denomClosed := Denominators.mul_closed withring, subring, denominators35have multiply := IsSubring.mul_closed with subring36obtain⟨d, hd, clears⟩:= ih37have localized : x ∈ localizationWithin(S, T, D) bysimp [Subset]38obtain⟨inX, e, he, numerator⟩:= localizationWithin.membership.forward with localized39have dIn : d ∈ S bysimp [Subset]40have eIn : e ∈ S bysimp [Subset]41have dInT : d ∈ T bysimp [Subset]42have eInT : e ∈ T bysimp [Subset]43have product := ClosedBinary.mem with denomClosed, hd, he44refine⟨S[d * e], product, ?_⟩45intros u hu46rw listSupport at hu47have alternatives := insert.membership.forward with hu48cases alternatives with equal | previous49 . rw equal50have member := ClosedBinary.mem with multiply, dInT, numerator51have equation : S[(d * e) * x] = S[d * (e * x)] byring52 rwa equation53 . have tailBound := listSupport.subset with*54have memberK : u ∈ K bysimp [Subset]55have memberLocal : u ∈ localizationWithin(S, T, D) bysimp [Subset]56have data := localizationWithin.membership.forward with memberLocal57have inU := data.left58have cleared := clears with u, previous59have member := ClosedBinary.mem with multiply, eInT, cleared60have equation : S[(d * e) * u] = S[e * (d * u)] byring61 rwa equation6263theorem localizationWithin.clear_finite (K : Set)64requires finite : Finite(K)65requires included : K ⊆ localizationWithin(S, T, D)66shows∃ d ∈ D, ∀ x ∈ K, S[d * x] ∈ T67proof68obtain⟨xs, list, covers⟩:= Finite.list_cover with finite69obtain⟨d, hd, clears⟩:= localizationWithin.clear_list at B, plus, z, minus, times, unit, T, D, K, xs with*70refine⟨d, hd, ?_⟩71intros x hx72have covered : x ∈ listSupport{K}(xs) bysimp [Subset]73exact clears with x, covered7475end Rings7677section Algebras78variable (A add zero neg mul one B plus z minus times unit f T D M : Set)79notationring R := (A, add, zero, neg, mul, one)80notationring S := (B, plus, z, minus, times, unit)81hypothesis source : IsCommRing(R)82hypothesis target : IsCommRing(S)83hypothesis hom : IsRingHom(f, R, S)84hypothesis subalgebra : Subalgebra(f, R, S, T)85hypothesis denominators : Denominators(S, T, D)8687theorem localizationWithin.clear_finite_span88requires finite : FiniteSpan(f, R, S, M)89requires included : M ⊆ localizationWithin(S, T, D)90shows∃ d ∈ D, ∀ x ∈ M, S[d * x] ∈ T91proof92have subring := Subalgebra.subring with source, target, hom, subalgebra93have submodule := Subalgebra.submodule with source, target, hom, subalgebra94have bound := IsSubring.subset_carrier with subring95have denomBound := Denominators.subset with target, subring, denominators96have ambient := Subset.transitive with denomBound, bound97obtain⟨G, finiteG, generators, spans⟩:= finite98have localized := Subset.transitive with generators, included99obtain⟨d, hd, clears⟩:= localizationWithin.clear_finite with target, subring, denominators, finiteG, localized100have dIn : d ∈ S bysimp [Subset]101have multipliers := rightMultipliers.submodule with source, target, hom, submodule, dIn102have localBound := localizationWithin.subset at B, times, T, D103have boundedG := Subset.transitive with localized, localBound104have generatorsClear : G ⊆ rightMultipliers(B, times, T, d)105intros u hu106have inB : u ∈ S bysimp [Subset]107have cleared := clears with u, hu108have commute : S[u * d] = S[d * u] byring109apply rightMultipliers.membership.backward110rw commute111refine⟨inB, cleared⟩112have allClear := linearSpan.least with source, target, hom, multipliers, generatorsClear113rw spans at allClear114refine⟨d, hd, ?_⟩115intros x hx116have member : x ∈ rightMultipliers(B, times, T, d) bysimp [Subset]117obtain⟨inB, cleared⟩:= rightMultipliers.membership.forward with member118have commute : S[d * x] = S[x * d] byring119 rwa commute120121end Algebras122