Boolean functions
There are 16 possible functions with 2 bits of input and 1 bit of output.
Of these, only 6 are gates:
AND, OR, XOR, NAND, NOR, XNOR
All possible Boolean functions can be written using at most 3 gates:
Set {AND, OR, NOT} is computationally complete.
Also {NAND}, {NOR}, and some others.
Example: use NAND to implement OR
x | y = ~~(x | y)
= ~(~x & ~y)
= ~x NAND ~y
Looks like we also need NOT
However, consider the following:
  ~x = ~x | ~x a == a | a
= ~(x & x) DeMorgan's law
= x NAND x Definition of NAND
So, x | y = (x NAND x) NAND (y NAND y)
A bit ugly, perhaps, but true.