Writing a logic expression from a problem statement

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Writing a logic expression from a problem statement

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. An alarm X sounds if the door is open (A) AND the system is switched on (B). Which expression is correct?
A X = A AND B
B X = A OR B
2. What is the first step when writing an expression from a problem statement?
A Fill in the output column of the truth table
B Give each condition an input letter such as A, B or C
3. A warning light X comes on if the temperature is too high (A) OR the pressure is too high (B), AND the system is armed (C). Which expression matches?
A X = A OR (B AND C)
B X = (A OR B) AND C
4. A window alarm X sounds if the window is open (A) AND the key is NOT in the panel (B). Which expression is correct?
A X = A AND (NOT B)
B X = NOT (A AND B)
5. A safety lock X is on when the door is closed (A) AND either the seat belt is fastened (B) OR the override is on (C). Which expression is correct?
A X = A AND (B OR C)
B X = (A AND B) OR C

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1X = (A AND B) OR C AThe brackets are missing, so it is unclear which gate is worked out first. The statement 'A and B together, or C' needs (A AND B) OR C.
2X = A AND (NOT B) BX = (A OR B) AND C
3The alarm sounds if the door is open (A) AND the system is switched on (B), OR if the panic button is pressed (C) CThe alarm sounds if A and B are both 1, or if C is 1 on its own
4A warning light comes on if the temperature is high (A) OR the pressure is high (B), AND the machine is running (C) DNOT C is used, but the statement says C is true (for example, the machine is running). NOT should only be used when the statement says 'not' or 'is off'.
5X = A AND B OR C EX is 1 only when A is 1 and B is 0
6X = (A OR B) AND NOT C FX = (A AND B) OR C

Definitions

X = (A AND B) OR C

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
# A = door open, B = window open X = A ___ B
2.
# Alarm if door (A) OR window (B) is open X = A __ B
3.
# A = door open, B = window locked # Alarm if door open AND window NOT locked X = A AND ___ B
4.
# A = door, B = window, C = key switch # X on if (door OR window) AND key on X = _A OR B) AND C
5.
# A = lid shut, B = guard shut, C = override # Runs if lid AND guard shut, or override X = (A AND B) OR _

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A # Alarm: door OR window open
B A = door, B = window
C X = A AND B
Question 2
A # Alarm: door open AND on
B A = door open, B = system on
C X = A OR B
Question 3
A # A guard shut, B stop pressed
B X = A AND B
C # Runs if shut and not pressed
Question 4
A # On if A or B, and not C
B X = (A AND B) AND NOT C
C # A dark, B motion, C override
Question 5
A # Buzzer: A, and B or C
B X = (A AND B) OR C
C # X = 1 when buzzer sounds

Answer Key

Writing a logic expression from a problem statement
Section A: Quick Questions
Q1
A — X = A AND B
Q2
B — Give each condition an input letter such as A, B or C
Q3
B — X = (A OR B) AND C
Q4
A — X = A AND (NOT B)
Q5
A — X = A AND (B OR C)
Section B: Match the Pairs
Q1
X = (A AND B) OR C → The alarm sounds if A and B are both 1, or if C is 1 on its own
Q2
X = A AND (NOT B) → X is 1 only when A is 1 and B is 0
Q3
The alarm sounds if the door is open (A) AND the system is switched on (B), OR if the panic button is pressed (C) → X = (A AND B) OR C
Q4
A warning light comes on if the temperature is high (A) OR the pressure is high (B), AND the machine is running (C) → X = (A OR B) AND C
Q5
X = A AND B OR C → The brackets are missing, so it is unclear which gate is worked out first. The statement 'A and B together, or C' needs (A AND B) OR C.
Q6
X = (A OR B) AND NOT C → NOT C is used, but the statement says C is true (for example, the machine is running). NOT should only be used when the statement says 'not' or 'is off'.
Section C: Definitions
Q1
X = (A AND B) OR C — Give each condition a letter (A, B, C), turn key words like AND, OR and NOT into gates, and use brackets to group parts so that X matches the wording of the statement.
Section D: Fill in the Blanks
Q1
# A = door open, B = window open X = A AND B
Q2
# Alarm if door (A) OR window (B) is open X = A OR B
Q3
# A = door open, B = window locked # Alarm if door open AND window NOT locked X = A AND NOT B
Q4
# A = door, B = window, C = key switch # X on if (door OR window) AND key on X = (A OR B) AND C
Q5
# A = lid shut, B = guard shut, C = override # Runs if lid AND guard shut, or override X = (A AND B) OR C
Section E: Spot the Error
Q1
C — The statement says door OR window, so the alarm sounds when either is open. The line should use OR: X = A OR B.
Q2
C — The alarm needs both conditions to be true, so the key word AND gives an AND gate. The line should be X = A AND B.
Q3
B — The statement says the stop button must NOT be pressed, so B needs a NOT gate. The line should be X = A AND (NOT B).
Q4
B — The statement says A or B, so the grouped part needs an OR gate, not AND. The line should be X = (A OR B) AND NOT C.
Q5
B — The wording says A is needed, together with B or C. The brackets must group B OR C: X = A AND (B OR C).