2D Puzzle Visualizations of Boolean Formulae

Eric Holloway

September 16, 2021

1 Randomly Sampling Disjunctive Normal (DNF) Formulae

A DNF formula is an OR of AND terms, such as (V1 AND NOT V2) OR (NOT V1 AND V2) to represent V1 XOR V2.

The puzzles are generated by randomly sampling a DNF formula from formulae with a set number of variables N, terms T, and term size K.

1.1 Example of DNF Formula

For example, with the setting N = 4, T = 2, K = 3, here is a formula that fits these settings:

The variables are V1, V2, V3, and V4.

The terms are:

  1. V1 AND NOT V2 AND V3
  2. V2 AND V3 AND V4

The literals are:

  1. V1
  2. V2
  3. NOT V2
  4. V3
  5. V4

1.2 Sampling Method

Here is how the sampling works.

  1. The sampling process is given the number of variables N, number of literals per term K and the number of terms T.
  2. Each term is randomly fills with literals, selecting uniformly from all possible literals.

2 Converting Formula to 2D Grid

To visualize the formula, the truth table generated by the boolean formulae is displayed as a 2D grid.

2.1 Generating 2D Coordinates

The logic variables are split into two groups, and each group’s binary values are converted into integers to form the coordinates.

For instance, with four variables we have two groups for the X and Y coordinates. I.e. X = {V1, V2} and Y = {V3, V4}. If we assign the variables as: V1 = 0, V2 = 1, V3 = 1, V4 = 0, we see that X and Y groups can represent binary numbers. I.e. X = {0, 1} and Y = {1, 0}. These binary numbers are then converted to integers, X = 2 and Y = 1.

2.2 Coloring Grid Cells

Each point in the boolean space described by the four variables has an assignment of 0 or 1 from the boolean formula. Converting the variabls to 2D coordinates, and using the formula truth value to fill in the grid where false is 0 and true is 1, turns the truth table into an grid.

As an example, use the formula V2 OR V3. The logic table and coordinates are the following.








V1V2X coord.V3V4Y coord.V2 OR V3







0 0 0 0 0 0 0
1 0 1 0 0 0 0
0 1 2 0 0 0 1
1 1 3 0 0 0 1
0 0 0 1 0 1 1
1 0 1 1 0 1 1
0 1 2 1 0 1 1
1 1 3 1 0 1 1
0 0 0 0 1 2 0
1 0 1 0 1 2 0
0 1 2 0 1 2 1
1 1 3 0 1 2 1
0 0 0 1 1 3 1
1 0 1 1 1 3 1
0 1 2 1 1 3 1
1 1 3 1 1 3 1







From the logic table, we can take the X and Y coordinates and create a 2D grid.






Y (down) X (right)0123










0 0011
1 1111
2 0011
3 1111





3 Generating the Puzzle

Two ways the grid can be converted into a puzzle is by either adding incorrect grid cell assignments, i.e. flipping 0 to 1 or 1 to 0, or by removing a cell assignment.

Then the puzzle solver’s task is to correct the flipped cells and fill in the missing cells.

3.1 Example Puzzle

Taking the previous grid, we can flip cell {0, 0} and erase cell {1, 1}, and generate the following puzzle.






Y (down) X (right)0123










0 1011
1 1_11
2 0011
3 1111