Cellular Automata/Counting Preimages

Preimages are configurations in the past that lead in one step to the present configuration.

Reversing the direction of time


The local transition function and the global transition function define the evolution of cellular automata in the forward time direction. To calculate preimages from the present configuration, inverses of the forward mappings must be defined.

The preimages of a single cell $$c_x^t$$ are the locally valid neighborhoods $$n_x^{t-1}$$ defined by the inverse of the local transition function


 * $$ f^{-1}(c_x^t) = \{ n_x^{t-1} \in S^N \; | \; f(n_x^{t-1})=c_x^t \} $$

Preimages $$C^{t-1}$$ of a configuration $$C^t$$ are defined by the inverse of the global transition function


 * $$ F^{-1}(C^t) = \{ C^{t-1} \in S^Z \; | \; f(C^{t-1})=C^t \} $$

Locally valid neighborhoods of adjacent cells must overlap correctly to become globally valid. De Bruijn diagrams describe how sequences can overlap an thus provide a method to calculate global inverses knowing the local inverse.

The number $$p$$ of preimages $$C^{t-1}$$ can vary from none to many, depending on the rule and the present configuration $$C^t$$, arising questions about the injectivity, surjectivity and reversibility of the rule.

De Bruijn diagrams


De Bruijn diagrams come from the theory describing shift registers. Its nodes are strings $$w$$ of symbols over some alphabet, usually all strings of a fixed length. Its directed links describe how this strings overlap if one of them is shifted. Here only shifts of a single cell are described.

There is a link from a source node $$w_s = a \alpha$$ to a drain node $$w_d = \beta b$$ if string $$w_s$$ overlap with string $$o_R$$ shifted right by one symbol. This means that the overlapping source substring $$\alpha$$ ($$w_s$$ without the start symbol $$a$$) is equal to the overlapping drain substring $$\beta$$ ($$w_d$$ without the end symbol $$b$$).

The topological matrix of the De Bruijn diagram is


 * $$ d_{w_s w_d} =

\begin{cases} 1, &  \alpha = \beta \\ 0, &  \alpha \neq \beta \end{cases} $$

For the diagram to be easier to read and use on cellular automata this book uses a diagram representation, where all the nodes are drawn twice. Nodes on the left are source points of links and nodes on the right are drain points of links. The direction of the links is chosen to point in the increasing direction of cell position indexes.


 * See also
 * There is more about De Bruijn diagrams in references.

Overlapping of adjacent neighborhoods


The overlap $$o_i$$ is the group cells from the overlapping neighborhoods of a pair of adjacent cells $$c_x c_{x+1}$$. The size of the overlapping $$k-1$$ is one cell less than the size of the neighborhood.


 * $$ o_x = c_{x+1-k_0} c_{x+2-k_0} \dots c_{x+k-k_0-1} $$

A compact representation of the overlap is a number with $$k-1$$ digits base $$|S|$$.


 * $$ o_x = \sum_{i=0}^{k-2}{c_{x+1-k_0+i} |S|^{k-2+i}} =

c_{x+1-k_0} |S|^{k-2} + c_{x+2-k_0} |S|^{k-2} + \dots + c_{x+k-k_0-1} |S|^0 $$

If a cell sequence $$... c_{x-2} c_{x-1} c_x c_{x+1} c_{x+2} c_{x+3} ...$$ is cut (or joined) into two parts between $$c_x$$ and $$c_{x+1}$$, the neighborhood of the last cell in the left part $$... c_{x-2} c_{x-1} c_x$$ is overlapping with the neighborhood of the first cell on the right part $$c_{x+1} c_{x+2} c_{x+3} ...$$. The overlap $$o_x$$ at the cut (or junction) is defined as above and is used to describe the boundaries of sequences.

Preimage matrix


The first step to the preimage matrix is constructing a De Bruijn diagram representing preimages of a single cell in a cellular automaton. Its nodes are all $$|S|^{k-1}$$ different overlaps of neighborhoods. The source nodes $$o_L$$ are overlaps on the left side of the cell and the drain nodes $$o_R$$ are overlaps on the right side of the cell. The links represent neighborhoods $$n$$ and connect nodes $$o_L$$ and $$o_R$$ according to the next two decompositions:
 * the neighborhood $$n=c_L o_R$$ is formed from the remaining left cell $$c_L$$ and the right overlap $$o_R$$ or
 * the neighborhood $$n=o_L c_R$$ is formed from the left overlap $$o_L$$ and the remaining right cell $$c_R$$

The topological matrix of the diagram is a square of $$|S|^{k-1} \times |S|^{k-1}$$ elements.


 * $$ D =

\left[ \begin{matrix} d_{00} & d_{01} & \cdots \\ d_{10} & d_{11} & \cdots \\ \vdots & \vdots & \ddots \end{matrix} \right] $$

The value of an element is $$1$$ if there is a link between nodes $$o_L o_R$$ and $$0$$ else.


 * $$ d_{o_L o_R} =

\begin{cases} 1, &  o_L c_R =  c_L o_R = n \\ 0, &  \mbox{else} \end{cases} $$

The next step is to form a symbolic De Bruijn matrix, where elements are link labels. A link representing the neighborhood $$n$$ is labeled according to the output cell value $$c=f(n)$$ defined by the local transition function. Node pairs without a link can be labeled with a dot.


 * $$ d_{o_L o_R} =

\begin{cases} f(n), &  o_L c_R =  c_L o_R = n \\ . ,  &  \mbox{else} \end{cases} $$

