Mathematical logic · first circuits
Foundations
Signals, inputs and outputs, truth tables and the rules inside gates.
Toggle the inputs and follow the wires. In construction tasks, a completed table specifies exactly what your circuit must do: it is the task, not a hint.
Theory
What are we building?
Take the statement “the button is pressed”. Its value is either true or false, written as 1 or 0. This is a Boolean value; a circuit passes it along a wire as a signal. We model the logic, not the voltage in a physical wire.
- Input AWhat we know: the button is pressed or released.
- RuleWhat to do with the input. Start with a wire that passes it through; add gates later.
- Output YThe result: the lamp is off (0) or on (1).
A truth table lists every possible input combination and its output. A column names a signal; a row is one case. One input gives two cases: 0 and 1. Two inputs give four: 00, 01, 10, 11. These are not four time steps: you can inspect the rows in any order.
First toggle A in the first circuit. In the next example, ↗ “Show case” in the table sets that case on the same circuit.
Chapter 1
Signals and tables
A statement can be true or false. A circuit represents these values with 1 and 0. Learn to read inputs, outputs and a complete list of possible cases.
Two values: 0 and 1
Let A mean ‘the door is open’. This is a statement: it is either true (1) or false (0). The switch sets input A, and lamp Y shows the circuit’s output.
Toggle A. What happens to Y?
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 |
|---|---|---|
| 0 | 0 | |
| 1 | 1 |
The lamp follows the input. A wire carries a value without changing it.
A truth table: every case
A truth table lists every possible input combination and its result. Here column A is the input and column Y is the output. The first row shows A = 0; the second shows A = 1.
Choose Show beside the first row, then the second. Compare the row’s values with the switch and lamp.
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 |
|---|---|---|
| 0 | 0 | |
| 1 | 1 |
One input gives two cases: 0 and 1. Choosing a row sets inputs for inspection; it does not change the circuit’s rule or submit an answer.
Chapter 2
The rule inside a gate
A logic gate receives input values and computes its output using one rule. Compare rules on the same inputs, rather than memorising names alone.
NOT: the opposite
NOT has one input. It changes 0 to 1 and 1 to 0.
Turn A on, then off. When is Y 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 |
|---|---|---|
| 0 | 1 | |
| 1 | 0 |
Y is on when A is off. This is negation: NOT A.
AND: both are needed
AND needs both conditions: for example, a door needs key A and permission B. Y turns on only at A = 1 and B = 1. Two inputs give four cases: 00, 01, 10 and 11.
Turn on only A, then only B, then both. Find these cases in the table.
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 | |
| 0 | 1 | 0 | |
| 1 | 0 | 0 | |
| 1 | 1 | 1 |
One on input is not enough: 1 AND 0 = 0. Both on: 1 AND 1 = 1.
OR: at least one
OR turns Y on if A is on, B is on, or both are on.
Try all four table rows. Include 1 and 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 | |
| 0 | 1 | 1 | |
| 1 | 0 | 1 | |
| 1 | 1 | 1 |
Logical OR includes both conditions being true: 1 OR 1 = 1.
XOR: exactly one
XOR is on when its inputs differ. Both off or both on gives 0.
Turn both inputs on. How is this different from OR?
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 | |
| 0 | 1 | 1 | |
| 1 | 0 | 1 | |
| 1 | 1 | 0 |
1 XOR 1 = 0. Exactly one is what makes XOR different from OR.
NAND: not both
NAND reverses the result of AND. Its output is 0 only when both inputs are 1; every other case gives 1.
Turn both inputs on. Then turn either one off. What happens to Y?
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 | 1 | |
| 0 | 1 | 1 | |
| 1 | 0 | 1 | |
| 1 | 1 | 0 |
NAND rejects only the 11 case. Putting NOT after AND gives the same rule: NOT(A AND B).
NOR: neither
NOR reverses the result of OR. Y is on only when both inputs are off. For example, an ‘all clear’ signal stays on while neither sensor is active.
Start with both inputs off. Turn one on, then both.
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 | 1 | |
| 0 | 1 | 0 | |
| 1 | 0 | 0 | |
| 1 | 1 | 0 |
NOR accepts only 00. NOT after OR gives the same result: NOT(A OR B). Neither for NOR is different from not both for NAND.
XNOR: matching values
XNOR reverses the result of XOR. It checks whether two values match: Y = 1 for both 00 and 11.
Make the inputs match, then differ. When does Y turn 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 | B | Y |
|---|---|---|---|
| 0 | 0 | 1 | |
| 0 | 1 | 0 | |
| 1 | 0 | 0 | |
| 1 | 1 | 1 |
XNOR checks whether two bits are equal. A bit is one 0 or 1 value; comparing multi-bit numbers requires checking every bit.
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 | B | Y |
|---|---|---|---|
| 0 | 0 | 0 | |
| 0 | 1 | 0 | |
| 1 | 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
The opposite
Lamp Y is on when A is off.
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 | Y |
|---|---|---|
| 0 | ? | |
| 1 | ? |
What the circuit must do
Required is the specified output for each case. ↗ sets that case on your circuit.
| Show case | A | Required Y |
|---|---|---|
| 0 | 1 | |
| 1 | 0 |
↗ shows a case. 0 / 1 is your answer for that row.
Build your answer, then press Check. Every input combination is tested.