From 9b0a68293eb085dfa27cbf80844eb1a387d14c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 21 Nov 2025 17:54:23 +0100 Subject: [PATCH 1/4] introduce the category of Bounded posets --- src/sage/categories/category_with_axiom.py | 1 + src/sage/categories/finite_lattice_posets.py | 22 ++++++++++- src/sage/categories/lattice_posets.py | 32 ++++++++-------- src/sage/categories/posets.py | 39 ++++++++++++++++++++ src/sage/combinat/posets/lattices.py | 2 +- 5 files changed, 77 insertions(+), 19 deletions(-) diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py index 5a98b9e364b..73288c7a3dc 100644 --- a/src/sage/categories/category_with_axiom.py +++ b/src/sage/categories/category_with_axiom.py @@ -1689,6 +1689,7 @@ class ``Sets.Finite``), or in a separate file (typically in a class "Commutative", "Cocommutative", "Associative", "Inverse", "Unital", "Division", "NoZeroDivisors", "Cellular", "AdditiveCommutative", "AdditiveAssociative", "AdditiveInverse", "AdditiveUnital", + "Bounded", "Extremal", "Trim", "Semidistributive", "CongruenceUniform", "Distributive", "Stone", "Endset", diff --git a/src/sage/categories/finite_lattice_posets.py b/src/sage/categories/finite_lattice_posets.py index 6c3af10965f..9e28da9db0f 100644 --- a/src/sage/categories/finite_lattice_posets.py +++ b/src/sage/categories/finite_lattice_posets.py @@ -9,6 +9,8 @@ # ***************************************************************************** from sage.categories.category_with_axiom import CategoryWithAxiom +from sage.categories.posets import Posets +from sage.misc.cachefunc import cached_method class FiniteLatticePosets(CategoryWithAxiom): @@ -19,9 +21,11 @@ class FiniteLatticePosets(CategoryWithAxiom): EXAMPLES:: sage: FiniteLatticePosets() - Category of finite lattice posets + Category of finite bounded lattice posets sage: FiniteLatticePosets().super_categories() - [Category of lattice posets, Category of finite posets] + [Category of lattice posets, + Category of finite posets, + Category of bounded posets] sage: FiniteLatticePosets().example() NotImplemented @@ -37,6 +41,20 @@ class FiniteLatticePosets(CategoryWithAxiom): True sage: TestSuite(C).run() """ + @cached_method + def extra_super_categories(self): + r""" + Return a list of the (immediate) super categories of + ``self``, as per :meth:`Category.super_categories`. + + EXAMPLES:: + + sage: FiniteLatticePosets().super_categories() + [Category of lattice posets, + Category of finite posets, + Category of bounded posets] + """ + return [Posets().Bounded()] class ParentMethods: diff --git a/src/sage/categories/lattice_posets.py b/src/sage/categories/lattice_posets.py index 172e9f58748..b371db20be0 100644 --- a/src/sage/categories/lattice_posets.py +++ b/src/sage/categories/lattice_posets.py @@ -201,10 +201,10 @@ class Extremal(CategoryWithAxiom): EXAMPLES:: sage: cat = FiniteLatticePosets().Extremal(); cat - Category of finite extremal lattice posets + Category of finite bounded extremal lattice posets sage: cat.super_categories() - [Category of finite lattice posets, + [Category of finite bounded lattice posets, Category of extremal lattice posets] """ class ParentMethods: @@ -226,9 +226,9 @@ class Trim(CategoryWithAxiom): EXAMPLES:: sage: cat = FiniteLatticePosets().Trim(); cat - Category of finite trim lattice posets + Category of finite bounded trim lattice posets sage: cat.super_categories() - [Category of finite lattice posets, + [Category of finite bounded lattice posets, Category of trim lattice posets] """ @cached_method @@ -241,7 +241,7 @@ def extra_super_categories(self): EXAMPLES:: sage: FiniteLatticePosets().Trim().super_categories() - [Category of finite lattice posets, + [Category of finite bounded lattice posets, Category of trim lattice posets] """ return [LatticePosets().Extremal()] @@ -265,10 +265,10 @@ class Semidistributive(CategoryWithAxiom): EXAMPLES:: sage: cat = FiniteLatticePosets().Semidistributive(); cat - Category of finite semidistributive lattice posets + Category of finite bounded semidistributive lattice posets sage: cat.super_categories() - [Category of finite lattice posets, + [Category of finite bounded lattice posets, Category of semidistributive lattice posets] """ class ParentMethods: @@ -290,9 +290,9 @@ class CongruenceUniform(CategoryWithAxiom): EXAMPLES:: sage: cat = FiniteLatticePosets().CongruenceUniform(); cat - Category of finite congruence uniform lattice posets + Category of finite bounded congruence uniform lattice posets sage: cat.super_categories() - [Category of finite lattice posets, + [Category of finite bounded lattice posets, Category of congruence uniform lattice posets] """ @cached_method @@ -305,7 +305,7 @@ def extra_super_categories(self): EXAMPLES:: sage: FiniteLatticePosets().CongruenceUniform().super_categories() - [Category of finite lattice posets, + [Category of finite bounded lattice posets, Category of congruence uniform lattice posets] """ return [LatticePosets().Semidistributive()] @@ -329,10 +329,10 @@ class Distributive(CategoryWithAxiom): EXAMPLES:: sage: cat = FiniteLatticePosets().Distributive(); cat - Category of finite distributive lattice posets + Category of finite bounded distributive lattice posets sage: cat.super_categories() - [Category of finite lattice posets, + [Category of finite bounded lattice posets, Category of distributive lattice posets] """ @cached_method @@ -345,7 +345,7 @@ def extra_super_categories(self): EXAMPLES:: sage: FiniteLatticePosets().Distributive().super_categories() - [Category of finite lattice posets, + [Category of finite bounded lattice posets, Category of distributive lattice posets] """ return [LatticePosets().Trim(), @@ -371,10 +371,10 @@ class Stone(CategoryWithAxiom): EXAMPLES:: sage: cat = FiniteLatticePosets().Stone(); cat - Category of finite stone lattice posets + Category of finite bounded stone lattice posets sage: cat.super_categories() - [Category of finite lattice posets, + [Category of finite bounded lattice posets, Category of stone lattice posets] """ @cached_method @@ -387,7 +387,7 @@ def extra_super_categories(self): EXAMPLES:: sage: FiniteLatticePosets().Stone().super_categories() - [Category of finite lattice posets, + [Category of finite bounded lattice posets, Category of stone lattice posets] """ return [LatticePosets().Distributive()] diff --git a/src/sage/categories/posets.py b/src/sage/categories/posets.py index 665bedc3bac..8de81685775 100644 --- a/src/sage/categories/posets.py +++ b/src/sage/categories/posets.py @@ -12,6 +12,7 @@ from sage.misc.abstract_method import abstract_method from sage.misc.lazy_import import LazyImport from sage.categories.category import Category +from sage.categories.category_with_axiom import CategoryWithAxiom from sage.categories.sets_cat import Sets @@ -719,3 +720,41 @@ class ElementMethods: # sage: x <= y # """ # return self.parent().le(self, other) + + class SubcategoryMethods: + def Bounded(self): + r""" + A bounded poset is a poset with a unique maximal element + and a unique minimal element. + + EXAMPLES:: + + sage: P = posets.DivisorLattice(24) + sage: P in Posets().Bounded() + True + """ + return self._with_axiom("Bounded") + + class Bounded(CategoryWithAxiom): + """ + The category of bounded posets. + + EXAMPLES:: + + sage: cat = Posets().Bounded(); cat + Category of bounded posets + + sage: cat.super_categories() + [Category of posets] + """ + class ParentMethods: + def is_bounded(self): + """ + Return whether ``self`` is a bounded poset. + + EXAMPLES:: + + sage: posets.TamariLattice(4).is_bounded() + True + """ + return True diff --git a/src/sage/combinat/posets/lattices.py b/src/sage/combinat/posets/lattices.py index e06fb09627f..035cc9aff4c 100644 --- a/src/sage/combinat/posets/lattices.py +++ b/src/sage/combinat/posets/lattices.py @@ -713,7 +713,7 @@ def LatticePoset(data=None, *args, **options): sage: L = LatticePoset([[1,2],[3],[3]], facade = True) sage: L.category() - Category of facade finite enumerated lattice posets + Category of facade finite enumerated bounded lattice posets sage: parent(L[0]) Integer Ring sage: TestSuite(L).run(skip = ['_test_an_element']) # is_parent_of is not yet implemented From dcec18ef9ee4f9c6717a0159ead189cf81c5818f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 21 Nov 2025 19:27:58 +0100 Subject: [PATCH 2/4] fixing one doctest --- src/sage/combinat/alternating_sign_matrix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/alternating_sign_matrix.py b/src/sage/combinat/alternating_sign_matrix.py index 5df9a34cc68..4083a8ebf77 100644 --- a/src/sage/combinat/alternating_sign_matrix.py +++ b/src/sage/combinat/alternating_sign_matrix.py @@ -1048,7 +1048,7 @@ class AlternatingSignMatrices(UniqueRepresentation, Parent): sage: L Finite lattice containing 7 elements sage: L.category() - Category of facade finite enumerated lattice posets + Category of facade finite enumerated bounded lattice posets """ def __init__(self, n): From dd65dbe6e07ab31f61487fb3526cfa482e9d8144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 27 Nov 2025 14:53:52 +0100 Subject: [PATCH 3/4] some tweaks --- src/sage/categories/finite_lattice_posets.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/sage/categories/finite_lattice_posets.py b/src/sage/categories/finite_lattice_posets.py index 9e28da9db0f..4abdb072f40 100644 --- a/src/sage/categories/finite_lattice_posets.py +++ b/src/sage/categories/finite_lattice_posets.py @@ -9,7 +9,7 @@ # ***************************************************************************** from sage.categories.category_with_axiom import CategoryWithAxiom -from sage.categories.posets import Posets +from sage.categories.lattice_posets import LatticePosets from sage.misc.cachefunc import cached_method @@ -44,8 +44,7 @@ class FiniteLatticePosets(CategoryWithAxiom): @cached_method def extra_super_categories(self): r""" - Return a list of the (immediate) super categories of - ``self``, as per :meth:`Category.super_categories`. + Implement the fact that a finite lattice is a bounded poset. EXAMPLES:: @@ -54,7 +53,7 @@ def extra_super_categories(self): Category of finite posets, Category of bounded posets] """ - return [Posets().Bounded()] + return [LatticePosets().Bounded()] class ParentMethods: From f021fdd616a852c9429265f4797e941fcdd1e36e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 27 Nov 2025 15:22:55 +0100 Subject: [PATCH 4/4] enhancement of repr : no "bounded finite lattice" --- src/sage/categories/category_with_axiom.py | 2 +- src/sage/categories/finite_lattice_posets.py | 2 +- src/sage/categories/lattice_posets.py | 33 ++++++++++---------- src/sage/combinat/alternating_sign_matrix.py | 2 +- src/sage/combinat/posets/lattices.py | 2 +- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py index 73288c7a3dc..f3d52b00507 100644 --- a/src/sage/categories/category_with_axiom.py +++ b/src/sage/categories/category_with_axiom.py @@ -1678,6 +1678,7 @@ class ``Sets.Finite``), or in a separate file (typically in a class "Differentiable", "Smooth", "Analytic", "AlmostComplex", "FinitelyGeneratedAsMagma", "WellGenerated", + "Bounded", "Facade", "Finite", "Infinite", "Enumerated", "Complete", "Nilpotent", @@ -1689,7 +1690,6 @@ class ``Sets.Finite``), or in a separate file (typically in a class "Commutative", "Cocommutative", "Associative", "Inverse", "Unital", "Division", "NoZeroDivisors", "Cellular", "AdditiveCommutative", "AdditiveAssociative", "AdditiveInverse", "AdditiveUnital", - "Bounded", "Extremal", "Trim", "Semidistributive", "CongruenceUniform", "Distributive", "Stone", "Endset", diff --git a/src/sage/categories/finite_lattice_posets.py b/src/sage/categories/finite_lattice_posets.py index 4abdb072f40..42939236314 100644 --- a/src/sage/categories/finite_lattice_posets.py +++ b/src/sage/categories/finite_lattice_posets.py @@ -21,7 +21,7 @@ class FiniteLatticePosets(CategoryWithAxiom): EXAMPLES:: sage: FiniteLatticePosets() - Category of finite bounded lattice posets + Category of finite lattice posets sage: FiniteLatticePosets().super_categories() [Category of lattice posets, Category of finite posets, diff --git a/src/sage/categories/lattice_posets.py b/src/sage/categories/lattice_posets.py index b371db20be0..f2d35a03e54 100644 --- a/src/sage/categories/lattice_posets.py +++ b/src/sage/categories/lattice_posets.py @@ -90,6 +90,7 @@ def join(self, x, y): """ class SubcategoryMethods: + def Stone(self): r""" A Stone lattice `(L, \vee, \wedge)` is a pseudo-complemented @@ -201,10 +202,10 @@ class Extremal(CategoryWithAxiom): EXAMPLES:: sage: cat = FiniteLatticePosets().Extremal(); cat - Category of finite bounded extremal lattice posets + Category of finite extremal lattice posets sage: cat.super_categories() - [Category of finite bounded lattice posets, + [Category of finite lattice posets, Category of extremal lattice posets] """ class ParentMethods: @@ -226,9 +227,9 @@ class Trim(CategoryWithAxiom): EXAMPLES:: sage: cat = FiniteLatticePosets().Trim(); cat - Category of finite bounded trim lattice posets + Category of finite trim lattice posets sage: cat.super_categories() - [Category of finite bounded lattice posets, + [Category of finite lattice posets, Category of trim lattice posets] """ @cached_method @@ -241,7 +242,7 @@ def extra_super_categories(self): EXAMPLES:: sage: FiniteLatticePosets().Trim().super_categories() - [Category of finite bounded lattice posets, + [Category of finite lattice posets, Category of trim lattice posets] """ return [LatticePosets().Extremal()] @@ -265,10 +266,10 @@ class Semidistributive(CategoryWithAxiom): EXAMPLES:: sage: cat = FiniteLatticePosets().Semidistributive(); cat - Category of finite bounded semidistributive lattice posets + Category of finite semidistributive lattice posets sage: cat.super_categories() - [Category of finite bounded lattice posets, + [Category of finite lattice posets, Category of semidistributive lattice posets] """ class ParentMethods: @@ -290,9 +291,9 @@ class CongruenceUniform(CategoryWithAxiom): EXAMPLES:: sage: cat = FiniteLatticePosets().CongruenceUniform(); cat - Category of finite bounded congruence uniform lattice posets + Category of finite congruence uniform lattice posets sage: cat.super_categories() - [Category of finite bounded lattice posets, + [Category of finite lattice posets, Category of congruence uniform lattice posets] """ @cached_method @@ -305,7 +306,7 @@ def extra_super_categories(self): EXAMPLES:: sage: FiniteLatticePosets().CongruenceUniform().super_categories() - [Category of finite bounded lattice posets, + [Category of finite lattice posets, Category of congruence uniform lattice posets] """ return [LatticePosets().Semidistributive()] @@ -329,10 +330,10 @@ class Distributive(CategoryWithAxiom): EXAMPLES:: sage: cat = FiniteLatticePosets().Distributive(); cat - Category of finite bounded distributive lattice posets + Category of finite distributive lattice posets sage: cat.super_categories() - [Category of finite bounded lattice posets, + [Category of finite lattice posets, Category of distributive lattice posets] """ @cached_method @@ -345,7 +346,7 @@ def extra_super_categories(self): EXAMPLES:: sage: FiniteLatticePosets().Distributive().super_categories() - [Category of finite bounded lattice posets, + [Category of finite lattice posets, Category of distributive lattice posets] """ return [LatticePosets().Trim(), @@ -371,10 +372,10 @@ class Stone(CategoryWithAxiom): EXAMPLES:: sage: cat = FiniteLatticePosets().Stone(); cat - Category of finite bounded stone lattice posets + Category of finite stone lattice posets sage: cat.super_categories() - [Category of finite bounded lattice posets, + [Category of finite lattice posets, Category of stone lattice posets] """ @cached_method @@ -387,7 +388,7 @@ def extra_super_categories(self): EXAMPLES:: sage: FiniteLatticePosets().Stone().super_categories() - [Category of finite bounded lattice posets, + [Category of finite lattice posets, Category of stone lattice posets] """ return [LatticePosets().Distributive()] diff --git a/src/sage/combinat/alternating_sign_matrix.py b/src/sage/combinat/alternating_sign_matrix.py index 4083a8ebf77..5df9a34cc68 100644 --- a/src/sage/combinat/alternating_sign_matrix.py +++ b/src/sage/combinat/alternating_sign_matrix.py @@ -1048,7 +1048,7 @@ class AlternatingSignMatrices(UniqueRepresentation, Parent): sage: L Finite lattice containing 7 elements sage: L.category() - Category of facade finite enumerated bounded lattice posets + Category of facade finite enumerated lattice posets """ def __init__(self, n): diff --git a/src/sage/combinat/posets/lattices.py b/src/sage/combinat/posets/lattices.py index 035cc9aff4c..e06fb09627f 100644 --- a/src/sage/combinat/posets/lattices.py +++ b/src/sage/combinat/posets/lattices.py @@ -713,7 +713,7 @@ def LatticePoset(data=None, *args, **options): sage: L = LatticePoset([[1,2],[3],[3]], facade = True) sage: L.category() - Category of facade finite enumerated bounded lattice posets + Category of facade finite enumerated lattice posets sage: parent(L[0]) Integer Ring sage: TestSuite(L).run(skip = ['_test_an_element']) # is_parent_of is not yet implemented