Skip to content

Commit 7dfefc4

Browse files
author
Release Manager
committed
Trac #27652: parent of plethysm
URL: https://trac.sagemath.org/27652 Reported by: mantepse Ticket author(s): Martin Rubey Reviewer(s): Travis Scrimshaw
2 parents 949866d + 0dcc0aa commit 7dfefc4

File tree

1 file changed

+76
-40
lines changed

1 file changed

+76
-40
lines changed

src/sage/combinat/sf/sfa.py

Lines changed: 76 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,33 +3031,53 @@ def plethysm(self, x, include=None, exclude=None):
30313031
30323032
- ``x`` -- a symmetric function over the same base ring as
30333033
``self``
3034-
30353034
- ``include`` -- a list of variables to be treated as
30363035
degree one elements instead of the default degree one elements
3037-
30383036
- ``exclude`` -- a list of variables to be excluded
30393037
from the default degree one elements
30403038
3039+
OUTPUT:
3040+
3041+
An element in the parent of ``x`` or the base ring `R` of ``self``
3042+
when ``x`` is in `R`.
3043+
30413044
EXAMPLES::
30423045
30433046
sage: Sym = SymmetricFunctions(QQ)
30443047
sage: s = Sym.s()
30453048
sage: h = Sym.h()
3046-
sage: s ( h([3])( h([2]) ) )
3049+
sage: h3h2 = h[3](h[2]); h3h2
3050+
h[2, 2, 2] - 2*h[3, 2, 1] + h[3, 3] + h[4, 1, 1] - h[5, 1] + h[6]
3051+
sage: s(h3h2)
30473052
s[2, 2, 2] + s[4, 2] + s[6]
30483053
sage: p = Sym.p()
3049-
sage: p([3])( s([2,1]) )
3054+
sage: p3s21 = p[3](s[2,1]); p3s21
3055+
s[2, 2, 2, 1, 1, 1] - s[2, 2, 2, 2, 1] - s[3, 2, 1, 1, 1, 1]
3056+
+ s[3, 2, 2, 2] + s[3, 3, 1, 1, 1] - s[3, 3, 2, 1] + 2*s[3, 3, 3]
3057+
+ s[4, 1, 1, 1, 1, 1] - s[4, 3, 2] + s[4, 4, 1] - s[5, 1, 1, 1, 1]
3058+
+ s[5, 2, 2] - s[5, 4] + s[6, 1, 1, 1] - s[6, 2, 1] + s[6, 3]
3059+
sage: p(p3s21)
30503060
1/3*p[3, 3, 3] - 1/3*p[9]
30513061
sage: e = Sym.e()
3052-
sage: e([3])( e([2]) )
3062+
sage: e[3](e[2])
30533063
e[3, 3] + e[4, 1, 1] - 2*e[4, 2] - e[5, 1] + e[6]
30543064
3055-
::
3065+
Note that the output is in the basis of the input ``x``::
3066+
3067+
sage: s[2,1](h[3])
3068+
h[4, 3, 2] - h[4, 4, 1] - h[5, 2, 2] + h[5, 3, 1] + h[5, 4]
3069+
+ h[6, 2, 1] - 2*h[6, 3] - h[7, 1, 1] + h[7, 2] + h[8, 1] - h[9]
3070+
3071+
sage: h[2,1](s[3])
3072+
s[4, 3, 2] + s[4, 4, 1] + s[5, 2, 2] + s[5, 3, 1] + s[5, 4]
3073+
+ s[6, 2, 1] + 2*s[6, 3] + 2*s[7, 2] + s[8, 1] + s[9]
3074+
3075+
Examples over a polynomial ring::
30563076
30573077
sage: R.<t> = QQ[]
30583078
sage: s = SymmetricFunctions(R).s()
30593079
sage: a = s([3])
3060-
sage: f = t*s([2])
3080+
sage: f = t * s([2])
30613081
sage: a(f)
30623082
t^3*s[2, 2, 2] + t^3*s[4, 2] + t^3*s[6]
30633083
sage: f(a)
@@ -3069,6 +3089,12 @@ def plethysm(self, x, include=None, exclude=None):
30693089
sage: s(1).plethysm(s(0))
30703090
s[]
30713091
3092+
When ``x`` is a constant, then it is returned as an element
3093+
of the base ring::
3094+
3095+
sage: s[3](2).parent() is R
3096+
True
3097+
30723098
Sage also handles plethysm of tensor products of symmetric functions::
30733099
30743100
sage: s = SymmetricFunctions(QQ).s()
@@ -3080,8 +3106,8 @@ def plethysm(self, x, include=None, exclude=None):
30803106
s[1, 1, 1] # s[3] + s[2, 1] # s[2, 1] + s[3] # s[1, 1, 1]
30813107
30823108
One can use this to work with symmetric functions in two sets of
3083-
commuting variables. For example, we verify the Cauchy identities (in
3084-
degree 5)::
3109+
commuting variables. For example, we verify the Cauchy identities
3110+
(in degree 5)::
30853111
30863112
sage: m = SymmetricFunctions(QQ).m()
30873113
sage: P5 = Partitions(5)
@@ -3142,39 +3168,41 @@ def plethysm(self, x, include=None, exclude=None):
31423168
Check that we can compute the plethysm with a constant::
31433169
31443170
sage: p[2,2,1](2)
3145-
8*p[]
3171+
8
31463172
31473173
sage: p[2,2,1](int(2))
3148-
8*p[]
3174+
8
31493175
31503176
sage: p[2,2,1](a1)
3151-
a1^5*p[]
3177+
a1^5
31523178
31533179
sage: X = algebras.Shuffle(QQ, 'ab')
31543180
sage: Y = algebras.Shuffle(QQ, 'bc')
3155-
sage: T = tensor([X,Y])
3181+
sage: T = tensor([X, Y])
31563182
sage: s = SymmetricFunctions(T).s()
3157-
sage: s(2*T.one())
3158-
(2*B[]#B[])*s[]
3183+
sage: s[2](5)
3184+
15*B[] # B[]
31593185
31603186
.. TODO::
31613187
31623188
The implementation of plethysm in
31633189
:class:`sage.data_structures.stream.Stream_plethysm` seems
31643190
to be faster. This should be investigated.
31653191
"""
3192+
from sage.structure.element import parent as get_parent
3193+
Px = get_parent(x)
31663194
parent = self.parent()
3195+
R = parent.base_ring()
3196+
31673197
if not self:
3168-
return self
3198+
return R(0)
31693199

3170-
R = parent.base_ring()
31713200
tHA = HopfAlgebrasWithBasis(R).TensorProducts()
3172-
from sage.structure.element import parent as get_parent
3173-
Px = get_parent(x)
31743201
tensorflag = Px in tHA
31753202
if not is_SymmetricFunction(x):
3176-
if Px is R: # Handle stuff that is directly in the base ring
3177-
x = parent(x)
3203+
if R.has_coerce_map_from(Px) or x in R:
3204+
x = R(x)
3205+
Px = R
31783206
elif (not tensorflag or any(not isinstance(factor, SymmetricFunctionAlgebra_generic)
31793207
for factor in Px._sets)):
31803208
from sage.rings.lazy_series import LazySymmetricFunction
@@ -3198,13 +3226,15 @@ def plethysm(self, x, include=None, exclude=None):
31983226

31993227
if tensorflag:
32003228
tparents = Px._sets
3201-
s = sum(d * prod(sum(_raise_variables(c, r, degree_one)
3202-
* tensor([p[r].plethysm(base(la))
3203-
for base, la in zip(tparents, trm)])
3204-
for trm, c in x)
3205-
for r in mu)
3206-
for mu, d in p(self))
3207-
return tensor([parent]*len(tparents))(s)
3229+
lincomb = Px.linear_combination
3230+
elt = lincomb((prod(lincomb((tensor([p[r].plethysm(base(la))
3231+
for base, la in zip(tparents, trm)]),
3232+
_raise_variables(c, r, degree_one))
3233+
for trm, c in x)
3234+
for r in mu),
3235+
d)
3236+
for mu, d in p(self))
3237+
return Px(elt)
32083238

32093239
# Takes a symmetric function f, and an n and returns the
32103240
# symmetric function with all of its basis partitions scaled
@@ -3218,7 +3248,11 @@ def pn_pleth(f, n):
32183248
def f(part):
32193249
return p.prod(pn_pleth(p_x.map_coefficients(lambda c: _raise_variables(c, i, degree_one)), i)
32203250
for i in part)
3221-
return parent(p._apply_module_morphism(p(self), f, codomain=p))
3251+
ret = p._apply_module_morphism(p(self), f, codomain=p)
3252+
if Px is R:
3253+
# special case for things in the base ring
3254+
return next(iter(ret._monomial_coefficients.values()))
3255+
return Px(ret)
32223256

32233257
__call__ = plethysm
32243258

@@ -6202,21 +6236,20 @@ def _nonnegative_coefficients(x):
62026236
return x >= 0
62036237

62046238
def _variables_recursive(R, include=None, exclude=None):
6205-
"""
6239+
r"""
62066240
Return all variables appearing in the ring ``R``.
62076241
62086242
INPUT:
62096243
62106244
- ``R`` -- a :class:`Ring`
6211-
- ``include``, ``exclude`` (optional, default ``None``) --
6212-
iterables of variables in ``R``
6245+
- ``include``, ``exclude`` -- (optional) iterables of variables in ``R``
62136246
62146247
OUTPUT:
62156248
6216-
- If ``include`` is specified, only these variables are returned
6217-
as elements of ``R``. Otherwise, all variables in ``R``
6218-
(recursively) with the exception of those in ``exclude`` are
6219-
returned.
6249+
If ``include`` is specified, only these variables are returned
6250+
as elements of ``R``. Otherwise, all variables in ``R``
6251+
(recursively) with the exception of those in ``exclude`` are
6252+
returned.
62206253
62216254
EXAMPLES::
62226255
@@ -6251,15 +6284,15 @@ def _variables_recursive(R, include=None, exclude=None):
62516284
except AttributeError:
62526285
try:
62536286
degree_one = R.gens()
6254-
except NotImplementedError:
6287+
except (NotImplementedError, AttributeError):
62556288
degree_one = []
62566289
if exclude is not None:
62576290
degree_one = [g for g in degree_one if g not in exclude]
62586291

62596292
return [g for g in degree_one if g != R.one()]
62606293

62616294
def _raise_variables(c, n, variables):
6262-
"""
6295+
r"""
62636296
Replace the given variables in the ring element ``c`` with their
62646297
``n``-th power.
62656298
@@ -6276,6 +6309,9 @@ def _raise_variables(c, n, variables):
62766309
sage: S.<t> = R[]
62776310
sage: _raise_variables(2*a + 3*b*t, 2, [a, t])
62786311
3*b*t^2 + 2*a^2
6279-
62806312
"""
6281-
return c.subs(**{str(g): g ** n for g in variables})
6313+
try:
6314+
return c.subs(**{str(g): g ** n for g in variables})
6315+
except AttributeError:
6316+
return c
6317+

0 commit comments

Comments
 (0)