1-- Ideals, filters, and prime ideals of a bundled lattice2-- 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.Lattice.Ideals8import Ideal9import Sublattices1011-- An ideal is a nonempty lower set closed under joins, a filter a nonempty12-- upper set closed under meets, and a prime ideal a proper ideal that13-- contains a factor of every meet it contains.14predicate LatticeIdeal (P I : Set) := IsLatticeIdeal(points(P), le(P), I)15predicate LatticeFilter (P F : Set) := IsLatticeFilter(points(P), le(P), F)16predicate LatticePrimeIdeal (P I : Set) := IsLatticePrimeIdeal(points(P), le(P), I)1718notationinfixl68"⊔"=> call2(sup(P), _, _) viahypothesis LatticeIdeal(P, I) for P.points19notationinfixl69"⊓"=> call2(inf(P), _, _) viahypothesis LatticeIdeal(P, I) for P.points20notationinfix50"≤"=> Le(P, _, _) viahypothesis LatticeIdeal(P, I) for P.points21notationinfixl68"⊔"=> call2(sup(P), _, _) viahypothesis LatticeFilter(P, F) for P.points22notationinfixl69"⊓"=> call2(inf(P), _, _) viahypothesis LatticeFilter(P, F) for P.points23notationinfix50"≤"=> Le(P, _, _) viahypothesis LatticeFilter(P, F) for P.points24notationinfixl68"⊔"=> call2(sup(P), _, _) viahypothesis LatticePrimeIdeal(P, I) for P.points25notationinfixl69"⊓"=> call2(inf(P), _, _) viahypothesis LatticePrimeIdeal(P, I) for P.points26notationinfix50"≤"=> Le(P, _, _) viahypothesis LatticePrimeIdeal(P, I) for P.points2728instance LatticeIdeal.unbundled (P I : Set)29requires ideal : LatticeIdeal(P, I)30shows IsLatticeIdeal(points(P), le(P), I)31proof32simp [LatticeIdeal]3334instance LatticeFilter.unbundled (P F : Set)35requires filter : LatticeFilter(P, F)36shows IsLatticeFilter(points(P), le(P), F)37proof38simp [LatticeFilter]3940instance LatticePrimeIdeal.unbundled (P I : Set)41requires prime : LatticePrimeIdeal(P, I)42shows IsLatticePrimeIdeal(points(P), le(P), I)43proof44simp [LatticePrimeIdeal]4546theorem LatticeIdeal.mk (A r I : Set)47requires ideal : IsLatticeIdeal(A, r, I)48shows LatticeIdeal(Order.mk(A, r), I)49proof50unfold LatticeIdeal51rw [Order.mk.points, Order.mk.le]52exact ideal5354theorem LatticeFilter.mk (A r F : Set)55requires filter : IsLatticeFilter(A, r, F)56shows LatticeFilter(Order.mk(A, r), F)57proof58unfold LatticeFilter59rw [Order.mk.points, Order.mk.le]60exact filter6162theorem LatticePrimeIdeal.mk (A r I : Set)63requires prime : IsLatticePrimeIdeal(A, r, I)64shows LatticePrimeIdeal(Order.mk(A, r), I)65proof66unfold LatticePrimeIdeal67rw [Order.mk.points, Order.mk.le]68exact prime6970instance LatticeIdeal.lattice_of (P I : Set)71requires ideal : LatticeIdeal(P, I)72shows Lattice(P)73proof74unfold Join.Lattice75exact IsLatticeIdeal.lattice with (LatticeIdeal.unbundled with ideal)7677instance LatticeFilter.lattice_of (P F : Set)78requires filter : LatticeFilter(P, F)79shows Lattice(P)80proof81unfold Join.Lattice82exact IsLatticeFilter.lattice with (LatticeFilter.unbundled with filter)8384instance LatticePrimeIdeal.ideal_of (P I : Set)85requires prime : LatticePrimeIdeal(P, I)86shows LatticeIdeal(P, I)87proof88unfold LatticeIdeal89exact IsLatticePrimeIdeal.ideal with (LatticePrimeIdeal.unbundled with prime)9091-- The principal lower and upper sets of a point.92def Iic (P a : Set) : Set:= segment(points(P), le(P), a)93def Ici (P a : Set) : Set:= upperSegment(points(P), le(P), a)9495theorem Iic.membership (P a x : Set)96shows x ∈ Iic(P, a) ↔ (x ∈ points(P) ∧ relates(le(P), x, a))97proof98simp [Iic, segment]99100theorem Ici.membership (P a x : Set)101shows x ∈ Ici(P, a) ↔ (x ∈ points(P) ∧ relates(le(P), a, x))102proof103simp [Ici, upperSegment]104105section IdealLaws106variable (P I : Set)107hypothesis ideal : LatticeIdeal(P, I)108109theorem LatticeIdeal.subset_points110shows I ⊆ points(P)111proof112exact IsLatticeIdeal.subset with (LatticeIdeal.unbundled with ideal)113114theorem LatticeIdeal.mem_points (a : Set)115requires aIn : a ∈ I116shows a ∈ points(P)117proof118have subset := LatticeIdeal.subset_points with ideal119exact subset with a, aIn120121theorem LatticeIdeal.nonempty_of122shows Nonempty(I)123proof124exact IsLatticeIdeal.nonempty with (LatticeIdeal.unbundled with ideal)125126instance LatticeIdeal.sup_mem (a b : Set)127requires aIn : a ∈ I128requires bIn : b ∈ I129shows a ⊔ b ∈ I130proof131have aCarrier := LatticeIdeal.mem_points with ideal, aIn132have bCarrier := LatticeIdeal.mem_points with ideal, bIn133rw sup.join134exact IsLatticeIdeal.join_closed with (LatticeIdeal.unbundled with ideal), aIn,135 bIn136137theorem LatticeIdeal.mem_of_le (a : Set) (b ∈ points(P))138requires aIn : a ∈ I139requires hba : b ≤ a140shows b ∈ I141proof142exact IsLatticeIdeal.downward with (LatticeIdeal.unbundled with ideal), aIn,143assumption, (Le.relates with hba)144145instance LatticeIdeal.inf_mem_left (a : Set) (b ∈ points(P))146requires aIn : a ∈ I147shows a ⊓ b ∈ I148proof149have aCarrier := LatticeIdeal.mem_points with ideal, aIn150rw inf.meet151exact IsLatticeIdeal.meet_closed with (LatticeIdeal.unbundled with ideal), aIn,152assumption153154theorem LatticeIdeal.sup_mem_iff (a b ∈ points(P))155shows a ⊔ b ∈ I ↔ (a ∈ I ∧ b ∈ I)156proof157rw sup.join158exact IsLatticeIdeal.join_iff with (LatticeIdeal.unbundled with ideal),159assumption, assumption160161end IdealLaws162163section IdealBounds164variable (P I : Set)165hypothesis bounded : BoundedLattice(P)166hypothesis ideal : LatticeIdeal(P, I)167168theorem LatticeIdeal.bot_mem169shows bot(P) ∈ I170proof171exact IsLatticeIdeal.bottom with (BoundedLattice.unbundled with bounded),172 (LatticeIdeal.unbundled with ideal)173174end IdealBounds175176section FilterLaws177variable (P F : Set)178hypothesis filter : LatticeFilter(P, F)179180theorem LatticeFilter.subset_points181shows F ⊆ points(P)182proof183exact IsLatticeFilter.subset with (LatticeFilter.unbundled with filter)184185theorem LatticeFilter.mem_points (a : Set)186requires aIn : a ∈ F187shows a ∈ points(P)188proof189have subset := LatticeFilter.subset_points with filter190exact subset with a, aIn191192theorem LatticeFilter.nonempty_of193shows Nonempty(F)194proof195exact IsLatticeFilter.nonempty with (LatticeFilter.unbundled with filter)196197instance LatticeFilter.inf_mem (a b : Set)198requires aIn : a ∈ F199requires bIn : b ∈ F200shows a ⊓ b ∈ F201proof202have aCarrier := LatticeFilter.mem_points with filter, aIn203have bCarrier := LatticeFilter.mem_points with filter, bIn204rw inf.meet205exact IsLatticeFilter.meet_closed with (LatticeFilter.unbundled with filter),206 aIn, bIn207208theorem LatticeFilter.mem_of_le (a : Set) (b ∈ points(P))209requires aIn : a ∈ F210requires hab : a ≤ b211shows b ∈ F212proof213exact IsLatticeFilter.upward with (LatticeFilter.unbundled with filter), aIn,214assumption, (Le.relates with hab)215216instance LatticeFilter.sup_mem_left (a : Set) (b ∈ points(P))217requires aIn : a ∈ F218shows a ⊔ b ∈ F219proof220have aCarrier := LatticeFilter.mem_points with filter, aIn221rw sup.join222exact IsLatticeFilter.join_closed with (LatticeFilter.unbundled with filter),223 aIn, assumption224225theorem LatticeFilter.inf_mem_iff (a b ∈ points(P))226shows a ⊓ b ∈ F ↔ (a ∈ F ∧ b ∈ F)227proof228rw inf.meet229exact IsLatticeFilter.meet_iff with (LatticeFilter.unbundled with filter),230assumption, assumption231232end FilterLaws233234section FilterBounds235variable (P F : Set)236hypothesis bounded : BoundedLattice(P)237hypothesis filter : LatticeFilter(P, F)238239theorem LatticeFilter.top_mem240shows top(P) ∈ F241proof242exact IsLatticeFilter.top with (BoundedLattice.unbundled with bounded),243 (LatticeFilter.unbundled with filter)244245end FilterBounds246247section PrimeLaws248variable (P I : Set)249hypothesis prime : LatticePrimeIdeal(P, I)250251theorem LatticePrimeIdeal.ne_points252shows I ≠ points(P)253proof254exact IsLatticePrimeIdeal.proper with (LatticePrimeIdeal.unbundled with prime)255256theorem LatticePrimeIdeal.mem_or_mem (a b ∈ points(P))257requires meetIn : a ⊓ b ∈ I258shows a ∈ I ∨ b ∈ I259proof260rw inf.meet at meetIn261exact IsLatticePrimeIdeal.prime with (LatticePrimeIdeal.unbundled with prime),262assumption,263assumption, meetIn264265end PrimeLaws266267-- The whole points, principal ideals and filters, intersections, and268-- duality.269theorem LatticeIdeal.univ (P : Set)270requires lattice : Lattice(P)271requires nonempty : Nonempty(points(P))272shows LatticeIdeal(P, points(P))273proof274unfold LatticeIdeal275exact IsLatticeIdeal.whole with (Lattice.unbundled with lattice), nonempty276277theorem LatticeFilter.univ (P : Set)278requires lattice : Lattice(P)279requires nonempty : Nonempty(points(P))280shows LatticeFilter(P, points(P))281proof282unfold LatticeFilter283exact IsLatticeFilter.whole with (Lattice.unbundled with lattice), nonempty284285theorem IsLatticeIdeal.principal (P a : Set)286requires lattice : Lattice(P)287requires aIn : a ∈ points(P)288shows LatticeIdeal(P, Iic(P, a))289proof290unfold LatticeIdeal291unfold Iic292exact IsLatticeIdeal.principal with (Lattice.unbundled with lattice), aIn293294theorem IsLatticeFilter.principal (P a : Set)295requires lattice : Lattice(P)296requires aIn : a ∈ points(P)297shows LatticeFilter(P, Ici(P, a))298proof299unfold LatticeFilter300unfold Ici301exact IsLatticeFilter.principal with (Lattice.unbundled with lattice), aIn302303theorem LatticeIdeal.inter (P I J : Set)304requires hI : LatticeIdeal(P, I)305requires hJ : LatticeIdeal(P, J)306shows LatticeIdeal(P, I ∩ J)307proof308unfold LatticeIdeal309exact IsLatticeIdeal.intersection with (LatticeIdeal.unbundled with hI),310 (LatticeIdeal.unbundled with hJ)311312theorem LatticeIdeal.dual (P I : Set)313requires ideal : LatticeIdeal(P, I)314shows LatticeFilter(dual(P), I)315proof316unfold LatticeFilter317rw [dual.points, dual.le]318exact IsLatticeIdeal.converse with (LatticeIdeal.unbundled with ideal)319320theorem LatticeFilter.dual (P F : Set)321requires filter : LatticeFilter(P, F)322shows LatticeIdeal(dual(P), F)323proof324unfold LatticeIdeal325rw [dual.points, dual.le]326exact IsLatticeFilter.converse with (LatticeFilter.unbundled with filter)327