From 4fc107afcb3e73fdb4fb6acebfff6e183f924a8b Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 16 Nov 2026 13:24:18 +0800 Subject: [PATCH 01/15] NOR-21 preregistration: fixed degree512/1024, 36 new public sources, adversarial counterfactuals and resource thresholds --- research/nor21_degree_scaling/README.md | 49 +++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 research/nor21_degree_scaling/README.md diff --git a/research/nor21_degree_scaling/README.md b/research/nor21_degree_scaling/README.md new file mode 100644 index 000000000..f6071c564 --- /dev/null +++ b/research/nor21_degree_scaling/README.md @@ -0,0 +1,49 @@ +# NOR-21: degree-512/1024 exact public-verifier scaling and out-of-grammar failures + +**Preregistered 16 November 2026, before generating fresh NOR-21 cases or opening test grades.** Continues [NOR-19 #181](https://github.com/MoralityLabAI/Compactification-Theory/pull/181) and [NOR-20 #183](https://github.com/MoralityLabAI/Compactification-Theory/pull/183), with exact coefficient-streamed semantic equivalence from [MathCan #101](https://github.com/patrickdugan/MathCan/pull/101). + +## Questions + +1. Does the exact four-unary cached **coefficient-streaming** verifier remain faster and lower in Python temporary allocation than native sixteen-template checking and eager cached sixteen-template checking at **512 and 1,024 public coefficients**? +2. Does public-program certification respond correctly when the true task is outside its complete sixteen-program family? There are two different failures: a **publicly inconsistent demonstration**, which a full public mask should reject; and a **hidden future override**, where all public observations admit a generated program but the withheld future target disagrees. The latter is an indistinguishability counterexample to unconditional future correctness, not a failure of the family-conditional theorem. + +The original finite RRC25 grammar is frozen: four unary operators I/N/R/S, delays 64/80/96/112, spacings 24/32, amplitudes ±1/±2, and all sixteen ordered U/V candidate pairs. We change only the number of public coefficients and the source-generating distribution. The original 192-degree RRC25 native checker is **not** used as an oracle for larger degrees, because it deliberately truncates to degree 192. Every proposed scaled checker implements the original exact interpreter semantics at its registered degree. + +## Frozen source and evaluation grid + +- Public demonstration degrees: **512 and 1024**, inclusive, with exactly two input/output demonstrations per source. +- Public query INPUT degrees: **768 and 1536**, respectively. Withheld query OUTPUT is inaccessible to every verifier and every input fixture. +- Source families: **wide_dense_small**, with nonzero coefficients uniformly sampled from ±{1,2}; **wide_sparse_small**, coefficients sampled from ±{1,2} with 0.12 probability and exact zeros otherwise; **wide_rational_short**, reciprocal of a normalized polynomial with nonzero coefficient ±1 at degree 1 and three additional ±1/±2 coefficients at random degrees 2–12. Even small polynomial coefficients can produce much wider reciprocal-series coefficients; report actual observed widths. +- Cases: **two independent replicate cohorts** indexed r=0,1. For each degree and family in each cohort, generate **three independent source cases**, one of each registered case kind: in_grammar, public_corrupt, future_shift. Total **36 cases**, comprising **18 cases at each degree**, 12 in-scope truthful cases, 12 public-visible corruptions and 12 hidden-future overrides across all degrees. Each case has its own source seed and complete-public input hash. No two cases may share a complete-public input hash, including future-shift cases, to avoid treating public twins as independent timing observations. +- Source seeds: corpus.SEED + **94210000** + 1,000,003*r + 100,009*(0 for degree512 else 1) + 10,007*family_index + 331*casekind_index. Draw a deterministic six-field original grammar program and three fresh normalized sources. Select the first candidate with one public header, exact complete original-program membership and a **unique public-query hypothetical output among all publicly accepted templates** for each *in_grammar* and *future_shift* source. For public_corrupt, alter the second demo's final observed degree coefficient by +1 and require the exact sixteen-template public mask to be empty. Skip unsuitable programs; limit to 80 independent attempts per seed, fail closed on exhaustion. These are predeclared source-filter conditions, not posthoc future-outcome tuning. +- The source generator may know the planted true program to generate cases, but must serialize **only public demonstrations, public query INPUT, the public header, kind and source seed/attempt, and exact public-native accepted mask/unanimity** to the benchmark fixture. The planted program and hidden target never enter the fixture. Source selection may use only full public-demo compatibility and public-query hypothetical candidate predictions. +- Evaluation creates a separate sealed native-generator oracle only **after all public policies have frozen their choices**. For future_shift, the sealed target equals the valid generating program's true future output with its degree-query final coefficient incremented by 1. That produces a valid-world counterfactual with exactly the same complete public observations as the shifted world and a different target. Record the public-input digest identity of the two possible worlds, without exposing private future arrays. For public_corrupt, the public mask must be empty and the verifier must abstain. + +This study introduces a fresh source-generating distribution. Its synthetic cases are excluded by new disjoint seed ranges from NOR11–20 and have explicit source hash uniqueness checks, but source-distribution independence alone is not proof of generality to an external theorem prover. + +## Fixed public comparison algorithms + +Every mode separately computes all sixteen candidate predicted query outputs using four shared exact public unary transforms and separately verifies all sixteen candidate templates against both demonstrations at full registered degree. All return the identical original native 16-bit acceptance mask, output-unanimity predicate, and chosen candidate or abstention decision. A full public mask of zero **must produce an abstention** rather than a Python assertion. + +- native16: independently execute each public program via the original RRC25 exact execute implementation applied to sources truncated at the **registered degree**. +- cached16: evaluate four unary transforms per demo and materialize sixteen full candidate outputs at once, using the same finite-series exact formula. +- stream16: four unary transforms per demo, compare candidate predictions coefficient by coefficient with early mismatch exit; at most one demo's unary maps remain live and no full candidate output tuples are materialized. +- chunk4: construct at most four candidate outputs at once, release them after comparing, then proceed. + +All four modes use the same query-first order for this comparison, so the changing candidate-buffer strategy is isolated from query/verification execution order. Query continuation simulation is charged to all modes. The experiment also records verifier-only allocation in a separate untimed pass, because query outputs may dominate end-to-end memory. + +## Timing, memory, and resource policy + +Use the hosted Ubuntu 24.04 CPython 3.12 runner. Each mode gets one warmup and **three measured repetitions per case** in a deterministic shuffled order; collect garbage before each and disable GC during measured segments. Record raw query/verification/certificate/total nanosecond times, per-case medians, and isolate Python-traced peak temporary allocation in separate untimed complete- and verifier-only runs. Record sampled subprocess RSS when available but do not infer temporary allocation equality from equal RSS. Actual Python integer bit widths and quadratic reciprocal recurrence product-count/operand-width proxy must be reported separately from time. + +The full scaled native verifier is potentially computationally expensive. Hosted CI fails closed after **60 minutes** for the full benchmark, and never silently lowers sample counts, drops the degree-1024 cohort, or changes seeds. Any resource-driven protocol revision requires a dated amendment **before** new heldout evaluation. + +## Preregistered outcome rules + +1. **Exactness:** all four modes reproduce the same public acceptance mask and the same output-unanimity/abstention choice on all 36 cases at each degree. +2. **Scope:** all twelve in_grammar cases must certify the correct withheld original program future. All twelve public_corrupt cases must show zero accepted public candidates and abstain. All twelve future_shift cases should yield public unanimity and a nominal certificate, while the sealed native future grader marks them wrong. At least one source from each degree must produce this explicit indistinguishability failure. These illustrate the boundary of the generator-membership premise. +3. **Scaling:** at **each** degree independently, median of case-paired native16/stream16 *complete* CPU ratios must be ≥**1.5×**; median of per-case stream16/cached16 complete traced Python peaks must be ≤**0.80**, with lower streaming memory on ≥**14/18 cases**. The streaming-vs-native speedup and full streaming-vs-cached peak ratio must be computed on the same 18 case identities per degree. All cases in each degree have unique public inputs. +4. Report by degree, source family and case kind: median complete and verifier-only time, complete and verifier-only temporary Python allocation, peak observed reciprocal bit width, native and cached exact R invocation counts, and the count of possible out-of-family false acceptances. A deterministic **4096-draw two-cohort blocked bootstrap** yields conditional intervals for the two paired ratios, clearly labeled as only two cohorts. +5. The degree scaling result is a **CPU engineering observation**, not a formal O(n²) native-time theorem. Lean companion work formalizes exact degree-independent public acceptance and the impossibility of unconditional target correctness when two worlds have identical public observations but incompatible future labels. + +The public fixture will be pinned by SHA-256 before being measured, and raw first-run evidence will be source-locked and independently audited. Any failure of degree-1024 runtime, source uniqueness, exactness or the out-of-family controls is recorded as a failure. From 8c91e0991a57e7aebcc7e6e8f14ec793636db7e9 Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 16 Nov 2026 13:26:56 +0800 Subject: [PATCH 02/15] NOR-21: implement public exact 512/1024 coefficient native cached streaming chunk verifiers, sealed target counterfactuals and CPU allocation benchmark --- research/nor21_degree_scaling/experiment.py | 699 ++++++++++++++++++++ 1 file changed, 699 insertions(+) create mode 100644 research/nor21_degree_scaling/experiment.py diff --git a/research/nor21_degree_scaling/experiment.py b/research/nor21_degree_scaling/experiment.py new file mode 100644 index 000000000..64ac5efc1 --- /dev/null +++ b/research/nor21_degree_scaling/experiment.py @@ -0,0 +1,699 @@ +"""NOR-21: exact degree scaling and explicit out-of-family counterfactuals. + +The public fixture contains two degree-512/1024 demonstrations, public +query INPUT of degree-768/1536, and the frozen public header. The private +generating program and hidden query OUTPUT are NEVER part of a public +fixture. Sealed correctness is evaluated separately *after* all policy +choices are frozen. Every policy is an exact finite interpreter. + +Scientific boundaries: + - Publicly corrupted demonstration => all 16 candidate checks fail; + responsible verifier abstains. + - Hidden future override => same complete public data as a valid world, + but different target, so public-only certainty can fail outside the + enumerated generating family even for exact mask unanimity. +""" +from __future__ import annotations + +import argparse +from collections import Counter, defaultdict +from hashlib import sha256 +import gc +import json +import math +import os +from pathlib import Path +import platform +import random +import statistics +import subprocess +import sys +import time +import tracemalloc + +HERE=Path(__file__).resolve().parent +ROOT=HERE.parents[1] +if str(ROOT) not in sys.path: + sys.path.insert(0,str(ROOT)) + +from research.rrc_compactification import compound25 as corpus +from research.nor17_prefix_certificates import experiment as nor17 +from research.nor19_streamed_verifier import benchmark as nor19 +from research.nor18r_runtime import benchmark as nor18r + +SCHEMA="nor21.degree_512_1024_out_of_grammar_cpu_memory.v1" +FIXTURE_SCHEMA="nor21.public_only_source_36_degree512_1024.v1" +DEGREES=(512,1024) +FAMILIES=("wide_dense_small","wide_sparse_small","wide_rational_short") +KINDS=("in_grammar","public_corrupt","future_shift") +MODES=("native16","cached16","stream16","chunk4") +REPLICATES=2 +SAMPLE_COUNT=len(DEGREES)*len(FAMILIES)*len(KINDS)*REPLICATES +SEED_OFFSET=94210000 +WARMUPS=1 +TRIALS=3 +BOOTSTRAPS=4096 +BOOT_SEED=202611210521 +SPEED_THRESHOLD=1.5 +MEMORY_RATIO_THRESHOLD=.80 +MIN_MEMORY_WINS_PER_DEGREE=14 + + +def canonical(x): + return (json.dumps(x,sort_keys=True,indent=2,ensure_ascii=True)+"\n").encode() + + +def random_coeff(rng): + return rng.choice((-2,-1,1,2)) + + +def public_source(rng,family,degree): + if family not in FAMILIES or degree<512: + raise ValueError("unsupported source family or degree") + if family=="wide_dense_small": + return (1,)+tuple(random_coeff(rng) for _ in range(degree)) + if family=="wide_sparse_small": + return (1,)+tuple(random_coeff(rng) if rng.random()<.12 else 0 + for _ in range(degree)) + # Rational-series input generated from a short polynomial. Its actual + # coefficients may be far wider than ±2 source polynomial coefficients. + p=[1]+[0]*degree + p[1]=rng.choice((-1,1)) + for _ in range(3): + p[rng.randint(2,12)]+=random_coeff(rng) + return corpus.d.operate(tuple(p),"R") + + +def seed(rep,degree,family,kind): + if not (0<=rep=degree+1 and degree>=max(corpus.DELAYS) + return nor17.candidate_outputs(src,h,degree) + + +def native_mask(c,h,public_degree): + """Original RRC25 exact execute semantics with explicit degree.""" + bits=0 + for j in range(16): + p=program(h,j) + if all(corpus.execute(src[:public_degree+1],p)== + y[:public_degree+1] for src,y in c.demos): + bits|=1<=k+delta: + value+=amp*u[n-k-delta] + if n>=k+2*delta: + value+=amp*v[n-k-2*delta] + if value!=observed[n]: + mask &= ~(1<