Skip to content
The Lumenary
Grades 3–5Ages 8–11 35 min

True, false, and, or, not

Sentences that are true or false, the three little words that join them, and why one counterexample beats a thousand examples.

Formally verified · 15 LeanComputationally tested · 2 PythonAI-drafted · awaiting human reviewMathematically reviewed: Awaiting human review

Your guides: Chloe, Margaret, Gideon

MotivationH

True or false?

In a classroom in Hanoi, Ms Lan plays a game with her class. She reads out a sentence, and everyone holds up a green card for true or a red card for false.

  • "7 is bigger than 4." Green cards everywhere.
  • "10 is an odd number." Red cards.
  • "Every number that ends in 2 can be shared equally between 4 people." Minh thinks: 12 can (3 each), 32 can (8 each), 52 can (13 each)… He holds up green. Linh holds up red. "What about 22?" she says. "22 shared between 4 is 5 each, with 2 left over."

One number was enough to win the argument. Minh had checked three numbers, and he was right about all three — but the sentence talked about every number that ends in 2, and 22 breaks it.

For hundreds of years, people in Europe used "all swans are white" as an example of something everybody knew. In Australia, black swans had been there all along: the Noongar people of the south-west knew them well. When Dutch sailors led by Willem de Vlamingh saw black swans on what is now called the Swan River in 1697, a single kind of bird was enough to show that the old sentence was false.

IntuitionH

Sentences that are true or false

Some sentences are true or false. Mathematicians call them statements.

SentenceStatement?
"3 + 4 = 7."yestrue
"3 + 4 = 8."yesfalse — but still a statement!
"Every square has four corners."yestrue
"Is 9 an odd number?"noa question
"Write down an even number."noan instruction
"Mangoes are the tastiest fruit."not a mathematical onepeople disagree, and there is no way to check

A false statement is still a statement. "3 + 4 = 8" is a perfectly good statement: it just happens to be false.

We can build bigger statements out of smaller ones with three little words: and, or and not. Think of two light switches and a lamp. If the switches are in a row, one after the other, the lamp lights only when switch pp and switch qq are both on. If they are side by side, the lamp lights when pp or qq is on — and of course also when both are.

pqandpqor
Two switches, p and q, and a lamp. Left: the switches in a row — electricity must pass through both, so the lamp lights only when p and q are both on. Right: the switches side by side — the lamp lights when p or q is on, including when both are.
DefinitionsH

Big ideas

Definition— statement

A statement is a sentence that is either true or false (and not both).

Definition— and, or, not

Let PP and QQ be statements.

  • "PP and QQ" is true when both PP and QQ are true. Otherwise it is false.
  • "PP or QQ" is true when at least one of PP, QQ is true — one of them, or the other, or both. It is false only when both are false.
  • "not PP" is true exactly when PP is false.

We can show all of this in a truth table. Each row is one possible case. With two statements there are only four cases: both true, only the first true, only the second true, both false.

PPQQPP and QQPP or QQnot PP
truetruetruetruefalse
truefalsefalsetruefalse
falsetruefalsetruetrue
falsefalsefalsefalsetrue

Definition— every and some

An "every" statement (also said with "all" or "always") claims that something is true for each one of a collection: "every even number ends in 0, 2, 4, 6 or 8".

A "some" statement (also said with "there is" or "at least one") claims that it is true for at least one: "some number is both even and bigger than 100".

Definition— counterexample

A counterexample to "every xx has property PP" is one particular xx that does not have property PP. For "every number that ends in 2 is divisible by 4", the number 22 is a counterexample.

Worked examplesH

Let's try together

Example— Joining statements

Let PP be "12 is even" (true) and QQ be "12 is bigger than 20" (false).

  • "12 is even and 12 is bigger than 20" is false: for "and" both parts must be true, and QQ is not.
  • "12 is even or 12 is bigger than 20" is true: one true part is enough.
  • "12 is not bigger than 20" is true, because QQ is false.

Example— Or means “one or the other, or both”

"6 is even or 6 is a multiple of 3." Both parts are true. Is the whole statement true? In mathematics, yes. The word "or" always allows both.

Everyday language is sometimes different. When a waiter in a café asks "tea or coffee?", they usually mean one of them, not both. In mathematics, if we ever mean "one or the other but not both", we say so in exactly those words.

Example— The opposite of “all”

