Interactive companion

Gadgets for two-dimensional majority

Step through the gadgets that embed Boolean circuits into the synchronous majority rule on the square lattice. Every frame below is an exact state of the original two-dimensional dynamics, checked against a direct simulation of the rule; the elementary pieces and the square blocks are the configurations drawn in the paper's figures. The circuit compiler lays any Boolean circuit out on the paper's grid of square blocks and gives the configuration that evaluates it.

From The Two-Dimensional Majority Rule is P-Complete, by Pedro Montealegre and Martín Ríos-Wilson (Facultad de Ingeniería y Ciencias, Universidad Adolfo Ibáñez).

The rule and the code

The rule

Each cell is in state +1 or −1 and all cells update simultaneously. A cell adopts the majority state of its four nearest neighbors and keeps its current state on a tie; equivalently, it takes the strict majority of five votes, its own and its neighbors'.

T T+2

Signals are times

A logical 1 is an early signal: the port is +1 at its reading time T. A logical 0 is a late signal: the port is still −1 at T and becomes +1 by T + 2. A zero is a late signal, not an absent source.

Reading the figures

All cells obey the same rule; colors only distinguish roles. Outlined cells are the ports, and an output port is highlighted at its reading time.

  • +1, background
  • +1, signal
  • −1
  • port

Gadget

t = 0

Keyboard: ← → step, Space play/pause, Home/End first/last frame.

Initial configuration (t = 0) of this case:

How the pieces fit

From gadgets to circuits

Wires and turns carry signals; the duplicator copies them; AND and OR compute. The crossover lets two signals pass through one region, which is the central difficulty in two dimensions. Packed into square blocks of side 153 with a common interface, the pieces tile a grid that evaluates any monotone circuit: the paper's reduction from the monotone circuit value problem.

Reproducibility

The data in data/gadgets.js are produced by tools/build_data.py from a copy of the project's generators (tools/generator/, with SHA-256 provenance). The crossover, AND and OR are the configurations drawn in the paper's figures, read from the PDF by tools/extract_figures.py; the build simulates the rule from their initial panels and requires every panel of each figure to be reproduced exactly. For the other pieces it re-runs the generators' own checks against a direct simulation of the majority rule. For the elementary pieces and the fuse, it then simulates the rule again, independently, for every displayed frame (all frames). It also checks the reading times and the output values stated in the paper.

python3 -B tools/build_data.py        # regenerate and verify the data
python3 -B tools/build_standalone.py  # single-file version in dist/

The circuit compiler has its own tests. One checks every piece of the grid alone, and complete grids for all 970 monotone circuits with up to four gates, against a direct simulation of the rule. Another runs the page's compiler on example circuits, for every input assignment, with an independent simulation of the rule on the full torus. Two scripts check downloaded files, in Golly and from the 0/1 matrix.

python3 -B tools/test_grid.py --direct   # pieces and the 970 circuits, against the rule
node tools/test_grid.cjs --all            # the page's compiler, with the fuse, on the examples and the 970 circuits
python3 -B tools/check_rle_golly.py --bgolly <bgolly> file.rle
python3 -B tools/check_matrix.py file.txt

Embed a gadget

Any gadget can be shown alone, for example inside another page, with ?embed=<gadget>. Optional parameters: case (such as 10 or early), t and autoplay=1.

<iframe src="https://<user>.codefloe.page/<repository>/?embed=crossover&case=10"
        width="100%" height="960" style="border:0" loading="lazy"
        title="Temporal crossover"></iframe>

Gadget names: wire, crossover, turn, and, or, duplicator, block-and, block-or, block-cross, block-dup, fuse.