#14126: Count Number of Linear Extensions of a Poset
-------------------------------------+-------------------------------------
Reporter: csar | Owner: sage-combinat
Type: enhancement | Status: needs_work
Priority: major | Milestone: sage-6.4
Component: combinatorics | Resolution:
Keywords: days45 | Merged in:
Authors: Jori Mäntysalo | Reviewers:
Report Upstream: N/A | Work issues:
Branch: u/jmantysalo | Commit:
/count-lin-ext | f908696aa7c63cefbc382af326cfe085e0dfa522
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by kdilks):
After much staring at Maple code, I now mostly understand the algorithm to
generate a naturally labelled poset isomorphic to the order ideal lattice
given a naturally labelled poset.
The idea is similar to what you mentioned. Run a loop that takes the
lattice of order ideals for P restricted to `{1,...,k}`, and think about
what happens when you add `k+1`. You need to know which order ideal
`I_{k+1}` corresponds to the principal order ideal generated by `k+1` (but
with `k+1` removed, since we haven't added it to the poset yet).
Now, you create a list `K` of the order ideals that lie above `I_{k+1}` in
your partial lattice of order ideals. Each of these is going to yield a
new order ideal to add to your list (the corresponding ideal `I` plus the
new `k+1`). Make sure that `K` is ordered so that our lattice of order
ideals stayed naturally labelled. The relations you need to add are `I` is
covered by `I` plus `k+1`, and for every relation `A` covers `B` in `K`,
you're going to have to add `A` plus `k+1` covers `B` plus `k+1`.
The main subtlety is in creating and maintaining a helper list that will
eventually tell you where `I_{k+1}` is by the time you reach the `k+1`st
step. Call the list `L`, indexed by your poset elements, initialize it
with all 1s. As you go along, after `k` iterations, the entry `L[j]` tells
you which order ideal corresponds to `I_j` restricted to `1...k`. If you
add something incomparable to `j`, then `I_j` restricted to `1...k+1`
doesn't change. If you add something comparable to `j`, then `I_j`
restricted to `1...k+1` is one of the things in `K` plus `k+1`. So if we
started with `N` order ideals, and `I_j` restricted to `1...k` was the
`r`th thing in `K`, then `I_j` restricted to `1...k+1` will be the `N+r`th
thing, and we update `L` accordingly.
Since it might take me some time to actually sit down and implement this,
I agree that it makes sense to just change the
{{{P.linear_extensions().cardinality()}}} method to something simple like
{{{P.order_ideals_lattice().chain_polynomial().leading_coefficient()}}}
(maybe with an optional parameter allowing one to default back to the
iterator). Then I can work on a separate ticket for generating a naturally
labelled poset isomorphic to the order ideal lattice, which
{{{P.linear_extensions().cardinality()}}} could eventually utilize.
--
Ticket URL: <https://trac.sagemath.org/ticket/14126#comment:37>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.