Obtaining the poset of subsets

Let G be a set of subsets of a set with $n$ elements. Here a (stupid) example:

p=5
S = Subsets([1,..,p])
G=[t for t in S if sum(t)==p]
display(S)
display(G)

My question is how do I obtain the set G as a poset in Sage? Thanks for any help.

edit retag close merge delete

Sort by » oldest newest most voted

I assume you want to construct boolean lattice. If so, it's defined in Sage's Catalog of posets and lattices:

posets.BooleanLattice(p, use_subsets=True)

ADDED. A subposet can be constructed as

p=5
B = posets.BooleanLattice(p, use_subsets=True)
B.subposet(t for t in B if sum(t)==p)
more

Thanks, but I actually want the subposet of the whole Boolean lattice consisting of a certain subsets of all subsets. See the example where I want the subset G as a subposet of the Boolean lattice.

( 2023-05-09 01:03:07 +0200 )edit

Then you can use .subposet() method to obtain that of boolean lattice.

( 2023-05-09 02:02:29 +0200 )edit

Like this

sage: S = Subsets([1,..,5])
sage: G = [t for t in S if sum(t)<=3]
sage: Poset((G, lambda x,y: x.issubset(y)))
Finite poset containing 5 elements

And I am slightly tempted to say RTFM.

more