# Cellular Automata/Counting Preimages

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

## Contents

## Reversing the direction of time[edit]

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 are the *locally valid neighborhoods* defined by the inverse of the local transition function

Preimages of a configuration are defined by the inverse of the global transition function

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 of preimages can vary from none to many, depending on the rule and the present configuration , arising questions about the injectivity, surjectivity and reversibility of the rule.

## De Bruijn diagrams[edit]

De Bruijn diagrams come from the theory describing shift registers. Its nodes are strings 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 to a drain node if string overlap with string shifted right by one symbol. This means that the overlapping source substring ( without the start symbol ) is equal to the overlapping drain substring ( without the end symbol ).

The topological matrix of the De Bruijn diagram is

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.

## Preimage diagrams and matrices[edit]

### Overlapping of adjacent neighborhoods[edit]

The overlap is the group cells from the overlapping neighborhoods of a pair of adjacent cells . The size of the overlapping is one cell less than the size of the neighborhood.

A compact representation of the overlap is a number with digits base .

If a cell sequence is cut (or joined) into two parts between and , the neighborhood of the last cell in the left part is overlapping with the neighborhood of the first cell on the right part . The overlap at the cut (or junction) is defined as above and is used to describe the boundaries of sequences.

**Example (Overlapping of neighborhoods in rule 110)**:

{{{2}}}

### Preimage matrix[edit]

The first step to the preimage matrix is constructing a De Bruijn diagram representing preimages of a single cell in a cellular automaton. It's nodes are all different overlaps of neighborhoods. The source nodes are overlaps on the left side of the cell and the drain nodes are overlaps on the right side of the cell. The links represent neighborhoods and connect nodes and according to the next two decompositions:

- the neighborhood is formed from the remaining left cell and the right overlap or
- the neighborhood is formed from the left overlap and the remaining right cell

The topological matrix of the diagram is a square of elements.

The value of an element is if there is a link between nodes and else.

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

The last step is to form *preimage matrices* one for each of the available cell states . There is a link between a pair of nodes only if the relative neighborhood leads to the desired cell value .

**Example (De Bruijn and preimage diagrams in rule 110)**:

{{{2}}}

### The preimage matrix of a sequence[edit]

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

Entries in the matrix represent the number of preimages of length that begin with the left overlapping and end with the right overlapping .

The preimage matrix of a string of cells is the multiplied chain of single cell matrices

The preimage matrix of an empty string is an identity matrix.

**Proof:** Proof of the preimage matrix equation for sequences

### Preimage boundary conditions[edit]

The *preimage vector* consists of nonnegative integer entries, one for each of the possible neighborhood overlaps or nodes of the preimage diagram.

Elements of the preimage vector count the preimages that contain an overlap of value at position in the present cell sequence.

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 the*right boundary vector*is used, it counts preimages to the right from the junction - to describe the
*left boundary*of the string the*left boundary vector*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 .

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

Quiescent and ether backgrounds can be represented by periodic sequences.

- See also

- Cellular Automata/Boundary Conditions for more details on boundary conditions

**Example (Some common boundary conditions in rule 110)**:

{{{2}}}

### Counting preimages[edit]

The number of preimages (paths through the network) of a sequence with the left boundary condition and the right boundary condition is defined as

The unrestricted boundary is commonly used and it counts all the preimages of a sequence exactly ones. The number of preimages is simply the sum of all elements in the preimage matrix .

#### Preimages of a cyclic string of cells[edit]

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 is the sum of elements on the diagonal.

#### Garden of eden[edit]

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 (all elements are zero).

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

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

**Example (Garden of eden sequences in rule 110)**:

{{{2}}}

## Proofs[edit]

### Proof of the preimage matrix equation for sequences[edit]

The proof of the formula on sequences is an induction on the length of the string.

- Base ()
- If the length of the string is than there is no shift and nodes are linked only to themselves.
- For the string of length the meaning of the single cell preimage matrix elements is evident from the definition.
- Induction

## References[edit]

- Harold V. McIntosh,
*Linear Cellular Automata Via de Bruijn Diagrams*, August 10, 1991 (HTML, PDF) - Harold V. McIntosh,
*Ancestors: Commentaries on The Global Dynamics of Cellular Automata by Andrew Wuensche and Mike Lesser (Addison-Wesley, 1992)*, July 20, 1993 (HTML, PDF) - Erica Jen,
*Enumeration of Preimages in Cellular Automata*, Complex Systems 3 (5) (1989) 421-456 - Burton Voorhees,
*Predecessors of cellular automata states II. Pre-images of finite sequences*, Phisica D 73 (1-2) (1994) 136-151 - Iztok Jeras, Andrej Dobnikar
*Algorithms for computing preimages of cellular automata configurations*PDF

## Software[edit]

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