Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cardinality of partitions of negative values #33323

Closed
tscrim opened this issue Feb 11, 2022 · 17 comments
Closed

Cardinality of partitions of negative values #33323

tscrim opened this issue Feb 11, 2022 · 17 comments

Comments

@tscrim
Copy link
Collaborator

tscrim commented Feb 11, 2022

This should work (as long as it accepts negative values, which there is nothing wrong with it, it is just an empty set), but it results in an overflow error:

sage: Partitions(-5)
Partitions of the integer -5
sage: _.cardinality()

CC: @darijgr @fchapoton @jhpalmieri

Component: combinatorics

Author: Travis Scrimshaw

Branch/Commit: c340478

Reviewer: John Palmieri

Issue created by migration from https://trac.sagemath.org/ticket/33323

@tscrim tscrim added this to the sage-9.6 milestone Feb 11, 2022
@tscrim
Copy link
Collaborator Author

tscrim commented Feb 11, 2022

Commit: c340478

@tscrim
Copy link
Collaborator Author

tscrim commented Feb 11, 2022

comment:1

That is for the default using flint, but gap is wrong:

sage: Pm5.cardinality(algorithm='gap')
1
sage: Pm5.cardinality(algorithm='pari')
0

This is needed for doctests on #30680.


New commits:

c340478Partitions of negative n is always 0.

@tscrim
Copy link
Collaborator Author

tscrim commented Feb 11, 2022

@fchapoton
Copy link
Contributor

comment:2

I would rather think that most combinatorial objects return a ValueError:
see DyckWords(-2), BinaryTrees(-2), Posets(-2), Tableaux(-2) and TamariIntervalPosets(-2).

AlternatingSignMatrices(-2) returns an ArithmeticError.

But Compositions(-2), SuperPartitions(-2) and Permutations(-2)"work".

If you prefer, returning the empty set would be another solution. Do we have such an object ?

@tscrim
Copy link
Collaborator Author

tscrim commented Feb 11, 2022

comment:3

Perhaps it would be better for these to raise a ValueError to be consistent with other objects. However, we would also need to make sure that this continues to work:

sage: s = SymmetricFunctions(QQ).s()
sage: list(s.basis(-2))
[]

We do not seem to have a singular EmptySet object, just EmptySetError.

@tscrim
Copy link
Collaborator Author

tscrim commented Feb 11, 2022

comment:4

In order to keep that continuing to work, I think we would need a more long-term fix, which would include specifying the valid indices for the grading monoid of any graded module.

@jhpalmieri
Copy link
Member

comment:5

This looks simple and these things work:

sage: P = Partitions(-3)
sage: P.cardinality()
0
sage: list(P)
[]
sage: for a in P: print(a)
sage:

I'm somewhat agnostic about whether Partitions(-3) should raise an error or return an empty set. It feels somewhat different in flavor than Posets(-3) because it doesn't make sense to ask for a poset with -3 elements, while you could ask for all partitions of the number -3 — there just aren't any. But I don't have strong feelings either way.

@darijgr
Copy link
Contributor

darijgr commented Feb 11, 2022

comment:6

For the sake of (e.g.) the Euler pentagonal number theorem, it makes the most sense to return the empty set. Otherwise, the sum needs to be broken up at some nasty bounds.

@jhpalmieri
Copy link
Member

comment:7

This can also be a stopgap ticket until a more permanent solution is found.

@tscrim
Copy link
Collaborator Author

tscrim commented Feb 13, 2022

comment:8

An interesting comparison point:

sage: Pm = Permutations(-3)
sage: [x for x in Pm]    
[[]]
sage: Pm.cardinality()
ValueError: factorial -- must be nonnegative

So there are bugs there that can be handled on another ticket.

@jhpalmieri
Copy link
Member

comment:9

In my opinion we should merge this ticket and then think about long-term solutions elsewhere.

@tscrim
Copy link
Collaborator Author

tscrim commented Feb 18, 2022

comment:10

@fchapoton, any objections to John doing the review for this as a stopgap ticket?

@fchapoton
Copy link
Contributor

comment:11

no objection whatsoever ; I have no monopoly on reviews

@tscrim
Copy link
Collaborator Author

tscrim commented Feb 18, 2022

comment:12

We value your opinion. Plus, all objections should be resolved before a positive review too.

@jhpalmieri
Copy link
Member

comment:13

Let's merge this as is, and on other tickets continue to think about how to handle these situations.

@jhpalmieri
Copy link
Member

Reviewer: John Palmieri

@vbraun
Copy link
Member

vbraun commented Feb 21, 2022

Changed branch from public/combinat/negative_partition_card-33323 to c340478

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants