Quarry School

Computer Science Foundations / Reason with true and false

Reason with true and false

Subject: Computing

All 5 lessons, in order.

The unit at a glance

  1. Read a two-state predicate

    A librarian looks at the four slots on a returns cart.

  2. Fill an AND table

    Imagine a pottery studio pickup desk.

  3. Fill an OR table

    Imagine an apartment resident who can report a broken light by phone, by email, or by both.

  4. Negate a condition

    Imagine a shop sign that always shows exactly one of its two faces, OPEN or CLOSED.

  5. Check two rules against every input pair

    A resident reads two proposed rules for deciding whether there is no parcel at either door.

Rules (5)
  • Read a two-state predicate

    This paper model uses one or more labeled slots, each with a known state. For each slot, record the Boolean answer to “Is this slot free?” Use true for free and false for occupied.

    Use the states from one moment and keep them fixed while you work. The rule here covers a fixed set of slots with no missing states. For the whole set, give true if one or more slots are free. Give false if zero slots are free.

  • Fill an AND table

    A AND B gives true only when A and B are both true. If either input is false, the result is false.

  • Fill an OR table

    For two Boolean inputs, A OR B gives true if at least one input is true. It gives false if both are false.

    Assume both input values are known and refer to the same light. The paper model answers whether the resident made a report. Delivery, reading the report, and repairing the light are outside the model.

  • Negate a condition

    The input to NOT is the known value you start with, here the value of A. In this paper model it can be either of the two Boolean values, false or true. Write those values in lowercase and use uppercase NOT to show that you’re reversing a value. The output is the value you get from the rule. For false, write true. For true, write false.

  • Check two rules against every input pair

    Compare the two final rule answers on the same row. If every row matches, the rules are equivalent. If any row differs, record that input pair as a counterexample.

Recipes (5)
  • Read a two-state predicate
    1. Write the total number of slots and the number occupied.
    2. Subtract the occupied count from the total. Give true if the free count is one or more. Give false if it is zero.
    3. To check, draw one box per slot and start with every box unmarked. Visit the slots once in label order. Mark each occupied box and leave each free box unmarked. Stop after the last label. Count the unmarked boxes and use that count to answer the question again.
  • Fill an AND table
    1. Draw three columns. Label them A (receipt present), B (name matches) and A AND B (result). Make four rows beneath the labels.
    2. From top to bottom, write false/false, false/true, true/false, true/true. In each pair, put the first value under A and the second under B. Use only true and false for the inputs. Leave the four result spaces blank.
    3. Start at the top and work down. Tick each input that is true. Write true in the result column if the row has two ticks. Write false if it has fewer.
    4. Stop when every row has a result.
  • Fill an OR table
    1. Draw the table on paper with A on the left, B in the middle, and Reported on the right.
    2. Write the input pairs from top to bottom. Write false and false, false and true, true and false, then true and true. Start with all four Reported spaces blank.
    3. Start at the top. Read A first. If A is true, write true in Reported. If A is false, read B and copy it into Reported.
    4. Move down one row at a time. Stop when every Reported space has a value.
  • Negate a condition
    1. Draw a table on paper with rows for CLOSED and OPEN. Add columns for A and NOT A and leave their cells blank.
    2. Start with CLOSED. Check whether that row’s face shows OPEN to fill in A. Then use NOT to write the other value beside it.
    3. Repeat that process for OPEN. Once both rows have a NOT A value, stop filling the table.
    4. Check by using each value in the NOT A column as the input to the rule one more time. From top to bottom, true gives false and false gives true. Compare false, then true, with the original A column. Both rows match.
  • Check two rules against every input pair
    1. Write the four input pairs in order. Leave the result and comparison cells blank.
    2. In the first row, find A OR B. Flip that result and record it under NOT (A OR B).
    3. In the same row, flip A to get NOT A and flip B to get NOT B. Use OR on those two values to fill (NOT A) OR (NOT B).
    4. Compare the answers under NOT (A OR B) and (NOT A) OR (NOT B). Mark the row match or mismatch.
    5. Repeat the calculation and comparison for the remaining rows. Finish the fourth row even if you have already found a counterexample.
Traps (5)
  • Read a two-state predicate

    On the returns cart, the count 1 answers “How many slots are free?” That one free slot makes the answer to “Is at least one slot free?” true. Keep the free count and the predicate result on separate lines.

  • Fill an AND table

    Suppose a visitor has a receipt and gives a name that differs from the tag. Only A gets a tick. That row gives false, so the piece stays at the desk.

  • Fill an OR table

    Suppose the resident phones and then emails. Does the email cancel the phone report? The phone report still counts after the email, so keep Reported true in the marked last row, where both inputs are true.

  • Negate a condition

    Leave the sign alone and work with the value on your paper. Turning the sign would give you a different observation. If the face is covered, stop before writing either value. Find out which face was showing at noon before you choose a row.

  • Check two rules against every input pair

    Two matches can look like proof that the rules are equivalent. If you check only false/false and true/true, you miss the mixed rows, where one input is true and the other is false. Each mixed row makes the rules disagree.

Lesson 1 of 5

Read a two-state predicate

Subject: ComputingOpen this lesson
Leans on 1Comes back in 0

1 In plain words

A librarian looks at the four slots on a returns cart. Each slot is a place for a book. Three slots hold books, so they are occupied. The fourth is empty, so it is free.

The slot information is the input. In this lesson, a predicate is a question that gives true or false for the stated input. For this cart, ask “Is at least one slot free?” At least one means one or more. There is one free slot, so the answer is true.

Python’s two Boolean values are True and False. On paper, write them as true and false. Remember to read the question before choosing the answer.

2 Picture it

ABCDFreeIs any slot free?true

The four cart slots are labeled A through D. A, B and C hold books. D is empty and labeled Free. An arrow points to the question Is any slot free? and the result true.

Check the whole cart for a free return slot.

3 Why

Every slot in the drawing is either occupied or free. Subtracting the number of occupied slots from the total gives the number of free slots. A single free slot is enough to answer true.

A program gives a computer instructions to follow. The steps below give you instructions to follow on paper.

4 The rule

This paper model uses one or more labeled slots, each with a known state.

For each slot, record the Boolean answer to “Is this slot free?” Use true for free and false for occupied.

Use the states from one moment and keep them fixed while you work. The rule here covers a fixed set of slots with no missing states. For the whole set, give true if one or more slots are free. Give false if zero slots are free.

5 How

  1. Write the total number of slots and the number occupied.
  2. Subtract the occupied count from the total. Give true if the free count is one or more. Give false if it is zero.
  3. To check, draw one box per slot and start with every box unmarked. Visit the slots once in label order. Mark each occupied box and leave each free box unmarked. Stop after the last label. Count the unmarked boxes and use that count to answer the question again.

6 Trace

Follow the states of the returns cart
Slot or questionFree?Explanation
AfalseA holds books.
BfalseB holds books.
CfalseC holds books.
DtrueD is empty.
At least one free?trueSubtract 3 from 4 to get one free slot. Marking the occupied boxes independently leaves only D unmarked.

7 The trap

On the returns cart, the count 1 answers “How many slots are free?” That one free slot makes the answer to “Is at least one slot free?” true. Keep the free count and the predicate result on separate lines.

Quick checks

Quick check 1 of 2

On another returns cart, A and C are occupied and B and D are free. Write the free count. Then answer ‘Is at least one slot free?’

Show the steps and the answer
Answer

2 free slots. The predicate result is true.

Why: Four slots minus two occupied slots leaves two free slots. You can point to B and D. Two is at least one, so the result is true.

Source: Python Software Foundation, Built-in Types (Python 3.13 documentation)

Quick check 2 of 2

A parcel rack holds packages. It has six known slots, and all six are occupied. Is at least one slot free?

Show the steps and the answer
Answer

false

Why: Six slots minus six occupied slots leaves zero free slots. Every box gets a mark, so there is no free slot to point to.

Source: Python Software Foundation, Built-in Types (Python 3.13 documentation)

Sources

  1. Built-in Types (Python 3.13 documentation). Python Software Foundation. Python Software Foundation License Version 2. Read 26 Nov 2026.
  2. Programming Languages (Computer Science Field Guide). University of Canterbury Computer Science Education Research Group. CC BY-SA 4.0 International. Read 26 Nov 2026.

Lesson 2 of 5

Fill an AND table

Subject: ComputingOpen this lesson
Leans on 0Comes back in 0

1 In plain words

Imagine a pottery studio pickup desk. The clerk hands over a piece only when the visitor has the receipt and their name matches the name on the tag. Each thing the clerk checks is a condition. Call the conditions A (receipt present) and B (name matches).

The answer to each check is an input. On paper, write true for yes and false for no. These are the two Boolean values. Read A AND B as “Are both checks true?” Remember that both checks have to pass for the clerk to hand over the piece.

