Surjective non-pre-injective linear automaton on F2
A linear automaton over K^2 on the free group F2.
- Class:
SurjectiveLinearAutomatonSystem - Import:
from skcomplex.systems.computer_science.automata import SurjectiveLinearAutomatonSystem - Field:
computer_science/automata - Topics:
group,cellular automaton,free group,linear,Garden of Eden - References:
- Ceccherini-Silberstein and Coornaert 2023
Use this system
The block imports the class and simulates the system with its default parameters and its tuned run settings.
from skcomplex.systems.computer_science.automata import SurjectiveLinearAutomatonSystem
trajectory = SurjectiveLinearAutomatonSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
radius |
5 |
modulus |
2 |
initial |
None |
random_state |
0 |
solver |
'auto' |
backend |
'auto' |
Tags
The system with its default parameters has these capability tags, which solvers and analyses check.
| Tag | Values |
|---|---|
| Time | discrete |
| Space | lattice |
| Laws | update |
| Randomness | unknown |
| Domains | integer |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class SurjectiveLinearAutomatonSystem(BaseSystem):
"""A linear automaton over `K^2` on the free group F2.
It is surjective but not pre-injective. Every cell becomes `q1(x(ga)) + q1(x(ga^-1)) + q2(x(gb)) + q2(x(gb^-1))`,
where `q1(h, k) = (h, 0)` and `q2(h, k) = (0, h)`, over the field of a prime number `modulus` of elements
(Ceccherini-Silberstein and Coornaert 2023, Section 8.11). The configuration `(0, 1)` at the identity and 0
elsewhere maps to 0, so the automaton is not pre-injective, while a preimage of every configuration is built by
induction on the word length, so it is surjective, which the Garden of Eden theorem forbids on amenable groups.
Cells on the boundary of the ball read 0 outside it. The system has the coordinates `cells.first` and
`cells.second`.
Args:
radius:
The radius of the ball of F2.
modulus:
The prime size of the field `K`.
initial:
The initial pairs, an array of shape `(sites, 2)`, or `None` for random ones.
random_state:
The seed or generator of the random initial pairs.
label:
The label of the system, which names it when it is nested in another one.
solver:
The solver of the problem, or `'auto'` for the one the system chooses.
backend:
The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.
Raises:
ParameterError:
The modulus is below 2.
Examples:
>>> from skcomplex.systems.computer_science.automata import SurjectiveLinearAutomatonSystem
>>> SurjectiveLinearAutomatonSystem(radius=2).prepare().simulate(until=1).get_values('cells.first').shape
(2, 17)
"""
field = 'computer_science/automata'
topics = ('group', 'cellular automaton', 'free group', 'linear', 'Garden of Eden')
references = ('Ceccherini-Silberstein and Coornaert 2023',)
until = 10
dt = 1
observables = (
Observable('first_mean', group='cells', variable='first'),
Observable('second_mean', group='cells', variable='second'),
)
def __init__(
self,
*,
radius: int = 5,
modulus: int = 2,
initial: npt.ArrayLike | None = None,
random_state: int | np.random.Generator | None = 0,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.radius = radius
self.modulus = modulus
self.initial = initial
self.random_state = random_state
def _get_pairs(self, space: BaseSpace) -> Array:
"""Return the initial pairs, one row of two coordinates per site, random modulo the modulus by default."""
if self.modulus < MIN_MODULUS:
error_msg = f'The order of the cyclic group H is at least 2, but it is {self.modulus}.'
raise ParameterError(error_msg)
size = space.prepare().size_
if self.initial is not None:
return np.asarray(self.initial, dtype=float).reshape(size, 2)
return np.random.default_rng(self.random_state).integers(0, self.modulus, (size, 2)).astype(float)
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of pairs on a ball of the free group of rank 2 and the linear rule."""
super()._prepare(context)
space = CayleySpace(free_group(2), ball=self.radius)
pairs = self._get_pairs(space)
self.system_ = System(
self.label,
elements=[PairCellElement('cells', first=pairs[:, 0], second=pairs[:, 1], space=space)],
interactions=[SurjectiveLinearRuleInteraction('rule', target='cells', modulus=self.modulus)],
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
PairCellElement, fromElement
Interactions:
SurjectiveLinearRuleInteraction, fromInteraction
class PairCellElement(Element):
"""Cell of an automaton over the product `H x H` of the integers modulo `n`.
For a prime `n` the product is `K^2`. With `space`, the element holds one cell on every site.
Args:
label:
The label of the cells.
first:
The initial first coordinate, an integer from 0 to `n - 1`, or one per cell.
second:
The initial second coordinate, an integer from 0 to `n - 1`, or one per cell.
space:
The space with one cell on every site, such as a group, or `None` for one cell.
Examples:
>>> from skcomplex.systems.computer_science.automata import PairCellElement
>>> PairCellElement('cell', first=1).first
1
"""
def __init__(
self,
label: str,
*,
first: Annotated[float | Array, ZZ] = 0,
second: Annotated[float | Array, ZZ] = 0,
space: BaseSpace | None = None,
) -> None:
super().__init__(label, space=space)
self.first = first
self.second = second
class SurjectiveLinearRuleInteraction(Interaction):
"""Linear rule on pairs, `q1(x(ga)) + q1(x(ga^-1)) + q2(x(gb)) + q2(x(gb^-1))`.
The maps are `q1(h, k) = (h, 0)` and `q2(h, k) = (0, h)`, over the field of a prime number of elements.
Args:
label:
The label of the interaction.
target:
The cells on the free group, whose states `first` and `second` the rule updates.
modulus:
The prime size of the field `K`.
Examples:
>>> from skcomplex.systems.computer_science.automata import SurjectiveLinearRuleInteraction
>>> SurjectiveLinearRuleInteraction('rule', target='cells', modulus=3).modulus
3
"""
def __init__(self, label: str, *, target: Role = 'cells', modulus: int = 2) -> None:
super().__init__(label)
self.target = target
self.modulus = modulus
def _get_function(self) -> Callable[..., tuple[Array, Array]]:
"""Return the rule on the pairs at `a`, `a^-1`, `b`, and `b^-1`."""
modulus = self.modulus
def linear(*values: Array, **kwargs: object) -> tuple[Array, Array]:
first = values[:4]
return (first[0] + first[1]) % modulus, (first[2] + first[3]) % modulus
return linear
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the rule of the pairs as the law.
Args:
context:
The namespace of the elements a binding of the roles names.
"""
super()._prepare(context)
states = (context.target.first, context.target.second)
self.laws_: list[BaseLaw] = [
UpdateLaw(states, self._get_function(), neighborhood=FREE_GENERATORS, label=self.label),
]