Mathematical logic · first circuits
Boolean laws
Equivalence, simplification, reordering, distribution, absorption, De Morgan and universal gates.
A law is a replacement valid for every input case. Theory compares complete Y and Z branches. In a game, no completed table gives the answer: inspect the circuits before deciding.
Theory
Chapter 1
What it means to replace a circuit
Y and Z show two ways to compute a rule from the same inputs. Equality must hold in every table row, not just in the current case.
Two inversions restore the input
The upper path sends A through NOT twice; the lower path connects it directly to the lamp. Here = means that Y and Z match for every possible input.
NOT (NOT A) = A
Toggle A and follow 0 becoming 1, then 0 again.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | Y | Z |
|---|---|---|---|
| 0 | 0 | 0 | |
| 1 | 1 | 1 |
Two consecutive NOT gates can be removed. Removing just one changes the rule.
Chapter 2
Constants 0 and 1
A fixed source is not a variable input in a truth table. See when it changes nothing and when it determines the result completely.
AND with one
The source marked 1 is always on: it is a constant, not another variable input. AND’s other condition is already met, so only A determines the result.
A AND 1 = A
Check both positions of A. The constant 1 does not toggle.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | Y | Z |
|---|---|---|---|
| 0 | 0 | 0 | |
| 1 | 1 | 1 |
One is the identity value for AND: adding AND 1 changes nothing.
OR with zero
A constant 0 adds no extra way to turn OR on. The output follows its only variable input, A.
A OR 0 = A
Turn A on and off. Compare the direct path with the OR path.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | Y | Z |
|---|---|---|---|
| 0 | 0 | 0 | |
| 1 | 1 | 1 |
Zero is the identity value for OR.
Zero blocks AND
AND needs two ones. If one input is always 0, changing the other cannot turn the lamp on.
A AND 0 = 0
Set A = 1. Why is Y still off?
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | Y | Z |
|---|---|---|---|
| 0 | 0 | 0 | |
| 1 | 0 | 0 |
AND 0 always produces 0. This output does not depend on A, although A remains an input of the circuit being examined.
One enables OR
OR needs at least one 1. The constant 1 already supplies it, regardless of A.
A OR 1 = 1
Turn A off. Do both lamps remain on?
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | Y | Z |
|---|---|---|---|
| 0 | 1 | 1 | |
| 1 | 1 | 1 |
OR 1 always produces 1. AND 1, in contrast, follows A.
Chapter 3
Repetition and opposites
One source can feed several inputs. Identical values and opposite values lead to different simplifications.
Repeating a condition in AND
Two wires can carry the same source value. Requiring ‘A and A’ adds no new condition.
A AND A = A
Watch both AND inputs while changing A.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | Y | Z |
|---|---|---|---|
| 0 | 0 | 0 | |
| 1 | 1 | 1 |
The repeated condition can be removed. This property is called idempotence.
Repeating a condition in OR
OR has two inputs, but both are connected to A here. Repeating the same condition adds no new possibility.
A OR A = A
Compare Y and Z at A = 0 and A = 1.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | Y | Z |
|---|---|---|---|
| 0 | 0 | 0 | |
| 1 | 1 | 1 |
OR, like AND, lets us remove a repeated condition. This does not hold for XOR: A XOR A is 0.
A condition and its opposite
One path carries A; the other carries its opposite, NOT A. They can never both be 1.
A AND NOT A = 0
Toggle A. Which AND input now carries 0?
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | Y | Z |
|---|---|---|---|
| 0 | 0 | 0 | |
| 1 | 0 | 0 |
A contradiction is false in every case. The whole construction can therefore be replaced with a constant 0.
A condition or its opposite
One of A and NOT A must be 1. That is enough for OR.
A OR NOT A = 1
Find the 1 on one of the two paths for each position of A.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | Y | Z |
|---|---|---|---|
| 0 | 1 | 1 | |
| 1 | 1 | 1 |
In two-valued logic this rule is always true. It is the law of excluded middle.
Chapter 4
Order and grouping
First swap two inputs, then regroup three conditions. The operation stays the same throughout each rule.
Swap the inputs of AND
The upper AND receives A then B; the lower one receives B then A. The wires changed position, but both gates still require two ones.
A AND B = B AND A
Compare the 0,1 and 1,0 cases carefully.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | Y | Z |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | |
| 0 | 1 | 0 | 0 | |
| 1 | 0 | 0 | 0 | |
| 1 | 1 | 1 | 1 |
The input order of AND does not affect its result. This is the commutative law.
Swap the inputs of OR
OR depends on whether at least one input is 1, not on which wire arrives first.
A OR B = B OR A
Turn on only A, then only B. Compare both outputs.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | Y | Z |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | |
| 0 | 1 | 1 | 1 | |
| 1 | 0 | 1 | 1 | |
| 1 | 1 | 1 | 1 |
OR is commutative too. Swapping its inputs does not mean changing the gate.
Group AND in two ways
Parentheses show which pair is combined first. Both versions need all three inputs to be 1.
(A AND B) AND C = A AND (B AND C)
Turn all inputs on, then turn them off one at a time.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | C | Y | Z |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | |
| 0 | 0 | 1 | 0 | 0 | |
| 0 | 1 | 0 | 0 | 0 | |
| 0 | 1 | 1 | 0 | 0 | |
| 1 | 0 | 0 | 0 | 0 | |
| 1 | 0 | 1 | 0 | 0 | |
| 1 | 1 | 0 | 0 | 0 | |
| 1 | 1 | 1 | 1 | 1 |
AND gates may be regrouped. This is the associative law.
Group OR in two ways
We can combine A with B first, or B with C. Both paths turn the result on when any of the three inputs is on.
(A OR B) OR C = A OR (B OR C)
Try A = 1, B = 1 and C = 1 in turn, keeping the other inputs off.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | C | Y | Z |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | |
| 0 | 0 | 1 | 1 | 1 | |
| 0 | 1 | 0 | 1 | 1 | |
| 0 | 1 | 1 | 1 | 1 | |
| 1 | 0 | 0 | 1 | 1 | |
| 1 | 0 | 1 | 1 | 1 | |
| 1 | 1 | 0 | 1 | 1 | |
| 1 | 1 | 1 | 1 | 1 |
OR is associative too. Parentheses cannot be moved freely between different operations.
Chapter 5
Shared conditions and redundant paths
Distribute a shared condition across two paths, then find paths that do not affect the result at all. This helps us understand and simplify real circuits.
Share a condition across two paths
Let A be a shared permission, with B and C as two ways to start. We can check the permission after choosing a way, or check it on each path separately.
A AND (B OR C) = (A AND B) OR (A AND C)
Turn A off and C on. Neither path should bypass the shared permission.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | C | Y | Z |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | |
| 0 | 0 | 1 | 0 | 0 | |
| 0 | 1 | 0 | 0 | 0 | |
| 0 | 1 | 1 | 0 | 0 | |
| 1 | 0 | 0 | 0 | 0 | |
| 1 | 0 | 1 | 1 | 1 | |
| 1 | 1 | 0 | 1 | 1 | |
| 1 | 1 | 1 | 1 | 1 |
AND distributes over OR. In the right-hand circuit A applies to both paths, not just the first one.
Two conditions with a shared override
Here A is sufficient on its own. Without A, both B and C are needed. On the right, A enables both inputs of the final AND.
A OR (B AND C) = (A OR B) AND (A OR C)
Turn A on with B = 0 and C = 0. Then turn A off and find which pair is needed.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | C | Y | Z |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | |
| 0 | 0 | 1 | 0 | 0 | |
| 0 | 1 | 0 | 0 | 0 | |
| 0 | 1 | 1 | 1 | 1 | |
| 1 | 0 | 0 | 1 | 1 | |
| 1 | 0 | 1 | 1 | 1 | |
| 1 | 1 | 0 | 1 | 1 | |
| 1 | 1 | 1 | 1 | 1 |
In Boolean logic OR also distributes over AND. This rule must not be transferred to ordinary numerical addition and multiplication.
An unnecessary alternative inside AND
If A is off, the first AND input already blocks the result. If A is on, the OR is also on regardless of B.
A AND (A OR B) = A
Keep A unchanged and toggle B several times.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | Y | Z |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | |
| 0 | 1 | 0 | 0 | |
| 1 | 0 | 1 | 1 | |
| 1 | 1 | 1 | 1 |
B has no effect on the final output. Both gates can be replaced by a wire from A: this is absorption.
An unnecessary condition inside OR
When A is on, OR is already on. When A is off, A AND B cannot be on. The second path adds no new cases.
A OR (A AND B) = A
Try to find a value of B that changes the output while A stays unchanged.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | Y | Z |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | |
| 0 | 1 | 0 | 0 | |
| 1 | 0 | 1 | 1 | |
| 1 | 1 | 1 | 1 |
Both positions of B give the same result. This is the other form of the absorption law.
Chapter 6
Negating a combined condition
De Morgan’s laws connect negation of a whole condition with negation of its inputs. Distinguish ‘not both’ from ‘neither’.
Not both: De Morgan’s first law
‘The two conditions are not both true’ means that at least one is false. It does not mean that both must be off.
NOT (A AND B) = (NOT A) OR (NOT B)
Check mixed inputs 0,1 and 1,0, then the pair 1,1.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | Y | Z |
|---|---|---|---|---|
| 0 | 0 | 1 | 1 | |
| 0 | 1 | 1 | 1 | |
| 1 | 0 | 1 | 1 | |
| 1 | 1 | 0 | 0 |
Moving the negation to both inputs changes AND into OR.
Neither: De Morgan’s second law
‘Neither condition is true’ requires two zeros. Negating each input turns those into the two ones needed by AND.
NOT (A OR B) = (NOT A) AND (NOT B)
Start with 0,0 and turn on one input at a time. When do Y and Z turn off?
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | Y | Z |
|---|---|---|---|---|
| 0 | 0 | 1 | 1 | |
| 0 | 1 | 0 | 0 | |
| 1 | 0 | 0 | 0 | |
| 1 | 1 | 0 | 0 |
Moving the negation to both inputs changes OR into AND. Every input must be negated.
Chapter 7
One gate type for different rules
Apply the identities we have learned: NAND alone or NOR alone can implement NOT, AND and OR. Universality means construction is possible, not that it produces the smallest circuit.
Build OR using only NAND
A NAND with identical inputs acts as NOT. The first two NAND gates invert A and B; the last computes NOT (NOT A AND NOT B).
A OR B = (A NAND A) NAND (B NAND B)
Follow both copies of A into the first NAND. Then check the 0,0 case.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | Y | Z |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | |
| 0 | 1 | 1 | 1 | |
| 1 | 0 | 1 | 1 | |
| 1 | 1 | 1 | 1 |
NAND can implement NOT; inverting a NAND result implements AND. Together with the OR shown here, that is enough to build any Boolean function: NAND is universal.
Build AND using only NOR
A NOR with identical inputs also implements NOT. The first two NOR gates invert the inputs; the last computes NOT (NOT A OR NOT B).
A AND B = (A NOR A) NOR (B NOR B)
Check 1,1, then turn off just one input.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | Y | Z |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | |
| 0 | 1 | 0 | 0 | |
| 1 | 0 | 0 | 0 | |
| 1 | 1 | 1 | 1 |
NOR implements NOT; inverting NOR implements OR. The construction shown adds AND, so NOR is universal too. A circuit built this way is not necessarily the shortest one.
Practice
Your own circuit
Tap a component to add it, or drag it onto the board. Connect a right-hand dot to another component’s left-hand dot: drag a wire or tap both dots in turn. Tap an input to toggle 0/1.
Keyboard and controls
Tab selects a component or port. Enter activates it. Arrow keys on a title move the component; Shift takes larger steps. Delete removes the selection, Esc cancels a wire. Ctrl/Cmd+Z undoes an edit.
? means the signal is unknown. Connect every input of the component.
On a narrow screen, pan the board by swiping its empty space. Only component titles and ports start a drag.
Tap a component to add it, or drag it onto the board. Connect a right-hand dot to another component’s left-hand dot: drag a wire or tap both dots in turn. Tap an input to toggle 0/1.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | Y | Z |
|---|---|---|---|
| 0 | 0 | 0 | |
| 1 | 1 | 1 |
Your own table: what should happen?
Change the “Wanted” column. Then build a circuit with the same output in every row.
Games
Remove the redundant path
Build A OR (A AND B). The B path adds no cases: try using no gates. Input B may remain unconnected.
Add a gate → connect the dots → press Check. Toggle inputs to try cases.
Tap a component to add it, or drag it onto the board. Connect a right-hand dot to another component’s left-hand dot: drag a wire or tap both dots in turn. Tap an input to toggle 0/1.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | Y |
|---|---|---|---|
| 0 | 0 | ? | |
| 0 | 1 | ? | |
| 1 | 0 | ? | |
| 1 | 1 | ? |
What the circuit must do
Required is the specified output for each case. ↗ sets that case on your circuit.
| Show case | A | B | Required Y |
|---|---|---|---|
| 0 | 0 | 0 | |
| 0 | 1 | 0 | |
| 1 | 0 | 1 | |
| 1 | 1 | 1 |
↗ shows a case. 0 / 1 is your answer for that row.
Build your answer, then press Check. Every input combination is tested.