Group, ring, etc. actions on objects.
The terminology and notation used is suggestive of groups acting on sets, but this framework can be used for modules, algebras, etc.
A group action \(G \times S \rightarrow S\) is a functor from \(G\) to Sets.
Warning
An Action object only keeps a weak reference to the underlying set which is acted upon. This decision was made in trac ticket #715 in order to allow garbage collection within the coercion framework (this is where actions are mainly used) and avoid memory leaks.
sage: from sage.categories.action import Action
sage: class P: pass
sage: A = Action(P(),P())
sage: import gc
sage: _ = gc.collect()
sage: A
<repr(<sage.categories.action.Action at 0x...>) failed: RuntimeError: This action acted on a set that became garbage collected>
To avoid garbage collection of the underlying set, it is sufficient to create a strong reference to it before the action is created.
sage: _ = gc.collect()
sage: from sage.categories.action import Action
sage: class P: pass
sage: q = P()
sage: A = Action(P(),q)
sage: gc.collect()
0
sage: A
Left action by <__main__.P instance at ...> on <__main__.P instance at ...>
AUTHOR:
Bases: sage.categories.functor.Functor
This is a consistent interface for acting on a by g, regardless of whether it’s a left or right action.
Bases: sage.categories.morphism.Morphism
The endomorphism defined by the action of one element.
EXAMPLES:
sage: A = ZZ['x'].get_action(QQ, self_on_left=False, op=operator.mul)
sage: A
Left scalar multiplication by Rational Field on Univariate Polynomial
Ring in x over Integer Ring
sage: A(1/2)
Action of 1/2 on Univariate Polynomial Ring in x over Integer Ring
under Left scalar multiplication by Rational Field on Univariate
Polynomial Ring in x over Integer Ring.
Bases: sage.categories.action.Action
An action that acts as the inverse of the given action.
TESTS:
This illustrates a shortcoming in the current coercion model. See the comments in _call_ below:
sage: x = polygen(QQ,'x')
sage: a = 2*x^2+2; a
2*x^2 + 2
sage: a / 2
x^2 + 1
sage: a /= 2
sage: a
x^2 + 1
Bases: sage.categories.action.Action
A precomposed action first applies given maps, and then applying an action to the return values of the maps.
EXAMPLES:
We demonstrate that an example discussed on trac ticket #14711 did not become a problem:
sage: E = ModularSymbols(11).2
sage: s = E.modular_symbol_rep()
sage: del E,s
sage: import gc
sage: _ = gc.collect()
sage: E = ModularSymbols(11).2
sage: v = E.manin_symbol_rep()
sage: c,x = v[0]
sage: y = x.modular_symbol_rep()
sage: A = y.parent().get_action(QQ, self_on_left=False, op=operator.mul)
sage: A
Left scalar multiplication by Rational Field on Abelian Group of all
Formal Finite Sums over Rational Field
with precomposition on right by Conversion map:
From: Abelian Group of all Formal Finite Sums over Integer Ring
To: Abelian Group of all Formal Finite Sums over Rational Field