Unbounded-alphabet automaton
An additive automaton over the nonnegative integers, x'(n) = x(n - 1) + x(n).
- Class:
UnboundedAlphabetAutomatonSystem - Import:
from skcomplex.systems.computer_science.automata import UnboundedAlphabetAutomatonSystem - Field:
computer_science/automata - Topics:
lattice,integers,additive,pascal triangle - 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 UnboundedAlphabetAutomatonSystem
trajectory = UnboundedAlphabetAutomatonSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
size |
101 |
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 UnboundedAlphabetAutomatonSystem(BaseSystem):
"""An additive automaton over the nonnegative integers, `x'(n) = x(n - 1) + x(n)`.
It starts from a single 1.
Its alphabet has no bound: from a single 1 the cells after `t` steps hold the binomial coefficients `C(t, k)`, so
every row of Pascal's triangle appears. Reduced modulo 2, the rule is the mirror image of the additive automaton
`x(n) + x(n + 1)` of Ceccherini-Silberstein and Coornaert (2023, Example 3.3.8), which this system lifts to the
nonnegative integers. The system has the cells `cells.value`.
Args:
size:
The number of cells of the ring.
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 UnboundedAlphabetAutomatonSystem
>>> int(UnboundedAlphabetAutomatonSystem(9).prepare().system_.elements[0].value.sum())
1
"""
field = 'computer_science/automata'
topics = ('lattice', 'integers', 'additive', 'pascal triangle')
references = ('Ceccherini-Silberstein and Coornaert 2023',)
until = 50
dt = 1
def __init__(
self,
size: int = 101,
*,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.size = size
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of the cells, a single 1, and their additive rule."""
super()._prepare(context)
value = np.zeros(self.size)
value[self.size // 2] = 1.0
self.system_ = System(
self.label,
elements=[PascalCellElement('cells', value=value, space=LatticeSpace(self.size))],
interactions=[AdditiveRuleInteraction('addition', target='cells')],
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
PascalCellElement, fromElement
Interactions:
AdditiveRuleInteraction, fromInteraction
class PascalCellElement(Element):
"""Cell of an automaton over the nonnegative integers.
With `space`, the element holds one cell on every site.
Args:
label:
The label of the cells.
value:
The initial value, a nonnegative integer, or one value per cell.
space:
The space with one cell on every site, such as a lattice, or `None` for one cell.
Examples:
>>> from skcomplex.systems.computer_science.automata import PascalCellElement
>>> PascalCellElement('cell', value=3).value
3
"""
def __init__(
self,
label: str,
*,
value: Annotated[float | Array, NN] = 0,
space: BaseSpace | None = None,
) -> None:
super().__init__(label, space=space)
self.value = value
class AdditiveRuleInteraction(Interaction):
"""Additive rule over the nonnegative integers, `x'(n) = x(n - 1) + x(n)`.
From a single 1 the cells after `t` steps hold the binomial coefficients `C(t, k)`.
Args:
label:
The label of the interaction.
target:
The cells whose state `value` the rule updates.
Examples:
>>> from skcomplex.systems.computer_science.automata import AdditiveRuleInteraction
>>> AdditiveRuleInteraction('addition', target='cells').target
'cells'
"""
def __init__(self, label: str, *, target: Role = 'cells') -> None:
super().__init__(label)
self.target = target
@staticmethod
def _add(left: Array, center: Array, **kwargs: object) -> Array:
"""Return the sum of a cell and its left neighbour."""
return left + center
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the sum with the left neighbour 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._add, neighborhood=PREDECESSORS, label=self.label)]