sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.37k stars 469 forks source link

Completion of the free algebra, and also lazy symmetric functions in a single alphabet should not have a shift method #37633

Open mantepse opened 6 months ago

mantepse commented 6 months ago

Steps To Reproduce

Currently, we have

sage: R = algebras.Free(QQ, ('a', 'b'), degrees=(1, 2))
sage: L = R.completion()
sage: e = L(R.gen(0))
sage: e, e.valuation(), e.shift(1), e.shift(1).valuation()
(a, 1, a, 2)

which is nonsense. The same is true for LazySymmetricFunctions(SymmetricFunctions(QQ).s()).

Expected Behavior

The shift method should raise an error or should not be available at all.

Actual Behavior

See above.

Additional Information

I think we are using _arity for two things which are only superficially related, and I guess we should simply unentangle that, perhaps as follows:

Perhaps this also has something to do with _internal_poly_ring and _laurent_poly_ring, but I haven't thought about it.

At the same time, we might want to add special classes similar to LazySymmetricFunction for the completion of the free algebra.

Environment

irrelevant.

Checklist

tscrim commented 6 months ago

Thinking a bit about this, I think we should set _arity to None, which should then disallow it for use in any method.

It does not make sense to tie the input homogeneity to the number of tensor product factors. The tensor product algebra could have a grading not connected to the gradings of the individual factors. It works as a default, but that should belong to the category of tensor product of graded algebras. I think we need a better _element_constructor_ for this too.

For __call__, should we implement it, we would just pass it to the corresponding elements. The only place arity is used in the __call__ of the multivariate lazy series is to just have an earlier error with a (marginally IMO) better error message.

I don't think we should special case the free algebra as much as possible. In particular, a free algebra on 1 generator is the same as the univariate polynomial ring (if we allow noncommutative base rings), and I doubt anyone is asking for shifts in that case. I'm not sure if we want lazy Laurent series to support noncommutative base rings, but that would be better waiting until someone asks for it.