# Group, ring, etc. actions on objects.¶

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
Traceback (most recent call last):
...
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:

• Robert Bradshaw: initial version
class sage.categories.action.Action
act(g, a)

This is a consistent interface for acting on a by g, regardless of whether it’s a left or right action.

actor()
codomain()
domain()
is_left()
left_domain()
operation()
right_domain()
class sage.categories.action.ActionEndomorphism
class sage.categories.action.InverseAction

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

codomain()
class sage.categories.action.PrecomposedAction
codomain()
domain()

#### Previous topic

Example of a set with grading