Skip to content

Muller's pre-injective non-surjective automaton on F2

Muller's automaton on the free group F2, pre-injective but not surjective.

  • Name: muller_automaton
  • Field: computer_science/automata
  • Formalism: lattice dynamics
  • References: Ceccherini-Silberstein and Coornaert 2023

Select this system

from skcomplex.systems import create_simulation, create_system, describe

system = create_system('muller_automaton')
entry = describe('muller_automaton')
trajectory = create_simulation('muller_automaton').prepare().run().trajectory_

Factory

@register_system(
    field='computer_science/automata',
    tags=('group', 'cellular automaton', 'free group', 'Garden of Eden'),
    references=('Ceccherini-Silberstein and Coornaert 2023',),
    defaults={'until': 10, 'dt': 1},
    observables=_pair_observables,
)
def muller_automaton(
    *,
    radius: int = 5,
    modulus: int = 2,
    initial: npt.ArrayLike | None = None,
    random_state: int | np.random.Generator | None = 0,
) -> System:
    """Return Muller's automaton on the free group F2, pre-injective but not surjective.

    The alphabet is `A = H x H` for the cyclic group `H` of order `modulus`, and every cell becomes
    `p1(x(ga)) + p2(x(gb)) + p1(x(ga^-1)) + p2(x(gb^-1))`, where `p1(h, k) = (h, 0)` and `p2(h, k) = (k, 0)`
    (Ceccherini-Silberstein and Coornaert 2023, Section 5.11). The image lies in `H x {0}`, so the automaton is not
    surjective, yet two configurations that differ on a finite set have different images, so it is pre-injective, which
    the Garden of Eden theorem forbids on amenable groups. For a prime modulus it is the linear automaton over `K^2` of
    Section 8.10. Cells on the boundary of the ball read 0 outside it.

    Args:
        radius:
            The radius of the ball of F2.

        modulus:
            The order of `H`, at least 2.

        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.

    Returns:
        system:
            The system, with the coordinates `cells.first` and `cells.second`.

    Raises:
        ParameterError:
            The modulus is below 2.

    Examples:
        >>> from skcomplex.systems.computer_science.automata import muller_automaton
        >>> muller_automaton(radius=2).elements[0].prepare().size_
        17
    """
    return _pair_system(_muller, radius=radius, modulus=modulus, initial=initial, random_state=random_state)

Components

Elements:

  • PairCellElement, from Element

Interactions:

  • LocalRuleInteraction
class PairCellElement(Element):
    """Cell of an automaton over the product `H x H` of the integers modulo `n` with itself, or `K^2` for a prime `n`.

    Args:
        label:
            The label of the cell or the lattice group.

        visual:
            How the element is drawn, or `None` for `default_visual_`.

        first:
            The initial first coordinate, an integer from 0 to `modulus - 1`.

        second:
            The initial second coordinate, an integer from 0 to `modulus - 1`.

        modulus:
            The order `n` of the cyclic group `H`, the size of the field `K` when prime.

    Examples:
        >>> from skcomplex.systems.computer_science.automata import PairCellElement
        >>> PairCellElement('cell', first=1).modulus
        2
    """

    def __init__(
        self,
        label: str,
        visual: VisualSpec | None = None,
        *,
        first: Annotated[float, StateSpec(domain=ZZ)] = 0,
        second: Annotated[float, StateSpec(domain=ZZ)] = 0,
        modulus: Annotated[float, ParameterSpec(domain=RealSet.open(0, oo))] = 2,
    ) -> None:
        super().__init__(label, visual=visual)
        self.first = first
        self.second = second
        self.modulus = modulus

