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

Bug in k-bounded symmetric functions #13743

Closed
sagetrac-chrisjamesberg mannequin opened this issue Nov 22, 2012 · 23 comments
Closed

Bug in k-bounded symmetric functions #13743

sagetrac-chrisjamesberg mannequin opened this issue Nov 22, 2012 · 23 comments

Comments

@sagetrac-chrisjamesberg
Copy link
Mannequin

The indices method of the KBoundedSubspace class is done wrong. The code is:

self.indices = ConstantFunction(Partitions(NonNegativeIntegers(), max_part=k))

Partitions is not meant to take a set. It will usually complain if you input something like NonNegativeIntegers but due to a bug in partitions, it allows it if you have optional arguments.

This creates the following bugs when playing around with k-Schur functions:

sage: ks = SymmetricFunctions(QQ).kBoundedSubspace(3,1).kschur()
sage: f = ks[2,1]
sage: f.coefficient(f.support()[0])
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)

/Users/chrisberg/<ipython console> in <module>()

/Applications/sage/local/lib/python2.7/site-packages/sage/combinat/free_module.pyc in coefficient(self, m)
    479         # that can be turned on or off
    480         C = self.parent()._basis_keys
--> 481         assert m in C, "%s should be an element of %s"%(m, C)
    482         if hasattr(C, "element_class") and not isinstance(m, C.element_class):
    483             m = C(m)

AssertionError: [2, 1] should be an element of Partitions of the integer An example of an infinite enumerated set: the non negative integers satisfying constraints max_part=3

Depends on #13605
Depends on #14228

CC: @anneschilling @zabrocki @tscrim

Component: combinatorics

Author: Travis Scrimshaw

Reviewer: Mike Zabrocki

Merged: sage-5.9.beta0

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

@nthiery
Copy link
Contributor

nthiery commented Nov 22, 2012

comment:1

That Partitions accepts a set is in fact not a bug. Granted, it should be documented, and there certainly are many cases like this one where this is not supported (so I agree with the existence of this ticket). But this is definitely a feature we want (and that is, more or less, implemented in IntegerListsLex).

Cheers,
Nicolas

@anneschilling
Copy link

comment:2

You can just do

sage: ks = SymmetricFunctions(QQ).kschur(3,1)
sage: f = ks[2,1]
sage: f[Partition([2,1])]
1

Anne

@zabrocki
Copy link
Mannequin

zabrocki mannequin commented Nov 24, 2012

Dependencies: 13605

@zabrocki
Copy link
Mannequin

zabrocki mannequin commented Nov 24, 2012

comment:3

As far as I can tell, Travis' changes to Partitions may fix this bug.  I am adding him as cc on this ticket. There are currently still conflicts between the symmetric functions and Partitions. Perhaps they are resolved it is possible that they will fix this problem so he can take this into account as he writes his patch. So for instance after I apply Travis' patch trac_13605-partition_options-ts.patch I have:

    sage: ks = SymmetricFunctions(QQ).kBoundedSubspace(3,1).kschur()
    sage: f = ks([2,1])
    sage: f.coefficient(f.support()[0])
    1

However the same patch currently causes a different problem with symmetric functions:


sage: ks[2,1]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Applications/sage-5.4.rc2/devel/sage-combinat/<ipython console> in <module>()

/Applications/sage-5.4.rc2/local/lib/python2.7/site-packages/sage/combinat/sf/new_kschur.pyc in __getitem__(self, c, *rest)
    298                 ks3[]
    299             """
--> 300             if isinstance(c, Partition_class):
    301                 assert len(rest) == 0
    302             else:

TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types

Travis, was it your intention to allow Partitions( NonNegativeIntegers(), max_part=k ) to represent the set of all Partitions with max_part=k?

@tscrim
Copy link
Collaborator

tscrim commented Nov 24, 2012

comment:4

Replying to @zabrocki:

However the [trac_13605-partition_options-ts.patch] currently causes a different problem with symmetric functions:


sage: ks[2,1]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Applications/sage-5.4.rc2/devel/sage-combinat/<ipython console> in <module>()

/Applications/sage-5.4.rc2/local/lib/python2.7/site-packages/sage/combinat/sf/new_kschur.pyc in __getitem__(self, c, *rest)
    298                 ks3[]
    299             """
--> 300             if isinstance(c, Partition_class):
    301                 assert len(rest) == 0
    302             else:

TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types

I'll go through now and scrub all instances of Partition_class from the sage code so you can adequately test to see if the patch (unintentionally) fixes this problem.

Travis, was it your intention to allow Partition( NonNegativeInteger(), max_part=k ) to represent the set of all Partitions with max_part=k?

Do you mean Partitions(NonNegativeIntegers(), max_part=k) with the s's? If so, this has some quirks noted in the wierdness page. However, if you mean exactly what you wrote, then I believe that should raise an exception since Partition() should return a single partition, although maybe with that input, one should get a random partition with max part k...

