← GCSE Computer Science · OCR · GCSE Computer Science revision
⭐ 0
OCR GCSE Computer Science (J277) · 2.4 Boolean logic
Mini-Lesson

Boolean logic

2 missions. Guess, learn, then check. Your place is saved.

  1. Mission 1"Tea or coffee?" Would a computer's OR let you have both?
  2. Mission 2Three sensors, one alarm: how many cases must you test?
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

NOTANOT A0110
  • 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.
  • NOT A is also called negation; ¬A is accepted too.
Boolean logic · AND, OR, NOT

AND

Truth tablesABA AND B000010100111ANDABA OR B000011101111OR
  • AND has two inputs. The output is 1 only when both inputs are 1.
  • If either input is 0, the output is 0.
  • AND is also called conjunction; A ∧ B is accepted too.
ABA AND B
000
010
100
111
Boolean logic · AND, OR, NOT

OR

Truth tablesABA AND B000010100111ANDABA OR B000011101111OR
  • 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".
  • OR is also called disjunction; A ∨ B is accepted too.
ABA OR B
000
011
101
111
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

Logic gate symbols

Logic gate symbolsANDABQABQ000010100111ORABQABQ000011101111NOTAQAQ0110XORABQABQ000011101110
  • 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".
  • 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?
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
Boolean logic · combining operators

Every combination of three inputs

Counting the rows1 inputA012 rows×22 inputsAB000110114 rows×23 inputsABC0000010100111001011101118 rows
  • Each input can be 0 or 1, so each new input doubles the number of rows.
  • 1 input: 2 rows. 2 inputs: 4 rows. 3 inputs: 8 rows.
  • Fill the input columns by counting up in binary from 000 to 111. Then no row is missed or repeated.
Boolean logic · combining operators

Working columns

Working columnsABCA AND BNOT CP000011001000010011011000100011101000110111111101
  • For a long statement, add a column for each part.
  • Example: P = (A AND B) OR NOT C.
  • Column 4: A AND B. Column 5: NOT C. Column 6: P = column 4 OR column 5.
  • Working columns are optional, but they stop you mixing up steps.
ABCA AND BNOT CP
000011
001000
010011
011000
100011
101000
110111
111101
Your answer
?Q = (A OR B) AND NOT 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 · combining operators

From a problem to a logic statement

  • Give each condition a letter (1 = true, 0 = false).
  • "and" → AND; "or" / "either" → OR; "not" / "is off" → NOT.
  • 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

Alarm circuitANDD AND SORDSPX
  • 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.
Quick check
?Look at the circuit in the diagram. Which logic statement does it represent?
Which expression?ABCQ
Mission check

?Three sensors, one alarm. How many different input combinations must the truth table cover?
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.
  • 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.
🏆

Mini-lesson complete!

⭐⭐⭐

You've worked through Boolean logic for OCR GCSE Computer Science (J277). 🎉

  1. Mission 1"Tea or coffee?" Would a computer's OR let you have both?
  2. Mission 2Three sensors, one alarm: how many cases must you test?

Your stars: 0 / 0

Next: test yourself in the Verify stage.

📣 Smashed it? Share your score

Challenge a mate to beat your stars, or show a parent how you got on.

→ Back to GCSE Computer Science · OCR

Specification points and sources for this lesson are listed at the bottom of the page.

Sources (1)

The specification points and sources behind this lesson.

  1. 1 OCR J277 spec v3.1, 2.4.1 Boolean logic