Ask Your Question

Obtaining the poset of subsets

asked 2023-05-08 12:57:47 +0200

klaaa gravatar image

updated 2023-05-08 13:13:48 +0200

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

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

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

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2023-05-08 17:52:35 +0200

Max Alekseyev gravatar image

updated 2023-05-09 03:28:55 +0200

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

B = posets.BooleanLattice(p, use_subsets=True)
B.subposet(t for t in B if sum(t)==p)
edit flag offensive delete link 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.

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

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

Max Alekseyev gravatar imageMax Alekseyev ( 2023-05-09 02:02:29 +0200 )edit

answered 2023-05-09 21:04:51 +0200

FrédéricC gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2023-05-08 12:57:47 +0200

Seen: 148 times

Last updated: May 09 '23