Power-series automaton
The automaton τ(x)(n) = x(n) - t x(n + 1) over the power series K[[t]].
- Class:
PowerSeriesAutomatonSystem - Import:
from skcomplex.systems.computer_science.automata import PowerSeriesAutomatonSystem - Field:
computer_science/automata - Topics:
lattice,infinite alphabet,power series,bijective - 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 PowerSeriesAutomatonSystem
trajectory = PowerSeriesAutomatonSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
size |
31 |
order |
8 |
field |
'QQ' |
initial |
None |
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 | vector |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class PowerSeriesAutomatonSystem(BaseSystem):
"""The automaton `τ(x)(n) = x(n) - t x(n + 1)` over the power series `K[[t]]`.
The power series are formal, on a ring. The alphabet `K[[t]]` has infinite dimension, and the automaton is bijective
with the inverse `sigma(y)(n) = sum_j t^j y(n + j)`, which is not continuous, so it is no cellular automaton
(Ceccherini-Silberstein and Coornaert 2023, Exercise 1.37). The cells hold the series truncated at the order, which
keeps every coefficient below it exact, since the coefficient of `t^i` of the image reads coefficients of `t^i` and
`t^(i - 1)` alone. From the constant series 1 at one cell, the cells at step `s` hold `C(s, k) (-t)^k` at the `k`-th
cell to the left, as long as `k` stays below the order. The system has the coefficients `cells.value`.
Args:
size:
The number of cells of the ring.
order:
The number of coefficients kept.
field:
The field `K`, `'QQ'`, `'RR'`, or `'GF(p)'`.
initial:
The initial coefficients, an array of shape `(size, order)`, or `None` for the series 1 in the middle cell.
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.
Examples:
>>> from skcomplex.systems.computer_science.automata import PowerSeriesAutomatonSystem
>>> PowerSeriesAutomatonSystem(5, order=3).prepare().system_.elements[0].value.shape
(5, 3)
"""
field = 'computer_science/automata'
topics = ('lattice', 'infinite alphabet', 'power series', 'bijective')
references = ('Ceccherini-Silberstein and Coornaert 2023',)
until = 12
dt = 1
def __init__(
self,
size: int = 31,
*,
order: int = 8,
field: str = 'QQ',
initial: npt.ArrayLike | None = None,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.size = size
self.order = order
self.field = field
self.initial = initial
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of the cells of truncated series and their difference."""
super()._prepare(context)
ring = PowerSeriesSpec(self.order, self.field)
if self.initial is None:
values = np.zeros((self.size, self.order))
values[self.size // 2, 0] = 1.0
else:
values = np.asarray(self.initial, dtype=float)
cells = PowerSeriesCellElement('cells', ring=ring, value=values, space=LatticeSpace(self.size))
self.system_ = System(
self.label,
elements=[cells],
interactions=[PowerSeriesDifferenceInteraction('difference', target='cells', ring=ring)],
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
PowerSeriesCellElement, fromElement
Interactions:
PowerSeriesDifferenceInteraction, fromInteraction
class PowerSeriesCellElement(Element):
"""Cell of an automaton over a ring `K[[t]]` of truncated formal power series.
The series are truncated at an order. The cell holds the value `value` in the ring it is given, the coefficients
`a_0, ..., a_{order - 1}` of a series, which a local rule reads as one row per cell.
Args:
label:
The label of the cell or the cells.
ring:
The truncated power series ring of the values.
value:
The coefficients of the series, one row per cell, or a number for every coefficient.
space:
The space with one cell on every site, such as a lattice, or `None` for one cell.
Examples:
>>> from skcomplex.core.components import PowerSeriesSpec
>>> from skcomplex.systems.computer_science.automata import PowerSeriesCellElement
>>> PowerSeriesCellElement('cell', ring=PowerSeriesSpec(3)).ring.order
3
"""
def __init__(
self,
label: str,
*,
ring: PowerSeriesSpec = RATIONAL_SERIES,
value: npt.ArrayLike = 0.0,
space: BaseSpace | None = None,
) -> None:
super().__init__(label, space=space)
self.ring = ring
self.value = value
def _get_hints(self) -> dict[str, object]:
"""Return the hint of the value, in the ring of the cell.
The ring describes the value, so it is no value itself.
"""
return {'value': Annotated[object, self.ring]}
class PowerSeriesDifferenceInteraction(Interaction):
"""Difference `τ(x)(n) = x(n) - t x(n + 1)` of cells holding truncated power series.
The coefficients of every series sit on the last axis of the state `value`, and the product with `t` shifts them
by one place in the ring.
Args:
label:
The label of the interaction.
target:
The cells whose state `value` the difference changes.
ring:
The truncated power series ring of the values.
Examples:
>>> from skcomplex.core.components import PowerSeriesSpec
>>> from skcomplex.systems.computer_science.automata import PowerSeriesDifferenceInteraction
>>> PowerSeriesDifferenceInteraction('difference', target='cells', ring=PowerSeriesSpec(3)).ring.order
3
"""
def __init__(self, label: str, *, target: Role = 'cells', ring: PowerSeriesSpec = RATIONAL_SERIES) -> None:
super().__init__(label)
self.target = target
self.ring = ring
def _get_function(self) -> Callable[[Array, Array], Array]:
"""Return `x(n) - t x(n + 1)` in the ring, with the coefficients on the last axis."""
ring = self.ring
variable = ring.get_coefficients_of(ring.ring.gen())
def difference(here: Array, right: Array, **kwargs: object) -> Array:
return ring.reduce(here - ring.multiply(variable, right))
return difference
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the difference with the cell to the right as the law.
Args:
context:
The namespace of the elements a binding of the roles names.
"""
super()._prepare(context)
value = context.target.value
self.laws_: list[BaseLaw] = [
UpdateLaw(value, self._get_function(), neighborhood=FORWARD, label=self.label),
]