Lecture 10: Cellular automatons =============================== Before this class you should: .. include:: prep10.txt Before next class you should: .. include:: prep11.txt Note taker: Samuel Manley Today's class introduced Cellular Automata including: * What is Cellular Automata * What is 0-D Cellular Automata * What is 1-D Cellular Automata * Wolfram's Cellular Automata Experiments * Classifying Cellular Automata * Turing Machine * Universality * Principle of Computational Equivalence What is Cellular Automata ------------------------- A cellular automaton is a model of a world governed by very simple physics. The term "cellular" refers to the fact that the world is divided into discrete chunks called cells, forming a structured grid. An "automaton" is a type of machine that performs computation, often as a mathematical abstraction. Cellular automata operate based on predefined rules that dictate how the system evolves over time. Time itself is divided into discrete steps, and these rules specify how to update the state of the world at each step. For example, in a single-cell cellular automaton, the evolution can be represented as follows: Example #1: Single-cell CA: :math:`X_i, X_0 = 0` - **Rule #1**: :math:`X_i = X_{i-1} + 1` - **Rule #2**: :math:`X_i = (X_{i-1} + 1) \mod 2` Most Wolfram's cellular automata are deterministic, meaning that given the same initial state, they always produce the same result. Other models exist where randomness plays a role. What is 1-D Cellular Automata ----------------------------- A cellular automaton (CA) is said to have dimensions when its cells are arranged in a contiguous space where certain cells are considered "neighbors." In the case of one-dimensional (1-D) cellular automata, there are three natural configurations: * **Finite sequence**, where a finite number of cells are arranged in a straight row. * **Ring**, in which a finite number of cells are arranged in a circular structure, ensuring that the endpoints are connected. * **Infinite sequence**, which consists of an unlimited number of cells arranged in a linear fashion. These configurations define the spatial structure of a 1-D CA, influencing how cells interact and evolve over time. To Create a one one-dimensional array the following code can be used: .. code-block:: python import numpy as np rows = 5 cols = 11 array = np.zeros((rows, cols), dtype=np.uint8) array[0, 5] = 1 print(array) +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ Wolfram's Cellular Automata Experiments --------------------------------------- The rules that govern how a system evolves over time rely on the concept of a "neighbourhood." This neighbourhood defines how a cell's state is influenced by its surroundings. Stephen Wolfram's experiments in the 1980s explored these ideas using a model where each cell could exist in one of two states: either 0 or 1. In his approach, each cell's neighbourhood consisted of three cells, including itself and its two adjacent neighbors. The behavior of the system is determined by a set of predefined rules. These rules can be represented as a table that maps the current state of a neighbourhood to the next state of the centre cell. +---------+-----+-----+-----+-----+-----+-----+-----+-----+ | prev | 111 | 110 | 101 | 100 | 011 | 010 | 001 | 000 | +---------+-----+-----+-----+-----+-----+-----+-----+-----+ | next | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | +---------+-----+-----+-----+-----+-----+-----+-----+-----+ Classifying Cellular Automata Experiments ----------------------------------------- Wolfram proposed that the behavior of cellular automata (CAs) can be grouped into four distinct classes: **Class 1** The simplest and least interesting CAs are those that evolve from almost any starting condition to the same uniform pattern; an example of this is Rule 0. **Class 2** Consists of simple patterns with nested structures, such as Rule 50. .. image:: images/chap05-1.png :width: 465 :alt: Example of Rule 50 Cellular Automata **Class 3** Includes CAs that generate apparent randomness, with Rule 30 being a notable example. .. image:: images/chap05-4.png :width: 465 :alt: Example of Rule 30 Cellular Automata **Class 4** Some one-dimensional CAs, most notably Rule 110, are Turing complete. This was rigorously demonstrated by Matthew Cook, who proved that Rule 110 can emulate a universal computer, meaning it has the computational power to perform any computable function. .. image:: images/chap05-5.png :width: 465 :alt: Example of Rule 110 Cellular Automata Turing Machine --------------- The abstract computer proposed by Alan Turing in 1936 is known as a Turing machine. It is a one-dimensional cellular automaton that extends infinitely in both directions. This machine is augmented with a read-write head, which, at any given time, is positioned over a single cell. The machine also maintains a register to record its current state and follows a table of rules to dictate its operations. The rule table specifies an action for each combination of the machine's state and the state of the cell under the read-write head. The set of actions includes modifying the cell's value and moving the head one position to the left or right. This simple yet powerful model forms the foundation of modern computing theory and provides insight into the capabilities and limits of computation. Universality ------------ The Turing Machine (TM) is particularly useful because it allows us to characterize the set of functions that can be computed by it. This set is referred to as "Turing computable." Interestingly, nearly every reasonable model of computation that has been proposed is Turing complete, meaning it can simulate a Turing Machine. Some of these computational models differ significantly from Turing Machines, yet they still possess the same computational power. This observation leads to the Church-Turing Thesis, which states that "Turing computability is the right, or at least natural, definition of computability." This thesis suggests that any function that can be effectively computed can be computed by a Turing Machine or an equivalent model. One particularly interesting alternative computational model is Rule 110, a cellular automaton (CA). Rule 110 is remarkable for its simplicity while still being computationally universal, meaning it is capable of performing any computation that a Turing Machine can execute. Principle of Computational Equivalence -------------------------------------- Classes 1 and 2 exhibit behavior that is "obviously simple," making their dynamics straightforward to understand. Class 3, while still simple in a sense, is less obviously so. In a way, perfect randomness is just as simple as perfect order, and true complexity emerges in the space between these two extremes. Wolfram asserts that Class 4 behavior is not just an anomaly but rather a common phenomenon in the natural world. Furthermore, he argues that nearly all systems exhibiting this behavior are computationally equivalent, meaning they share fundamental computational properties despite their apparent differences. Attributions ------------ [1] Think Complexity by Allen B. Downey.