Knaph

From English to Letters23 of 243 min read

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.

A timeline with two cards. The first, 1854, shows Boole and logic written with 1 and 0. The second, 1937, shows Shannon and a circuit with a switch and a bulb.

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.

ABANDOR
1111
1001
0101
0000

Two circuits with a battery and a bulb. In the first, two switches sit one after the other, so both must be closed: AND. In the second, two switches sit side by side, so either one is enough: OR.

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).

PQP ∨ Q¬(P ∧ Q)Light
TTTFF
TFTTT
FTTTT
FFFTF

A hall wall with two switches, one marked P and one marked Q, and a lit bulb above. The label says P is up and Q is down, so the light is on.

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

  1. Find two switches at home that control one light, or one lamp with a plug and a switch.
  2. Write a key, then fill in a four-row table: which positions turn the light on?
  3. 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.

Test your understanding

Sign in to test your understanding of this lesson and track your progress.