@zabrocki
Copy link
Mannequin

zabrocki mannequin commented Nov 24, 2012

comment:5

Do you mean Partitions(NonNegativeIntegers(), max_part=k) with the s's? If so, this has some quirks noted in the wierdness page. However, if you mean exactly what you wrote, then I believe that should raise an exception since Partition() should return a single partition, although maybe with that input, one should get a random partition with max part k...

I meant Partitions(NonNegativeIntegers(), max_part=k). Sorry for the double typos (corrected in comment).

@zabrocki
Copy link
Mannequin

zabrocki mannequin commented Nov 24, 2012

Changed dependencies from 13605 to #13605

@tscrim
Copy link
Collaborator

tscrim commented Nov 24, 2012

comment:7

In an ideal world, yes, that should be all partitions with max part k.

What I'm doing in #13605 won't really affect how input is handled, and if I understand this ticket correctly, it is to port the list input aspect of IntegerListsLex into Partitions. For this, my first thoughts give me one of three possibilities:

  1. Create new classes which act like Partitions_all which just iterates over all of the classes with specified n in the passed in set.
  2. Create DisjointUnionEnumeratedSets with an appropriate Family.
  3. Copy how IntegerListsLex does things

On a slight side note, IntegerListsLex has some finiteness issues that will might also need to be addressed; see #13749.

@sagetrac-chrisjamesberg
Copy link
Mannequin Author

comment:8

Two small comments:

First,

Partitions(NonNegativeIntegers())

returns a value error.

Second, your set

Partitions(NonNegativeIntegers(), max_part = 3)

has repr:

Partitions of the integer Non negative integers satisfying constraints max_part=3

which is confusing. I have implemented something similar to Travis' first suggested solution to deal with the k-quotient side of things.

@sagetrac-chrisjamesberg
Copy link
Mannequin Author

comment:9

Found another bug which is really related to this one. If we give an input to a kSchur function which isn't k-bounded, then it should return an error:

ks = SymmetricFunctions(QQ).kBoundedSubspace(3,1).kschur()
ks([4,1])
Traceback (click to the left of this block for traceback)
...
TypeError: do not know how to make x (= [4, 1]) an element of self
(=3-bounded Symmetric Functions over Rational Field with t=1 in the
3-Schur basis also with t=1)

But this should also return an error:

ks(Partition([4,1]))
ks3[4, 1]

@tscrim
Copy link
Collaborator

tscrim commented Mar 7, 2013

Changed dependencies from #13605 to #13605 #14228

@zabrocki
Copy link
Mannequin

zabrocki mannequin commented Mar 7, 2013

comment:11

Replying to @tscrim:

Does this affect at all #14235 (dependency one way or another?)

@tscrim
Copy link
Collaborator

tscrim commented Mar 7, 2013

comment:12

We both end up deleting the NonNegativeIntegers import (which is essentially trivial cleanup for both our patches), but other than that, the patches should(tm) commute.

@zabrocki
Copy link
Mannequin

zabrocki mannequin commented Mar 11, 2013

comment:13

Everything looks good. This seems to catch all the issues with having the correct indices in k-Schur functions that I can find. Thanks for coming back to this one.

@tscrim
Copy link
Collaborator

tscrim commented Mar 11, 2013

comment:14

Thank you for doing the review.

@jdemeyer
Copy link

Reviewer: Mike Zabrocki

@jdemeyer jdemeyer modified the milestones: sage-5.8, sage-5.9 Mar 11, 2013
@zabrocki
Copy link
Mannequin

zabrocki mannequin commented Mar 11, 2013

Changed author from Chris Berg to Travis Scrimshaw

@jdemeyer
Copy link

comment:17

This should be rebased to sage-5.8.rc0.

@zabrocki
Copy link
Mannequin

zabrocki mannequin commented Mar 14, 2013

comment:18

I've rebased to 5.8.rc0.

Apply: trac_13743-fix_kschur-ts.2.patch

@jdemeyer
Copy link

comment:19

It still doesn't apply properly, are you sure you have a clean build of sage-5.8.rc0?

applying /release/merger/patches/trac_13743-fix_kschur-ts.2.patch
patching file sage/combinat/partition.py
Hunk #3 succeeded at 304 with fuzz 2 (offset -1 lines).

@jdemeyer
Copy link

Attachment: trac_13743-fix_kschur-ts.2.patch.gz

@zabrocki
Copy link
Mannequin

zabrocki mannequin commented Mar 16, 2013

comment:20

I am restoring positive review. I had to recompile sage-5.8.rc0 to ensure that I didn't have a problem. This patch now applies cleanly.

@jdemeyer
Copy link

Merged: sage-5.9.beta0

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

4 participants