3 missions. Guess, learn, then check. Your place is saved.
Mission 1"Tea or coffee?" Would a computer's OR let you have both?
Mission 2Three sensors, one alarm: how many cases must you test?
Mission 3NAND flash is named after a logic gate. What does that gate do?
The specification points and sources are listed under the lesson: see Sources.
Mission 1
"Tea or coffee?" Would a computer's OR let you have both?
Make a guess: "Tea or coffee?" Would a computer's OR let you have both?
Boolean logic · AND, OR, NOT
1 or 0, and NOT
A Boolean value has only two states: 1 (TRUE) or 0 (FALSE).
A truth table lists every possible combination of inputs with the output for each.
NOT has one input and reverses it: NOT 0 = 1, NOT 1 = 0.
Write it as NOT A.
Boolean logic · AND, OR, NOT
AND
AND has two inputs. The output is 1 only when both inputs are 1.
If either input is 0, the output is 0.
Write it as A AND B.
A
B
A AND B
0
0
0
0
1
0
1
0
0
1
1
1
Boolean logic · AND, OR, NOT
OR
OR has two inputs. The output is 1 when at least one input is 1.
The output is 0 only when both inputs are 0.
This is wider than everyday "or", which often means "one or the other, not both".
Write it as A OR B.
A
B
A OR B
0
0
0
0
1
1
1
0
1
1
1
1
Your answer
?A = 1 and B = 0. Work out NOT A, then A AND B, then A OR B. Type the three output bits in that order.
Boolean logic · AND, OR, NOT
XOR
XOR (exclusive OR) has two inputs. The output is 1 when the inputs are different.
If both inputs are the same (both 0 or both 1), the output is 0.
Cambridge also calls it EOR.
Write it as A XOR B.
A
B
A XOR B
0
0
0
0
1
1
1
0
1
1
1
0
Quick check
?A hall light has a switch at each end. Flipping either switch changes the light, whatever the other switch is set to. Which operator gives this behaviour?
Boolean logic · AND, OR, NOT
Logic gate symbols
A logic gate is a circuit that carries out one logical operator.
AND: flat back, rounded front, two inputs.
OR: curved back, pointed front, two inputs.
NOT: a triangle with a small circle at the output. The circle means "reverse".
XOR: the OR shape with an extra curved line behind the inputs.
Inputs enter on the left; the output leaves on the right.
Quick check
?A cash machine gives out money only if the card is valid (V) and the PIN is correct (P). Which logic statement matches?
Mission check
?"Tea or coffee?" A customer ticks both, so Tea = 1 and Coffee = 1. What does Tea OR Coffee give?
Yes. A computer's OR gives 1 when at least one input is 1, and that includes when both are 1. The output is 0 only when both inputs are 0.
Mission 2
Three sensors, one alarm: how many cases must you test?
Make a guess: Three sensors, one alarm: how many cases must you test?
Boolean logic · combining operators
Combining operators
One logic statement (expression) can use several operators, e.g. (A AND B) OR NOT C.
Work out brackets first.
NOT applies only to the input or bracket just after it.
Example: (1 AND 0) OR (1 AND 1) = 0 OR 1 = 1
XOR combines in the same way: NOT (1 XOR 0) = NOT 1 = 0
Boolean logic · combining operators
Every combination of three inputs
Each input can be 0 or 1, so each new input doubles the number of rows.
Use brackets to group conditions that go together.
Example: the alarm X sounds if the door is open (D) and the system is armed (S), or if the panic button (P) is pressed.
X = (D AND S) OR P
Quick check
?A greenhouse sprinkler W switches on when the soil is dry (D) and it is not raining (R), or when the manual override (M) is pressed. Which logic statement matches?
Boolean logic · combining operators
Logic circuits
A logic circuit joins gates with wires, inputs on the left. Each gate's output feeds the next gate.
To write the expression, work from the inputs to the output, one gate at a time.
The alarm X = (D AND S) OR P is an AND gate (inputs D, S) feeding an OR gate with P.
Draw the statement as given, without simplifying. Every gate except NOT has two inputs.
Quick check
?Look at the circuit in the diagram. Which logic statement does it represent?
Mission check
?Three sensors, one alarm. How many different input combinations must the truth table cover?
8. Each sensor can be 0 or 1, so each one doubles the number of cases: 2 × 2 × 2 = 8. Counting in binary from 000 to 111 lists all 8 rows, so no case is missed.
Mission 3
NAND flash is named after a logic gate. What does that gate do?
Make a guess: NAND flash is named after a logic gate. What does that gate do?
Boolean logic · NAND and NOR
NAND
NAND means NOT AND: an AND gate followed by NOT.
The output is 0 only when both inputs are 1. Otherwise it is 1.
Symbol: the AND shape with a small circle (bubble) on the output.
Write it as A NAND B, which equals NOT (A AND B).
A
B
A AND B
A NAND B
0
0
0
1
0
1
0
1
1
0
0
1
1
1
1
0
Boolean logic · NAND and NOR
NOR
NOR means NOT OR: an OR gate followed by NOT.
The output is 1 only when both inputs are 0. Otherwise it is 0.
Symbol: the OR shape with a small circle on the output.
Write it as A NOR B, which equals NOT (A OR B).
A
B
A OR B
A NOR B
0
0
0
1
0
1
1
0
1
0
1
0
1
1
1
0
Quick check
?A gate's output column, for inputs 00, 01, 10, 11, is 1, 0, 0, 0. Which gate is it?
Boolean logic · NAND and NOR
All six gates side by side
A bubble on the output reverses the column: NAND is AND reversed, NOR is OR reversed.
AND 0001 · NAND 1110 · OR 0111 · NOR 1000 · XOR 0110 (inputs 00, 01, 10, 11).
NOT is the only gate with one input. All the others have exactly two.
To spot a gate from its column, count the 1s and see which rows they are on.
Your answer
?X = (A NAND B) NOR C. Complete the output column for the rows 000, 001, 010, 011, 100, 101, 110, 111 (in that order). Type the 8 bits.
Boolean logic · NAND and NOR
From a truth table to an expression
Find each row where the output is 1.
For each such row, AND the inputs, with NOT on any input that is 0.
Join the row terms with OR.
Example: X = 1 on rows 01 and 10 gives X = (NOT A AND B) OR (A AND NOT B). That is XOR.
For a circuit, draw one 2-input gate per operator, without simplifying.
Quick check
?A truth table with inputs A, B, C has X = 1 only on rows 001 and 110. Which expression matches it?
Mission check
?NAND flash memory is named after the NAND gate. What does a NAND gate do?
A NAND gate is an AND gate followed by NOT. It outputs 0 only when both inputs are 1, and 1 for every other input.
Recap
Big ideas
Every input and output is 1 (TRUE) or 0 (FALSE). A truth table lists every combination of inputs.
AND: 1 only if both inputs are 1. OR: 1 if at least one input is 1. NOT: reverses its one input.
XOR: 1 only when the two inputs are different.
Work out brackets first; NOT applies only to what comes straight after it.
3 inputs give 8 rows: count in binary from 000 to 111, and add working columns for each part.
Turn a problem into a statement by giving each condition a letter and mapping "and", "or", "not".
In a circuit, each gate's output feeds the next gate; read it from inputs to output.
NAND = NOT AND (column 1110). NOR = NOT OR (column 1000). The bubble means NOT.
To write an expression from a truth table, AND the inputs for each row that outputs 1, then OR the row terms together.
🏆
Mini-lesson complete!
⭐⭐⭐
You've worked through Boolean logic for Cambridge IGCSE Computer Science (0478/0984). 🎉
Mission 1"Tea or coffee?" Would a computer's OR let you have both?
Mission 2Three sensors, one alarm: how many cases must you test?
Mission 3NAND flash is named after a logic gate. What does that gate do?