Teachers' Portal  /  IGCSE Computer Science 0478  /  Boolean logic  /  Writing logic expressions
Lesson pack · IGCSE Computer Science 0478 · 10 (3) · IGCSE

Writing logic expressions

Say it in logic. A logic expression describes a whole circuit in one line, such as X = (A AND B) OR NOT C.

Student lesson Lab, full screen
At a glance

The shape of the lesson

Topic
Boolean logic
Syllabus reference
Cambridge IGCSE Computer Science 0478, 10 (3)
Level
IGCSE
Duration
45 minutes, lab-led; stretches to a 60 minute block (see the contingency notes)
Position in topic
Lesson 4 of 4 in Boolean logic; follows Completing truth tables
Central model
Fig. 1: label the output of the first gate (P), then build the expression for X from it
Cooperative structure
Assessment
Stage 1 check and the exam-style plenary from the student lesson, plus the worksheet as the exit task
Learning objectives

By the end of the lesson, learners can

Section by section
  • From a circuit: Pick an expression in the lab and study the circuit it draws.
  • From a problem statement: Work through a problem in the lab: write your expression before revealing the answer.
  • From a truth table: Every row where X = 1 is one way of making the output true.
Key points to leave on the board
  • Circuits: label each gate output, work from the inputs to X, and bracket each gate.
  • Statements: and = AND, or = OR, not or = 0 means NOT; "either ... or" is one bracket.
  • Truth tables: one AND term per row with X = 1 (NOT on the 0s), joined with OR.
  • Check: substitute two rows of inputs into your expression.
The core visual model

One picture every idea returns to

A logic expression names the output and describes the gates in words: X = (A AND B) OR NOT C. Each gate with two inputs is written as (input OPERATOR input) in brackets, and NOT goes in front of the input or bracket it inverts. From a circuit, label each gate output and work from left to right. From a statement, translate and, or and not. From a truth table, write an AND term for each row where X = 1 and join the terms with OR.

A B C X P = A NOR B X = P XOR C = (A NOR B) XOR C
Fig. 1: label the output of the first gate (P), then build the expression for X from it
Lesson sequence

Forty-five minutes, phase by phase

TimePhaseWhat happens in the roomGrouping
0 to 5 minHook: predictOpen with the question in the title, Say it in logic.. A logic expression describes a whole circuit in one line, such as X = (A AND B) OR NOT C. Put the figure on the board: it is the one picture every idea in the lesson returns to.Whole class, then pairs
5 to 13 minTeach and check: From a circuitPick an expression in the lab and study the circuit it draws. Project tab 2 of the lab (Circuit and expression) and let a student drive it while the class predicts. Model the worked example Reading Fig. 1 on the board, one line at a time. Your turn: A and B go into an AND gate. C goes into a NOT gate. The outputs of these two gates go into a NOR gate, whose output is X. Write the expression.Whole class, then pairs
13 to 21 minTeach and check: From a problem statementWork through a problem in the lab: write your expression before revealing the answer. Project tab 3 of the lab (Problem statement to expression) and let a student drive it while the class predicts. Model the worked example Security light on the board, one line at a time. Your turn: X is 1 if exactly one of A and B is 1 and C is 0. Write the expression.Pairs
21 to 30 minTeach and check: From a truth tableEvery row where X = 1 is one way of making the output true. Model the worked example Two rows with X = 1 on the board, one line at a time. Your turn: A two-input table has X = 1, 0, 0, 1 for the rows 00, 01, 10, 11. Write an expression.Connect-Extend-Challenge
30 to 36 minCheckThe four Stage 1 questions from the student lesson, answered on mini whiteboards or by show of fingers. Re-teach the one most get wrong.Individual, then whole class
36 to 43 minPlenaryThe exam-style questions from Stage 2, one at a time: thirty seconds alone, then a random call. The feedback lines in the key give the examiner's wording.Individual, random call
43 to 45 minExit and homeworkSet the worksheet below (6 questions, 16 marks). Learners self-assess against the objectives before they leave.Individual
Timing and contingency

Protect the parts that carry the learning

