Skip to content
Tactiverge

School/△ Builder/Week 15

From safety rules to Boolean expressions

'The press may run only when the guard is shut, a hand is on each button and there is no fault.' Can you write that as one line of algebra?

About 35 min · 3 goals · Checked by automated tests

1.Why should I care?

Safety interlocks on machines, alarms and doors are Boolean expressions written in hardware. A mistranslated word can let a machine start when it must not, so engineers write the rule, the expression and the full truth table, and check that all three agree.

  • ◇ Translate a worded rule into a Boolean expression using AND, OR, NOT and XOR.
  • ◇ Move between an expression, its truth table and its gate diagram.
  • ◇ Spot ambiguous words ('or', 'unless') and resolve them before building.

2.Discover

Start from the interlock preset A · B · ¬C (A = guard closed, B = operator present, C = fault). Toggle the inputs to find the only row where Y = 1. Then type A · (B + C) and compare it with A · B + C: find a row where they differ. Finally write your own rule for a door alarm and check its truth table.

Loading the interactive…

Can't use the interactive? Read a description instead

The explorer takes a typed Boolean expression and shows three views: input switches with a live output, a gate diagram drawn from inputs on the left to the output on the right, and a full truth table with the current row marked. For the interlock A · B · ¬C, Y = 1 only on row 110: guard closed, operator present, no fault.

3.Checkpoint: guided practice

Check what you just discovered before going on. Hints appear after a wrong answer.

Practice 1

Machine runs only if the guard is closed (G), the operator is present (P) and there is no fault (F = 1 means fault). Which expression?

Practice 2 · a fresh version every time

Write out the 8-row truth table for Y = ¬A ⊕ C (inputs A, B, C). On how many rows is Y = 1?

rows

4.Apply it

Write the rule for a greenhouse vent: open if it is too hot OR too humid, but never while it is raining. Name your signals, write the expression, check its truth table in the explorer, and read the rows where the vent is open aloud.

5.Understand

Name the signals first

Give every input a letter and say what 1 means: G = 1 'guard closed', P = 1 'operator present', F = 1 'fault reported'. Writing what 1 means avoids the most common bug: a signal that is 1 when you thought it was 0.

Words to operators

'and', 'both', 'all' → ·. 'or', 'either', 'any' → +. 'not', 'no', 'unless' → ¬ (often 'X unless Y' becomes X · ¬Y). 'one or the other but not both' → ⊕. So the interlock is Y = G · P · ¬F.

Brackets carry meaning

AND binds tighter than OR, just as × binds tighter than +. A · B + C means (A · B) + C. If the rule says 'A and either B or C', write A · (B + C). When unsure, add brackets and check the truth table.

Check all three views

The expression is compact, the truth table is complete, and the gate diagram is what you build. If they disagree, one of them is wrong. For safety rules, read every row of the truth table aloud: 'guard open, operator present, no fault: machine off.'

Explain it another way

Translating rules into logic is like writing a recipe so exact that a robot cook cannot misunderstand it. Every 'and', 'or' and 'unless' becomes a symbol with one meaning only.

Worked example 1

'The fan runs if the temperature is high, unless the maintenance switch is on.' Write it as an expression.

Let T = 1 'temperature high' and M = 1 'maintenance switch on'. 'T unless M' = T · ¬M. Check: T = 1, M = 1 gives 0 (fan off for maintenance).

Common mix-ups

  • A · B + C means A AND (B OR C).
    ✓ AND is done first: it means (A · B) + C. Use brackets to say otherwise.
  • If the expression looks right, the truth table must be right.
    ✓ Always check every row; mistranslated words often show up on just one or two rows.

6.Practice on your own

Practice, not a test. Wrong answers get a hint and another try.

Practice 3

How many of the 8 rows of Y = A · (B + C) have Y = 1?

rows

Practice 4 · a fresh version every time

Write out the 8-row truth table for Y = (C ⊕ B) ⊕ A (inputs A, B, C). On how many rows is Y = 1?

rows

Practice 5

'The light is on if it is dark (D), unless the switch is off (S = 1 means switch off).' Which expression?

7.Predict

An alarm must sound if it is armed and either the door or the window opens. Which expression fits?

Guess first. Being wrong here is how the surprise works.

8.Reflect

Concepts: Logic gates and Boolean algebra · Robot safety and ethics