Conway's famous Game of Life is a cellular automaton with the following rules, where
To model this as a system of linear inequalities suitable for integer programming and pseudo-Boolean SAT solving, we rewrite the rules into a single condition:
It can be quickly verified that both systems are equivalent, but the latter is much easier to translate into pure linear inequalities.
We start by encoding that
So for
Now we encode
If
This completes the model construction, which is implemented as modelGOL(width, height, timesteps)
, where width and height specify the bounding box. To ensure that our simulated cells always stay within the bounds, we additionally force all cells on the boundary to be dead for all timesteps.
To run Game of Life backwards, we simply restrict reversePlay(width, height, timesteps, cells)
and find a solution in 4.8s using the pseudo-Boolean SAT solver Exact:
It also only takes only 10.7s to prove that no starting pattern exists which forms the "LIFE" example after 4 instead of 3 iterations.
To search for oscillators, i.e. patterns that repeat after a certain period, we need to add another binary auxiliary variable
Now we make sure that the patterns repeat after the period
As an example, we can look at period-3 oscillators, which are quite rare due to the binary nature of Game of Life. Again, using the Exact solver, we can prove that the following pattern called ‘Jam’ is indeed the smallest possible period-3 oscillator in a
Using the Cube-and-Conquer SAT solver treengeling, we can also show in just 20 minutes that no period-5 oscillator can exist in a 7x7 bounding box, proving optimality of the Fumarole 7x8 period-5 oscillator. One can additionally prove that no period 5 oscillator with fewer tiles than Fumarole can exist in a 7x8 bounding box in around 2 hours.
Since their installation can be quite tedious, you will find short installation instructions for the Exact Solver and the Or-Tools for Ubuntu here.
Install the required build tools:
sudo apt install build-essential lsb-release -y
sudo snap install cmake --classic
Download the binary here, then compile:
mkdir -p or-tools && tar -xzf or-tools_*.tar.gz --strip-components=1 -C or-tools && cd or-tools
make test
sudo cp bin/* /usr/local/bin
sudo cp -r lib/* /usr/local/lib
sudo cp -r share/* /usr/local/share
Now finally the CP-SAT solver can be used as:
solve --solver=sat --num_threads=16 --input=test.mps --sol_file=test.sol
Install the required build tools:
sudo apt-get install build-essential libbz2-dev coinor-libcoinutils-dev libboost-all-dev -y
To compile the solver:
git clone https://gitlab.com/nonfiction-software/exact.git && cd exact
git submodule init && git submodule update
mkdir soplex_build && cd soplex_build
cmake ../soplex -DBUILD_TESTING="0" -DSANITIZE_UNDEFINED="0" -DCMAKE_BUILD_TYPE="Release" -DBOOST="0" -DGMP="0" -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS="0" -DZLIB="0"
make -j 8
sudo make install
cd ../build_debug && cmake .. -DCMAKE_BUILD_TYPE="Release" -Dsoplex="ON" -Dcoinutils="ON"
make -j 8
make install
Now finally the pseudo-Boolean SAT solver can be used as:
Exact test.mps
(c) Mia Muessig