2 Picture it

ReceiptNameA AND Bfalsefalsefalsefalsetruefalsetruefalsefalsetruetruetrue

Receipt and Name list the pairs false/false, false/true, true/false and true/true. AND gives false, false, false and true, in that order. The last row is marked.

Only the row with both checks true gives true for AND.

3 Why

With A false, B can be false or true. With A true, B has the same two choices. Listing both choices for each value of A gives four rows and covers every pair.

The visitor can give their name even without a receipt, so the clerk can check B either way. The table assumes both answers are known and stay fixed for that row. If the tag is unreadable, the name check is undecided and the table has no row for it.

4 The rule

A AND B gives true only when A and B are both true.

If either input is false, the result is false.

5 How

  1. Draw three columns. Label them A (receipt present), B (name matches) and A AND B (result). Make four rows beneath the labels.
  2. From top to bottom, write false/false, false/true, true/false, true/true. In each pair, put the first value under A and the second under B. Use only true and false for the inputs. Leave the four result spaces blank.
  3. Start at the top and work down. Tick each input that is true. Write true in the result column if the row has two ticks. Write false if it has fewer.
  4. Stop when every row has a result.

6 Trace

Work the receipt and name checks
ABA AND BExplanation
falsefalsefalseNeither check passes.
falsetruefalseOnly the name check passes.
truefalsefalseOnly the receipt check passes.
truetruetrueBoth checks pass. This row appears in both the receipt-present list and the name-match list.

7 The trap

Suppose a visitor has a receipt and gives a name that differs from the tag. Only A gets a tick. That row gives false, so the piece stays at the desk.

Quick checks

Quick check 1 of 2

The name matches the tag, and the visitor has no receipt. Which input is false, and what is A AND B?

Show the steps and the answer
Answer

A is false. A AND B is false.

Why: The name check passes. The receipt check also has to pass for AND to give true.

Source: Python Software Foundation, Python 3.13 documentation, Built-in Types

Quick check 2 of 2

Suppose a school drummer needs both a drum and sticks. Drum present is true and sticks present is false. What does AND give?

Show the steps and the answer
Answer

false

Why: The missing sticks leave only one check true. AND needs both.

Source: Python Software Foundation, Python 3.13 documentation, Built-in Types

Sources

  1. Python 3.13 documentation, Built-in Types — Boolean Type. Python Software Foundation. Python Software Foundation License Version 2. Read 26 Nov 2026.
  2. Python 3.13 documentation, Built-in Types. Python Software Foundation. Python Software Foundation License Version 2. Read 26 Nov 2026.

Lesson 3 of 5

Fill an OR table

Subject: ComputingOpen this lesson
Leans on 0Comes back in 0

1 In plain words

Imagine an apartment resident who can report a broken light by phone, by email, or by both. In this example, any of those choices counts as a report.

Let A mean “phoned” and B mean “emailed.” These are the inputs, the facts you start with. Write true if the resident used that method and false if they didn't. True and false are the two Boolean values.

Read A OR B as “Did the resident phone, email, or do both?” Write the answer under Reported. Remember that one report is enough and both reports count. That's what inclusive means in inclusive OR.

2 Picture it

PhonedEmailedReportedfalsefalsefalsetruetruefalsetruetrue

The Phoned and Emailed columns show false/false, false/true, true/false and true/true. The Reported column is blank. The last row, with both inputs true, is marked.

Fill the Reported column using inclusive OR.

3 Why

If the resident phoned, you already have a report, whatever B says. If the resident didn't phone, the answer depends on whether they emailed. In that case, B already gives you the value to write in Reported.

4 The rule

For two Boolean inputs, A OR B gives true if at least one input is true.

It gives false if both are false.

Assume both input values are known and refer to the same light. The paper model answers whether the resident made a report. Delivery, reading the report, and repairing the light are outside the model.

5 How

  1. Draw the table on paper with A on the left, B in the middle, and Reported on the right.
  2. Write the input pairs from top to bottom. Write false and false, false and true, true and false, then true and true. Start with all four Reported spaces blank.
  3. Start at the top. Read A first. If A is true, write true in Reported. If A is false, read B and copy it into Reported.
  4. Move down one row at a time. Stop when every Reported space has a value.

6 Trace

Work the light report table
ABReportedExplanation
falsefalsefalseNo call and no email. The true-input count is zero.
falsetruetrueThe email counts as a report.
truefalsetrueThe phone call counts as a report.
truetruetrueBoth count. Counting true inputs gives 0, 1, 1, 2, so all but the first row qualify.

