Avenyra-Geometric-Memory-Physics / research /v2 /verify_zero_memory.py
PureOne's picture
Upload Avenyra Geometric Memory Physics v3.0.0
edd15df verified
Raw History Blame Contribute Delete
3.98 kB
#!/usr/bin/env python3
"""Exact finite seed checks for VELORYN; no stochastic or physical certification.
Uses only standard-library rational arithmetic. Checks independent vector
cross products against the one-/two-pulse classification and sharp budgets.
"""
from fractions import Fraction as F
from pathlib import Path
import json
import random
def add(x, y):
return tuple(a + b for a, b in zip(x, y))
def mul(c, x):
return tuple(c * a for a in x)
def dot(x, y):
return sum(a * b for a, b in zip(x, y))
def cross(x, y):
return (x[1]*y[2]-x[2]*y[1],
x[2]*y[0]-x[0]*y[2],
x[0]*y[1]-x[1]*y[0])
def random_vector(rng):
return tuple(F(rng.randint(-4, 4), rng.randint(1, 4)) for _ in range(3))
def main():
rng = random.Random(811026)
alphas = [F(-2), F(-1, 2), F(0), F(1, 2), F(1), F(2)]
one_cases = two_cases = 0
for j in range(50):
while True:
x = random_vector(rng)
v = cross(x, random_vector(rng))
r = dot(x, x)
if r and dot(v, v):
break
alpha = alphas[j % len(alphas)]
a = add(mul(alpha, x), v)
x1 = add(x, a)
b1 = cross(x, a)
U1 = dot(b1, b1)
assert dot(x, v) == 0
assert U1 == r * dot(v, v)
assert dot(x1, b1) == 0
assert dot(x1, x1) == (1+alpha)**2*r + U1/r
reconstructed = add(mul(alpha, x), mul(-1/r, cross(x, b1)))
assert reconstructed == a
one_cases += 1
# Build a separate prescribed two-pulse state x,b with b perpendicular x.
b = cross(x, random_vector(rng))
if dot(b, b) == 0:
b = cross(x, v)
U = dot(b, b)
p = add(mul(alpha, x), mul(1/r, cross(x, b)))
q = add(x, mul(-1, p))
assert add(p, q) == x
assert cross(p, q) == b
assert dot(x, b) == 0
p2, q2 = dot(p, p), dot(q, q)
quadratic_min = r/2 + 2*U/r
assert p2 + q2 - quadratic_min == 2*r*(alpha-F(1, 2))**2
pm = add(mul(F(1, 2), x), mul(1/r, cross(x, b)))
qm = add(x, mul(-1, pm))
assert dot(pm, pm) == dot(qm, qm)
assert dot(pm, pm)+dot(qm, qm) == quadratic_min
minimum_length_squared = r + 4*U/r
assert 4*dot(pm, pm) == minimum_length_squared
# Verify sqrt(p2)+sqrt(q2) >= sqrt(minimum_length_squared)
# without numerical square roots, by squaring only nonnegative sides.
remainder = minimum_length_squared-(p2+q2)
if remainder > 0:
assert 4*p2*q2 >= remainder**2
# Optimizing the prescribed endpoint norm gives sharp universal budgets.
assert quadratic_min**2 >= 4*U
assert minimum_length_squared**2 >= 16*U
two_cases += 1
sharp_cases = 0
for c in [F(1, 3), F(1, 2), F(1), F(3, 2), F(2)]:
p, q = (c, F(0), F(0)), (F(0), c, F(0))
x, b = add(p, q), cross(p, q)
r, U = dot(x, x), dot(b, b)
quadratic = dot(p, p)+dot(q, q)
length_squared = 4*dot(p, p)
assert r == 2*c*c
assert U == c**4
assert quadratic**2 == 4*U
assert length_squared**2 == 16*U
assert quadratic == r/2+2*U/r
assert length_squared == r+4*U/r
sharp_cases += 1
result = {
"status": "all exact rational finite seed checks passed",
"seed": 811026,
"one_pulse_classification_cases": one_cases,
"two_pulse_classification_and_budget_cases": two_cases,
"sharp_universal_budget_equality_cases": sharp_cases,
"arithmetic": "Python fractions.Fraction; exact equalities and inequalities",
"scope": "finite preparation identities only; no certification of entrance limits, physics, or priority",
}
destination = Path(__file__).resolve().parent / "seed_verification.json"
destination.write_text(json.dumps(result, indent=2)+"\n")
print(json.dumps(result, indent=2))
if __name__ == "__main__":
main()