-
-
Notifications
You must be signed in to change notification settings - Fork 492
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
Lazy species #38544
base: develop
Are you sure you want to change the base?
Lazy species #38544
Conversation
Documentation preview for this PR (built with commit d5f74fa; changes) is ready! 🎉 |
src/sage/rings/lazy_species.py
Outdated
def add_structures(labels): | ||
yield from self.structures(labels) | ||
yield from other.structures(labels) | ||
|
||
result = super()._add_(other) | ||
result.structures = add_structures | ||
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tscrim, I'm not sure whether this is the best way to do it. I tried to create a separate class SumSpeciesElement
inheriting from LazySpeciesElement
that only overrides the method structures
(and will override generating_series
, etc.), but got stuck.
I think I would like to turn the result of super()._add_(other)
into a SumSpeciesElement
instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other thing: I am not sure, but perhaps it would actually be nice to take some decisions of LazyModuleElement._add_
into account. For example, if one of the arguments is zero, I might not want to return a SumSpeciesElement, but rather the other summand.
However, this smells badly like duplicating a lot of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rethinking this: I guess it happens next to never that we are in one of the cases treated specially by LazyModuleElement._add_
(or _mul_
, etc.) So maybe my afterthought is thinking about the empty set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the following look correct to you? At least it works. I admit that the arguments super
requires are not super-clear to me.
class LazySpeciesElement(LazyCompletionGradedAlgebraElement):
...
def _add_(self, other):
return SumSpeciesElement(self, other)
...
class SumSpeciesElement(LazySpeciesElement):
def __init__(self, left, right):
self._left = left
self._right = right
coeff_stream = super(LazySpeciesElement, type(left))._add_(left, right)._coeff_stream
super().__init__(self.parent(), coeff_stream)
def structures(self, labels):
yield from self._left.structures(labels)
yield from self._right.structures(labels)
This is now mostly functional. The next decision is how to go about replacing the old species framework - @fchapoton, it would be great to have your input on this! There is some functionality which is definitively missing. I know of the following:
1-3 are probably very easy, I think that 5 does not really belong to the species code, but should rather be a feature of the lazy framwork. Most likely, there is more. More questions:
|
I realize that I have no idea whether a species structure should have any structure at all. I see the following two options:
Special species classes, such as The current approach is the second one, and I'm leaning towards it, although this doesn't quite follow the math. I think we could additionally add a |
I am encountering yet another design question, @tscrim, I think that's for you :-) I added a method Now consider a "special" lazy species, such as
What I'd like to have is that restriction preserves this, but of course, it doesn't:
I think that I guess we'll have to have a video call to sort this out, I'm afraid my explanation is as unclear as possible :-) |
Here is the next interesting question. I would like to make Consider the species of sets The implicit solver uses (essentially) the infinite polynomial ring to represent "undetermined" coefficients. For example, in degree 2, an undetermined species would be |
We provide an implementation of combinatorial species based on the lazy series framework and #38446.
dependencies: #38974