"""Executable examples for Chapters 30 and 32: delete a hypothesis, ask Z3. For a claim "H1 and ... and Hn imply G", dropping Hi and asking Z3 for a model of (the other hypotheses and not G): sat -> Hi is load-bearing; the model shows why unsat -> Hi is redundant given the others (or the claim is vacuous without it) Run from the repository root: uv run python content/examples/math/part4/part4_assumption_deletion_demo.py ILLUSTRATIVE. Not versioned claims; no EvidenceResult. A Z3 `sat` is a candidate witness that should be substituted back before it is called a refutation (Chapter 5), and `unsat` holds only for the encoding below (Chapter 10). Square root is encoded as a relation (s > 0, s*s = 1 - v*v), NOT Lean's junk-value convention, so results on that encoding can differ from Lean's (Chapter 11). """ import z3 t, x, v, g = z3.Reals("t x v gamma") s = z3.Real("s") # sqrt(1 - v^2) as a relation def check(label, hyps, goal): solver = z3.Solver() solver.add(*hyps) solver.add(z3.Not(goal)) r = solver.check() extra = "" if r == z3.sat: m = solver.model() extra = " model: " + ", ".join(f"{d}={m[d]}" for d in m) print(f"{label:58s} {r!s:6s}{extra}") gamma_rel = g * g * (1 - v * v) == 1 alg_goal = (g * (t - v * x)) ** 2 - (g * (x - v * t)) ** 2 == t * t - x * x print("== Chapter 30: algebraic Lorentz claim") check("full claim (gamma relation)", [gamma_rel], alg_goal) check("drop gamma relation", [], alg_goal) check("is |v|<1 redundant given the gamma relation?", [gamma_rel], z3.And(v > -1, v < 1)) check("does the gamma relation force gamma > 0?", [gamma_rel], g > 0) print("\n== Chapter 30: Pythagorean coordinate claim") ax, ay, bx, by, cx, cy = z3.Reals("ax ay bx by cx cy") dot = (bx - ax) * (cx - ax) + (by - ay) * (cy - ay) ab2 = (bx - ax) ** 2 + (by - ay) ** 2 ac2 = (cx - ax) ** 2 + (cy - ay) ** 2 bc2 = (cx - bx) ** 2 + (cy - by) ** 2 check("full claim (orthogonality)", [dot == 0], bc2 == ab2 + ac2) check("drop orthogonality", [], bc2 == ab2 + ac2) print("\n== Chapter 30: timelike order (gamma form)") goal = g * (t - v * x) > 0 base = {"gamma>0": g > 0, "gamma relation": gamma_rel, "t>0": t > 0, "timelike t^2>x^2": t * t - x * x > 0} check("full claim", list(base.values()), goal) for name in base: check(f"drop {name}", [h for k, h in base.items() if k != name], goal) print("\n== Chapter 32: physical hypotheses versus the algebraic hypothesis") phys = [v > -1, v < 1, s > 0, s * s == 1 - v * v, g * s == 1] # gamma = 1/sqrt(1-v^2) check("physical hypotheses imply the gamma relation", phys, gamma_rel) check("gamma relation implies physical gamma (gamma = 1/s)?", [gamma_rel, s > 0, s * s == 1 - v * v], g * s == 1)