Skip to content
myAudience.
← Explore the library

Truth tables connect circuits and programs

By UK GCSE Computer Science · independent study · myAudience

Prescribed gate shapes show A and B feeding AND; output T and independent C feed OR to Y. Separate NOT,AND,OR,XOR symbols distinguish the inversion circle and XOR extra input curve. Inputs1,0,0 give0; inputs1,0,1 give1.

Original built-in imagegen teaching raster; author inspected original and three served sizes2026-10-04. Independent derivative review pending. · Generated project artwork; no copied exam or publisher illustration. Independent rights/publication review pending.

Truth tables connect circuits and programs

Boolean algebra describes values 0 and 1, interpreted here as false and true. AND outputs 1 only for inputs 11; OR outputs 1 for 01, 10 and 11; XOR outputs 1 for 01 and 10 but not 11; NOT maps 0 to 1 and 1 to 0. XOR is “exactly one” for two inputs, unlike inclusive OR. A truth table is exhaustive for a fixed finite set of Boolean inputs. Entry skills are lesson 3 conditions and systematic tabulation. Up to three inputs give eight rows, because each of three positions has two independent choices.

For Y = (A AND B) OR C, compute intermediate T = A AND B before computing Y = T OR C. In input order 000,001,010,011,100,101,110,111, outputs are 0,1,0,1,0,1,1,1. A three-input diagram has two connected operations, not an AND of all three. The generated visual shows the dependency using the prescribed gate shapes: the AND output T and the independent input C feed OR. Its lower strip distinguishes NOT, AND, OR and XOR; practise drawing and recognising these symbols as well as tracing their outputs. NOT is conventionally an inversion with a small output circle, AND has a flat input edge and rounded output, OR has a curved input edge, and XOR adds a second curve at its input. This verbal guide does not replace drawing and recognising the prescribed symbols.

uses a dot for AND, plus for OR, an exclusive-OR symbol for XOR and an overbar for NOT. A plus in a Boolean expression does not mean integer addition: 1 OR 1 remains 1. Parentheses or intermediate columns remove ambiguity. To turn an expression into a circuit, create operations for innermost expressions first and connect their outputs to the next operation. To recover an expression from a circuit, name each internal wire and substitute its defining expression. This works in either direction and helps locate a wire connected to the wrong input.

In Python, bool-valued and/or/not express the same decisions, while a != b implements XOR when a and b are Booleans. Do not generalise that inequality to arbitrary values without a contract. Also Python and and or return operands and short-circuit; they are not physical gates evaluating at the same instant. We restrict inputs to Boolean values so the truth table comparison is meaningful. A short-circuit guard such as divisor != 0 and total / divisor > 3 avoids a division only because the left expression is evaluated first.

Exhaustive truth-table testing can establish equivalence of two expressions for all eight combinations in this model. It cannot establish that a sensor reliably reports its physical state or that a circuit has safe timing behaviour. If A means authorised adult, B means consent and C means emergency, Y permits an emergency independently of A and B. Whether that is ethical or secure is a policy question before it is a logic question. Enumerating a dangerous exception makes it visible; it does not justify the exception.

Runnable original Python 3 example (also saved verbatim in examples for CLI execution):
```python
from itertools import product

def decision(a, b, c):
return (a and b) or c

def exactly_one(a, b):
return a != b

outputs = [int(decision(a, b, c)) for a, b, c in product((False, True), repeat=3)]
assert outputs == [0, 1, 0, 1, 0, 1, 1, 1]
assert [int(exactly_one(a, b)) for a, b in product((False, True), repeat=2)] == [0, 1, 1, 0]
for a, b in product((False, True), repeat=2):
assert not (a and b) == ((not a) or (not b))
print(outputs)
```

Worked example: Create the table for Z = A XOR B and explain the difference from A OR B.

List 00, 01, 10, 11 exactly once.

XOR is true only when the inputs differ: 0,1,1,0.

OR is 0,1,1,1; the only changed row is 11.

Answer: XOR excludes the both-true case.

Check your understanding: Transfer: an alarm should sound when exactly one of two sensors reports an open door, but never during maintenance M. Give an expression, all eight outputs in A,B,M order, and a circuit design.

Answer: Z = (A XOR B) AND NOT M. Outputs for 000,001,010,011,100,101,110,111 are 0,0,1,0,1,0,0,0. Feed A and B to XOR, M to NOT, and both resulting outputs to AND.

Why: The maintenance condition must gate the entire XOR output. (A XOR (B AND NOT M)) fails when A is true during maintenance; row 101 is a counterexample. Enumerating every combination checks both the exclusive condition and the inhibit condition.

Author source references