Amina has four mangoes in a basket. Three are ripe and one is not.

  • "All the mangoes are ripe" — false (one is not ripe).
  • "None of the mangoes is ripe" — also false (three are ripe)!
  • "At least one mango is not ripe" — true.

So the opposite of "all the mangoes are ripe" is not "none of them is ripe". It is "at least one mango is not ripe". To show that "all are" is false, you only need to find one that is not.

Example— Breaking an “every” claim

Claim: "Every number that ends in 2 is divisible by 4."

The examples 12, 32, 52, 72 and 92 all fit: 12=4×312 = 4 \times 3, 32=4×832 = 4 \times 8, 52=4×1352 = 4 \times 13, 72=4×1872 = 4 \times 18, 92=4×2392 = 4 \times 23. Five examples in a row! But 22=4×5+222 = 4 \times 5 + 2 does not fit. One counterexample, so the claim is false. (In fact, among the numbers ending in 2, every other one fails: 2, 22, 42, 62, 82, …)

Example— Proving a “some” claim

Claim: "Some number is even and also prime." (A prime number has exactly two factors, 1 and itself.) We only need one example: 2 is even, and its only factors are 1 and 2. So the claim is true.

One example proves a "some" claim. One counterexample disproves an "every" claim. Nothing about this is a coincidence: "not every number fits" means exactly the same as "some number does not fit".

ProofH

Why one counterexample is enough — and many examples are not

Theorem— One counterexample is enough

If just one xx does not have property PP, then the statement "every xx has property PP" is false.

Proof

"Every xx has property PP" makes a promise about each xx, with no exceptions. The counterexample is an xx for which the promise is broken. A promise that is broken even once is not kept, so the statement is false.

∎

Now the other direction. Suppose you check a claim for 1,2,3,…1, 2, 3, \dots up to a million and it always works. Have you proved it for every whole number? No — there are infinitely many whole numbers, and you have checked only a million of them. The next one might break the pattern.

This really happens. Try the rule "n×n+n+11n \times n + n + 11 is a prime number":

nn012345678910
n×n+n+11n \times n + n + 11111317233141536783101121
prime?yesyesyesyesyesyesyesyesyesyesno

Ten primes in a row — and then 121=11×11121 = 11 \times 11.

When checking every case is a proof. Sometimes there are only a few cases, and then we can check them all. Here is a famous law about "not", "and" and "or", called De Morgan's law:

Theorem— De Morgan's law

For any statements PP and QQ: "not (PP and QQ)" is true exactly when "(not PP) or (not QQ)" is true.

Proof

There are only four cases. We check each one.

PPQQPP and QQnot (PP and QQ)not PPnot QQ(not PP) or (not QQ)
truetruetruefalsefalsefalsefalse
truefalsefalsetruefalsetruetrue
falsetruefalsetruetruefalsetrue
falsefalsefalsetruetruetruetrue

In every row the two bold columns agree. Since these four rows are all the cases there are, the law is proved.

∎

In everyday words: "It is not true that the shop is open and has bread" means "the shop is closed, or it has no bread (or both)".

Explore

Explore: truth tables and Venn diagrams

This truth-table machine fills in every row for you. It starts by comparing "pp or qq" with "one or the other but not both", written (p or q) and not (p and q). Look for the row marked ≠: that is the only case where they disagree.

Or, and “one but not both”

Think of p as “I have a brother” and q as “I have a sister”. Which row is different?

Read as: p ∨ q

Read as: (p ∨ q) ∧ ¬(p ∧ q)

Use the symbols ¬ ∧ ∨ → ↔, the words not, and, or, implies, iff, or ASCII ~ & | -> <->. Variables are single lowercase letters. ¬ binds tightest, then ∧, ∨, →, ↔; p → q → r means p → (q → r).

Try:

Contingent — true in 3 of 4 rows, false in the others.

Not equivalent — they differ in 1 of 4 rows (marked ≠).

pqp ∨ q(p ∨ q) ∧ ¬(p ∧ q)Rows where they differ
TTTF≠
TFTT
FTTT
FFFF

4 rows: one for every way of making the 2 variables true or false.

Now check De Morgan's law, and then try some of your own. Type not, and, or and the letters p, q, r.

Checking De Morgan's law

Change the second formula to “not p and not q”. Is it still the same in every row?

Read as: ¬(p ∧ q)

