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

Add support for homogeneous components of a filtered module #19397

Closed
tscrim opened this issue Oct 13, 2015 · 67 comments
Closed

Add support for homogeneous components of a filtered module #19397

tscrim opened this issue Oct 13, 2015 · 67 comments

Comments

@tscrim
Copy link
Collaborator

tscrim commented Oct 13, 2015

Separates out functionality of subset(d) for finite dimensional filtered modules with basis and implements a method to get the submodule spanned by a homogeneous piece.

Depends on #17096

CC: @sagetrac-sage-combinat @darijgr @nthiery @simon-king-jena

Component: categories

Author: Travis Scrimshaw

Branch/Commit: f9aaad5

Reviewer: John Palmieri

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

@tscrim
Copy link
Collaborator Author

tscrim commented Oct 13, 2015

comment:1

This will be useful along with the changes I'm making in #6102, which I think will be our first naturally graded finite-dimensional algebra in Sage.


Last 10 new commits:

570bc49Merge branch 'public/categories/super_categories-18044' into 6.9.b1
b91cd82trac #18044 correct one typo in the doc
7fd1df2Merge branch 'public/categories/super_categories-18044' of trac.sagemath.org:sage into public/categories/super_categories-18044
0579337Some reviewer tweaks and doc additions.
aec22ccAdded one more test.
4b2046fMerge branch 'public/categories/super_categories-18044' into public/categories/filtered_algebras-17096
3f67b6bFixing trivial doctest due to changes in category heirarchy.
fa476ddFixing double-colon in INPUT block.
6cc8b84Reviewer changes with Darij.
9c51a4cMerge branch 'public/categories/filtered_algebras-17096' of trac.sagemath.org:sage into public/categories/graded_components-TBA

@tscrim
Copy link
Collaborator Author

tscrim commented Oct 13, 2015

Commit: 9c51a4c

@tscrim
Copy link
Collaborator Author

tscrim commented Oct 13, 2015

@jhpalmieri
Copy link
Member

comment:2

You have the comment starting with

# TODO: which syntax do we prefer?

twice, along with two different basis methods in filtered_modules_with_basis.py.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 13, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

ae81aa7Fixing bad copying.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 13, 2015

Changed commit from 9c51a4c to ae81aa7

@jhpalmieri
Copy link
Member

comment:4

Is this a problem?

sage: A = GradedModulesWithBasis(ZZ).example()
sage: A.homogeneous_component(3).an_element()   # not printed like elements of A
3*B[[1, 1, 1]] + 3*B[[2, 1]] + B[[3]]
sage: a = A.homogeneous_component(3).an_element()
sage: a in A
False

Also, A(a) leads to a NotImplementedError. So once you have an element in a homogeneous component, there isn't an obvious way to view it as an element of the whole module.

@tscrim
Copy link
Collaborator Author

tscrim commented Oct 21, 2015

comment:5

I was originally taking care of this on #19359, but I've now moved this to #19448 (which you can set as a dependency if you feel it is warranted).

@jhpalmieri
Copy link
Member

comment:6

Will #19448 also make

list(A.homogeneous_component(4).basis())

and

list(A.homogeneous_component_basis(4))

