1-- Ideals generated by arbitrary sets and soundness of unit certificates (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.Ring.GeneratedIdeal8import Homomorphism910-- The bounded intersection of all ambient ideals containing the generators.11def idealSpan (A add zero neg mul G : Set) : Set:=12 {x ∈ A |∀ J, IsIdeal(A, add, zero, neg, mul, J) → G ⊆ J → x ∈ J}1314notationscoped idealSpan(R, G) => idealSpan(R.carrier, R.add, R.zero, R.neg, R.mul, G)1516theorem idealSpan.subset (A add zero neg mul G : Set)17shows idealSpan(A, add, zero, neg, mul, G) ⊆ A18proof19simp2021theorem idealSpan.contains (A add zero neg mul G : Set)22requires bounded : G ⊆ A23shows G ⊆ idealSpan(A, add, zero, neg, mul, G)24proof25intros x hx26apply idealSpan.membership.backward27refine⟨?_, ?_⟩28 . exact bounded with x, hx29 . intros J ideal includes30exact includes with x, hx3132theorem idealSpan.least (A add zero neg mul G J : Set)33requires ideal : IsIdeal(A, add, zero, neg, mul, J)34requires includes : G ⊆ J35shows idealSpan(A, add, zero, neg, mul, G) ⊆ J36proof37intros x hx38have data := idealSpan.membership.forward with hx39exact data.right with J, ideal, includes4041section Ring42variable (A add zero neg mul one : Set)43hypothesisring : IsCommRing(A, add, zero, neg, mul, one)44notationring R := (A, add, zero, neg, mul, one)4546theorem idealSpan.ideal (G : Set)47shows IsIdeal(A, add, zero, neg, mul, idealSpan(A, add, zero, neg, mul, G))48proof49have ordinary := IsCommRing.ring withring50have zeroIn := IsRing.zero_in_carrier with ordinary51have bounded := idealSpan.subset at A, add, zero, neg, mul, G52unfold IsIdeal53refine⟨bounded, ⟨?_, ⟨?_, ⟨?_, ?_⟩⟩⟩⟩54 . apply idealSpan.membership.backward at A, add, zero, neg, mul, G, zero55refine⟨zeroIn, ?_⟩56intros J ideal includes57exact IsIdeal.zero_closed with ideal58 . intros x hx y hy59have dx := idealSpan.membership.forward with hx60have dy := idealSpan.membership.forward with hy61have closed := IsRing.add_closed with ordinary, dx.left, dy.left62apply idealSpan.membership.backward63refine⟨closed, ?_⟩64intros J ideal includes65have xIn := dx.right with J, ideal, includes66have yIn := dy.right with J, ideal, includes67exact IsIdeal.add_closed with ideal, xIn, yIn68 . intros x hx69have data := idealSpan.membership.forward with hx70have closed := IsRing.neg_closed with ordinary, data.left71apply idealSpan.membership.backward72refine⟨closed, ?_⟩73intros J ideal includes74have member := data.right with J, ideal, includes75exact IsIdeal.neg_closed with ideal, member76 . intros a ha x hx77have data := idealSpan.membership.forward with hx78have leftClosed := IsRing.mul_closed with ordinary, ha, data.left79have rightClosed := IsRing.mul_closed with ordinary, data.left, ha80constructor81 . apply idealSpan.membership.backward at A, add, zero, neg, mul, G, a * x82refine⟨leftClosed, ?_⟩83intros J ideal includes84have member := data.right with J, ideal, includes85exact IsIdeal.mul_left_closed with ideal, ha, member86 . apply idealSpan.membership.backward at A, add, zero, neg, mul, G, x * a87refine⟨rightClosed, ?_⟩88intros K idealK includesK89have memberK := data.right with K, idealK, includesK90exact IsIdeal.mul_right_closed with idealK, ha, memberK9192theorem idealSpan.mono (G H : Set)93requires inclusion : G ⊆ H94requires bounded : H ⊆ A95shows idealSpan(A, add, zero, neg, mul, G) ⊆ idealSpan(A, add, zero, neg, mul, H)96proof97have ideal := idealSpan.ideal at A, add, zero, neg, mul, one, H withring98have includes := idealSpan.contains at A, add, zero, neg, mul, H with bounded99have generators := Subset.transitive with inclusion, includes100exact idealSpan.least with ideal, generators101102theorem idealSpan.eq_of_ideal (J : Set)103requires ideal : IsIdeal(A, add, zero, neg, mul, J)104shows idealSpan(A, add, zero, neg, mul, J) = J105proof106have bounded := IsIdeal.subset_carrier with ideal107have reflexive : J ⊆ J bysimp [Subset]108haveleft:= idealSpan.least with ideal, reflexive109haveright:= idealSpan.contains at A, add, zero, neg, mul, J with bounded110exact Subset.antisymmetric withleft, right111112theorem idealSpan.idempotent (G : Set)113shows idealSpan(A, add, zero, neg, mul, idealSpan(A, add, zero, neg, mul, G)) = idealSpan(A, add, zero, neg, mul, G)114proof115have ideal := idealSpan.ideal at A, add, zero, neg, mul, one, G withring116exact idealSpan.eq_of_ideal withring, ideal117118theorem idealSpan.unit_iff (G : Set)119shows1∈ idealSpan(A, add, zero, neg, mul, G) ↔ idealSpan(A, add, zero, neg, mul, G) = A120proof121have ideal := idealSpan.ideal at A, add, zero, neg, mul, one, G withring122have ordinary := IsCommRing.ring withring123constructor124 . intro member125exact IsIdeal.whole_of_one with ordinary, ideal, member126 . intro equal127have monoid := IsRing.multiplicative with ordinary128have member := IsMonoid.unit_in_carrier with monoid129 rwa equal130131-- A two-term convenience; arbitrary finite certificates live in FiniteCombination.132theorem idealSpan.unit_of_linear_combination2 (G p q a b : Set)133requires bounded : G ⊆ A134requires hp : p ∈ G135requires hq : q ∈ G136requires ha : a ∈ A137requires hb : b ∈ A138requires identity : a * p + b * q =1139shows1∈ idealSpan(A, add, zero, neg, mul, G)140proof141have ideal := idealSpan.ideal at A, add, zero, neg, mul, one, G withring142have includes := idealSpan.contains at A, add, zero, neg, mul, G with bounded143have pIn := includes with p, hp144have qIn := includes with q, hq145haveleft:= IsIdeal.mul_left_closed with ideal, ha, pIn146haveright:= IsIdeal.mul_left_closed with ideal, hb, qIn147have sum := IsIdeal.add_closed with ideal, left, right148 rwa identity at sum149150end Ring151152-- Abstract certificate soundness: evaluation maps will instantiate this theorem.153theorem idealSpan.unit_obstructs_vanishing (f A add zero neg mul one B plus z minus times unit G : Set)154requires source : IsCommRing(A, add, zero, neg, mul, one)155requires target : IsCommRing(B, plus, z, minus, times, unit)156requires hom : IsRingHom(f, A, add, zero, neg, mul, one, B, plus, z, minus, times, unit)157requires nontrivial : Nontrivial(B, z, unit)158requires bounded : G ⊆ A159requires certificate : one ∈ idealSpan(A, add, zero, neg, mul, G)160shows¬(∀ p ∈ G, f(p) = z)161proof162intro vanishes163have kernel := IsRingHom.kernel_ideal with source, target, hom164have generators : G ⊆ ringKernel(f, A, z)165intros p hp166have pIn := bounded with p, hp167have value := vanishes with p, hp168exact ringKernel.membership.backward with⟨pIn, value⟩169have included := idealSpan.least with kernel, generators170have unitIn := included with one, certificate171have data := ringKernel.membership.forward with unitIn172have identity := IsRingHom.one with hom173have distinct := Nontrivial.distinct with nontrivial174have equal : z = unit bycc175exact distinct with equal176177-- The ideal generated by a subset of a bundled ring.178def generatedIdeal (R G : Set) : Set:=179 idealSpan(R.carrier, R.add, R.zero, R.neg, R.mul, G)180181theorem generatedIdeal.value (R G : Set)182shows generatedIdeal(R, G) = idealSpan(R.carrier, R.add, R.zero, R.neg, R.mul, G)183proof184simp [generatedIdeal]185186section GeneratedIdeals187variable (R : Set)188hypothesis comm : CommRing(R)189190theorem generatedIdeal.ideal (G : Set)191shows Ideal(R, generatedIdeal(R, G))192proof193have parts := CommRing.parts with comm194have engine := idealSpan.ideal at R.carrier, R.add, R.zero, R.neg, R.mul,195 R.one, G with parts196rw generatedIdeal.value197exact Ideal.of_projections with engine198199theorem generatedIdeal.contains (G : Set)200requires bounded : G ⊆ R201shows G ⊆ generatedIdeal(R, G)202proof203rw generatedIdeal.value204exact idealSpan.contains at R.carrier, R.add, R.zero, R.neg, R.mul, G205with bounded206207theorem generatedIdeal.least (G J : Set)208requires ideal : Ideal(R, J)209requires includes : G ⊆ J210shows generatedIdeal(R, G) ⊆ J211proof212have parts := Ideal.parts with ideal213rw generatedIdeal.value214exact idealSpan.least with parts, includes215216theorem generatedIdeal.mono (G H : Set)217requires inclusion : G ⊆ H218requires bounded : H ⊆ R219shows generatedIdeal(R, G) ⊆ generatedIdeal(R, H)220proof221have ideal := generatedIdeal.ideal at R, H with comm222have includes := generatedIdeal.contains with comm, bounded223have generators := Subset.transitive with inclusion, includes224exact generatedIdeal.least with comm, ideal, generators225226theorem generatedIdeal.eq_of_ideal (J : Set)227requires ideal : Ideal(R, J)228shows generatedIdeal(R, J) = J229proof230have parts := Ideal.parts with ideal231rw generatedIdeal.value232exact idealSpan.eq_of_ideal with (CommRing.parts with comm), parts233234theorem generatedIdeal.unit_iff (G : Set)235shows R[1] ∈ generatedIdeal(R, G) ↔ generatedIdeal(R, G) = R.carrier236proof237have ideal := generatedIdeal.ideal at R, G with comm238havering:= CommRing.to_ring with comm239constructor240 . intro member241exact Ideal.contains_one withring, ideal, member242 . intro equal243have oneIn : R[1] ∈ R := Ring.one_mem with*244 rwa equal245246end GeneratedIdeals247