Ask Your Question
1

Obtaining a poset from Posets(n)

asked 2019-03-10 14:53:21 +0100

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. http://mathworld.wolfram.com/LinearEx... 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)
major_index(P)

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]
major_index(P)

I get the error:

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

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
1

answered 2019-03-10 16:55:30 +0100

FrédéricC gravatar image

updated 2019-03-10 16:56:21 +0100

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
True
sage: Permutation(x+1 for x in Q.linear_extension())
[4, 3, 2, 1]
edit flag offensive delete link more

Comments

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))

major_index(Q)`

but this gives me a similar error.

joakim_uhlin gravatar imagejoakim_uhlin ( 2019-03-12 11:26:15 +0100 )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

Stats

Asked: 2019-03-10 14:53:21 +0100

Seen: 299 times

Last updated: Mar 10 '19