# Cellular Automata/Mathematical Model

Formally, a cellular automaton is represented by the 4-tuple $(Z,S,N,f)$ where:
* $Z$ is the finite or infinite lattice
* $S$ is a finite set of cell states or values
* $N$ is the finite neighborhood
* $f$ is the local transition function defined by the transition table or the rule
The lattice is a finite or infinite discrete regular grid of cells on a finite number of dimensions. Each cell is defined by its discrete position (an integer number for each dimension) and by its discrete value (one of a finite set of integers). Time is also discrete. The future state of a cell (time $t+1$) is a function of the present state (time $t-1$) of a finite number of cells surrounding the observed cell called the neighborhood.

## One dimensional first order cellular automata

For the sake of readability the next definitions focus on one dimensional first order cellular automata.

### Lattice, cell and configuration

The infinite global state is a configuration $C\in S^{Z}$. $S$ is the finite set $k=|S|<\infty$ of cell states $c\in S$, for formalization purposes the states are enumerated $S=\{0,1,\dots ,k-1\}$. The lattice $Z$ is the infinite cyclic group of integers $\{...,-1,0,1,2,...\}$. The position of each cell inside the lattice is described by the position index $x\in Z$. Configurations are usually written as strings.
    $C=\dots c_{-1}c_{0}c_{1}c_{2}\dots c_{x-1}c_{x}c_{x+1}\dots$
The finite global state is a finite configuration $C\in S^{Z}$, where $Z$ is a finite lattice, a finite set $\{0,1,2,...,N-1\}$ of $N$ integers.
    $C=c_{0}c_{1}\dots c_{x-1}c_{x}c_{x+1}\dots c_{N-2}c_{N-1}$
Finite configurations and their parts can be generally written as strings denominated by small Greek letters from the beginning of the alphabet ($\alpha$, $\beta$, ...).

#### The number notation for strings

Strings can be compactly written as numbers. A string of $N$ characters $C$ from a set of $|S|$ symbols is translated into a $N$-digit base $|S|$ number. Usually strings are indexed from the left to the right but for the number notation indexing from right to left is more intuitive.
    $\alpha =\sum _{i=0}^{N-1}k^{N-1-i}c_{i}=k^{N-1}c_{0}+\cdots +k^{1}c_{N-2}+k^{0}c_{N-1}$

### Neighborhood, local transition function and rule
#### Neighborhood

The neighborhood $A$ of size $m=|A|$ is defined by the set of relative positions inside the configuration.
    $A=\{a_{0},a_{1},\dots ,a_{m-1}\}$
By applying the set $A$ onto an observed cell $c_{x}$ the neighborhood of this cell is obtained.
    $n_{x}=c_{x+a_{0}}c_{x-a_{1}}\dots c_{x+a_{m-1}}$
The name neighborhood can be used for booth the set of relative distances and for the actual substring of cells related to an observed cell.
A compact representation of the neighborhood value $n_{x}$ is a single integer defined as a number of $m$ digits base $k$.
    $n_{x}=\sum _{i=0}^{m-1}{k^{m-1-i}c_{x+a_{i}}}=c_{x+a_{0}}k^{m-1}+c_{x+a_{1}}k^{m-2}+\dots +c_{x+a_{m-1}}k^{0}$
For definitions of common neighborhoods see Neighborhoods.

#### Local transition function

The local transition function
    $f:S^{N}\mapsto S$
calculates the value of a single future cell $c_{x}$ from the neighborhood of the observed cell in the present.
    $c_{x}^{t+1}=f(n_{x}^{t})$
The transition table defines the local transition function by listing the output value for each input value.
The rule $f$ is a compact representation of the local transition function. It is a single integer defined as a number of $m$ digits base $k$.
    $f=\sum _{i=1}^{k^{m}-1}{f(i)k^{i}}=f(k^{m}-1)k^{k^{m}-1}+\dots +f(1)k^{1}+f(0)k^{0}$

##### See also

* Cellular Automata/Neighborhood for some frequently used neighborhoods
* Cellular Automata/Rule for some special rules
Example:
How to define rule 110 using the above formalization

### Global transition function

The global dynamics of CA are described by the global transition function
    $F:S^{Z}\mapsto S^{Z}$
