#17053: Add function for disjoint union and ordinal sum of posets
---------------------------------+-----------------------------
Reporter: jmantysalo | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-wishlist
Component: combinatorics | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
---------------------------------+-----------------------------
Old description:
> Sage has no function for direct sum of posets. What kind of function it
> should be?
>
> Let's say that poset `P` has elements `a` and `b`, `Q` has elements `c`
> and `d`. Then sum on P and Q could have elements
>
> 1) a,b,c,d. Function would check that there are no common elements.
> 2) (1,a),(1,b),(2,c),(2,c). Optional parameter would change first element
> of tuples.
> 3) 0,1,2,3. Function would just make poset isomorphic to P+Q with integer
> elements.
>
> Now, it would be nice to have also sum of arbitrary number of posets. So
> function could be something like
>
> `P.direct_sum(Q)` (case 1 as default?)
>
> `P.direct_sum(Q, labeling='default')` (case 2 / default)
>
> `P.direct_sum(Q, labeling=lambda n: chr(ord('a')+n))` (case 2 / non-
> default)
>
> `P.direct_sum(Q, labeling='plain')` (case 3)
>
> and if possible, accept something like
>
> `P1.direct_sum(P2, P3, P4, labeling=...)`
>
> Does this sound reasonable?
New description:
Sage has no function for disjoint union (or ''direct sum'') of posets,
neither for ordinal sum. These are mostly matter of wrapping right
function of graph + writing documentation.
At same time maybe parameter name for `disjoint_union` on Graphs should be
changed.
--
Comment (by jmantysalo):
Replying to [comment:9 ncohen]:
> It could even be
> {{{
> def direct_sum(self, other, labels='pairs'):
> if not hasattr(other, 'hasse_diagram'):
> raise ValueError('The input is not a finite poset.')
> return
Poset(self.hasse_diagram().disjoint_union(other.hasse_diagram(),
labels=labels))
> }}}
>
> Of course right now `Graph.disjoint_union` has no `labels` argument, but
we have something called `sage.misc.decorators.rename_keyword` precisely
for this reason (to change the name of an argument and handle the
deprecation warnings). And then the graph function would understand this
labels argument as it is clearer anyway.
But on documentation it seems that `rename_keyword` is only able to change
name of argument. Here we should also change value from `True` to `pairs`
and from `False` to `integers`.
> The thing is that checking the value of the keyword should be done only
once. Preferably in the graph method.
Sounds reasonable.
Other things: Enumerative Combinatorics by Richard P. Stanley uses
"disjoint union" as preferable name. It is also used on graphs, so it is
probably best to use here also.
I'll make some kind of commit just to show what I'm now thinking.
--
Ticket URL: <http://trac.sagemath.org/ticket/17053#comment:10>
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 http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.