How a Machine Learned to Make Decisions: Logic Gates
Planted 02026-08-01
Is this electrical signal high or low?
How can a computer add two numbers when none of its parts knows what a number is?
How can it recognize your face when no transistor knows what a face is?
At the bottom of every computer, beneath the apps, operating system, code, and mathematics, are components making distinctions so simple that they barely deserve to be called decisions:
Is this electrical signal high or low?
That’s it.
The mystery is how billions of tiny yes-or-no events become music, language, memory, and thought-like behavior.
No single person set out to invent that entire world. A schoolmaster tried to turn reasoning into algebra. Telephone engineers tried to route calls through forests of switches. A Bell Labs researcher carried spare relays home to his kitchen table. A graduate student stared at complicated circuit diagrams and realized that a century-old mathematics could make them intelligible.
Each person inherited a machine—or an idea—that could almost do what they needed.
The story of logic gates is the story of what happened when “almost” was no longer good enough.
It begins with a door.
1. The door with two locks
Imagine a secure room with two locks.
Alice has one key. Bob has the other. The door should open only when Alice’s key and Bob’s key are both turned.
We can describe each lock with a number:
0: not turned1: turned
The door follows this rule:
Alice Bob Door
0 0 Closed
0 1 Closed
1 0 Closed
1 1 Open
This is an AND rule.
The door opens when Alice and Bob act.
Now imagine an emergency door with two separate release buttons. Pressing either button should open it.
Button A Button B Door
0 0 Closed
0 1 Open
1 0 Open
1 1 Open
This is an OR rule.
The door opens when A or B is pressed.
Finally, imagine a refrigerator light. When the door is closed, the light is off. When the door is not closed, the light is on.
Door closed Light
0 1
1 0
This is a NOT rule. It reverses the input.
A logic gate is the electronic version of one of these arrangements:
A logic gate is a small circuit that receives signals, applies a fixed rule, and produces another signal.
The word gate is a metaphor. The circuit permits or blocks an electrical effect depending on the conditions at its inputs.
But a metaphor can hide a difficulty. Doors are large enough to see. Their locks have obvious meanings. Electrical signals do not arrive labeled true or false.
Before a circuit can make a logical decision, people must decide what its physical states will mean.
2. Zero and one are agreements
Inside a computer, 0 and 1 are not tiny printed numbers moving through wires.
They are names engineers give to different electrical conditions.
For example:
Low voltage → interpret as 0
High voltage → interpret as 1
Real voltages are imperfect. A computer does not usually demand exactly zero volts or exactly some other voltage. Instead, it recognizes ranges: sufficiently low counts as 0, and sufficiently high counts as 1.
This is one reason digital machines are robust. Small electrical errors can occur without changing the logical meaning.
The gate itself does not understand true, false, yes, or no. It merely responds to voltage. Humans decide what those voltages represent.
The same 1 might mean:
- a button is pressed;
- a number contains a particular binary digit;
- a pixel should be illuminated;
- a password matched;
- a missile is approaching;
- a musical speaker should move outward.
The electricity has no meaning by itself. Meaning comes from the system built around it.
That distinction—between a physical event and the meaning assigned to it—would eventually allow the same kinds of switches to represent numbers, words, images, instructions, and almost anything else.
But first, someone had to imagine that reasoning itself might be expressed as a manipulable system.
3. The schoolmaster who tried to calculate thought
George Boole did not arrive at logic through a modern university laboratory.
Born in 1815 to a family of modest means in Lincoln, England, he left the path of formal education early. When his father’s business failed, sixteen-year-old Boole became a teacher and helped support his family. He continued educating himself while working, studying languages and mathematics beyond what his schooling had provided. He later opened and ran schools before receiving a university professorship despite never having earned a university degree himself.
His circumstances made his ambition more striking.
Logic had long belonged primarily to philosophy: a discipline of verbal arguments, categories, and syllogisms. Boole began to suspect that reasoning might also possess an algebraic structure.
Consider statements such as:
- The object is red and round.
- The object is red or round.
- The object is not red.
The words and, or, and not seem ordinary. But they constrain what can be true. They behave according to repeatable rules.
Boole wanted to know whether those rules could be written symbolically and manipulated, much as an equation can be manipulated.
This was not an obviously useful project. There were no electronic computers waiting for a logic system. No factory was asking Boole to design gates. The practical consequences of his work were invisible.
In 1854, he published An Investigation of the Laws of Thought. Its title revealed the scale of the ambition. Boole was not merely cataloging valid arguments. He was trying to expose machinery beneath reasoning itself.
His algebra did not look exactly like the Boolean algebra taught today, and later mathematicians would refine and reinterpret it. But he had helped establish a radical possibility:
Reasoning could be represented as operations performed on symbols.
Boole could not have known that engineers would eventually build physical systems whose wires enacted rules descended from that algebra.
For decades, the mathematics and the machinery remained separated.
The mathematicians had rules without switches.
The engineers had switches without a general mathematical language for arranging them.
The breakthrough would come when people under pressure from a completely different problem—connecting telephone calls—filled rooms with devices that happened to behave like Boole’s symbols.
4. The room full of clicking switches
Long before digital computers, telephone networks faced a problem of scale.
A small exchange could be operated by people. A caller asked for a destination, and an operator physically connected one line to another. But as telephone systems grew, the number of possible connections grew with them. Human hands alone could not route every call quickly and reliably.
Telephone engineers turned to relays.
A relay is a switch operated by an electromagnet:
Electricity enters a coil
↓
The coil becomes magnetic
↓
It pulls a metal arm
↓
The arm opens or closes another circuit
This contained a profound possibility: one electrical signal could control another electrical signal.
Relay contacts could be wired in series:
Power ──[ A ]──[ B ]── Lamp
Current reaches the lamp only when A and B are both closed.
That is AND.
They could be wired in parallel:
┌──[ A ]──┐
Power ────┤ ├── Lamp
└──[ B ]──┘
Current reaches the lamp when either path is closed.
That is OR.
A relay could also have a spring-loaded contact that normally remained closed but opened when its electromagnet was energized.
That produced NOT.
The logic was no longer floating in the air as philosophy. It was embodied in copper wire, iron arms, springs, and electromagnets.
Yet the engineers arranging these devices were not usually thinking, “I am constructing Boolean algebra.” They were trying to make a network behave correctly. As the networks grew, their drawings filled with paths, contacts, coils, and crossings. A circuit could work and still be difficult to explain. Two designs could behave identically while looking completely different. Simplifying one often depended on hard-earned intuition.
Then a Bell Labs researcher named George Stibitz took some of the machinery home.
In 1937, Stibitz sat at his kitchen table with telephone relays, flashlight bulbs, batteries, wire, and a switch improvised from a strip of metal. He was not building a room-sized computer. He was testing a smaller, stranger possibility:
Could switches perform arithmetic?
His device accepted two binary digits. A light represented the result. It became known as the Model K, for the kitchen table on which it was assembled.
The experiment was modest enough to hold in two hands. But it crossed an important boundary. Relays no longer merely connected one telephone line to another. Arranged carefully, they could transform symbols according to the rules of arithmetic.
The machine clicked because calculation still required pieces of metal to move.
Stibitz had shown that switches could add. But his experiment did not yet provide a general method for designing every switching network a machine might need.
That problem was waiting for a graduate student at MIT.
5. The connection Claude Shannon noticed
Claude Shannon arrived at MIT with training in both mathematics and electrical engineering.
As a graduate student, he worked part-time on Vannevar Bush’s differential analyzer, a large analog calculating machine. Relays helped control parts of the apparatus. Around Shannon were the kinds of switching systems engineers knew how to build but could struggle to describe compactly.
Imagine trying to reason about a circuit whose drawing sprawls across a page.
A contact opens here. That interrupts a path there. Two branches reconnect elsewhere. A relay energized in one part of the machine changes the meaning of another route several steps away.
You might trace every possible path by hand. Then you might redraw the network, hoping the new version is simpler. With enough contacts, intuition becomes fragile. One missed connection can invalidate the whole design.
Shannon recognized that this physical mess had an abstract twin:
Open switch ↔ 0
Closed switch ↔ 1
Series connections ↔ AND
Parallel connections ↔ OR
Reversed contacts ↔ NOT
The relay engineers’ circuits behaved like Boolean expressions.
This was more than a clever analogy. It changed how a switching circuit could be designed.
An engineer could begin with the decision a machine needed to make, write that decision symbolically, simplify the expression using Boolean algebra, and then translate the result into switches. An existing circuit could be converted in the opposite direction: from wires into symbols, where equivalent structures were easier to compare.
Shannon developed this connection in his 1937 MIT master’s thesis, A Symbolic Analysis of Relay and Switching Circuits.
The thesis answered a practical frustration with an intellectual bridge.
Boole had developed an algebra without electrical machinery in mind.
Telephone engineers had developed electrical machinery without Boole’s algebra as a general design language.
Shannon saw that each completed the other.
Boole had turned reasoning into algebra.
Shannon helped turn that algebra into a method for constructing machinery.
The distance between a statement and a circuit had begun to collapse.
6. The gates are speaking
The common gates can be understood as tiny sentences.
NOT: “the opposite”
A NOT A
0 1
1 0
When the input is low, the output is high. When the input is high, the output is low.
AND: “all required conditions”
A B A AND B
0 0 0
0 1 0
1 0 0
1 1 1
The output becomes 1 only when every input is 1.
OR: “at least one condition”
A B A OR B
0 0 0
0 1 1
1 0 1
1 1 1
The output becomes 1 when one or both inputs are 1.
XOR: “exactly one”
A B A XOR B
0 0 0
0 1 1
1 0 1
1 1 0
XOR means exclusive OR. Its output is 1 when the inputs differ.
NAND: “not all”
NAND means NOT AND:
A B A NAND B
0 0 1
0 1 1
1 0 1
1 1 0
People sometimes misread NAND as “neither input.” It actually means:
“It is not the case that both inputs are 1.”
So the output is 0 only in the final row.
A truth table is a complete list of a gate’s possible input combinations and the resulting output. It is the gate’s entire personality. The gate has no moods, memory, judgment, or interpretation beyond that table.
This simplicity is not a defect. It is what makes a gate trustworthy.
A gate does not improvise. It does not become distracted. Given inputs within the expected electrical ranges, it fulfills the same small promise again and again.
The next discovery was that one promise could be connected to another.
7. How decisions become arithmetic
Return to Stibitz’s kitchen table.
What arrangement of simple decisions could make two binary digits add?
Write every possible case:
A B Sum Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
The final row contains the important surprise.
In binary:
1 + 1 = 10
The result has a 0 in the current position and carries a 1 into the next position—just as decimal addition carries a digit when a column becomes too large.
Look at the table again:
- The Sum column follows XOR.
- The Carry column follows AND.
So an XOR gate and an AND gate together can add two binary digits.
A ──┬──[ XOR ]── Sum
│
B ──┘
A ──┬──[ AND ]── Carry
│
B ──┘
This circuit is called a half-adder.
The name contains a warning.
A half-adder can combine two bits, but addition across several columns creates a third input: the carry arriving from the previous column.
Consider:
111
+ 001
-----
1000
The rightmost column produces a carry. The next column must add:
- the first number’s bit;
- the second number’s bit;
- the incoming carry.
The first success reveals the next obstacle. A circuit that adds only two inputs is not enough.
By combining two half-adders with another OR gate, engineers can construct a full adder—a circuit that accepts the incoming carry as well. Connect full adders in a chain, allowing each carry to enter the next column, and the machine can add longer binary numbers.
No gate understands addition.
One gate detects whether two bits differ. Another detects whether both are 1. Other gates route the carry forward. But when their outputs are arranged correctly, arithmetic emerges.
Stibitz’s small experiment was therefore larger than it appeared. It demonstrated one of computing’s central patterns:
Complex abilities do not have to exist inside the parts. They can arise from the relationships among simple parts.
But an adder still has a severe limitation.
Its purpose is frozen into its wiring.
It can add because a person arranged it to add. To subtract, compare, or choose between several operations, the arrangement must contain additional pathways and some signal that determines which pathway matters.
A calculating machine needs more than the ability to produce an answer.
It needs a way to choose what kind of answer to produce.
8. The problem of remembering
The circuits described so far react only to the present.
Change the inputs and the outputs change. Remove the inputs and nothing remains.
That is acceptable for a door. The door need only respond to the keys being turned now.
A computer faces a different problem.
Suppose a calculation requires ten steps. The machine finishes the first step and produces an intermediate result. Before it can use that result in the second step, the original inputs disappear.
If the machine cannot preserve what it has already discovered, every step begins from nothing.
A programmable computer requires a past.
At first, feeding the output of a circuit back into its input can sound like a mistake. Why send a result backward? Would the signals not chase one another endlessly, oscillate, or become unstable?
Often they can. Feedback is powerful partly because it is dangerous.
But with the proper arrangement—commonly using NAND or NOR gates—a circuit can settle into one of two stable states. A brief input can push it into one state, and feedback can keep it there after the original input disappears.
This is a latch, one of the simplest forms of electronic memory.
The circuit remembers one bit:
State 0
or
State 1
This was a conceptual transformation.
A network of gates was no longer merely reacting. It could possess a state determined partly by what had happened before.
Combine remembered bits and the machine can preserve a number. Add control signals and it can decide when to accept a new value and when to retain the old one. Arrange many storage elements and give them addresses, and the machine can select which location to read or change.
From latches come registers, counters, and memory systems.
Once a machine can make decisions and preserve results, it can perform a sequence of operations rather than a single fixed reaction.
Its behavior acquires a history.
But the relays that made these ideas tangible carried their own limit inside them.
Every decision still required metal to move.
9. The race to escape moving metal
A relay announces its work with a click.
An electromagnet pulls an armature. The armature travels through space. Metal contacts strike or separate. A spring eventually returns the mechanism.
This is wonderfully legible machinery. A person can sometimes hear a relay computer thinking.
It is also slow.
Metal has mass. It takes time to accelerate, travel, strike a contact, and return. Contacts can bounce, wear, collect dirt, or fail. A larger machine requires more relays, more movement, more wiring, and more opportunities for something to go wrong.
Engineers wanted switching without motion.
A vacuum tube could control the flow of electrons using an electric field. Because the switching happened electronically rather than through a moving metal arm, tube circuits could operate much faster than relay circuits.
This speed came at a price. Tubes were large, generated heat, consumed substantial power, and required extensive wiring.
ENIAC made both the achievement and the burden visible.
Completed during the 1940s and publicly unveiled in 1946, ENIAC used more than 17,000 vacuum tubes. It weighed roughly 30 tons and contained an immense quantity of hand-wired connections. It could calculate far faster than relay machines, but speed did not make it easy to command.
Six women—Kathleen McNulty, Jean Jennings, Betty Snyder, Marlyn Wescoff, Frances Bilas, and Ruth Lichterman—became its first programmers. They were given a machine whose operation had to be understood through diagrams, logical sequences, switches, cables, and panels. Programming meant decomposing a mathematical procedure into operations and then configuring the machine so that electrical pulses traveled through the required path.
The work was not incidental to ENIAC. Without a program, the machine’s speed had no direction.
Nor was programming merely “plugging in wires.” The programmers had to understand how the units interacted, anticipate timing, trace errors, and discover techniques for using a kind of machine that had barely existed before them.
The logic had become fast, but changing the machine’s behavior still demanded intimate physical knowledge of its body.
And the body still occupied a room.
Bell Labs faced a related physical limit in its communication systems. Vacuum tubes could amplify and switch signals, but they were bulky, power-hungry, and less reliable than engineers wanted for an expanding network.
The search for a smaller solid-state alternative did not proceed as a clean march from theory to success.
William Shockley pursued an early semiconductor amplifier that failed to work as intended. John Bardeen and Walter Brattain investigated what was happening at the boundary between a semiconductor and its contacts. Their experiments gradually produced amplification, then a working point-contact transistor in December 1947. Shockley soon developed a different junction-transistor design.
The story resists the shape of a lone-genius invention. It involved a research program, failed devices, competing explanations, experimental skill, theoretical insight, and complicated questions of credit.
Bardeen, Brattain, and Shockley later shared the 1956 Nobel Prize in Physics for their semiconductor research and the discovery of the transistor effect.
The physical embodiment of logic had changed again:
Moving mechanical relay
↓
Electronic vacuum tube
↓
Semiconductor transistor
The logical relationships did not change.
An AND circuit remained an AND circuit whether it was constructed from relays, tubes, individual transistors, or microscopic structures etched into a chip.
Eventually, integrated circuits placed many components on one piece of semiconductor material. Standard families of integrated logic circuits appeared in the early 1960s, helping turn gates into inexpensive, repeatable building blocks.
What had filled rooms could now be reproduced microscopically.
Miniaturization did more than make old machines smaller. It changed what people could afford to build, where computation could be placed, and how many logical operations could be composed into a single system.
The smallest dependable unit was becoming almost unimaginably small.
Yet the next surprise was logical rather than physical: even the variety of gates could be reduced.
10. Why NAND became the strange hero
NAND appears awkward.
AND and OR sound like ordinary words. NAND sounds like a grammatical accident.
Yet NAND has an extraordinary property:
Every Boolean operation can be constructed using NAND gates alone.
This is called functional completeness.
The underlying discovery has a complicated human history. Charles Sanders Peirce explored the possibility that a single logical connective could express the others in unpublished work around 1880. Henry Sheffer published a system based on a single connective in 1913, bringing the idea into wider mathematical logic.
The attraction was not that NAND sounded natural. It was that logical variety might be generated from one sufficient rule.
To see the power directly, begin with a NAND gate:
NAND(A, B) = NOT(A AND B)
Making NOT from NAND
Connect the same signal to both inputs:
A NAND A
Because A AND A is simply A:
A NAND A = NOT A
So NAND can make NOT.
Making AND from NAND
First calculate NAND:
X = A NAND B
Then invert X using another NAND:
X NAND X = NOT X
Because X was NOT(A AND B), inverting it gives:
A AND B
So NAND can make AND.
Making OR from NAND
First invert both inputs:
NOT A = A NAND A
NOT B = B NAND B
Then NAND those results:
(NOT A) NAND (NOT B)
This produces:
A OR B
Once NAND can reproduce NOT, AND, and OR, it can reproduce any circuit built from those operations. NAND and its dual, NOR, are therefore known as universal gates.
This does not mean engineers always build everything from NAND. Real designs use different gate arrangements depending on speed, power consumption, physical layout, manufacturing technology, and other constraints.
It means that NAND is logically sufficient.
A world of possible digital behavior is hiding inside one tiny rule:
Output
0only when both inputs are1.
But saying that a computer is “really just NAND gates” can also mislead. It describes the foundation while concealing the structures people build above it.
To understand a computer, we need more than one truthful description.
11. The final trick: levels of description
When you press a key, several different stories can all be true simultaneously.
At one level:
You typed the letter A.
At another:
A program received a keyboard event.
At another:
A processor executed instructions.
At another:
Registers changed their stored bit patterns.
At another:
Logic gates changed their outputs.
At another:
Transistors altered the paths through which current could flow.
At another:
Electric fields influenced electrons inside semiconductor material.
None of these explanations cancels the others. They are descriptions at different scales.
A novelist does not need to think about ink molecules to write a sentence. A programmer does not usually need to think about individual gates to write software. A circuit designer does not reason about every electron while arranging an adder.
Each person works at a level where certain details can be trusted and temporarily ignored.
That trust was built historically.
Boole trusted symbols to preserve logical relationships.
Shannon trusted algebra to preserve the behavior of switching circuits.
Stibitz trusted relays to preserve binary distinctions.
The ENIAC programmers trusted configured units to carry pulses in an intended sequence.
Modern programmers trust processors, compilers, operating systems, and libraries—layers created by people they will never meet.
Abstraction is sometimes described as hiding complexity. More precisely, it is the construction of a dependable boundary.
Below the boundary, enormous detail remains.
Above it, a person can act as though a simpler promise were true.
12. What a logic gate really is
A logic gate is not inherently made from electricity.
The same logical relationship can be embodied using:
- mechanical levers;
- water valves;
- electromagnetic relays;
- vacuum tubes;
- transistors;
- light;
- biological molecules;
- or even people following written instructions.
What makes something a logic gate is not its material.
It is the reliable relationship between its inputs and its output.
A gate is a promise:
Whenever the inputs have this pattern,
the output will have that pattern.
That promise became useful because generations of people learned how to join it to other promises.
Boole pursued a symbolic machinery of thought without knowing what engineers would make from it.
Telephone engineers filled exchanges with switches because human operators could not scale forever.
Stibitz carried relays to his kitchen table because he wanted to know whether switching could become calculation.
Shannon recognized that an old algebra could tame the complexity of modern circuits.
The ENIAC programmers learned to direct a machine whose speed was useless until someone gave its pulses a path.
Bardeen, Brattain, Shockley, and many others pushed switching out of moving metal and heated glass into semiconductor material.
None of them built the entire digital world.
Each solved a smaller problem whose solution changed what the next person could attempt.
A few gates make an adder.
More gates make a memory.
Adders and memories make processors.
Processors executing stored instructions make computers.
Computers become tools for writing, navigation, medicine, art, communication, and scientific discovery.
At the bottom, no component understands any of those things. There are only carefully organized physical events—high and low, conducting and not conducting—cascading through a network.
A computer is not powerful because its smallest parts are intelligent.
It is powerful because its smallest parts are dependable—and because people learned, across generations, how to compose their tiny decisions into structures of almost unimaginable complexity.
The room-sized machine clicking through one binary addition and the processor running a modern computer are separated by speed, scale, materials, and decades of human work.
But beneath them is the same small idea:
Take a signal. Apply a rule. Pass the result onward.
That is a logic gate.
And from that modest beginning, people taught machines to acquire arithmetic, memory, instructions—and eventually an entire digital world.