The last step is to form preimage matrices $$D(c)$$ one for each of the $$|S|$$ available cell states $$c$$. There is a link between a pair of nodes $$o_L o_R$$ only if the relative neighborhood $$n$$ leads to the desired cell value $$c$$.


 * $$ d_{o_L o_R}(c) =

\begin{cases} 1, &  o_L c_R =  c_L o_R = n \wedge f(n)=c \\ 0, &  \mbox{else} \end{cases} $$

The preimage matrix of a sequence
Before the definition of the preimage matrix can be extended to a sequence of cells $$\alpha$$ the meaning of the matrix elements must be defined, so the definition can be checked against it.

Entries $$d_{o_L o_R}$$ in the matrix $$D(\alpha)$$ represent the number of preimages of length $$|\alpha|+k-1$$ that begin with the left overlapping $$o_L$$ and end with the right overlapping $$o_R$$.


 * $$ \alpha^{t-1}=o_L\beta_R=\beta_L o_R \;\wedge\;  F(\alpha^{t-1})=\alpha^t

\quad\Rightarrow\quad |F^{-1}(\alpha^t)| = d_{o_L o_R}(\alpha^t) $$

The preimage matrix of a string of cells $$\alpha = c_p c_{p+1} \dots c_q$$ is the multiplied chain of single cell matrices


 * $$ D(\alpha) = D(c_p c_{p+1} \dots c_q) = \prod_{x=p}^{q} D(c_x) = D(c_p) \cdot D(c_{p+1}) \cdots D(c_q) $$

The preimage matrix of an empty string $$\varepsilon$$ is an identity matrix.


 * $$ D(\varepsilon) = I $$

Preimage boundary conditions


The preimage vector consists of $$|S|^{k-1}$$ nonnegative integer entries, one for each of the possible neighborhood overlaps or nodes of the preimage diagram.

Elements $$p_i$$ of the preimage vector $$b_x$$ count the preimages that contain an overlap $$o_x=i$$ of value $$i$$ at position $$x$$ in the present cell sequence.


 * $$ b_x = [p_0, p_1, \dots, p_{i-1}, p_{i}, p_{i+1}, \dots, p_{|S|^{k-1}-1}] $$

The preimage vector is used to describe the boundary or more precisely it can describe the preimage count at one side of a junction of two strings.
 * to describe the right boundary of the string $$\alpha = \dots c_{x-1} c_x$$ the right boundary vector $$b_R$$ is used, it counts preimages to the right from the junction
 * to describe the left boundary of the string $$\alpha = c_{x+1} c_{x+2} \dots$$ the left boundary vector $$b_L$$ is used, it counts preimages to the left from the junction

The unrestricted boundary is usually used to avoid any specific boundary. It is assumed that there is exactly one preimage for each overlap. All the entries in the vector are $$1$$.


 * $$ b_u = [1,1,\dots,1] \qquad  |b_u|=|S|^{k-1}$$

Since there can be an infinite number of preimage for a semi-infinite sequence, usually only periodic sequences are used, counting only preimages of the period $$\alpha$$


 * $$ b_L = b_u D(\alpha) \,$$
 * $$ b_R = D(\alpha) b_u^T $$

Quiescent and ether backgrounds can be represented by periodic sequences.


 * See also
 * Cellular Automata/Boundary Conditions for more details on boundary conditions

Counting preimages
The number of preimages $$p$$ (paths through the network) of a sequence $$\alpha$$ with the left boundary condition $$b_L$$ and the right boundary condition $$b_R$$ is defined as


 * $$ p = b_L D(\alpha) b_R^T $$

The unrestricted boundary is commonly used and it counts all the preimages of a sequence $$D(\alpha)$$ exactly once. The number of preimages is simply the sum of all elements in the preimage matrix $$D(\alpha)$$.


 * $$ p = b_u D(\alpha) b_u^T \,$$

Preimages of a cyclic string of cells
Since a string in a cyclic lattice must have the same overlapping at its left and right side, only elements on the diagonal of the De Bruijn matrix form valid preimages. The number of all preimages of a string $$\alpha$$ is the sum of elements on the diagonal.


 * $$ p = \sum_{i=0}^{|S|^{k-1}} d_{ii}(\alpha) $$

Garden of eden
A garden of eden sequence does not have preimages. For finite strings on an infinite lattice this is true exactly when the De Bruijn matrix of the string is a zero matrix $$M_0$$ (all elements are zero).


 * $$ D(\alpha) = M_0 \Rightarrow  \alpha \in G$$

Any string which substring is a garden of eden is a garden of eden.


 * $$ \forall \beta_L, \beta_R \; [ \alpha \in G \Rightarrow  \beta_L \alpha \beta_R \in G ] $$

A garden of eden can be the consequence of the boundary conditions, both restricted of cyclic boundaries.

Proof of the preimage matrix equation for sequences
The proof of the formula on sequences is an induction on the length of the string.
 * Base ($$l=0,1$$)
 * If the length of the string is $$0$$ than there is no shift and nodes are linked only to themselves.
 * For the string of length $$1$$ the meaning of the single cell preimage matrix elements is evident from the definition.


 * Induction
 * $$ D(\alpha a) = D(\alpha)D(a) \,$$

Software

 * 1) DDLab Tools for researching Cellular Automata, Random Boolean Networks, multi-value Discrete Dynamical Networks, and beyond; by Andy Wuensche.
 * 2) Iztok Jeras, Algorithms for computing preimages of cellular automata configurations TAR.BZ2
 * 3) Cellular Automata Pre-Image Generator CAPIG is a user-friendly free software made to find pre-images according to the user chosen configuration.