Read as: ¬p ∨ ¬q

Use the symbols ¬ ∧ ∨ → ↔, the words not, and, or, implies, iff, or ASCII ~ & | -> <->. Variables are single lowercase letters. ¬ binds tightest, then ∧, ∨, →, ↔; p → q → r means p → (q → r).

Try:

Contingent — true in 3 of 4 rows, false in the others.

Equivalent — the two formulas agree in all 4 rows.

pqp ∧ q¬(p ∧ q)¬p ∨ ¬qRows where they differ
TTTFF
TFFTT
FTFTT
FFFTT

4 rows: one for every way of making the 2 variables true or false.

What to notice:

  • With two letters there are 4 rows; with three letters there are 8. Each new letter doubles the number of rows.
  • If you change the second formula to not p and not q, the machine finds rows where the two formulas differ. "Not (p and q)" is not the same as "not p and not q".

The Venn diagram below shows the same ideas with sets. AA is the set of children who play football and BB is the set of children who play chess. Shade "plays football and chess", then "plays football or chess", then "does not play football".

Shade a set, discover its name

Click regions of the diagram (or use the buttons). The explorer names the set you have made and lists its elements.

A · plays footballB · plays chessUAmaraKenjiLucíaArjunFatimaMateusAigerimTavitaOlenaKwame

You have made

A ∩ B

{Kenji, Arjun}

Number of elements: 2

Try these

Challenge: two regions can be shaded in six different ways. Can you find all six, and name each one?

Formal mathematicsF

Gideon's true-or-false game

Gideon plays only with statements. For each one, decide: true or false? Then give a reason.

  1. "15 is odd and 15 is less than 10." — False. For "and", both parts must be true, and 15 is not less than 10.
  2. "4 is even or 4 is bigger than 3." — True. Both parts are true, and "or" allows both.
  3. "Every odd number bigger than 1 is prime." — False. 3, 5 and 7 fit, but 9=3×39 = 3 \times 3 is a counterexample.
  4. "I checked 100 numbers, so the double of every number is even." — The reason is not good enough! The statement is true, but only the "groups of 2" reason proves it for every number.
  5. "Not all the mangoes are ripe" means the same as "none of the mangoes is ripe." — False. It means at least one is not ripe.
For grown-ups · the same game in Lean, a proof checker

Lean can decide statements about small numbers by calculating:

and_exampleLean 4Proved here from basic factsFormally verified
/-- "12 is even **and** 12 is bigger than 20" is false, because its second part is false.
"12 is even **and** 12 is smaller than 20" is true, because both parts are true. -/
theorem and_example : ¬ (12 % 2 = 0 ∧ 12 > 20) ∧ (12 % 2 = 0 ∧ 12 < 20) := by
  decide
Axioms used: No axiomsformal/Lumenary/LogicStatements.leanTry it in the Lean web editor
or_exampleLean 4Proved here from basic factsFormally verified
/-- "Or" is inclusive. "6 is even **or** 6 is a multiple of 3" is true — and both of its parts
are true. "7 is even or 7 is bigger than 10" is false, because neither part is true. -/
theorem or_example : (6 % 2 = 0 ∨ 6 % 3 = 0) ∧ ¬ (7 % 2 = 0 ∨ 7 > 10) := by
  decide
Axioms used: No axiomsformal/Lumenary/LogicStatements.leanTry it in the Lean web editor
not_exampleLean 4Proved here from basic factsFormally verified
/-- "Not" swaps true and false. "7 is even" is false, so "7 is **not** even" is true. -/
theorem not_example : ¬ (7 % 2 = 0) := by
  decide
Axioms used: No axiomsformal/Lumenary/LogicStatements.leanTry it in the Lean web editor

