Ask Your Question

Obtaining a poset from Posets(n)

asked 2019-03-10 08:53:21 -0500

joakim_uhlin gravatar image

I have defined function that takes a poset $P$ as input and outputs the major index generating polynomial over all linear extensions of $P$. Here, the major index of a certain linear extension of $P$ is given by the major index of the corresponding permutation, see e.g. for an example of this correspondence.

def major_index(pos):
    poly = 0
    lst = pos.linear_extensions()
    for le in lst: 
        perm = Permutation(x.element for x in le)
        maj = perm.major_index()
        poly += x^maj
    return poly

If I write, for example

P = Poset(([1,2,3,4], [[1,3],[1,4],[2,3]]), linear_extension=True, facade=False)

Then I get

x^4 + x^3 + x^2 + x + 1

which is the correct output. I would like to use Posets(n) to generate all posets (up to isomorphism) with $n$ vertices. However, when I write

lst = Posets(3)
P = lst[3]

I get the error:

Traceback (click to the left of this block for traceback)
AttributeError: 'sage.rings.integer.Integer' object has no attribute

Clearly the error is due to the line

perm = Permutation(x.element for x in le)

But I don't understand how Posets(n) works and why I cannot just write lst[3] to obtain a poset.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2019-03-10 10:55:30 -0500

FrédéricC gravatar image

updated 2019-03-10 10:56:21 -0500

This is because all these posets are "facade". Try something like that :

sage: P = Posets(4)
sage: Q = next(iter(P))
sage: Q._is_facade
sage: Permutation(x+1 for x in Q.linear_extension())
[4, 3, 2, 1]
edit flag offensive delete link more


This partially solved my issues. But I would, if possible, like to use the major_index-function on the posets of Poset(n). So I would like to write something like

`P = Posets(3)

Q = next(iter(P))


but this gives me a similar error.

joakim_uhlin gravatar imagejoakim_uhlin ( 2019-03-12 05:26:15 -0500 )edit

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: 2019-03-10 08:53:21 -0500

Seen: 40 times

Last updated: Mar 10