The sequence carries about fifty minutes of material, so the lab is driven by one student while the class predicts rather than explored freely. Times are a guide.

Protected: the check at 30 minutes. It is the only individual read on whether the key idea landed, and it is not cut.

Cut first if the build overruns: the last check in From a truth table, never the check or the plenary.

In a 60 minute block: run worksheet questions 1 to 3 in class as a Rally Coach set and model both the hardest worked example and its check live.

Running the cooperative task

Connect-Extend-Challenge

After the new idea, each student writes three lines: how it connects to what they knew, how it extends their thinking, and what still challenges them. Pairs compare, then the challenges become the plenary.

The full structure, with its variations and the other twelve, is on the cooperative-learning page.

Examiner traps to pre-empt

What to head off, and how

Trap learners fall intoTeaching move that pre-empts it
Identify the gates from their shapes, not from where they sit.An OR shape with a circle is NOR, not OR; an extra curve behind it makes it XOR.
Brackets change the meaning.(D AND W) OR M and D AND (W OR M) give different outputs: for D = 0, W = 0, M = 1 the first is 1 and the second is 0.
Use NOT for the inputs that are 0 in a row, not for the ones that are 1.Check your expression by putting two rows back into it.
Worksheet

Writing logic expressions: worksheet

6 questions, 16 marks. Written in the style of the papers; no past paper question is reproduced.

NameClassDate
Q1 · write[2 marks]

A logic circuit has a NOT gate with input A. The output of the NOT gate and input B go into an AND gate. The output of the AND gate and input C go into an OR gate, whose output is X. Write the logic expression for X.

Q2 · write[3 marks]

A logic circuit has a NAND gate with inputs A and B and a NOR gate with inputs B and C. Both outputs go into an XOR gate, whose output is X. Write the logic expression for X.

Q3 · apply[3 marks]

A sprinkler S switches on (S = 1) if the soil is dry (D = 1) and it is not raining (R = 0), or if the temperature is very high (T = 1). Write the logic expression for S.

Q4 · apply[2 marks]

A two-input truth table has the output X = 1, 1, 0, 1 for the rows A B = 00, 01, 10, 11. Write a logic expression for X.

Q5 · data[3 marks]

A three-input truth table has X = 1 only in the rows A B C = 010 and 110. Every other row has X = 0. Write a logic expression for X.

Q6 · analysis[3 marks]

An alarm X sounds if the door is open (D = 1) and either the window is open (W = 1) or the motion sensor is triggered (M = 1). A student writes X = (D AND W) OR M. Explain the error, give the correct expression and give one set of inputs for which the two expressions differ.

Answer key and marking notes
Q1 · 2 marks
  • NOT A AND B for the first two gates, in a bracket.
  • X = (NOT A AND B) OR C.
Q2 · 3 marks
  • (A NAND B).
  • (B NOR C).
  • X = (A NAND B) XOR (B NOR C).
Q3 · 3 marks
  • Not raining is NOT R.
  • D AND NOT R in one bracket.
  • S = (D AND NOT R) OR T.
Q4 · 2 marks
  • X is 0 only when A = 1 and B = 0.
  • X = NOT A OR B (or the equivalent (NOT A AND NOT B) OR (NOT A AND B) OR (A AND B)).
Q5 · 3 marks
  • Row 010: (NOT A AND B) AND NOT C.
  • Row 110: (A AND B) AND NOT C; join the two with OR.
  • X = ((NOT A AND B) AND NOT C) OR ((A AND B) AND NOT C), which is equivalent to X = B AND NOT C.
Q6 · 3 marks
  • The student's expression lets the motion sensor sound the alarm even when the door is closed.
  • Correct: X = D AND (W OR M).
  • For example D = 0, W = 0, M = 1: the student's expression gives 1 but the correct one gives 0.
Quiz

6 multiple-choice questions on this lesson

From the topic question bank. Assign them in the app for a marked score in your gradebook, or run the topic as a class game.

Q11 mark

Which logic expression represents this circuit?

