PureOne's picture
Publish Neixarua release 3: manuscript, proofs, claim corpus and reproducibility
ee3d849 verified
Raw History Blame Contribute Delete
13.1 kB
#!/usr/bin/env python3
"""Exact and symbolic demonstrations for the continuation geometry chapter.
The finite tests and symbolic identities supplement the analytic proofs.
They do not establish topology, all-history stationarity or generic
Newtonian completeness by sampling. No empirical data are used.
"""
from __future__ import annotations
import argparse
import json
from pathlib import Path
import sympy as s
from sympy.physics.wigner import wigner_3j
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--output", type=Path,
default=Path(__file__).resolve().parents[1] /
"verification" / "results" / "v2_geometry_results.json")
args = parser.parse_args()
checks = []
def exact(name, expressions, detail, **extra):
residuals = [s.simplify(s.trigsimp(x)) for x in expressions]
assert all(x == 0 for x in residuals), (name, residuals)
checks.append({"name": name, "passed": True,
"symbolic_residuals": list(map(str, residuals)),
"detail": detail, **extra})
def check(name, condition, detail, **extra):
assert condition, name
checks.append({"name": name, "passed": True,
"detail": detail, **extra})
# A complete two-dimensional observation cone despite positive appends.
identity = s.eye(2)
anisotropy = s.Matrix([[3, 4], [4, -3]])
plus = (5 * identity + anisotropy) / 2
minus = (5 * identity - anisotropy) / 2
L = lambda a: s.Matrix([a[0, 0] - a[1, 1], 2 * a[0, 1]])
check("opposite_anisotropies_have_positive_appends",
set(plus.eigenvals()) == {0, 5} and
set(minus.eigenvals()) == {0, 5},
"Both append matrices are PSD; their observed directions are opposite.")
exact("anisotropy_cancels_while_total_accumulation_grows",
list(L(plus) - s.Matrix([3, 4])) +
list(L(minus) + s.Matrix([3, 4])) +
list(plus + minus - 5 * identity) + [s.trace(plus + minus) - 10],
"The scalar kernel hides the total trace, which increases to ten.")
weighted_kernel = s.diag(2, 1)
weighted_L = lambda a: a[0, 0] - 2 * a[1, 1]
check("positive_definite_kernel_need_not_be_identity",
weighted_L(weighted_kernel) == 0 and
weighted_L(identity) != 0 and
all(x > 0 for x in weighted_kernel.eigenvals()),
"The exact collapse criterion is broader than L(I)=0.")
energy_rows = []
for n in (1, 2, 3, 10, 100, 1000):
gamma = s.Matrix([[s.Rational(1, n), 1], [1, n]])
assert gamma.det() == 0 and s.trace(gamma) > 0
energy_rows.append({"n": n, "a": str(gamma[0, 0]),
"b": "1", "trace": str(s.trace(gamma))})
check("nonclosed_image_requires_unbounded_hidden_trace", True,
"Rank-one PSD examples approach the forbidden record (0,1); "
"the all-parameter divergence is proved analytically.",
exact_examples=energy_rows)
a, b, energy = s.symbols("a b energy", real=True)
exact("bounded_energy_record_region",
[s.Matrix([[a, b], [b, energy-a]]).det() -
(a * (energy-a) - b*b)],
"For 0<=a<=E this determinant condition is exactly the compact budget region.")
# An asymmetric stationary observation can move within the collapsed cone.
paths = {(i, (i+1) % 3): s.Rational(1, 3) for i in range(3)}
reversed_paths = {(j, i): p for (i, j), p in paths.items()}
path_tv = sum(abs(paths.get(x, 0)-reversed_paths.get(x, 0))
for x in set(paths) | set(reversed_paths)) / 2
trace_costs = []
for phase in range(3):
gamma = s.diag(phase, 0)
start = gamma.copy()
state = phase
for _ in range(3):
nxt = (state + 1) % 3
change = nxt - state
delta = s.diag(max(change, 0), max(-change, 0))
gamma += delta
assert gamma[0, 0] - gamma[1, 1] == nxt
state = nxt
assert gamma - start == 2 * s.eye(2)
trace_costs.append(str(s.trace(gamma - start)))
check("stationary_quotient_does_not_imply_reversible_records",
path_tv == 1 and trace_costs == ["4", "4", "4"],
"A uniformly phased directed three-cycle has stationary one-time "
"laws and TV=1 from its reverse, while positive hidden appends "
"increase the unobserved trace by four each cycle.",
forward_reverse_pair_tv=str(path_tv),
hidden_trace_increase_per_cycle=trace_costs)
# Independent exact evaluation of the imported angular coupling formula.
wigner_rows = []
expected = [s.Rational(5), s.Rational(10, 3), s.Rational(10, 7),
s.Rational(5, 14), s.Rational(5, 126)]
for degree in range(5):
square = s.simplify(wigner_3j(2, 2, degree, 2, -2, 0)**2)
factorial = (s.factorial(4)**2 /
(s.factorial(4-degree)*s.factorial(5+degree)))
assert square == factorial and 25*square == expected[degree]
wigner_rows.append({"L": degree, "wigner_square": str(square),
"four_pi_singular_value_squared": str(25*square)})
check("quadrupolar_angular_map_all_irreducibles_nonzero",
sum(2 * degree + 1 for degree in range(5)) == 25,
"SymPy's exact Wigner implementation independently matches the "
"factorial identity and all 25 Hermitian dimensions.",
irreducibles=wigner_rows)
gamma = s.diag(3, 3, 1, 0, 0)
gamma[0, 1] = gamma[1, 0] = 1
completion = 4*s.eye(5)-gamma
check("quadrupolar_optimal_completion_nontrivial_coherence",
max(gamma.eigenvals()) == 4 and
all(x >= 0 for x in completion.eigenvals()) and
s.trace(completion) == 13 and gamma + completion == 4*s.eye(5),
"A nondiagonal covariance has eigenvalues 4,2,1,0,0 and exact "
"optimal full-isotropy append cost thirteen.",
initial_trace=str(s.trace(gamma)), append_trace=str(s.trace(completion)))
lam = s.symbols("lam", real=True)
witness = s.Matrix([1, 1, 0, 0, 0])
exact("completion_matching_lower_certificate",
[(witness.T*(lam*s.eye(5)-gamma)*witness)[0]-2*(lam-4)],
"The top-eigenvector PSD test forces lambda>=4, attaining the construction.")
pure = s.ones(5)/5
check("rank_one_full_isotropy_cost_four_times_energy",
pure.rank() == 1 and s.trace(pure) == 1 and
all(x >= 0 for x in (s.eye(5)-pure).eigenvals()) and
s.trace(s.eye(5)-pure) == 4,
"This cost targets full quadrupolar flux isotropy, not only memory multipoles.")
# Rational circle parametrization: exact probabilities, no floating-point angles.
u = s.symbols("u", real=True)
radius = s.Rational(3, 5)
x = (1-u*u)/(1+u*u)
y = 2*u/(1+u*u)
prob = s.Matrix([1+radius*x, 1-radius*x, 1+radius*y, 1-radius*y])/4
reverse = s.Matrix([prob[1], prob[0], prob[3], prob[2]])
uniform = s.ones(4, 1)/4
exact("orientation_circle_reversal_pair",
[x*x+y*y-1, sum(prob)-1] + list((prob+reverse)/2-uniform),
"The two antipodal branches average to the symmetric uniform law.")
tvs = []
for value in (s.Rational(-3), s.Rational(-1), s.Rational(-1, 2),
s.Rational(0), s.Rational(1, 2), s.Rational(1), s.Rational(3)):
pp = prob.subs(u, value)
qq = reverse.subs(u, value)
tv = s.simplify(sum(abs(z) for z in pp-qq)/2)
assert all(z > 0 for z in pp) and tv >= radius/2
tvs.append(str(tv))
check("uniform_directional_separation_finite_rational_examples", True,
"Finite exact checks illustrate the analytic lower bound r/2. "
"The no-section theorem is topological and is not inferred from samples.",
r=str(radius), tv_values=tvs)
weight = (1+x)/2
barycenter = weight*prob+(1-weight)*reverse
exact("continuous_randomized_selection_has_balanced_midpoint",
list(barycenter.subs(u, 1)-uniform) + [weight.subs(u, 1)-s.Rational(1, 2)],
"A valid continuous randomized representative balances at x=0. "
"Its realized branch remains oriented.")
# Full rational symbolic solution of the zero-energy two-body problem.
q = s.Matrix([(1-u*u)/2, u, 0])
distance = (1+u*u)/2
time = (u+u**3/3)/2
momentum = s.Matrix([-u, 1, 0])/distance
d_dt = lambda value: s.diff(value, u)/distance
exact("parabolic_orbit_hamilton_equations",
[s.diff(time, u)-distance, (q.T*q)[0]-distance**2] +
list(d_dt(q)-momentum) +
list(d_dt(momentum)+q/distance**3),
"Symbolic rational identities hold for every real u, not just a numerical orbit.")
kinetic = (momentum.T*momentum)[0]/2
potential = -1/distance
dilation = (q.T*momentum)[0]
size = (q.T*q)[0]
exact("parabolic_energy_dilation_and_lagrange_jacobi",
[kinetic+potential, dilation-u, d_dt(dilation)-1/distance,
d_dt(size)-2*dilation, d_dt(d_dt(size))-2/distance],
"H=0, D=u, I'=2D and I''=-2V prove the exact two-sided size mechanism.")
exact("parabolic_shape_complexity_is_constant",
[-potential*distance-1],
"The dimensionless proxy (-V)sqrt(I) is identically one; "
"a size Janus point alone supplies no entropy-growth theorem.")
dimension = s.symbols("dimension", integer=True, positive=True)
scale_exponent = dimension/2 + 1-s.Rational(1, 2)-1
exact("janus_flux_similarity_exponent",
[scale_exponent-(dimension-1)/2],
"Volume, delta(H), delta(D) and positive crossing factor have "
"weights d/2, 1, -1/2 and -1 respectively.",
particle_counts={str(n): str(scale_exponent.subs(dimension, 3*n-3))
for n in range(2, 9)})
speed, crossing = s.symbols("speed crossing", positive=True)
exact("correct_clock_preserves_section_flux",
[(speed*crossing)/speed-crossing],
"The invariant density 1/f cancels the crossing speed f exactly. "
"No claim of probability normalization follows.")
t = s.symbols("t", real=True)
integral = s.integrate(1/(1+t*t), (t, -s.oo, s.oo))
exact("finite_occupation_weight_can_hide_clock_incompleteness",
[s.diff(s.atan(t), t)-1/(1+t*t), integral-s.pi],
"For Y=(1+t^2)d/dt, the formal invariant density is integrable, "
"but tau=atan(t) has finite endpoints and the clocked flow is incomplete.")
# Probability-versus-possibility comparison on a finite exact metric space.
theta = s.Rational(2, 5)
vertices = [(1, 1), (1, 0), (0, -1), (-1, -1), (-1, 0), (0, 1)]
pure_possibility = max(abs(theta*(max(a0, 0)-max(b0, 0)))
for a0, b0 in vertices)
mixed = max(abs((1-theta)*(a0-b0)/2 +
theta*(max(a0, 0)-max(b0, 0)))
for a0, b0 in vertices)
check("possibility_queries_exceed_sampling_of_a_fixed_law",
pure_possibility == theta and mixed == (1+theta)/2,
"For the unit discrete metric and c anchored at zero, enumerate "
"the six Lipschitz-polytope vertices; the piecewise-linear "
"break lines a=0,b=0 add no larger value.",
symmetric_law_possibility_defect=str(pure_possibility),
mixed_law_possibility_defect=str(mixed))
# Exact equal-stress ensembles, using complex rational amplitudes.
basis = [s.eye(3)[:, j] for j in range(3)]
null_fields = []
for i, j in ((0, 1), (1, 2), (2, 0)):
null_fields.extend([(basis[i]+s.I*basis[j])/2,
(basis[i]-s.I*basis[j])/2])
coherency = sum((f*f.H for f in null_fields), s.zeros(3))
null_invariants = [(f.T*f)[0] for f in null_fields]
first_proper = sum(abs((f.T*f)[0]) for f in basis)
exact("equal_stress_null_field_decomposition",
list(coherency-s.eye(3)) + null_invariants + [first_proper-3],
"Both ensembles have J=I_3; one has mean individual proper energy "
"three and the six null fields have zero. Weights are absorbed "
"into amplitudes, as specified in the analytic construction.")
payload = {"suite": "v2_record_geometry",
"sympy_version": s.__version__,
"demonstration_count": len(checks),
"all_passed": all(c["passed"] for c in checks),
"checks": checks,
"limitations": "Exact finite examples and symbolic identities "
"supplement analytic proofs. They do not certify a cosmological "
"model, generic N-body completeness, or the topological "
"no-section theorem by numerical sampling."}
args.output.parent.mkdir(parents=True, exist_ok=True)
args.output.write_text(json.dumps(payload, indent=2)+"\n")
print(json.dumps({"suite": payload["suite"],
"demonstrations": len(checks), "all_passed": True,
"output": str(args.output)}))
if __name__ == "__main__":
main()