Invert both inputs, NAND them, and De Morgan hands you an OR. A ready-made basics circuit you can open in the TorchAnvil simulator.
You've seen NAND turn into NOT and into AND. Now for the third corner of the trick: three NANDs, wired just right, become an OR. The magic ingredient is De Morgan's law.
De Morgan says !(!A & !B) = A | B. Read that right to left: if you
want A OR B, you can instead invert both inputs, AND them, and invert
the result.
The circuit does exactly that, using only NANDs:
!A.!B.!A and !B and produces !(!A & !B) — which
by De Morgan is A | B.| A | B | !A | !B | Lamp (A OR B) |
|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 | 1 |
This closes the universality proof. NAND alone can build NOT, AND, and OR — and from those three you can build every logic function, every adder, every memory cell, every CPU. One gate type is enough for the entire digital world. That's why NAND is often called "the universal gate" in textbooks.
nand-as-and sample. Same gate, very different
wiring, opposite behavior.