7 The trap

Suppose the resident phones and then emails. Does the email cancel the phone report? The phone report still counts after the email, so keep Reported true in the marked last row, where both inputs are true.

Quick checks

Quick check 1 of 2

The resident phoned and emailed about the same light. What goes in Reported?

Show the steps and the answer
Answer

true

Why: Both inputs are true, so the row has at least one true input.

Source: Python Software Foundation, Built-in Types: Boolean Operations (Python 3.13)

Quick check 2 of 2

A class looks in two supply drawers for a stencil. Their stencil is a sheet with a star-shaped hole for tracing a star. A means the left drawer has it. B means the right drawer has it. If A is false and B is true, what is A OR B?

Show the steps and the answer
Answer

true

Why: The right drawer has the stencil, so at least one drawer has it.

Source: Python Software Foundation, Built-in Types: Boolean Operations (Python 3.13)

Sources

  1. Built-in Types: Boolean Operations (Python 3.13). Python Software Foundation. Python Software Foundation License Version 2. Read 26 Nov 2026.

Lesson 4 of 5

Negate a condition

Subject: ComputingOpen this lesson
Leans on 0Comes back in 0

1 In plain words

Imagine a shop sign that always shows exactly one of its two faces, OPEN or CLOSED. At noon it shows CLOSED. Keep that moment fixed as you work.

Let A stand for the condition “the sign shows OPEN.” Here a condition is a statement you can mark true if it fits what you see or false if it doesn’t. A is false. Read NOT A as “the sign does not show OPEN.” That statement is true.

True and false are called truth values. To negate a condition, take its known truth value and write the other one. Use the table to look up the two cases.

2 Picture it

SignANOT ACLOSEDfalsetrueOPENtruefalse

The CLOSED sign gives false for A and true for NOT A. The OPEN sign gives true for A and false for NOT A.

Read A for each sign face, then reverse its truth value.

3 Why

Each row shows one possible view of the sign at noon. Read both statements against the face in that row. The OPEN face fits “the sign shows OPEN,” and the CLOSED face fits “the sign does not show OPEN.” Exactly one statement fits the face in each row.

4 The rule

The input to NOT is the known value you start with, here the value of A.

In this paper model it can be either of the two Boolean values, false or true. Write those values in lowercase and use uppercase NOT to show that you’re reversing a value. The output is the value you get from the rule. For false, write true. For true, write false.

5 How

  1. Draw a table on paper with rows for CLOSED and OPEN. Add columns for A and NOT A and leave their cells blank.
  2. Start with CLOSED. Check whether that row’s face shows OPEN to fill in A. Then use NOT to write the other value beside it.
  3. Repeat that process for OPEN. Once both rows have a NOT A value, stop filling the table.
  4. Check by using each value in the NOT A column as the input to the rule one more time. From top to bottom, true gives false and false gives true. Compare false, then true, with the original A column. Both rows match.

6 Trace

Read the shop sign
Face at noonANOT AExplanation
CLOSEDfalsetrueThe sign does not show OPEN. Reading the sentence directly confirms true.
OPENtruefalseThe sign shows OPEN, so its negation is false.

7 The trap

Leave the sign alone and work with the value on your paper. Turning the sign would give you a different observation. If the face is covered, stop before writing either value. Find out which face was showing at noon before you choose a row.

Quick checks

Quick check 1 of 2

At noon the sign shows OPEN. What are A and NOT A? Reverse the output once more. What do you get?

Show the steps and the answer
Answer

A is true, NOT A is false, and reversing false gives true again.

Why: OPEN makes A true. The first reversal gives false and the second gives back the starting value.

Source: Python Software Foundation, Python 3.13 Built-in Types: Boolean Operations

Quick check 2 of 2

A desk lamp is known to be on. Let L mean ‘the lamp is on’. What are L and NOT L?

Show the steps and the answer
Answer

L is true and NOT L is false.

Why: The given on state makes L true. Reversing true gives false.

Source: Python Software Foundation, Python 3.13 Built-in Types: Boolean Operations

Sources

  1. Python 3.13 Built-in Types: Boolean Operations. Python Software Foundation. Python Software Foundation License Version 2. Read 26 Nov 2026.

Lesson 5 of 5

Check two rules against every input pair

Subject: ComputingOpen this lesson
Leans on 0Comes back in 0

1 In plain words

