Skip to content
Cambridge IGCSE0478

Boolean logic

Computer Science 0478 Chapter Notes

What this chapter covers

Boolean logic
ShareWhatsAppPost
Boolean logic notes

Read online free. Download a watermarked copy with a free account.

Read the notes

The full Boolean logic notes as text: skim, search, and jump between subtopics.

~8 min read

1. NOT, AND and OR gates

Every gate has its own standard symbol. Draw the symbol from the syllabus.

A NOT gate has one input and gives the opposite value: 1 becomes 0 and 0 becomes 1. All the other gates have two inputs.

An AND gate outputs 1 only when both inputs are 1. An OR gate outputs 1 when at least one input is 1.

X = NOT A

X = A AND B

X = A OR B

Examiner insight

“Some candidates need to take more care when drawing logic gates to make sure each gate has its own distinctive shape, for example, NOR and XOR gates shouldn’t have straight sides with curved backs, as this could confuse them with NOT gates.” “Circles or text-based logic circuits are not enough to demonstrate understanding and the correct symbols must be used.”

Worked example 12 marks

Complete the truth table for the logic expression X = NOT A OR B.

ABX
00
01
10
11
  1. 1

    NOT A: 1, 1, 0, 0 for the four rows [1]

  2. 2

    X = (NOT A) OR B: 1, 1, 0, 1 [1]

2. NAND, NOR and XOR gates

A NAND gate is an AND gate followed by NOT. Its output is 0 only when both inputs are 1.

A NOR gate is an OR gate followed by NOT. Its output is 1 only when both inputs are 0.

An XOR (EOR) gate outputs 1 only when its two inputs are different. With inputs 1 and 1 an OR gate gives 1 but an XOR gate gives 0.

X = A NAND B

X = A NOR B

X = A XOR B

Examiner insight

“The most common incorrect gate given was a NOR gate given in place of the XOR gate.” “Some candidates drew a circle at the right point of the XOR gate. This turns the gate into an XNOR gate, which is incorrect.”

Worked example 12 marks

A two-input OR gate and a two-input XOR gate both have the inputs A = 1 and B = 1. State the output of each gate.

  1. 1

    OR gate: output 1, because at least one input is 1 [1]

  2. 2

    XOR gate: output 0, because the two inputs are not different [1]

3. Drawing a circuit from an expression

Build the circuit gate by gate from the expression, working out the brackets first. Do not simplify the expression.

The mark scheme gives one mark for each correct gate, with its correct inputs. A NOT is a gate of its own.

The gates for X = (A NAND NOT B) XOR (A NOR C) are:

``` G1 ← NOT B G2 ← A NAND G1 G3 ← A NOR C X ← G2 XOR G3 ```

Examiner insight

“A common error was mixing up the B OR NOT C and drawing NOT (B OR C) instead.” “Candidates who constructed a logic circuit directly from the given logic expression without attempting to simplify or otherwise alter any of the logic gates generally achieved the best marks.”

Worked example 15 marks

Consider the logic expression:

Z = NOT (B OR NOT C) XOR (A NAND C)

Draw a logic circuit for this logic expression. Each logic gate must have a maximum of two inputs. Do not simplify the logic expression.

  1. 1

    gate 1: `NOT C` [1]

  2. 2

    gate 2: `B OR` (output of gate 1) [1]

  3. 3

    gate 3: `NOT` (output of gate 2) [1]

  4. 4

    gate 4: `A NAND C` [1]

  5. 5

    gate 5: output of gate 3 `XOR` output of gate 4, giving Z [1]

4. Completing a truth table from an expression

A three-input truth table has eight rows, from 000 to 111. Use a working column for each gate, then combine the columns. Check the last column against the original expression, not against your own circuit.

Marks go by the number of correct outputs: four marks for eight correct outputs, three for six or seven, two for four or five, one for two or three.

Examiner insight

“A small number of candidates gave a response that was the exact opposite to the expected answer suggesting either an extra NOT had been applied or a NOT had been missed.” “Use of the original logic expression is recommended to answer this question.”

Worked example 14 marks

Consider the logic expression:

X = (A NAND NOT B) XOR (A NOR C)

Complete the truth table from the given logic expression.

ABCX
000
001
010
011
100
101
110
111
  1. 1

    `A NAND NOT B` by row: 1, 1, 1, 1, 0, 0, 1, 1

  2. 2

    `A NOR C` by row: 1, 0, 1, 0, 0, 0, 0, 0

  3. 3

    XOR the two columns: X = 0, 1, 0, 1, 0, 0, 1, 1 (eight correct outputs) [4]

5. Writing an expression from a circuit or statement

