Datasets:
Formats:
json
Languages:
English
Size:
< 1K
Tags:
mathematics
signed-area
history-dependent-dynamics
reachability
linear-algebra
reproducible-research
Download code/verify_candidates.py from PureOne/avenyra-area-feedback: direct link, hf CLI and curl.
- Browser
- Download file 6.76 kB
-
https://huggingface.co/datasets/PureOne/avenyra-area-feedback/resolve/main/code/verify_candidates.py
- Command line
-
hf download hf://datasets/PureOne/avenyra-area-feedback/code/verify_candidates.py
-
curl -L -o verify_candidates.py https://huggingface.co/datasets/PureOne/avenyra-area-feedback/resolve/main/code/verify_candidates.py
6.76 kB
| #!/usr/bin/env python3 | |
| """Exact finite checks for the radical-product alternative. | |
| Python 3 standard library only. This checks finite instances, not novelty or | |
| universal theorems. The manuscript appendix supplies the proofs. | |
| Run: | |
| python verify_candidates.py | |
| """ | |
| from itertools import product | |
| import json | |
| def recurrence_terminal(N, m): | |
| """Iterate the stated scalar one-step recurrence to its fixed point.""" | |
| while True: | |
| nxt = max(m, 2 * min(m, N - m - 1)) | |
| if nxt == m: | |
| return m | |
| if not m < nxt <= N - 1: | |
| raise AssertionError((N, m, nxt)) | |
| m = nxt | |
| def interval_formula(N, m): | |
| """Evaluate the closed terminal formula independently of the recurrence.""" | |
| n = N - 1 | |
| a = m | |
| while 2 * a < n: | |
| a *= 2 | |
| return max(a, 2 * (n - a)) | |
| def literal_step(S, caps): | |
| """Monomial update by complementary supports and pairwise multiplication. | |
| Exponents are tuples. This function does not use interval endpoints or the | |
| tensor dimension formula. Coordinates exceeding their truncation cap | |
| represent a zero product and are omitted. | |
| """ | |
| S = frozenset(S) | |
| dark = { | |
| u for u in S | |
| if tuple(cap - value for cap, value in zip(caps, u)) not in S | |
| } | |
| out = set(S) | |
| for u in dark: | |
| for v in dark: | |
| w = tuple(a + b for a, b in zip(u, v)) | |
| if all(value <= cap for value, cap in zip(w, caps)): | |
| out.add(w) | |
| return frozenset(out), frozenset(dark) | |
| def literal_terminal(S, caps): | |
| S = frozenset(S) | |
| rounds = 0 | |
| while True: | |
| nxt, dark = literal_step(S, caps) | |
| if nxt == S: | |
| return S, dark, rounds | |
| if not S < nxt: | |
| raise AssertionError("Literal update was not strictly extensive") | |
| S = nxt | |
| rounds += 1 | |
| def interval_support(m): | |
| return frozenset((i,) for i in range(1, m + 1)) | |
| def check_async_sequence(N, products, expected): | |
| S = interval_support(1) | |
| for i, j in products: | |
| nxt, dark = literal_step(S, (N,)) | |
| if (i,) not in dark or (j,) not in dark: | |
| raise AssertionError(("Unauthorized asynchronous product", S, i, j)) | |
| born = (i + j,) | |
| if i + j > N or born in S or born not in nxt: | |
| raise AssertionError(("Invalid asynchronous birth", S, born)) | |
| S = S | {born} | |
| if S != frozenset((i,) for i in expected): | |
| raise AssertionError(("Wrong asynchronous endpoint", S, expected)) | |
| nxt, dark = literal_step(S, (N,)) | |
| if nxt != S: | |
| raise AssertionError("Asynchronous endpoint was not terminal") | |
| return { | |
| "N": N, | |
| "products": [list(pair) for pair in products], | |
| "terminal_exponents": sorted(i for (i,) in S), | |
| "terminal_dark_exponents": sorted(i for (i,) in dark), | |
| } | |
| def main(): | |
| recurrence_cases = 0 | |
| for N in range(2, 301): | |
| for m in range(1, N): | |
| actual = recurrence_terminal(N, m) | |
| expected = interval_formula(N, m) | |
| if actual != expected: | |
| raise AssertionError(("Recurrence/formula mismatch", N, m, actual, expected)) | |
| recurrence_cases += 1 | |
| assert recurrence_cases == 44850 | |
| literal_interval_cases = 0 | |
| literal_boundary_cases = 0 | |
| for N in range(2, 41): | |
| for m in range(1, N): | |
| actual, dark, rounds = literal_terminal(interval_support(m), (N,)) | |
| expected = interval_support(interval_formula(N, m)) | |
| if actual != expected: | |
| raise AssertionError(("Literal interval mismatch", N, m, actual, expected)) | |
| literal_interval_cases += 1 | |
| for seed in (frozenset(), interval_support(N)): | |
| actual, dark, rounds = literal_terminal(seed, (N,)) | |
| if actual != seed or rounds != 0: | |
| raise AssertionError(("Boundary state not fixed", N, seed, actual)) | |
| literal_boundary_cases += 1 | |
| assert literal_interval_cases == 780 | |
| assert literal_boundary_cases == 78 | |
| n13 = [] | |
| for m in (3, 4): | |
| S = interval_support(m) | |
| dimensions = [len(S)] | |
| while True: | |
| nxt, dark = literal_step(S, (13,)) | |
| if nxt == S: | |
| break | |
| S = nxt | |
| dimensions.append(len(S)) | |
| n13.append({"initial_m": m, "dimensions_until_fixed": dimensions}) | |
| assert [item["dimensions_until_fixed"] for item in n13] == [[3, 6, 12], [4, 8]] | |
| tensor_rows = [] | |
| for r in range(1, 7): | |
| seed = frozenset(product((1, 2), repeat=r)) | |
| first, initial_dark = literal_step(seed, (4,) * r) | |
| second, terminal_dark = literal_step(first, (4,) * r) | |
| expected = 2**r + 3**r - r - 2 | |
| if len(first) != expected or second != first: | |
| raise AssertionError(("Tensor dimension/terminality mismatch", r, len(first), expected)) | |
| if r >= 2 and len(terminal_dark) != 3**r - 2**r - r - 1: | |
| raise AssertionError(("Tensor terminal radical mismatch", r)) | |
| tensor_rows.append({ | |
| "r": r, | |
| "initial_dimension": len(seed), | |
| "initial_radical_dimension": len(initial_dark), | |
| "terminal_dimension": len(first), | |
| "terminal_radical_dimension": len(terminal_dark), | |
| "first_update_is_terminal": second == first, | |
| }) | |
| assert [row["terminal_dimension"] for row in tensor_rows] == [2, 9, 30, 91, 268, 785] | |
| asynchronous = [ | |
| check_async_sequence(7, [(1, 1), (2, 2), (1, 2)], [1, 2, 3, 4]), | |
| check_async_sequence(7, [(1, 1), (1, 2), (2, 3), (1, 3)], [1, 2, 3, 4, 5]), | |
| ] | |
| result = { | |
| "status": "PASS", | |
| "arithmetic": "Exact integer exponents and finite sets; Python standard library", | |
| "recurrence_vs_closed_formula": { | |
| "N_range_inclusive": [2, 300], | |
| "m_range": "1 <= m < N", | |
| "cases": recurrence_cases, | |
| }, | |
| "independent_literal_interval_updates": { | |
| "N_range_inclusive": [2, 40], | |
| "m_range": "1 <= m < N", | |
| "cases": literal_interval_cases, | |
| }, | |
| "literal_boundary_states": { | |
| "N_range_inclusive": [2, 40], | |
| "states_per_N": "empty and {1,...,N}", | |
| "cases": literal_boundary_cases, | |
| }, | |
| "N13_nonmonotonicity": n13, | |
| "literal_tensor_cases": tensor_rows, | |
| "asynchronous_terminal_histories": asynchronous, | |
| "scope": ( | |
| "Finite instances and implementation consistency only. These checks " | |
| "do not establish universal theorems, priority, general nonmonomial " | |
| "behavior, perturbation robustness, or computational usefulness." | |
| ), | |
| } | |
| print(json.dumps(result, indent=2)) | |
| if __name__ == "__main__": | |
| main() | |