The Same Tables in Machines
Dad's hall has two light switches, one downstairs and one upstairs. Either one can turn the light on or off. Nobody inside the wall is thinking. Could a table be built out of wires?
Logic as algebra
In 1854 George Boole published The Laws of Thought. He wrote logic like algebra, using 1 and 0. True became 1, and false became 0.
In programming, true and false values are still called booleans, after him.
Switches follow the tables
In 1937 Claude Shannon, in his master's thesis, showed that circuits of relays and switches can follow those same tables. A logic gate is a small circuit with one or two inputs and one output. 1 means on and 0 means off.
The AND gate is on only if both inputs are on: two switches in a row, and the current needs both. The OR gate is on if at least one input is on: two switches side by side. The NOT gate flips its input.
| A | B | AND | OR |
|---|---|---|---|
| 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 |
| 0 | 0 | 0 | 0 |
The hall light
Rule: each switch flips the light. With both switches down, the light is off. Let P = The downstairs switch is up and Q = The upstairs switch is up.
The light is on when exactly one switch is up. That is the only-one or from earlier: (P ∨ Q) ∧ ¬(P ∧ Q).
| P | Q | P ∨ Q | ¬(P ∧ Q) | Light |
|---|---|---|---|---|
| T | T | T | F | F |
| T | F | T | T | T |
| F | T | T | T | T |
| F | F | F | T | F |
That is four gates: OR, AND, NOT and a last AND. Every computer is built from gates like these, in huge numbers.
Careful
A gate does not think. It only follows its table. Everything a computer does comes from many simple tables joined together.
Try it at home
- Find two switches at home that control one light, or one lamp with a plug and a switch.
- Write a key, then fill in a four-row table: which positions turn the light on?
- Say which gate each part of the circuit is like: in a row, side by side, or a flip.
Words to know
- logic gate - a small circuit that turns inputs into one output by a table
- AND, OR, NOT - three gates: both on, at least one on, flip
- 1 and 0 - on and off; true and false
Big idea
Boole wrote logic as algebra in 1854. Shannon showed in 1937 that switches follow the same tables, so machines can do logic.