Help with coercion / action for tensor product

93 views
Skip to first unread message

Martin R

unread,
Feb 23, 2024, 9:44:39 AM2/23/24
to sage-devel
Dear all!

I badly need help to make the following work. Let M be a module over a ring Q, and let R be a ring with a coercion from Q to R.  Then I want to be able to multiply elements in R with elements in tensor products of M.  This is https://github.com/sagemath/sage/pull/37413, and is (hopefully) the final stumbling block for https://github.com/sagemath/sage/pull/37033.

Multiplying elements in R with elements in M works.

Here is an example:

sage: M = CombinatorialFreeModule(QQ, [1,2,3])
sage: m = M.an_element(); m
2*B[1] + 2*B[2] + 3*B[3]

sage: R.<x> = QQ[]
sage: r = x + 1

sage: r * m
(2*x+2)*B[1] + (2*x+2)*B[2] + (3*x+3)*B[3]

sage: T = M.tensor(M)
sage: t = T.an_element(); t
2*B[1] # B[1] + 2*B[1] # B[2] + 3*B[1] # B[3]

sage: r * t
TypeError

Help is greatly appreciated.  There is already some info at the ticket, but I don't know how to proceed.

Best wishes,

Martin

Nils Bruin

unread,
Feb 23, 2024, 3:07:19 PM2/23/24
to sage-devel
On Friday 23 February 2024 at 06:44:39 UTC-8 Martin R wrote:
Dear all!

I badly need help to make the following work. Let M be a module over a ring Q, and let R be a ring with a coercion from Q to R.  Then I want to be able to multiply elements in R with elements in tensor products of M.

It looks to me you should first base extend M to M_R, a module over R, using the coercion map Q->R.  So I don't think R acts on M. It acts on M_R.

Do you want the coercion system to be smart enough to construct that base extension for you? I'm not sure I'd expect the system to do that or even be in favour of the system doing that on its own.

Martin R

unread,
Feb 23, 2024, 5:37:37 PM2/23/24
to sage-devel
I just prepared a very long answer.  Doing so I had to check something in my code.  This in turn lead me to discover a bug, which might slightly change things.  I am too tired right now to fix the bug (it might not be easy), so please give me a night.

This might reduce the problem to nothing, but I don't know yet.

I'm sorry!

Martin

Martin R

unread,
Feb 24, 2024, 4:37:08 AM2/24/24
to sage-devel
sage: h = SymmetricFunctions(QQ).h()
sage: S = LazySymmetricFunctions(h)
sage: E = S(lambda n: h[n])
sage: T = LazySymmetricFunctions(tensor([h, h]))
sage: X = tensor([h[1],h[[]]])
sage: Y = tensor([h[[]],h[1]])
sage: A = T.undefined()
sage: B = T.undefined()
sage: T.define_implicitly([A, B], [A - X*E(B), B - Y*E(A)])
sage: A[:5]
[h[1] # h[],
 h[1] # h[1],
 h[1] # h[2] + h[1, 1] # h[1],
 h[1] # h[3] + 2*h[1, 1] # h[1, 1] + h[2, 1] # h[1]]

:-)

diff --git a/src/sage/rings/lazy_series_ring.py b/src/sage/rings/lazy_series_ring.py
index 02a477e4e0..f168435ac9 100644
--- a/src/sage/rings/lazy_series_ring.py
+++ b/src/sage/rings/lazy_series_ring.py
@@ -3147,6 +3147,7 @@ class LazyCompletionGradedAlgebra(LazySeriesRing):
        from sage.misc.mrange import cartesian_product_iterator
        from sage.categories.tensor import tensor
        B = self._internal_poly_ring.base_ring()
+        B = B.change_ring(R)
        if self._arity == 1:
            return list(B.homogeneous_component_basis(n))
        l = []

Thank you so much!

Martin
Reply all
Reply to author
Forward
0 new messages