Member-only story
The NAND gate. One gate to rule them all.
Chronicles of my descent into madness.
Level 1: The human world.
A NAND gate (NOT-AND) is a logic gate which produces an output which is false only if all its inputs are true.
It doesn’t sound too useful from a practical sense. After all, how often are you reasoning about something with two inputs, and you want to figure out what happens exactly when they are both not true at the same time?
Let’s say, for example, that you want to paint a chair red. For that, you need two things: a chair, and a bucket of red paint. Let’s call them “C” and “R”. Let’s say that you have an algorithm CAN_PAINT which takes those inputs and returns true if you can paint the chair. Such an algorithm would use the AND operation.
Now, suppose an algorithm NAND_ALGORITHM exists, which takes C and R as inputs. Can you imagine a practical use-case for such an algorithm? It would returns true only when:
- There is no chair and no red paint.
- There is a chair but no red paint.
- There is red paint but no chair.