10 Boolean logic

Show All Section Notes
Test yourself on Boolean logic 13 questions — drag-to-order, code completion, matching and multiple choice.
Start the quiz

Logic Expressions

Watch this lesson Video 10.3 · 9:23 · Moving between expression, truth table and circuit — in every direction the syllabus asks for

1. Understanding the Syntax

A logic problem can be represented three ways, and the syllabus expects you to move freely between all of them: as a logic expression, as a truth table, and as a logic circuit. This lesson works through every one of those conversions.

Expressions themselves can be written in two notations. You must be comfortable with both:

  • Textual: $X = (\text{A AND B}) \text{ OR (NOT C)}$
  • Symbolic: $X = (A \cdot B) + \bar{C}$

In symbolic notation, AND is a dot, OR is a plus, and NOT is a bar drawn over the top. The dot and plus are borrowed from arithmetic but do not mean multiply and add — they mean AND and OR.

2. Reading a Logic Circuit

A logic circuit is a diagram: inputs enter on the left, pass through gates, and produce an output on the right. Here is the circuit for the expression we will use throughout this lesson.

A B C AND NOT OR X
$X = (\text{A AND B}) \text{ OR (NOT C)}$

To write the expression from a circuit, work left to right, gate by gate:

1 Label each gate's output. The AND gate takes A and B, so its output is A AND B. The NOT gate takes C, so its output is NOT C.
2 Feed those labels forward. The OR gate's two inputs are the outputs you just labelled, so X = (A AND B) OR (NOT C).
3 Bracket every gate output as you carry it forward. Without brackets, A AND B OR NOT C is ambiguous and will not be credited.

3. Worked Example: Building a Truth Table

Scenario: create a truth table for the expression:

X = (A AND B) OR (NOT C)

Step-by-Step Breakdown

1 Identify Inputs: There are 3 inputs (A, B, C). This means there are $2^3 = 8$ possible combinations.
2 Create Intermediate Columns: Solve the brackets first. Create a column for (A AND B) and another for (NOT C).
3 Final Output: Use the OR gate to combine the two intermediate columns.

The Resulting Truth Table

List the input combinations by counting up in binary — 000, 001, 010, and so on — so that no combination is missed or repeated. The five highlighted rows are the ones where the output is 1; they are used again in section 4.

A B C A AND B NOT C X
000011
001000
010011
011000
100011
101000
110111
111101

4. Writing an Expression from a Truth Table

This is the reverse direction, and it has a reliable method that always works. It is called the sum of products.

1 Look only at the rows where the output is 1. Ignore every row where the output is 0.
2 Write one AND term per row. For each of those rows, AND all the inputs together, putting NOT in front of any input that is 0 in that row.
3 OR all the terms together. The output is 1 if any of those rows occurs.

Applying that to the five highlighted rows above:

Row A=0 B=0 C=0 → (NOT A AND NOT B AND NOT C)
Row A=0 B=1 C=0 → (NOT A AND B AND NOT C)
Row A=1 B=0 C=0 → (A AND NOT B AND NOT C)
Row A=1 B=1 C=0 → (A AND B AND NOT C)
Row A=1 B=1 C=1 → (A AND B AND C)

OR those five terms together and you have a valid expression for X.

Correct, but not tidy. That five-term expression and the much shorter (A AND B) OR (NOT C) produce identical truth tables — they are the same function written two ways. Sum of products is guaranteed to give you an answer, which is what matters under exam pressure; it does not promise the shortest one. Unless a question asks you to simplify, a correct sum-of-products expression earns the marks.

5. Drawing a Circuit from an Expression

To go the other way, work outwards from the brackets, exactly as you would evaluate arithmetic.

1 Draw the inputs as labelled lines down the left-hand side, one per variable.
2 Draw a gate for each bracket first. (A AND B) becomes an AND gate fed by A and B; (NOT C) becomes a NOT gate fed by C.
3 Draw the gate that joins them. The OR in the middle of the expression becomes an OR gate fed by the two gate outputs.
4 Label the final output X, and check that every input you listed is actually connected to something.

Here is a second circuit to read for practice. Work out its expression before checking the caption.

P Q R NAND OR S
$S = (\text{NOT (P AND Q)}) \text{ OR R}$  —  the bubble on the AND gate makes it NAND

6. Common Logic Gate Combinations

  • NAND Logic: $\text{NOT (A AND B)}$ is the same as saying "Output 0 only when A and B are 1".
  • NOR Logic: $\text{NOT (A OR B)}$ is the same as saying "Output 1 only when A and B are both 0".

On a circuit diagram, NAND and NOR are drawn as an AND or OR gate with a small bubble on the output. That bubble is the NOT. Missing it is the single most common mistake when reading a circuit, and it inverts every value in your output column.

⚠️ Exam Tips:
  • Always use intermediate columns. Even if the question does not ask for them, drawing them prevents logic errors that ruin the entire output column.
  • List input combinations by counting up in binary so none is missed or duplicated.
  • When reading a circuit, write the output of each gate onto the diagram before combining them.
  • Check for bubbles on gate outputs — they turn AND into NAND and OR into NOR.