diff --git a/src/sage/algebras/lie_algebras/poincare_birkhoff_witt.py b/src/sage/algebras/lie_algebras/poincare_birkhoff_witt.py index 3b59303d0dc..bb808d1c2d4 100644 --- a/src/sage/algebras/lie_algebras/poincare_birkhoff_witt.py +++ b/src/sage/algebras/lie_algebras/poincare_birkhoff_witt.py @@ -609,24 +609,24 @@ def _act_on_(self, x, self_on_left): return ret cm = get_coercion_model() L = self.parent()._g - if self_on_left: - if cm.discover_action(L, x.parent(), mul): - ret = x.parent().zero() + X = x.parent() + action = X.get_action(L, self_on_left=not self_on_left) + if action: + assert action.actor() is L + ret = X.zero() + if self_on_left: for mon, coeff in self._monomial_coefficients.items(): term = coeff * x for k, exp in reversed(mon._sorted_items()): for _ in range(exp): term = L.monomial(k) * term ret += term - return ret - else: - if cm.discover_action(x.parent(), L, mul): - ret = x.parent().zero() + else: for mon, coeff in self._monomial_coefficients.items(): - term = coeff * x + term = x * coeff for k, exp in reversed(mon._sorted_items()): for _ in range(exp): term = term * L.monomial(k) ret += term - return ret + return ret return None diff --git a/src/sage/structure/coerce_actions.pyx b/src/sage/structure/coerce_actions.pyx index e1ff3b378e7..aa4567dc337 100644 --- a/src/sage/structure/coerce_actions.pyx +++ b/src/sage/structure/coerce_actions.pyx @@ -159,7 +159,7 @@ cdef class ActedUponAction(GenericAction): def detect_element_action(Parent X, Y, bint X_on_left, X_el=None, Y_el=None): r""" - Return an action of X on Y as defined by elements of X, if any. + Return an action of Y on X as defined by elements of X, if any. EXAMPLES: @@ -197,6 +197,23 @@ def detect_element_action(Parent X, Y, bint X_on_left, X_el=None, Y_el=None): Traceback (most recent call last): ... RuntimeError: an_element() for <__main__.MyParent object at ...> returned None + + Check that we have a right action of the symmetric group on the + polynomial ring, but not a left action:: + + sage: S3 = SymmetricGroup(3) + sage: R. = QQ[] + sage: detect_element_action(R, S3, True) + Right action by Symmetric group of order 3! as a permutation group on + Multivariate Polynomial Ring in x, y, z over Rational Field + sage: detect_element_action(R, S3, False) + + Also, we don't have an action of the polynomial ring on the + symmetric group:: + + sage: detect_element_action(S3, R, True) + sage: detect_element_action(S3, R, False) + """ cdef Element x @@ -224,15 +241,15 @@ def detect_element_action(Parent X, Y, bint X_on_left, X_el=None, Y_el=None): except CoercionException as msg: _record_exception() - # element x defining _act_on_ - try: - if x._act_on_(y, X_on_left) is not None: - return ActOnAction(X, Y, X_on_left, False) - except CoercionException: - _record_exception() - - # element x defining _acted_upon_ if isinstance(Y, Parent): + # element y defining _act_on_ + try: + if y._act_on_(x, not X_on_left) is not None: + return ActOnAction(Y, X, not X_on_left, False) + except CoercionException: + _record_exception() + + # element x defining _acted_upon_ try: if x._acted_upon_(y, X_on_left) is not None: return ActedUponAction(Y, X, not X_on_left, False)