1-- Prime ideals of a bundled ring: PrimeIdeal(R, I) under a ring hypothesis,2-- the bridges to the form over separate pieces, the factor laws, and the3-- primality of maximal ideals in a commutative ring; everything here is ZF4-- Part of Cumulus, the Grace17 mathematics library.5-- Copyright (c) 2026 Grant Passmore.6-- Released under the Apache License 2.0. See LICENSE in the repository root.7-- Authors: Grant Passmore89module Grace.Cumulus.Algebra.Ring.PrimeIdeal10import Ideal11import PrimeIdealCore1213-- Under a hypothesis Ring(R), a prime ideal is a proper ideal that contains14-- a factor of every product it contains. IsPrimeIdeal(A, add, zero, neg, mul,15-- one, I) remains the form over separate pieces, bridged below.16section Definitions17variable (R : Set)18hypothesisring : Ring(R)1920predicate PrimeIdeal (I : Set) :=21 ProperIdeal(R, I) ∧ (∀ x y ∈ R, x * y ∈ I → x ∈ I ∨ y ∈ I)2223end Definitions2425notationinfixl60"+"=> call2(R.add, _, _) viahypothesis PrimeIdeal(R, I) for I26notationinfixl70"*"=> call2(R.mul, _, _) viahypothesis PrimeIdeal(R, I) for I27notationprefix75"-"=>apply(R.neg, _) viahypothesis PrimeIdeal(R, I) for I28notationinfixl60"-"=> Ring.sub(R, _, _) viahypothesis PrimeIdeal(R, I) for I2930instance PrimeIdeal.parts (R I : Set)31requires prime : PrimeIdeal(R, I)32shows IsPrimeIdeal(R.carrier, R.add, R.zero, R.neg, R.mul, R.one, I)33proof34obtain⟨proper, factors⟩:= prime35have parts := ProperIdeal.parts with proper36unfold IsPrimeIdeal37exact⟨parts, factors⟩3839theorem PrimeIdeal.of_projections (R I : Set)40requires prime : IsPrimeIdeal(R.carrier, R.add, R.zero, R.neg, R.mul, R.one,41 I)42shows PrimeIdeal(R, I)43proof44obtain⟨proper, factors⟩:= prime45have bundled := ProperIdeal.of_projections with proper46unfold PrimeIdeal.PrimeIdeal47exact⟨bundled, factors⟩4849theorem PrimeIdeal.of_parts (A add zero neg mul one I : Set)50requires prime : IsPrimeIdeal(A, add, zero, neg, mul, one, I)51shows PrimeIdeal(Ring.mk(A, add, zero, neg, mul, one), I)52proof53have shifted : IsPrimeIdeal(Ring.carrier(Ring.mk(A, add, zero, neg, mul, one)),54 Ring.add(Ring.mk(A, add, zero, neg, mul, one)),55 Ring.zero(Ring.mk(A, add, zero, neg, mul, one)),56 Ring.neg(Ring.mk(A, add, zero, neg, mul, one)),57 Ring.mul(Ring.mk(A, add, zero, neg, mul, one)),58 Ring.one(Ring.mk(A, add, zero, neg, mul, one)), I)59 ring_projections60exact PrimeIdeal.of_projections with shifted6162instance PrimeIdeal.to_proper (R I : Set)63requires prime : PrimeIdeal(R, I)64shows ProperIdeal(R, I)65proof66obtain⟨proper, factors⟩:= prime67exact proper6869theorem PrimeIdeal.to_ideal (R I : Set)70requires prime : PrimeIdeal(R, I)71shows Ideal(R, I)72proof73have proper := PrimeIdeal.to_proper with prime74exact ProperIdeal.to_ideal with proper7576section PrimeLaws77variable (R I : Set)78hypothesisring : Ring(R)79hypothesis prime : PrimeIdeal(R, I)8081-- A product lies in a prime ideal exactly when a factor does.82theorem PrimeIdeal.mem_or_mem (x y : R)83requires productIn : x * y ∈ I84shows x ∈ I ∨ y ∈ I85proof86obtain⟨proper, factors⟩:= prime87have xIn : x ∈ R byassumption88have yIn : y ∈ R byassumption89exact factors with x, xIn, y, yIn, productIn9091theorem PrimeIdeal.mem_of_mul (x y : R)92requires productIn : x * y ∈ I93requires absent : y ∉ I94shows x ∈ I95proof96have alternatives := PrimeIdeal.mem_or_mem with*97cases alternatives with xIn | yIn98 . exact xIn99 . exfalso100exact absent with yIn101102theorem PrimeIdeal.mul_mem_iff (x y : R)103shows x * y ∈ I ↔ x ∈ I ∨ y ∈ I104proof105have ideal := PrimeIdeal.to_ideal with prime106constructor107 . intro productIn108exact PrimeIdeal.mem_or_mem with*109 . intro alternatives110cases alternatives with xIn | yIn111 . exact Ideal.mul_right_mem with*112 . exact Ideal.mul_left_mem with*113114end PrimeLaws115116section CommutativeRings117variable (R : Set)118hypothesis comm : CommRing(R)119120-- In a commutative ring every maximal ideal is prime.121theorem MaximalIdeal.prime (M : Set)122requires maximal : MaximalIdeal(R, M)123shows PrimeIdeal(R, M)124proof125have parts := CommRing.parts with comm126have engine := MaximalIdeal.parts with maximal127have prime := IsMaximalIdeal.is_prime with parts, engine128exact PrimeIdeal.of_projections with prime129130end CommutativeRings131