A resident reads two proposed rules for deciding whether there is no parcel at either door. The first says, “Both doors are empty.” The second says, “At least one door is empty.” Picture a parcel at the front door and an empty side door. The first rule says no and the second says yes.

Let A stand for “a parcel is present at the front door” and B for “a parcel is present at the side door.” An input is a value you start with. Each input here is Boolean, meaning its value is either true or false. Write true for a door with a parcel and false for an empty door. Write A first in each pair, then B.

Keep two moves beside your table. Inclusive OR gives true when one or both of the values it joins are true. It gives false when both are false. NOT flips one value. It turns true into false and false into true.

Parentheses group parts of a rule. On paper, work out each group before using its result. Read NOT (A OR B) as “flip the answer to A OR B.” Read (NOT A) OR (NOT B) as “flip each input, then join the flipped values with OR.”

Treat each row as a snapshot. Assume you know both door states and they stay fixed while you work. The table records presence only, so it leaves out parcel counts, uncertain observations and changes over time.

On paper, start with the A and B columns filled and the other cells blank. From top to bottom, the pairs are false/false, false/true, true/false, true/true. The slash separates the two values. Stop when you have written and compared the two rule answers in the fourth row.

2 Picture it

A / BRule 1Rule 2false / falsetruetruefalse / truefalsetruetrue / falsefalsetruetrue / truefalsefalse

For false/false, both rules give true. For false/true and true/false, Rule 1 gives false and Rule 2 gives true. Those two rows are marked. For true/true, both rules give false.

Rule 1 is NOT (A OR B). Rule 2 is (NOT A) OR (NOT B).

3 Why

Hold A at false and try both values of B. Then hold A at true and try both values of B again. Those four rows cover every allowed pair because each input has exactly two possible values.

Two rules are equivalent when they give the same answer on every allowed pair. A pair that makes their answers differ is a counterexample. One such pair settles the question because equivalence requires a match on every row.

4 The rule

Compare the two final rule answers on the same row.

If every row matches, the rules are equivalent. If any row differs, record that input pair as a counterexample.

5 How

  1. Write the four input pairs in order. Leave the result and comparison cells blank.
  2. In the first row, find A OR B. Flip that result and record it under NOT (A OR B).
  3. In the same row, flip A to get NOT A and flip B to get NOT B. Use OR on those two values to fill (NOT A) OR (NOT B).
  4. Compare the answers under NOT (A OR B) and (NOT A) OR (NOT B). Mark the row match or mismatch.
  5. Repeat the calculation and comparison for the remaining rows. Finish the fourth row even if you have already found a counterexample.

6 Trace

Check the two parcel rules on the same four pairs
ABNOT (A OR B)(NOT A) OR (NOT B)Explanation
falsefalsetruetrueBoth doors are empty. Both rules give true.
falsetruefalsetrueOne parcel makes A OR B true. One empty door makes the OR of the flipped inputs true.
truefalsefalsetrueThe same disagreement occurs with the parcel at the other door.
truetruefalsefalseNeither door is empty. The number of empty doors across the rows is 2, 1, 1, 0.

7 The trap

Two matches can look like proof that the rules are equivalent. If you check only false/false and true/true, you miss the mixed rows, where one input is true and the other is false. Each mixed row makes the rules disagree.

Quick checks

Quick check 1 of 2

A resident checks false/false and true/true. The rule answers match both times. Which pairs still need checking, and what does each rule give on those pairs?

Show the steps and the answer
Answer

The unchecked pairs are false/true and true/false. Each gives false for NOT (A OR B) and true for (NOT A) OR (NOT B).

Why: Each remaining pair has one door with a parcel and one empty door. The first rule needs two empty doors. One empty door satisfies the second rule.

Source: Python Software Foundation, Built-in Types, Boolean Operations (Python 3.13)

Quick check 2 of 2

A classroom checks for a marker in each of two cups. A means a marker is present in the red cup and B means a marker is present in the blue cup. With A true and B false, what do NOT (A OR B) and (NOT A) OR (NOT B) give?

Show the steps and the answer
Answer

NOT (A OR B) gives false. (NOT A) OR (NOT B) gives true.

Why: A OR B is true, so flipping it gives false. NOT A is false and NOT B is true, so joining them with OR gives true.

Source: Python Software Foundation, Built-in Types, Boolean Operations (Python 3.13)

Sources

  1. Built-in Types, Boolean Operations (Python 3.13). Python Software Foundation. Python Software Foundation License Version 2. Read 26 Nov 2026.