"""Boundary and seeded-error checks for Chapters 5, 10, 18, 22 and 24. Run from the repository root: uv run python content/examples/math/tool-chapters/ch05_10_18_22_24_checks.py Illustrative checks. They are not claim-bound EvidenceResults. """ from sympy import Rational, simplify, sqrt, symbols import z3 print("sympy", __import__("sympy").__version__, "z3", z3.get_version_string()) # --- Chapter 5: seeded SymPy witness --------------------------------------- t, x, v = symbols("t x v", real=True) shear = t**2 - (x + v * t) ** 2 original = t**2 - x**2 assignment = {t: Rational(0), x: Rational(0), v: Rational(1, 2)} residual_value = simplify((shear - original).subs(assignment)) original_value = simplify(original.subs(assignment)) transformed_value = simplify(shear.subs(assignment)) valid = residual_value != 0 and transformed_value != original_value print("ch05 seeded residual:", residual_value) print("ch05 seeded witness valid:", valid) # --- Chapter 10: seeded weakened gamma hypothesis -------------------------- T, X, V, G = z3.Reals("t x v gamma") goal_negation = (G * (T - V * X)) ** 2 - (G * (X - V * T)) ** 2 != T * T - X * X seeded = z3.Solver() seeded.add(G * G * (1 - V * V) >= 1) seeded.add(goal_negation) outcome = seeded.check() print("ch10 weakened hypothesis negation:", outcome) if outcome == z3.sat: print("ch10 weakened model:", seeded.model()) # --- Chapter 18: sign-slip check ------------------------------------------ gamma = 1 / sqrt(1 - v**2) normal_t = gamma * (t - v * x) normal_x = gamma * (x - v * t) slip_t = gamma * (t - v * x) slip_x = gamma * (x + v * t) point = {t: Rational(5), x: Rational(3), v: Rational(3, 5)} print("ch18 normal interval at (5,3):", simplify((normal_t**2 - normal_x**2).subs(point))) print("ch18 sign-slip interval at (5,3):", simplify((slip_t**2 - slip_x**2).subs(point))) print("ch18 normal factors at (5,3):", simplify((normal_t - normal_x).subs(point)), simplify((normal_t + normal_x).subs(point))) print("ch18 sign-slip factors at (5,3):", simplify((slip_t - slip_x).subs(point)), simplify((slip_t + slip_x).subs(point))) # --- Chapter 22: timelike boundary and seeded velocity bound -------------- valid_boundary = z3.Solver() valid_boundary.add(V > -1, V < 1, T > 0) valid_boundary.add(X >= -T, X <= T, T - V * X <= 0) print("ch22 valid boundary negation:", valid_boundary.check()) seeded_boundary = z3.Solver() seeded_boundary.add(V >= -1, V <= 1, T > 0) seeded_boundary.add(X >= -T, X <= T, T - V * X <= 0) outcome = seeded_boundary.check() print("ch22 seeded |v|<=1 negation:", outcome) if outcome == z3.sat: print("ch22 seeded model:", seeded_boundary.model()) # --- Chapter 24: v=0 deletion boundary ------------------------------------- gamma_rel = G * G * (1 - V * V) == 1 with_gamma = z3.Solver() with_gamma.add(V == 0, gamma_rel, goal_negation) print("ch24 v=0 with gamma relation:", with_gamma.check()) without_gamma = z3.Solver() without_gamma.add(V == 0, goal_negation) outcome = without_gamma.check() print("ch24 v=0 without gamma relation:", outcome) if outcome == z3.sat: print("ch24 v=0 model:", without_gamma.model())