Name each gate and its inputs, then join the parts with brackets. A circuit with three inputs and one output gives an expression such as `(A XOR B) OR (B AND NOT C)`.

The mark scheme gives one mark for each bracketed part, such as A XOR B and B AND NOT C, and one for the correct expression. In a statement, "and", "or" and "not" give AND, OR and NOT.

Examiner insight

“The most common error was the inputs of the AND gate for A AND T being A AND NOT T.”

Worked example 13 marks

A greenhouse fan F switches on when the temperature sensor T is 1 and the window sensor W is not 1, or when the manual switch M is 1. Write the logic expression for F.

  1. 1

    the first condition: T AND NOT W [1]

  2. 2

    the second condition, M, is joined with OR [1]

  3. 3

    correct expression: F = (T AND NOT W) OR M [1]

6. Writing an expression from a truth table

Take each row whose output is 1. Write the AND of the inputs for that row, with NOT on any input that is 0.

Join the rows with OR. Check the expression by working out its truth table again.

Worked example 13 marks

The truth table has inputs A and B and output X. Write a logic expression for X.

ABX
000
011
101
110
  1. 1

    rows with X = 1: A = 0, B = 1 and A = 1, B = 0 [1]

  2. 2

    row terms: NOT A AND B, and A AND NOT B [1]

  3. 3

    X = (NOT A AND B) OR (A AND NOT B). A XOR B has the same truth table. [1]

Recap

  • NOT has one input. Every other gate has two.
  • AND: 1 only if both inputs are 1. OR: 1 if at least one input is 1.
  • NAND and NOR are AND and OR followed by NOT.
  • XOR: 1 only if the inputs are different.
  • Draw the circuit from the expression without simplifying. One mark per gate.
  • A three-input truth table has eight rows. Marks go by the number of correct outputs.
  • From a truth table: AND the inputs in each row with output 1, then OR the rows.

End-of-chapter exercise

Test yourself on the whole chapter. Work through these before moving on.

  1. State the number of inputs of a NOT gate. State its output when the input is 1.2 marks
  2. State the output of an AND gate and the output of an OR gate when both have the inputs 1 and 0.2 marks
  3. State the output of a NAND gate when both inputs are 1. Give a reason.2 marks
  4. Give the output of a NOR gate for the input pairs 00, 01, 10 and 11, in that order.2 marks
  5. A two-input gate outputs 1 only when its inputs are different. Name the gate.1 mark
  6. A lamp L is on when the switch S is 1 and the sensor T is 0. Write the logic expression for L.2 marks
  7. Complete the truth table for the logic expression X = (A OR B) AND NOT C. | A | B | C | X | | --- | --- | --- | --- | | 0 | 0 | 0 | | | 0 | 0 | 1 | | | 0 | 1 | 0 | | | 0 | 1 | 1 | | | 1 | 0 | 0 | | | 1 | 0 | 1 | | | 1 | 1 | 0 | | | 1 | 1 | 1 | |4 marks
  8. A safe unlocks (X = 1) only when its two keys P and Q are in the same position. The truth table gives X for each pair of inputs. Write the logic expression for X. Check it for P = 1 and Q = 0. | P | Q | X | | --- | --- | --- | | 0 | 0 | 1 | | 0 | 1 | 0 | | 1 | 0 | 0 | | 1 | 1 | 1 |4 marks
  9. A student is asked to give the gates for Z = (A OR NOT B) NAND (B XOR C) without simplifying. The student writes: ``` G1 ← A OR B G2 ← NOT G1 G3 ← B XOR C Z ← G2 NAND G3 ``` (a) State the student's error. [1] (b) Give the correct gates in order. Each gate has a maximum of two inputs. [4] (c) Work out the number of rows of the truth table in which the student's circuit gives the wrong output. [3]8 marks
  10. A cold store alarm X sounds (X = 1) when the door sensor D is 1 and the temperature sensor T is not 1, or when exactly one of the temperature sensor T and the power sensor P is 1. (a) Write the logic expression for X. [3] (b) Complete the truth table for X. [4] (c) An engineer replaces the last gate of the circuit with a NOR gate. Give the new output column and the number of rows in which the alarm now sounds. [2] | D | T | P | X | | --- | --- | --- | --- | | 0 | 0 | 0 | | | 0 | 0 | 1 | | | 0 | 1 | 0 | | | 0 | 1 | 1 | | | 1 | 0 | 0 | | | 1 | 0 | 1 | | | 1 | 1 | 0 | | | 1 | 1 | 1 | |9 marks

Go deeper

Practise and revise with member-only material for this chapter.

Free notes are just the start.

Unlock every Workbook and Chapter at a Glance, and generate your own worksheets and predicted papers.

Explore plans

Related chapters