Opened 8 years ago

Closed 8 years ago

#13743 closed defect (fixed)

Bug in k-bounded symmetric functions

Reported by: chrisjamesberg Owned by: sage-combinat
Priority: major Milestone: sage-5.9
Component: combinatorics Keywords:
Cc: aschilling, zabrocki, tscrim, Merged in: sage-5.9.beta0
Authors: Travis Scrimshaw Reviewers: Mike Zabrocki
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #13605 #14228 Stopgaps:

Description

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

Attachments (1)

trac_13743-fix_kschur-ts.2.patch (7.8 KB) - added by jdemeyer 8 years ago.

Download all attachments as: .zip

Change History (22)

comment:1 follow-up: Changed 8 years ago by nthiery

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

comment:2 in reply to: ↑ 1 Changed 8 years ago by aschilling

You can just do

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

Anne

comment:3 follow-up: Changed 8 years ago by zabrocki

  • Cc tscrim added
  • Dependencies set to 13605

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?

Last edited 8 years ago by zabrocki (previous) (diff)

comment:4 in reply to: ↑ 3 ; follow-up: Changed 8 years ago by tscrim

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

comment:5 in reply to: ↑ 4 Changed 8 years ago by zabrocki

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

comment:6 Changed 8 years ago by zabrocki

  • Dependencies changed from 13605 to #13605

comment:7 Changed 8 years ago by tscrim

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.

comment:8 Changed 8 years ago by chrisjamesberg

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.

Last edited 8 years ago by chrisjamesberg (previous) (diff)

comment:9 Changed 8 years ago by chrisjamesberg

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]

comment:10 follow-up: Changed 8 years ago by tscrim

  • Dependencies changed from #13605 to #13605 #14228
  • Status changed from new to needs_review

comment:11 in reply to: ↑ 10 Changed 8 years ago by zabrocki

Replying to tscrim:

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

comment:12 Changed 8 years ago by tscrim

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.

comment:13 Changed 8 years ago by zabrocki

  • Status changed from needs_review to positive_review

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.

comment:14 Changed 8 years ago by tscrim

Thank you for doing the review.

comment:15 Changed 8 years ago by jdemeyer

  • Milestone changed from sage-5.8 to sage-5.9
  • Reviewers set to Mike Zabrocki

comment:16 Changed 8 years ago by zabrocki

  • Authors changed from Chris Berg to Travis Scrimshaw

comment:17 Changed 8 years ago by jdemeyer

  • Status changed from positive_review to needs_work

This should be rebased to sage-5.8.rc0.

comment:18 Changed 8 years ago by zabrocki

I've rebased to 5.8.rc0.

Apply: trac_13743-fix_kschur-ts.2.patch

comment:19 Changed 8 years ago by jdemeyer

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

Changed 8 years ago by jdemeyer

comment:20 Changed 8 years ago by zabrocki

  • Status changed from needs_work to positive_review

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.

comment:21 Changed 8 years ago by jdemeyer

  • Merged in set to sage-5.9.beta0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.