class LocalRuleInteraction(Interaction):
    """Local rule of a cellular automaton, which sets the next value of every cell from its ordered neighbourhood.

    The rule is a table of the next value of every configuration of the neighbourhood, `TableSpec`, a rule of the sum
    of the neighbourhood, `TotalisticSpec`, a rule of the cell and the sum of its neighbours, `OuterTotalisticSpec`, an
    object whose `table()` returns a `TableSpec`, or a function. A function receives one array per neighbour of every
    read state, in neighbourhood order, with one value per cell, the uniform array `random` when the rule is stochastic,
    and the parameters of the bound group it names, and returns the next values of the states, one array per state. A
    state of several components per cell, such as a truncated power series of `PowerSeriesSpec`, reaches a function as
    one row of components per cell. A `StateTranslationNeighborhood` reads a group space at the product of every site
    and the group element that the first read state holds there.

    Args:
        label:
            The label of the interaction, unique among the parts of its system.

        target:
            The path of the group on the cells of a lattice, the nodes of a network, or a Cayley graph.

        state:
            The name of the state the rule sets, or a tuple of the names of the states it sets together.

        rule:
            The table, the totalistic rule, or the function.

        neighborhood:
            The ordered neighbourhood of every cell, such as `VonNeumannNeighborhood(center=True)`.

        reads:
            The names of the states whose neighbourhoods a function reads, or `None` for the states it sets.

        schedule:
            `'synchronous'`, `'random-sequential'`, `'random-site'`, `'checkerboard'`, or `'colored'`.

        stochastic:
            Whether a function receives the uniform random array `random`.

    Raises:
        ValidationError:
            The state or the read states are not names, or the neighbourhood is not a neighbourhood.

    Examples:
        >>> from skcomplex.core.components.interactions import LocalRuleInteraction
        >>> from skcomplex.core.components.spaces import VonNeumannNeighborhood
        >>> from skcomplex.core.specs import TotalisticSpec
        >>> parity = TotalisticSpec({1: 1, 3: 1})
        >>> around = VonNeumannNeighborhood(n_dim=1, center=True)
        >>> rule = LocalRuleInteraction('parity', target='cells', state='cell', rule=parity, neighborhood=around)
        >>> rule.schedule
        'synchronous'
    """

    law_classes: ClassVar[tuple[type[BaseLaw], ...]] = (LocalRuleLaw,)

    def __init__(
        self,
        label: str,
        *,
        target: Annotated[str, RoleSpec(elements=(ElementKind.ANY,), states=('state', 'reads'))],
        state: str | tuple[str, ...],
        rule: object,
        neighborhood: BaseNeighborhood,
        reads: Sequence[str] | None = None,
        schedule: str = 'synchronous',
        stochastic: bool = False,
    ) -> None:
        super().__init__(label)
        self.target = target
        self.state = state
        self.rule = rule
        self.neighborhood = neighborhood
        self.reads = reads
        self.schedule = schedule
        self.stochastic = stochastic

    def _get_names(self) -> tuple[str, ...]:
        """Return the names of the states the rule sets."""
        return (self.state,) if isinstance(self.state, str) else tuple(self.state)

    def _check(self) -> None:
        """Raise an error for states that are not names, or a neighbourhood that is not one.

        Raises:
            ValidationError:
                The state or the read states are not names, or the neighbourhood is not a neighbourhood.
        """
        super()._check()
        names = [*self._get_names(), *(self.reads or ())]
        if not names or not all(isinstance(name, str) and name.isidentifier() for name in names):
            error_msg = f'The local rule {self.label!r} sets {self.state!r} and reads {self.reads!r}. Give state names.'
            raise ValidationError(error_msg)
        if not isinstance(self.neighborhood, BaseNeighborhood):
            error_msg = f'The neighbourhood of the local rule {self.label!r} is {self.neighborhood!r}. Give one.'
            raise ValidationError(error_msg)

    def _get_laws(self, namespace: SimpleNamespace) -> list[BaseLaw]:
        """Return the local rule law of the states of the target.

        Args:
            namespace:
                The namespace of the symbols the laws can use, with `namespace.target`.

        Returns:
            laws:
                The local rule law.
        """
        targets = tuple(getattr(self._get_member(namespace, 'target'), name) for name in self._get_names())
        reads = (
            None
            if self.reads is None
            else tuple(getattr(self._get_member(namespace, 'target'), name) for name in self.reads)
        )
        return [
            LocalRuleLaw(
                targets[0] if isinstance(self.state, str) else targets,
                self.neighborhood,
                self.rule,
                reads=reads,
                schedule=self.schedule,
                stochastic=self.stochastic,
                label=self.label,
            ),
        ]