Refute a 'for all' claim with one exact witness
Test the shear on convenient inputs, watch it pass, then find the exact residual and the single point that refutes it.
The chapter’s claim is that a universal statement is refuted by one valid witness, and that passing tests are weak evidence because the inputs people try first are often degenerate. The claim under test is that the shear t′ = t, x′ = x + vt preserves t² − x². This program tries the convenient inputs, then a grid, then the residual itself, all in exact arithmetic.
Run it
Save this as quantifiers.py and run it with Python 3.11 or later. It uses the standard library only.
"""Every, some, none: why passing tests are weak evidence (standard library only).
Claim: the shear t' = t, x' = x + v t preserves t^2 - x^2 for all t, x, v.
Exact arithmetic with fractions, so a zero means zero.
"""
from fractions import Fraction as F
def residual(t, x, v):
"""(t'^2 - x'^2) - (t^2 - x^2) for the shear."""
return (t * t - (x + v * t) ** 2) - (t * t - x * x)
print("Convenient inputs (each one degenerate):")
for t, x, v, why in [(0, 5, F(1, 2), "t = 0"), (3, 7, 0, "v = 0"), (2, F(-1, 2), F(1, 2), "x = -vt/2")]:
print(f" t={t!s:>4} x={x!s:>5} v={v!s:>4} residual {residual(F(t), F(x), F(v))} ({why})")
print("\nA grid of ordinary inputs, t, x in -3..3 and v in {1/4, 1/2, 3/4}:")
grid = [(F(t), F(x), v) for t in range(-3, 4) for x in range(-3, 4) for v in (F(1, 4), F(1, 2), F(3, 4))]
fails = [p for p in grid if residual(*p) != 0]
print(f" {len(grid) - len(fails)} of {len(grid)} pass; {len(fails)} fail")
print("\nThe residual is -v t (2x + v t): it vanishes only on a thin set.")
assert all(residual(t, x, v) == -v * t * (2 * x + v * t) for t, x, v in grid)
print(" identity holds at every grid point: True")
w = (F(1), F(0), F(1, 2))
print(f"\nWitness t=1, x=0, v=1/2: residual {residual(*w)}. One point refutes 'for all'.")
print("\nPythagoras with the right angle deleted, A=(0,0) B=(1,0) C=(1,1):")
d2 = lambda p, q: (p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2
A, B, C = (0, 0), (1, 0), (1, 1)
print(f" d2(B,C) = {d2(B, C)}, d2(A,B) + d2(A,C) = {d2(A, B) + d2(A, C)}, residual {d2(B, C) - d2(A, B) - d2(A, C)}")
print("\nOrder of quantifiers, over the integers:")
print(" forall x exists y, y > x: for each x, y = x + 1 works, e.g.",
", ".join(f"x={x}: y={x + 1}" for x in (-5, 0, 7)))
print(" exists y forall x, y > x: every candidate y fails at x = y, e.g.",
", ".join(f"y={y}: x={y} gives {y} > {y} False" for y in (0, 10**6)))Expected outcome
Convenient inputs (each one degenerate):
t= 0 x= 5 v= 1/2 residual 0 (t = 0)
t= 3 x= 7 v= 0 residual 0 (v = 0)
t= 2 x= -1/2 v= 1/2 residual 0 (x = -vt/2)
A grid of ordinary inputs, t, x in -3..3 and v in {1/4, 1/2, 3/4}:
21 of 147 pass; 126 fail
The residual is -v t (2x + v t): it vanishes only on a thin set.
identity holds at every grid point: True
Witness t=1, x=0, v=1/2: residual -1/4. One point refutes 'for all'.
Pythagoras with the right angle deleted, A=(0,0) B=(1,0) C=(1,1):
d2(B,C) = 1, d2(A,B) + d2(A,C) = 3, residual -2
Order of quantifiers, over the integers:
forall x exists y, y > x: for each x, y = x + 1 works, e.g. x=-5: y=-4, x=0: y=1, x=7: y=8
exists y forall x, y > x: every candidate y fails at x = y, e.g. y=0: x=0 gives 0 > 0 False, y=1000000: x=1000000 gives 1000000 > 1000000 FalseThe three convenient inputs all pass: each is a degenerate case (t = 0, v = 0, or x = −vt/2). On an ordinary grid most points fail, and the residual explains why: it is −vt(2x + vt), zero only on a thin set. One witness, t = 1, x = 0, v = 1/2, with residual −1/4, refutes the “for all”. The same pattern refutes Pythagoras with the right angle deleted. The last lines show why the order of “for all” and “there exists” matters.
Mechanism and limitations
Documented: Chapter 10 of the book sets out the mathematics; this program is a self-contained demonstration of it, not one of the laboratory’s recorded investigations.
Observed: the output above, produced by running the program exactly as shown.
Not shown:
- The grid is a test, not a proof: the residual identity is checked at 147 points here; in general it is a polynomial identity to be proved algebraically.
- The witness refutes only the claim as stated. It says nothing about which repair is right (that is the next chapter).
Related worked example: Chapter 2 .
Challenge this result
Copy this into the AI assistant of your choice, or work through it yourself. Check any finding against the recorded evidence.
Examine the claim that the shear t′ = t, x′ = x + vt does not preserve t² − x².
Recompute the residual −vt(2x + vt) by hand, check that the witness (1, 0, 1/2)
lies in the claim's domain, and find every input on which the claim happens to
hold. Then state precisely the order of quantifiers in "for every x there is a
y with y > x" and explain why swapping them changes the claim.
Chapter: https://programmer.ie/books/math/10-chapter/
Example: https://programmer.ie/examples/math/10-chapter/
Program: https://github.com/ernanhughes/math/blob/main/notebooks/math/programs/10-quantifiers.py
Distinguish what the record shows from what you infer. If you cannot open a link, ask me for the material; do not invent it.Canonical source and the program .
Understand this example
Copy this prompt into your AI tool. No code runs here.
Apply this example
Copy this prompt into your AI tool. No code runs here.