Chapter 9
The problems, seen from outside
“The Boolean view” ran the machine as gates that see only bits. We can see more than the gates do. Read an input n as its two bits, n = 2·hb + lb, and each problem is itself a Boolean function of them: {3} is hb AND lb, {1, 2, 3} is hb OR lb, {1, 2} is hb XOR lb, and {0, 2, 3} is hb OR NOT lb. That is a fact about the problems, found by looking at all 16 at once. The machine reaches each answer the long way instead, six ticks of the same gates.
Theorem 9. The 16 problems are exactly the 16 Boolean functions of two bits: each problem is one function of hb and lb, and each function is one problem.
Proof. A function of two bits is its four values, one per input, and a problem is the same four answers, so the two are counted alike, 2^4 = 16. tests/test_theorems.c evaluates the 16 expressions below at all four inputs, finds each one true at its problem's members alone and the 16 truth tables all different, and finds each problem decided by some program. src/boolean_main.c holds each expression to a program run on the machine and prints the table, and the book's build holds the table to that output.
| code | problem | as hb and lb |
|---|---|---|
| 0 | { } | 0 |
| 1 | {0} | NOT (hb OR lb) |
| 2 | {1} | NOT hb AND lb |
| 3 | {0, 1} | NOT hb |
| 4 | {2} | hb AND NOT lb |
| 5 | {0, 2} | NOT lb |
| 6 | {1, 2} | hb XOR lb |
| 7 | {0, 1, 2} | NOT (hb AND lb) |
| 8 | {3} | hb AND lb |
| 9 | {0, 3} | NOT (hb XOR lb) |
| 10 | {1, 3} | lb |
| 11 | {0, 1, 3} | NOT hb OR lb |
| 12 | {2, 3} | hb |
| 13 | {0, 2, 3} | hb OR NOT lb |
| 14 | {1, 2, 3} | hb OR lb |
| 15 | {0, 1, 2, 3} | 1 |
So the 16 problems, the 16 puzzles of Nibble, are the 16 two-input connectives.