On Bool (Lean's type with the two values true and false), && is "and" and || is "or". Their whole truth tables are short enough to write out, and De Morgan's law is proved by checking the four rows — exactly the human proof above:

and_tableLean 4Proved here from basic factsFormally verified
/-- The whole truth table of **and**: `p && q` is true in just one row, the row where both are
true. -/
theorem and_table :
    (true && true) = true ∧ (true && false) = false ∧
    (false && true) = false ∧ (false && false) = false := by
  decide
Axioms used: No axiomsformal/Lumenary/LogicStatements.leanTry it in the Lean web editor
or_tableLean 4Proved here from basic factsFormally verified
/-- The whole truth table of **or**: `p || q` is false in just one row, the row where both are
false. In the first row both parts are true, and so is `p || q`: this "or" is inclusive. -/
theorem or_table :
    (true || true) = true ∧ (true || false) = true ∧
    (false || true) = true ∧ (false || false) = false := by
  decide
Axioms used: No axiomsformal/Lumenary/LogicStatements.leanTry it in the Lean web editor
de_morgan_andLean 4Proved here from basic factsFormally verified
/-- **De Morgan's law for "and".** "Not (p and q)" has the same truth value as
"(not p) or (not q)" in every row. There are only four rows (`cases p <;> cases q`), so
checking all of them is a complete proof. -/
theorem de_morgan_and (p q : Bool) : (!(p && q)) = (!p || !q) := by
  cases p <;> cases q <;> rfl
Axioms used: No axiomsformal/Lumenary/LogicStatements.leanTry it in the Lean web editor

For statements in general (Prop), Lean proves the "or" version of the law by reasoning, without any table:

not_or_iffLean 4Proved here from basic factsFormally verified
/-- The same law for statements (`Prop`), proved by reasoning instead of a table. If neither
`P` nor `Q` may hold, then `P` fails and `Q` fails; and if both fail, "P or Q" cannot hold. -/
theorem not_or_iff (P Q : Prop) : ¬ (P ∨ Q) ↔ ¬ P ∧ ¬ Q :=
  ⟨fun h => ⟨fun hp => h (Or.inl hp), fun hq => h (Or.inr hq)⟩,
   fun ⟨hnp, hnq⟩ h => h.elim hnp hnq⟩
Axioms used: No axiomsformal/Lumenary/LogicStatements.leanTry it in the Lean web editor

Five confirming examples, and then a counterexample that settles the question. Notice the ¬ ∀: "not every number ending in 2 is divisible by 4".

ending_in_two_examplesLean 4Proved here from basic factsFormally verified
/-- Five confirming examples: 12, 32, 52, 72 and 92 all end in 2, and all of them are divisible
by 4. -/
theorem ending_in_two_examples : ∀ n ∈ [12, 32, 52, 72, 92], n % 10 = 2 ∧ n % 4 = 0 := by
  decide
Axioms used: No axiomsformal/Lumenary/LogicStatements.leanTry it in the Lean web editor
ending_in_two_counterexampleLean 4Proved here from basic factsFormally verified
/-- …and yet "every number that ends in 2 is divisible by 4" is **false**. One counterexample
is enough: 22 ends in 2, but 22 = 4 × 5 + 2 leaves a remainder. -/
theorem ending_in_two_counterexample : ¬ ∀ n : Nat, n % 10 = 2 → n % 4 = 0 :=
  fun h => absurd (h 22 rfl) (by decide)
Axioms used: No axiomsformal/Lumenary/LogicStatements.leanTry it in the Lean web editor
odd_not_always_primeLean 4Proved here from basic factsFormally verified
/-- "Every odd number bigger than 1 is prime" (has no factors except 1 and itself) is false:
3, 5 and 7 fit, but 9 is odd and has the factor 3. -/
theorem odd_not_always_prime :
    ¬ ∀ n : Nat, n > 1 → n % 2 = 1 → ∀ d, d ∣ n → d = 1 ∨ d = n := by
  intro h
  have h3 := h 9 (by decide) (by decide) 3 ⟨3, rfl⟩
  omega
Axioms used: propext, Quot.soundformal/Lumenary/LogicStatements.leanTry it in the Lean web editor

A "some" statement (∃, "there exists") is proved by giving one example — here 2:

even_prime_existsLean 4Proved here from basic factsFormally verified
/-- A "some" statement needs just one example. "Some number is even and has no factors except 1
and itself" is true: 2 is such a number. -/
theorem even_prime_exists : ∃ n : Nat, n % 2 = 0 ∧ n > 1 ∧ ∀ d, d ∣ n → d = 1 ∨ d = n := by
  refine ⟨2, rfl, by decide, fun d hd => ?_⟩
  have hle : d ≤ 2 := Nat.le_of_dvd (by decide) hd
  have hpos : 0 < d := Nat.pos_of_dvd_of_pos hd (by decide)
  omega
Axioms used: propext, Quot.soundformal/Lumenary/LogicStatements.leanTry it in the Lean web editor

Checking 100 cases, and proving every case at once. Both are machine-checked, but they say different things: the first is about the numbers 0 to 99 only.

double_checked_to_100Lean 4Proved here from basic factsFormally verified
/-- Checking 100 cases: for each of the numbers 0, 1, …, 99, the double is even. Lean checks
the cases one by one. This says nothing yet about 100, or 1000. -/
theorem double_checked_to_100 : ∀ n, n < 100 → (2 * n) % 2 = 0 := by
  decide
Axioms used: No axiomsformal/Lumenary/LogicStatements.leanTry it in the Lean web editor
double_is_evenLean 4Applies a library theoremFormally verified
/-- Proving every case at once: for **every** whole number `n`, `2 × n` is even, because
`2 × n` is `n` groups of 2 with nothing left over. This applies core Lean's
`Nat.mul_mod_right`. -/
theorem double_is_even (n : Nat) : (2 * n) % 2 = 0 :=
  Nat.mul_mod_right 2 n
Axioms used: propextformal/Lumenary/LogicStatements.leanTry it in the Lean web editor

Finally, the rule that the opposite of "all pass" is "at least one fails", proved for every list and every yes-or-no test, and Amina's basket of mangoes as an example:

not_all_iff_exists_notLean 4Proved here from basic factsFormally verified
/-- **The opposite of "all pass" is "at least one fails"** — not "none pass". For any list of
things and any yes-or-no test `p`: it is *not* true that every item passes exactly when some
item fails. Proved for every list, by working through the list one item at a time. -/
theorem not_all_iff_exists_not {α : Type} (items : List α) (p : α → Bool) :
    ¬ (∀ x ∈ items, p x = true) ↔ ∃ x ∈ items, p x = false := by
  induction items with
  | nil => simp
  | cons a as ih =>
    cases h : p a <;> simp [h, ih]
Axioms used: propext, Quot.soundformal/Lumenary/LogicStatements.leanTry it in the Lean web editor
not_all_ripeLean 4Proved here from basic factsFormally verified
/-- A basket of four mangoes, ripe or not. "All the mangoes are ripe" is false, but "none of the
mangoes is ripe" is false too: the opposite of "all" is "at least one is not". -/
theorem not_all_ripe :
    ¬ (∀ ripe ∈ [true, true, false, true], ripe = true) ∧
    ¬ (∀ ripe ∈ [true, true, false, true], ripe = false) ∧
    (∃ ripe ∈ [true, true, false, true], ripe = false) := by
  decide
Axioms used: propextformal/Lumenary/LogicStatements.leanTry it in the Lean web editor

What is not formalised here: deciding whether an everyday sentence (like "mangoes are the tastiest fruit") is a statement at all. That is a question about language, not a theorem.

ComputationC

Margaret checks every row — and hunts for counterexamples

Truth tables: and, or, not in every rowPythonExact computationExhaustive finite checkComputationally tested
"""Truth tables for and, or, not - and checking a law in every row.

Each of two statements p and q is either true or false, so there are only
four rows to consider. The program prints the truth tables of 'and', the
inclusive 'or', the exclusive 'one or the other but not both' and 'not'. It
then checks De Morgan's laws and 'not (not p) = p' in every row, and shows
the one row where the inclusive and exclusive 'or' disagree. Because there
are only four rows, checking all of them is a complete proof of these laws -
unlike checking examples of a claim about all whole numbers.
"""

import textwrap
from itertools import product

ROWS = list(product([True, False], repeat=2))

def word(value):
    """'T' for true and 'F' for false."""
    return "T" if value else "F"

def inclusive_or(p, q):
    """True when at least one of p, q is true (the mathematician's 'or')."""
    return p or q

def exclusive_or(p, q):
    """True when exactly one of p, q is true ('one or the other, not both')."""
    return p != q

def same_in_every_row(rule1, rule2):
    """Do two rules give the same truth value in all four rows?"""
    return all(rule1(p, q) == rule2(p, q) for p, q in ROWS)

def rows_that_differ(rule1, rule2):
    """The rows (p, q) in which two rules give different truth values."""
    return [(p, q) for p, q in ROWS if rule1(p, q) != rule2(p, q)]

def main():
    print("p  q  | p and q | p or q | one but not both | not p")
    for p, q in ROWS:
        print(f"{word(p)}  {word(q)}  |    {word(p and q)}    |"
              f"   {word(inclusive_or(p, q))}    |"
              f"        {word(exclusive_or(p, q))}         |   {word(not p)}")
    print()
    print("not (p and q) = (not p) or (not q) in all 4 rows:",
          same_in_every_row(lambda p, q: not (p and q),
                            lambda p, q: (not p) or (not q)))
    print("not (p or q) = (not p) and (not q) in all 4 rows:",
          same_in_every_row(lambda p, q: not (p or q),
                            lambda p, q: (not p) and (not q)))
    print("not (not p) = p in all 4 rows:",
          same_in_every_row(lambda p, q: not (not p), lambda p, q: p))
    differ = rows_that_differ(inclusive_or, exclusive_or)
    print("Rows where 'or' and 'one but not both' differ:",
          ", ".join(f"p={word(p)}, q={word(q)}" for p, q in differ))
    print()
    print(textwrap.fill(
        "Epistemic status: exact and exhaustive. Two statements can only be "
        "true or false in 4 combinations, and every combination was "
        "checked, so this is a complete proof of these laws. A check of "
        "many examples of a claim about all whole numbers is different: "
        "there are infinitely many cases, so examples cannot finish the job.",
        width=78,
    ))

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.
Counterexample hunting up to 10000PythonExhaustive finite checkCounterexampleComputationally tested
"""Hunting for counterexamples to claims about every whole number.

The program tests five 'every' claims on the whole numbers up to 10000. For
each claim it counts the examples that fit and the counterexamples, and
reports the first counterexample. Some claims fail quickly; one fails only
after ten successes in a row; one (Goldbach's conjecture) has no
counterexample here or in far bigger computer searches, yet nobody has
proved it; one (the double of a number is even) is proved in the lesson.
A counterexample disproves a claim; a search without one proves nothing.
"""

import textwrap

LIMIT = 10000

def primes_up_to(n):
    """is_prime[k] for 0 <= k <= n, by the sieve of Eratosthenes."""
    is_prime = [False, False] + [True] * (n - 1)
    for p in range(2, int(n ** 0.5) + 1):
        if is_prime[p]:
            for multiple in range(p * p, n + 1, p):
                is_prime[multiple] = False
    return is_prime

PRIME = primes_up_to(LIMIT + 200)

def is_prime(n):
    """Is n a prime number? (Uses the sieve, so n must be in its range.)"""
    return PRIME[n]

def sum_of_two_primes(n):
    """Can n be written as p + q with p and q prime?"""
    return any(is_prime(p) and is_prime(n - p) for p in range(2, n // 2 + 1))

# Each claim: (description, which numbers it is about, the property).
CLAIMS = [
    ("every number ending in 2 is divisible by 4",
     lambda n: n % 10 == 2, lambda n: n % 4 == 0),
    ("every odd number bigger than 1 is prime",
     lambda n: n > 1 and n % 2 == 1, is_prime),
    ("n x n + n + 11 is prime for every n (tested up to n = 100)",
     lambda n: n <= 100, lambda n: is_prime(n * n + n + 11)),
    ("every even number from 4 on is a sum of two primes",
     lambda n: n >= 4 and n % 2 == 0, sum_of_two_primes),
    ("the double of every number is even",
     lambda n: True, lambda n: (2 * n) % 2 == 0),
]

def hunt(about, holds, limit=LIMIT):
    """Count fits and counterexamples among n = 0..limit; first failure."""
    fits, counterexamples, first = 0, 0, None
    for n in range(limit + 1):
        if about(n):
            if holds(n):
                fits += 1
            else:
                counterexamples += 1
                if first is None:
                    first = n
    return fits, counterexamples, first

def main():
    print(f"Testing five claims on the whole numbers 0 to {LIMIT}.")
    for text, about, holds in CLAIMS:
        fits, bad, first = hunt(about, holds)
        print()
        print(f"Claim: {text}")
        if first is None:
            print(f"  {fits} examples fit; no counterexample found.")
        else:
            print(f"  {fits} examples fit, {bad} counterexamples;"
                  f" the first is {first}.")
    n = 10
    print()
    print(f"The n x n + n + 11 claim works for n = 0, 1, ..., 9, then fails:"
          f" {n * n + n + 11} = 11 x 11.")
    print()
    print(textwrap.fill(
        "Epistemic status: an exhaustive search of a finite range. Each "
        "counterexample found is a complete disproof of its claim. Finding "
        "no counterexample proves nothing: Goldbach's conjecture has been "
        "checked by computers far beyond this range and is still unproved, "
        "while 'the double of every number is even' is proved in the lesson "
        "by reasoning, not by checking.",
        width=78,
    ))

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Look carefully at what the computer found. Three claims are disproved: a counterexample settles the matter for good. But for two claims it found no counterexample — and that does not make them proved:

  • "The double of every number is even" is proved, but by the "groups of 2" reason, not by the computer.
  • "Every even number from 4 on is the sum of two primes" (4=2+24 = 2 + 2, 6=3+36 = 3 + 3, 8=3+58 = 3 + 5, 10=5+510 = 5 + 5, …) is called Goldbach's conjecture, after Christian Goldbach, who discussed claims like it in letters with Leonhard Euler in 1742. Computers have checked every even number up to 4,000,000,000,000,000,000. Nobody has ever found a counterexample — and nobody has ever proved it. It is one of the most famous unsolved problems in mathematics.
For grown-ups · what kind of evidence this is

The truth-table check is exhaustive: two statements have exactly four combinations of truth values, so checking all four is a complete proof of De Morgan's laws. The counterexample hunt is an exhaustive search of a finite range: each counterexample is a disproof, while a range without counterexamples is evidence only. Goldbach's conjecture has been verified by computer for all even numbers up to 4×10184 \times 10^{18} (Oliveira e Silva, Herzog and Pardi, 2014) and remains open.

Exercises

Your turn

Read each sentence slowly. Is it a statement? Is it true? What is your reason? You can ask for a hint whenever you like.

1. True, false, and, or, not

Warm-upHuman

Which of these sentences are statements (sentences that are either true or false)? Choose all that are.

Choose all that apply

2. True, false, and, or, not

Warm-upHuman

Which of these statements are true? Choose all that are.

Choose all that apply

3. True, false, and, or, not

CoreHuman

How many of the whole numbers from 1 to 20 make this statement true?

"nn is even or nn is a multiple of 5."

4. True, false, and, or, not

CoreHuman

How many of the whole numbers from 1 to 20 make this statement true?

"nn is even and nn is a multiple of 3."

5. True, false, and, or, not

CoreHuman

Kofi claims: "Every odd number from 11 to 25 is prime." Find all the counterexamples to his claim. Write them separated by commas, like {1, 2}.

(A prime number has exactly two factors: 1 and itself.)

Write elements separated by commas. Order and repeats don’t matter — just like in a set!

6. True, false, and, or, not

CoreHuman

Zara checks the claim "n×n+n+11n \times n + n + 11 is a prime number" for n=0,1,2,…,9n = 0, 1, 2, \dots, 9 and gets 11, 13, 17, 23, 31, 41, 53, 67, 83, 101 — all prime. What can she conclude?

Choose one

7. True, false, and, or, not

CoreHuman

Which sentence means the opposite of "All the pencils in the box are red"?

Choose one

8. True, false, and, or, not

StretchHuman

The sign on the café door is wrong. It says: "We are open and we have mandazi today." Which sentence must be true?

Choose one

9. True, false, and, or, not

StretchFormal

In Lean, ∀ n : Nat means "for every whole number nn", → means "then" and ¬ means "not". Which Lean statement says: "Not every number that ends in 2 is divisible by 4"?

Choose one
Common misconceptionsH

Things that trip people up

Misconception

"I checked lots of examples, so it's always true." Examples can make us believe a claim, but they cannot prove a claim about every whole number: there are always more numbers to check. "n×n+n+11n \times n + n + 11 is prime" works ten times in a row and then fails. To be sure, we need a reason that works for every number.

Misconception

"Or means one or the other, but not both." In mathematics "or" is inclusive: "PP or QQ" is true when PP is true, when QQ is true, and when both are true. "6 is even or 6 is a multiple of 3" is true.

Misconception

"The opposite of ‘all are’ is ‘none are’." The opposite of "all the children walked to school" is "at least one child did not walk to school". Maybe almost everyone walked, and one child came by bus.

Misconception

"A false sentence is not a statement." It is! "3 + 4 = 8" is a statement — a false one. A statement is any sentence that is either true or false.

Misconception

"One counterexample is just an exception, so the rule is still true." In mathematics, "every" means every. A single counterexample makes an "every" statement false. (Sometimes we can repair the claim — "every number ending in 12, 32, 52, 72 or 92 is divisible by 4" is true — but that is a new statement.)

ViewpointsH

Other ways of seeing

Computation— Computers think in true and false

Inside every computer and phone are millions of tiny switches, each either on or off — true or false. Engineers connect them into logic gates: an AND gate gives "on" only when both of its inputs are on, an OR gate when at least one is, and a NOT gate swaps on and off. Out of nothing but these gates a computer adds numbers, shows pictures and plays music. When you program a computer you use the same words: "if the score is bigger than 10 and time is up, then show 'You win!'" — see Repetition and decisions.

Number theory— The number theorist's unsolved claims

Number theory, the study of whole numbers, is full of "every" claims that are easy to say and very hard to prove. Goldbach's conjecture (every even number from 4 on is the sum of two primes) has been checked for enormous numbers but is still unproved. Other claims were believed for a long time and then disproved by a counterexample that was very hard to find. In 1769 Leonhard Euler guessed that four fifth powers can never add up to a fifth power. Nearly two hundred years later, in 1966, Leon Lander and Thomas Parkin used a computer search to find 275+845+1105+1335=144527^5 + 84^5 + 110^5 + 133^5 = 144^5. That is why number theorists insist on proofs: in a world of infinitely many numbers, a pattern in the first few million is not enough.

Set-theoretic connectionH

And, or, not with sets

The three little words match the three ways of making new sets that you can meet in the lesson on sets. Let AA be the set of numbers from 1 to 20 that are even, and BB the set of numbers from 1 to 20 that are multiples of 3.

  • "even and a multiple of 3" picks out the intersection A∩B={6,12,18}A \cap B = \{6, 12, 18\};
  • "even or a multiple of 3" picks out the union A∪BA \cup B: the 10 even numbers, plus the odd multiples of 3 (3, 9, 15) — 13 numbers in all, with 6, 12 and 18 counted once;
  • "not even" picks out the complement of AA: the odd numbers from 1 to 20.

The inclusive "or" is exactly why the union contains the overlap. And De Morgan's law for statements becomes a law for sets: the complement of A∩BA \cap B is the union of the complements.

Later, in quantifiers and propositional logic, you will write "every" as ∀\forall and "some" as ∃\exists, and work with truth tables for longer formulas.

History & global context

History and global context

  • Ancient Greece. Aristotle (4th century BCE) studied arguments built from "all", "some" and "no" — for example "all … are …, and all … are …, so all … are …". A century later the Stoic thinker Chrysippus studied how whole statements are joined by words like "and", "or" and "if".
  • Ancient India. The Nyāya school of philosophy developed a careful theory of anumāna, inference: how to reason correctly from what we know to something new, using general rules and examples.
  • Ancient China. The Mohist Canon, written by followers of the philosopher Mozi around the 4th and 3rd centuries BCE, discusses how to make distinctions and argue correctly.
  • Persia and the Islamic world. Ibn Sīnā (Avicenna, 980–1037) wrote at great length on logic, including statements joined by "if… then" and "either… or".
  • Algebra of logic. In 1847 Augustus De Morgan, in London, wrote down the laws that now carry his name. In 1854 George Boole, working in Cork in Ireland, published The Laws of Thought, treating true and false like the numbers 1 and 0, and "and", "or", "not" like arithmetic.
  • Logic in machines. In 1937 Claude Shannon, then a student in the United States, showed that circuits of switches — like the ones in the picture above — can carry out Boole's logic. Every modern computer is built on this idea.
  • Black swans. The Roman poet Juvenal (around 100 CE) called something impossibly rare "a rare bird, very like a black swan". In Australia, black swans were an everyday sight.
Further reading

For grown-ups: further reading

  • Raymond Smullyan, Alice in Puzzle-Land (1982) and What Is the Name of This Book? (1978) — logic puzzles that delight children and adults.
  • Lewis Carroll, The Game of Logic (1886) — a playful introduction to reasoning with "all", "some" and "none".
  • George Pólya, Mathematics and Plausible Reasoning, Volume 1: Induction and Analogy in Mathematics (1954) — on how examples suggest conjectures, and why only proofs settle them.
  • Tim Bell, Ian H. Witten and Mike Fellows, Computer Science Unplugged (1998; later editions) — classroom activities, including how computers use true and false.