equal? (Can they be equal? The elements in the first are elements in a particular homogeneous component. The elements in the second are elements in the whole module. At least they should look the same when you print them, and I think #19448 should take care of that.)

@jhpalmieri
Copy link
Member

comment:7

One mathematical issue: in defining homogeneous_component, you have

category = ModulesWithBasis(self.category().base_ring())

A homogeneous component of an R-module need not be an R-module itself in a natural way: for example, if the base ring is the graded ring R=k[x, x-1] with x in some nonzero degree, then for any homogeneous component of any graded R-module, x would have to act trivially (because x has nonzero degree). On the other hand, x is supposed to be invertible.

It will always be a module over the degree 0 part of the base ring, though.

@darijgr
Copy link
Contributor

darijgr commented Oct 24, 2015

comment:8

John: I fear that this notion of grading is not currently implemented in Sage (again, hardly anyone's deliberate design choice, but an artifact of ungraded base rings being the de-facto standard in combinatorics). Almost all of the current code in FilteredModulesWithBasis currently assumes that the base ring is ungraded :(

Incidentally, IMHO this issue shows that we are mistaken in the assumption that in order to equip an algebra with a grading, we should add degree and similar functions to the class. Many algebras have several natural gradings, and each of them comes with its own notion of a graded module. When you speak of a "graded R[x]-module", you have to specify whether x has degree 1 or 0 (or anything else); even in combinatorics, both of these cases happen. So if/when we make R[x] into a graded ring, what should its grading be? I think it shouldn't. There should be a two graded rings, called PolynomialRing(QQ).trivial_grading() and PolynomialRing().degree_grading() or something like this, while PolynomialRing(QQ) itself should just be a QQ-algebra. Actually the trivial_grading() function should be defined generically on any module and return the corresponding graded module with trivial grading. And there can be further gradings and filtrations likewise (I can see good uses for filtered the tensor algebra by word length, number of distinct letters, maximal multiplicity of a letter, etc. -- there is no way the code should decide between them for the user!).

@jhpalmieri
Copy link
Member

comment:9

For this situation, what about code like

try:
    R = self.base_ring().homogeneous_component(0)
    # or R = self.base_ring().base_ring()??
except AttributeError:
    R = self.base_ring()
category = ModulesWithBasis(self.category().R)

This may end up calling homogeneous_component recursively, but eventually that should end with an ungraded base ring.

Yes, I also agree that we need to allow for multiple possible gradings. I think this has been discussed before. To construct a graded ring you should specify a ring and a grading on it, and different gradings give different graded rings.

@tscrim
Copy link
Collaborator Author

tscrim commented Oct 26, 2015

comment:10

However there is a technical problem with doing that in the short-term in that submodule currently does not differentiate between coordinate rings and base rings (think ZZ-submodule in a QQ-module). See also Jeroen's comments in #18310.

So if we were decided to do do the above, then we should add coordinate ring support in #19448 and make that a dependency of this one.

Alternatively we could just raise a NotImplementedError for now if the module and base ring are both graded.

@jhpalmieri
Copy link
Member

comment:11

I think we should do something, just to acknowledge that it is an issue that we might address later. A NotImplementedError sounds fine to me. Whatever is simplest, I think.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 26, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

cd186d0Merge branch 'public/categories/homogeneous_components-19397' of trac.sagemath.org:sage into public/categories/homogeneous_components-19397
f89275bRaise a NotImplementedError if the base ring is filtered.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 26, 2015

Changed commit from ae81aa7 to f89275b

@tscrim
Copy link
Collaborator Author

tscrim commented Oct 26, 2015

comment:13

The simple way is to raise a NotImplementedError for now. Although now I find myself wishing for filtered magmas...

@jhpalmieri
Copy link
Member

comment:14

This looks okay to me.

@jhpalmieri
Copy link
Member

Reviewer: John Palmieri

@jhpalmieri
Copy link
Member

comment:41

I think there is a word ("when"?) missing in the "TODO" comment.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 18, 2016

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

068adf3Trying to avoid infinite lists and adding a TODO comment.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 18, 2016

Changed commit from 6c0e7bd to 068adf3

@tscrim
Copy link
Collaborator Author

tscrim commented Apr 18, 2016

comment:43

Replying to @jhpalmieri:

I think there is a word ("when"?) missing in the "TODO" comment.

True. I also was able to make it so the text ended at the same position. :P FYI - I decided to amend my previous commit instead of a new one.

@jhpalmieri
Copy link
Member

comment:44

Okay, I'm happy with this now. If you think it's not ready, revert my positive review.

@tscrim
Copy link
Collaborator Author

tscrim commented Apr 18, 2016

comment:45

It is good. Thank you. MRO issue is now #20460.

@vbraun
Copy link
Member

vbraun commented Apr 19, 2016

comment:46
sage -t --long src/sage/categories/filtered_modules_with_basis.py
**********************************************************************
File "src/sage/categories/filtered_modules_with_basis.py", line 160, in sage.categories.filtered_modules_with_basis.FilteredModulesWithBasis.ParentMethods.basis
Failed example:
    A.basis(4)
Expected:
    Traceback (most recent call last):
    ...
    AttributeError: 'IndexedFreeAbelianMonoid_with_category' object has no attribute 'list'
Got:
    <BLANKLINE>
    Traceback (most recent call last):
      File "/mnt/disk/home/buildslave-sage/slave/sage_git/build/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 496, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/mnt/disk/home/buildslave-sage/slave/sage_git/build/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 858, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.categories.filtered_modules_with_basis.FilteredModulesWithBasis.ParentMethods.basis[5]>", line 1, in <module>
        A.basis(Integer(4))
      File "/mnt/disk/home/buildslave-sage/slave/sage_git/build/local/lib/python2.7/site-packages/sage/categories/filtered_modules_with_basis.py", line 186, in basis
        return self.homogeneous_component_basis(d)
      File "/mnt/disk/home/buildslave-sage/slave/sage_git/build/local/lib/python2.7/site-packages/sage/categories/filtered_modules_with_basis.py", line 215, in homogeneous_component_basis
        S = [i for i in list(self._indices) if self.degree_on_basis(i) == d]
      File "sage/structure/parent.pyx", line 1548, in sage.structure.parent.Parent.__len__ (/mnt/disk/home/buildslave-sage/slave/sage_git/build/src/build/cythonized/sage/structure/parent.c:12470)
        return len(self.list())
      File "/mnt/disk/home/buildslave-sage/slave/sage_git/build/local/lib/python2.7/site-packages/sage/categories/infinite_enumerated_sets.py", line 76, in list
        raise NotImplementedError("infinite list")
    NotImplementedError: infinite list
**********************************************************************
1 item had failures:
   1 of  10 in sage.categories.filtered_modules_with_basis.FilteredModulesWithBasis.ParentMethods.basis
    [214 tests, 1 failure, 0.75 s]

@jhpalmieri
Copy link
Member

comment:47

Volker, I don't see this failure when I run doctests or when I do it by hand, and I don't see it on the patchbots, either. Do you have any ideas why?

@tscrim
Copy link
Collaborator Author

tscrim commented Apr 19, 2016

comment:48

I also don't get the failure. Maybe something changed with the example implementation in another (already closed) ticket? I certainly can see why this failure might occur...and it is an easy enough fix...

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 23, 2016

Changed commit from 068adf3 to aa85da2

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 23, 2016

Branch pushed to git repo; I updated commit sha1. New commits:

13fee78Merge branch 'public/categories/homogeneous_components-19397' of trac.sagemath.org:sage into public/categories/homogeneous_components-19397
aa85da2Fixing change in error message and corresponding documentation.

@tscrim
Copy link
Collaborator Author

tscrim commented Apr 23, 2016

comment:50

The problem occurred in beta5 (in fact, I believe I know exactly which ticket caused it...). I fixed the error message and the documentation (I am pretty sure a NotImplementedError will be more common with this change anyways...).

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 23, 2016

Changed commit from aa85da2 to f9aaad5

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 23, 2016

Branch pushed to git repo; I updated commit sha1. New commits:

f9aaad5Fixing docstring (which should have been on the last commit).

@jhpalmieri
Copy link
Member

comment:52

Looks good to me. Passes all tests.

@tscrim
Copy link
Collaborator Author

tscrim commented Apr 23, 2016

comment:53

Replying to @jhpalmieri:

Looks good to me. Passes all tests.

Thank you.

@vbraun
Copy link
Member

vbraun commented Apr 25, 2016

Changed branch from public/categories/homogeneous_components-19397 to f9aaad5

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