Posets

sage.categories.posets.Posets

The category of posets i.e. sets with a partial order structure.

EXAMPLES:

sage: Posets()
Category of posets
sage: Posets().super_categories()
[Category of sets]
sage: P = Posets().example(); P
An example of a poset: sets ordered by inclusion

The partial order is implemented by the mandatory method le():

sage: x = P(Set([1,3])); y = P(Set([1,2,3]))
sage: x, y
({1, 3}, {1, 2, 3})
sage: P.le(x, y)
True
sage: P.le(x, x)
True
sage: P.le(y, x)
False

The other comparison methods are called lt(), ge(), gt(), following Python’s naming convention in operator. Default implementations are provided:

sage: P.lt(x, x)
False
sage: P.ge(y, x)
True

Unless the poset is a facade (see Sets.Facade), one can compare directly its elements using the usual Python operators:

sage: D = Poset((divisors(30), attrcall("divides")), facade = False)
sage: D(3) <= D(6)
True
sage: D(3) <= D(3)
True
sage: D(3) <= D(5)
False
sage: D(3) < D(3)
False
sage: D(10) >= D(5)
True

At this point, this has to be implemented by hand. Once trac ticket #10130 will be resolved, this will be automatically provided by this category:

sage: x < y      # todo: not implemented
True
sage: x < x      # todo: not implemented
False
sage: x <= x     # todo: not implemented
True
sage: y >= x     # todo: not implemented
True