A B C X
  • AX = (A OR B) NAND C
  • BX = (A NAND B) OR C
  • CX = A OR (B NAND C)
  • DX = (A OR B) AND C
Q21 mark

A heater H switches on (H = 1) when it is cold (T = 1) and the window is not open (W = 0). Which logic expression is correct?

  • AH = T AND NOT W
  • BH = T AND W
  • CH = NOT T AND W
  • DH = T OR NOT W
Q31 mark

Which logic expression matches this truth table?

A B X 0 0 0 0 1 0 1 0 1 1 1 0
  • AX = A AND NOT B
  • BX = NOT A AND B
  • CX = A OR NOT B
  • DX = A NAND B
Q41 mark

In the logic expression X = (A NOR B) XOR C, what do the brackets around A NOR B show?

  • Athat A NOR B is one gate whose output is an input to the XOR gate
  • Bthat A NOR B must be inverted before it is used
  • Cthat A and B are both inputs to the XOR gate
  • Dthat A NOR B is the final output of the circuit
Q51 mark

Which logic expression matches this truth table?

A B C X 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 1 1 1 0 0 1 1 1 0
  • AX = NOT B AND C
  • BX = B AND NOT C
  • CX = NOT A AND C
  • DX = (A XOR B) AND C
Q61 mark

A light X is on (X = 1) if exactly one of the switches A and B is on (= 1), or if the sensor C is off (C = 0). Which logic expression is correct?

  • AX = (A XOR B) OR NOT C
  • BX = (A OR B) OR NOT C
  • CX = (A XOR B) AND NOT C
  • DX = A XOR (B OR NOT C)
Quiz key
Q1: A

The first gate has the curved OR shape and takes A and B, giving (A OR B). The last gate is the D-shaped AND body with a circle, so it is NAND, with inputs (A OR B) and C: X = (A OR B) NAND C. (A NAND B) OR C swaps the two gates. A OR (B NAND C) feeds the wrong inputs into the first gate. (A OR B) AND C ignores the circle that inverts the output.

Q2: A

Both conditions are needed, so AND; the window condition is true when W = 0, so it is NOT W: H = T AND NOT W. T AND W would heat only when the window is open. NOT T AND W puts the NOT on the wrong input. T OR NOT W would heat a warm room just because the window is shut.

Q3: A

X = 1 only in row A = 1, B = 0, so X needs A and NOT B together: X = A AND NOT B. NOT A AND B is 1 in row 01 instead. A OR NOT B is 1 in rows 00, 10 and 11. A NAND B is 1 in every row except 11.

Q4: A

Each bracket is one gate worked out first; its output then feeds the next gate, here the XOR gate with C. Brackets do not invert anything: only NOT (or the circle in NAND and NOR) does that. A and B go into the NOR gate, not straight into the XOR gate. The final output X comes from the XOR gate, the last operator outside the brackets.

Q5: A

X = 1 only in rows 001 and 101, giving ((NOT A AND NOT B) AND C) OR ((A AND NOT B) AND C). A changes between the two rows, so it does not matter: X = NOT B AND C. B AND NOT C is 1 in rows 010 and 110 instead. NOT A AND C is 1 in rows 001 and 011, so it gives the wrong output for 011 and 101. (A XOR B) AND C is 1 in rows 011 and 101, so it gives the wrong output for 001 and 011.

Q6: A

"Exactly one of A and B" is A XOR B, and "or if C is off" adds OR NOT C: X = (A XOR B) OR NOT C. (A OR B) OR NOT C would also light when both switches are on. Using AND would need both conditions at once. A XOR (B OR NOT C) groups the sensor with B instead of keeping A XOR B together.

Lab and demo

What to project

The student lesson embeds these tabs. Open them full screen on the projector; every slider has a drag handle on the stage.

Slides

Slides for this lesson

A projectable deck for every pack is on the way. Until then, present the student lesson full screen: its sections, figure and lab tabs follow the same order as the plan above.

Also for this topic

Everything else you can use

Original work by the TheLucidSTEM team. The worksheet items are written in the style of the papers; no past paper question is reproduced.
Previous lessonCompleting truth tables