$F$ translates the current (present) configuration $C^{t}$ into the next (future) configuration $C^{t+1}$
    $C^{t+1}=F\left(C^{t}\right)$
The global transition function $F$ is defined by the local transition function $f$ as
    $F(\dots c_{x-1}c_{x}c_{x+1}\dots )=\dots f(n_{x-1})f(n_{x})f(n_{x+1})\dots$

### Finite lattices and lattice boundaries

Infinite cellular automata have no boundary, so its boundary description $B$ is omitted. But there is no way to simulate an infinite system using a finite system. The simulation must focus on a finite part of length $l$.
The neighborhood used in the local transition function oversteps the lattice boundary for $r_{L}$ cells at the left and $r_{R}$ cells at the right.
There are two common solutions to the overstepping problem:
* the lattice is wrapped into a circle (torus for 2D CA)
* the values of the overstepping parts of the neighborhood are defined explicitly as the boundary $B$

#### Cyclic boundaries

Cyclic boundaries are frequently used as there is no need to explicitly define the boundary value and no external information is introduced into the CA that could otherwise cause interference at the boundaries.
The state of a finite lattice cellular automata is a configuration in the lattice $S^{Z}$, where $Z$ is a cyclic group of integers modulo $N$ ($\{0,1,...,N-1\}$).
    $C=c_{0}c_{1}\dots c_{x-1}c_{i}c_{x+1}\dots c_{N-1}\qquad c\in S$
The cyclic position index is calculated as
    $x_{\circ }=x\mod N\qquad x\leq 0\vee x>N$

#### Explicitly defined boundaries

Explicitly defined boundaries are less common as the simple constant values are useful only for CA where we observe events on a quiescent background with period 1. The boundary can be defined as a single set (the left and the right part combined) of cell values of length $k-1$ (there is no boundary cell with index 0)
    $B=\{b_{-k_{0}},\dots b_{-2},b_{-1},b_{l},b_{N+1},\dots ,b_{k-k_{0}-1}\}\quad b\in S$
For space and time periodic quiescent backgrounds time dependent boundaries can be used $B=B(t)$.

## Generalizations
### Multidimensional cellular automata

The definition of n-dimensional CA is similar to that of one dimensional CA, the lattice becomes n-dimensional and $k$ and $k_{0}$ become vectors of length $n$.

#### 2D cellular automata

The 2D lattice can be tiled with cells in different ways:
* square grid (4-fold rotational symmetry)
* triangular grid (3-fold symmetry) or hexagonal grid (6-fold symmetry)
* quasi periodic grid (Penrose tiling)
2D cellular automata are often used to simulate real dynamic systems (fluid and gas dynamics)

##### See also

* Cellular Automata/Neighborhood for some frequently used neighborhoods

#### Cellular automata on groups

One further generalization of the concept of a CA extends the n-dimensional construct. Given a finitely generated group, $G$, and a alphabet, $A$, we may define the configuration space to be $C=A^{G}$. That is, each configuration is a map from $G$ into $A$. If $G$ is abelian, then the group is isomorphic to some quotient space of $Z^{n}$ and may be regarded as a n-dimensional lattice with possibly periodic boundary conditions. This space admits a group action, where $c^{g}(h)=c(g'h)$ where $g'$ is the inverse of $g$. Any finitely generated group is a metric space, in which the distance between any two elements, $d(g,h)$ can be defined to be the minimum length of the set of paths connecting $g$ and $h$ on the groups Cayley graph. We define a metric on the configuration space, $d(c,c')$ to be 0 if the two configurations are identical, and the infimum of $1/(1+d(e,h))$ over the set of $h$ such that $c$ and $c'$ disagree at $h$ and where $e$ denotes the identity element of the group. We define a cellular automata to be a continuous mapping, $f:C\to C$, that commutes with the group action and an initial configuration $c_{0}$. The evolution of the system is defined by $c_{n+1}=f(c_{n})$.

### Higher order cellular automata

The CA is of higher order if not only the present but past configurations too are used to calculate the future. A second-order local transition function is defined as
    $c_{x}^{t+1}=f(n_{x}^{t},n_{x}^{t-1})$
Second-order local transition functions are often used to construct reversible rules.