From ee81d7e993025b62983ac3def76991af1a58eb01 Mon Sep 17 00:00:00 2001 From: apoursh <8867770+apoursh@users.noreply.github.com> Date: Thu, 12 Nov 2026 14:29:51 -0500 Subject: [PATCH] Resolve cubic repair at arity 24 with three dyadic queries --- .../cubic-r24-general-frame/CERTIFICATE.json | 15 ++ research/cubic-r24-general-frame/PROOF.md | 170 ++++++++++++++++++ research/cubic-r24-general-frame/README.md | 115 ++++++++++++ research/cubic-r24-general-frame/SOURCES.json | 36 ++++ research/cubic-r24-general-frame/TASK.json | 102 +++++++++++ research/cubic-r24-general-frame/VERIFY.json | 63 +++++++ .../independent_check.py | 166 +++++++++++++++++ research/cubic-r24-general-frame/verify.py | 157 ++++++++++++++++ 8 files changed, 824 insertions(+) create mode 100644 research/cubic-r24-general-frame/CERTIFICATE.json create mode 100644 research/cubic-r24-general-frame/PROOF.md create mode 100644 research/cubic-r24-general-frame/README.md create mode 100644 research/cubic-r24-general-frame/SOURCES.json create mode 100644 research/cubic-r24-general-frame/TASK.json create mode 100644 research/cubic-r24-general-frame/VERIFY.json create mode 100644 research/cubic-r24-general-frame/independent_check.py create mode 100644 research/cubic-r24-general-frame/verify.py diff --git a/research/cubic-r24-general-frame/CERTIFICATE.json b/research/cubic-r24-general-frame/CERTIFICATE.json new file mode 100644 index 0000000000..415005f52a --- /dev/null +++ b/research/cubic-r24-general-frame/CERTIFICATE.json @@ -0,0 +1,15 @@ +{ + "arity": 24, + "forms": [[11, 19], [1, 9], [1, 25]], + "defect_weights": ["-23/1024", "1679/64", "3749/1024"], + "repair": [ + ["shear", "a", "1"], + ["query", "a", "-3749/1024"], + ["shear", "b", "-11/256"], + ["query", "b", "-376832"], + ["shear", "b", "11/256"], + ["shear", "a", "-16"], + ["query", "a", "-1679/64"], + ["shear", "a", "-9"] + ] +} diff --git a/research/cubic-r24-general-frame/PROOF.md b/research/cubic-r24-general-frame/PROOF.md new file mode 100644 index 0000000000..ab9deb77e4 --- /dev/null +++ b/research/cubic-r24-general-frame/PROOF.md @@ -0,0 +1,170 @@ +# Optimal three-query dyadic repair at arity 24 + +Prepared by apoursh with substantial OpenAI Codex assistance. Apache-2.0. +The fixed reader and rational two-query comparison are due to Nick Petalas +(PR6200); the general-frame dyadic contract is apoursh's PR6212. This answers +the r=24 case of Nick Petalas's PR6653, Open next question 1. + +## Contract + +Work in R=Z[1/2], with arbitrary distinct incoming streams (Y,A,B) in the +exact-arithmetic contract of PR6212. Retain all 24 children, in order: + +``` +y += a^3 +a += b +``` + +The eager comparator undoes the source shift after each child and ends at +(Y+24A^3,A,B). The deferred endpoint is +(Y+sum_{i=0}^{23}(A+iB)^3,A+24B,B). Only appended, input-independent dyadic +linear source changes and signed weighted cube queries are allowed. There +is no output feedback, intermediate observation, child-interior access, +nonlinear source change, output recoding or borrowed clean state. Reading +either named source a or b is allowed and separately priced. Every source +change below is an elementary shear in SL2(R). + +**Theorem.** The exact minimum number of appended weighted cube queries at +r=24 is three. An attaining program uses five source shears, no scratch +registers, and restores both arbitrary incoming sources. Five is an upper +bound on shear count, not a shear-minimality claim. No physical cost saving +or new multiplication exponent is asserted. + +## Exact identity + +The output defect is + +``` +D24 = sum_{i=0}^{23}(A+iB)^3 - 24A^3 + = 828 A^2 B + 12972 A B^2 + 76176 B^3. +``` + +Here S1=276, S2=4324 and S3=76176=276^2. The new certificate is + +``` +D24 = -(23/1024)(11A+19B)^3 + +(1679/64)(A+9B)^3 + +(3749/1024)(A+25B)^3. (1) +``` + +Multiplying by 1024 gives an integer coefficient check: + +| Monomial | -23(11A+19B)^3 | 26864(A+9B)^3 | 3749(A+25B)^3 | Sum | +|---|---:|---:|---:|---:| +| A^3 | -30613 | 26864 | 3749 | 0 | +| A^2 B | -158631 | 725328 | 281175 | 847872 | +| A B^2 | -273999 | 6527952 | 7029375 | 13283328 | +| B^3 | -157757 | 19583856 | 58578125 | 78004224 | + +The last column is 1024 times the coefficient vector of D24. Thus (1) is +a polynomial identity, rather than a conclusion inferred from sample inputs. + +The discovery uses PR6653's node condition +`e2(c)=((2r-1)/3)e1(c)-r(r-1)/2`. Taking c1=19/11 and c2=9 gives c3=25; +solving the coefficient equations and unnormalizing the first form gives +(1). The slope 19/11 is not dyadic, but the actual form 11A+19B and its +weight are dyadic. A projective slope is a ratio of row entries and need not +belong to R. This is the general-frame possibility excluded from PR6653's +integer-direction search, not a contradiction to that finite search. We do +not prove that every r=24 certificate must use a nonmonic form. + +## Literal repair and dirty restoration + +Starting from the actual deferred endpoint, append exactly: + +``` +a += b +y -= (3749/1024)*a^3 +b -= (11/256)*a +y -= 376832*b^3 +b += (11/256)*a +a -= 16*b +y -= (1679/64)*a^3 +a -= 9*b +``` + +After the first shear a=A+25B. The next source change gives + +``` +b = B - (11/256)(A+25B) = -(11A+19B)/256. +``` + +Since `376832 = 23*256^3/1024`, the middle query adds +`+(23/1024)(11A+19B)^3`. The following shear restores b=B exactly while +a stays A+25B. The last two source shifts visit A+9B and then A. +Consequently the three queries subtract (1), and the final endpoint is +(Y+24A^3,A,B) for arbitrary dirty Y,A,B. In particular, b is restored before +its use in the final a shifts. No copy or initialization of either source +is needed. Each event is invertible by reversing its sign; no query writes +its source and no shear reads its own target in the added expression. + +The nonmonic query is reached by an explicit legal frame, so primitive-row +completion or division by 11 is unnecessary. At that query the source matrix is + +``` +[ 1 25 ] +[ -11/256 -19/256 ], +``` + +with determinant (-19+275)/256=1. All other source frames are also products +of the displayed determinant-one dyadic shears. + +## Three queries are necessary + +The following specializes the rational comparison from PR6200/PR6212, and +makes the r=24 lower bound self-contained. Any appended program with at most +two queries represents D24 by at most two rational weighted cubes, after +negating the query weights. General source frames merely change their two +linear forms; this argument allows all such forms, even ones not realizable +by a source frame. + +A single cube cannot have zero A^3 coefficient but nonzero A^2 B coefficient. +Discard zero-weight terms; a single term was already excluded. With two +nonzero weights, both A coefficients must be nonzero: otherwise A^3 +cancellation forces both A coefficients to vanish, contradicting A^2 B. +Normalize over Q. Cancellation of A^3 then gives + +``` +D24 = lambda*((A+tB)^3 - (A+sB)^3), +lambda*(t-s)=276, t+s=4324/276=47/3, +t^2+t*s+s^2=76176/276=276. +``` + +The first equality forces t!=s. The last two give + +``` +(t-s)^2 = 4*276 - 3*(47/3)^2 = 1103/3. +``` + +This reduced fraction has denominator 3. A rational square in lowest terms +has a square denominator, so no rational t,s exist. Two rational queries are +therefore impossible, and in particular two dyadic queries are impossible. +Together with the explicit program this proves the exact minimum three. + +## Complete event boundary and unpaid obligations + +Let `La_k` price a shear a+=k*b, `Lb_k` a shear b+=k*a, and `Qa_k`, `Qb_k` +a weighted cube query into y on the named source. Each price must include +its actual coefficient, source access, private restoration and return under +one matched backend. The complete appended event inventory is + +``` +I24 = La_1 + Qa_(-3749/1024) + Lb_(-11/256) + Qb_(-376832) + + Lb_(11/256) + La_(-16) + Qa_(-1679/64) + La_(-9). +``` + +The eager event bill is `24 Qa_1 + 24 La_1 + 24 La_(-1)`. The deferred bill +retains `24 Qa_1 + 24 La_1` and adds I24. Thus, after establishing matched +prices for the common events, a saving would require + +``` +I24 + Omega_deferred - Omega_eager < 24 La_(-1), +``` + +where the Omega terms include any remaining caller, routing, precision, +storage, dispatch or controller overhead not already included in the event +prices. These terms and the physical event prices are unknown, not zero. +In particular, the large middle weight and the query on b must be priced; +a backend exposing only a cannot treat that read as free. This is a local +coefficient/restoration result and a complete symbolic event inventory, +not a priced supplier, an asymptotic improvement or a selected-frontier change. diff --git a/research/cubic-r24-general-frame/README.md b/research/cubic-r24-general-frame/README.md new file mode 100644 index 0000000000..790f86324c --- /dev/null +++ b/research/cubic-r24-general-frame/README.md @@ -0,0 +1,115 @@ +# Arity 24 has an optimal three-query dyadic repair + +**Scoped exact result; no new κ.** Prepared by apoursh with substantial +OpenAI Codex assistance. Apache-2.0. + +This resolves the r=24 case in Open next question 1 of Nick Petalas's +[PR6653](https://github.com/CrocSwap/integer-mult-bounds/pull/6653). +Its bounded integer-direction search left this arity open. A nonmonic +source form supplies a three-query repair with dyadic coefficients: + +``` +D24 = -(23/1024)(11A+19B)^3 + +(1679/64)(A+9B)^3 + +(3749/1024)(A+25B)^3. +``` + +Here D24 is the excess output of the 24 retained children `y += a^3; a += b` +over the eager endpoint `Y+24A^3`. The [proof](PROOF.md) supplies a legal +three-query, five-shear repair that restores both arbitrary dirty sources, +and proves that two queries are impossible even over Q. Thus **three is +the exact query minimum** in the dyadic general-frame contract. + +The direction 19/11 is not dyadic, although its actual source row and weight +are. This addresses the general-frame gap in PR6653 rather than just enlarging +its integer search box. It does not prove that monic repairs at r=24 are +impossible. No source snapshot, clean scratch or access to child interiors +is used; reading b is allowed and separately charged in the inherited model. +The five shears are an explicit upper bound, not an optimality claim. + +## Evidence and replay + +From the repository root, using CPython 3.12 and only the standard library: + +```sh +python3.12 -B scripts/research_package.py --package research/cubic-r24-general-frame +python3.12 -I -W error -B research/cubic-r24-general-frame/verify.py +python3.12 -I -W error -B research/cubic-r24-general-frame/independent_check.py +``` + +The registered replay runs both implementations normally and with `-O`. +Explicit checks remain active in optimized Python. + +- [CERTIFICATE.json](CERTIFICATE.json) records the three forms, exact weights + and complete eight-event repair. +- [verify.py](verify.py) obtains weights by exact elimination, reconstructs + the target from all 24 literal children, and symbolically checks every + source frame, the arbitrary-input endpoint and the named-source event bill. + It authenticates the three live source files and rejects their in-memory + mutations, plus ten program/domain controls. +- [independent_check.py](independent_check.py) imports neither the certificate + nor the primary verifier. It directly expands the identity, independently + replays the symbolic and literal programs, tests 12 dirty rational inputs, + and rejects eight coefficient, chronology and restoration mutations. +- The written proof, not the finite dirty-input checks, supplies the universal + identity and rational lower bound. Independent implementation by another + Codex agent is not independent human or proof-kernel review. + +The discovery searched primitive rational slopes b/a with 1<=a<=16 and +|b|<=96, deriving a third slope via PR6653's node equation. Acceptance here +replays only the resulting exact certificate; it does not depend on search +completeness. No negative claim about other arities follows from that search. + +## Scope, coordination and next questions + +[TASK.json](TASK.json) preserves the original contextual card and declares +this as a changed-scope coefficient/restoration side result. The family +decision is **narrow**: stop at this missing r=24 implication. The proof lists +all retained and appended events; physical event prices, precision, storage, +routing and the complete matched caller bill remain unknown. Three queries +need not be cheaper than 24 eager restoration shears. The selected result +and its five framework assumptions are unchanged. + +Upstream was pulled from canonical main at +`e54523517d0f03e58352e647c403a5af3e525a57`. Source-bound baseline orientation +passed; this was not a selected-supplier cold replay. Live all-state PR +searches on 2026-11-12 found no r=24 follow-up to PR6653 (queries included +`cubic 24`, `cubic nonmonic`, `cubic general frames`, and `1679 3749`). +The dedicated overlap helper's remote corpora were unavailable because `gh` +was absent; cached Discussion pages did not establish complete current +coverage. No public advance claim was posted. These are overlap checks, +not a global novelty certificate. + +### Open next questions + +1. **Remaining arities:** do r=15,22,30,31 admit three dyadic queries in + general frames? Start from primitive integer source rows and the exact + node equation; normalized rational slopes must not be required dyadic. + The blocker is global coefficient integrality; a finite failed search + supplies no four-query lower bound. +2. **Physical price at r=24:** does the complete eight-event repair beat + eager restoration under one pinned backend? Start by pricing the query + on the temporary b row with weight -376832 and the two dyadic b shears, + using the exact inequality in PROOF.md. Coefficient preparation, routing, + precision, storage and caller overhead remain unpriced. + +These questions and concrete first steps are also recorded in TASK.json. + +## Attribution and source binding + +Nick Petalas supplies PR6200's reader/defect/rational comparison and PR6653's +node equation and open r=24 question. apoursh's +[PR6212](https://github.com/CrocSwap/integer-mult-bounds/pull/6212) supplies +the dyadic general-frame contract and unrestricted query floor; the r=24 +specialization is reproduced in the proof. The earlier original-B, +power-of-two and equal-step families retain apoursh/PR6215, +AAAmirinu/PR6246 and CubeJerry/PR6250's credit. Their inclusion in PR6653's +prior-coverage list is not claimed as new work here. + +[SOURCES.json](SOURCES.json) binds the exact main-tree predecessor bytes, +original catalogue and selected record. The PR6653 source head is +`3ea9965e13457fdafc70b784305d026ebfa8faa2`, retained by merge +`2273ea7c7c83d7bc311d0c5805e832eed13f408b`; replay pins the retained files +at the package base. No predecessor or shared infrastructure file is changed. +Classical binary-form decomposition and exact elimination are not claimed +as new general methods. diff --git a/research/cubic-r24-general-frame/SOURCES.json b/research/cubic-r24-general-frame/SOURCES.json new file mode 100644 index 0000000000..050daf76e7 --- /dev/null +++ b/research/cubic-r24-general-frame/SOURCES.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/cubic-three-query-arities/CERTIFICATES.json", + "usage": "input", + "git_blob": "ae72c7ef712704e4915e396facea262a256707ff", + "sha256": "b4839a5cfff2f69d902622a06d271842a079e953f534fb4c7dbc2b152589aef9" + }, + { + "path": "research/cubic-three-query-arities/README.md", + "usage": "input", + "git_blob": "80c3a43f12e0ad4d586ed69eb3c8278cb60475e2", + "sha256": "d6f818ad69170fde178582595d3b5aa3e5ea1e6e4fde9d8e866f185aa2de5b55" + }, + { + "path": "research/dyadic-cubic-repair/PROOF.md", + "usage": "input", + "git_blob": "a1c41a9afc83302f8b664bb45467821b9c088f0f", + "sha256": "1296f12278e198b6a22d8d88355cd58c1ee4fc2ab0e6941721614bb06cb1e7d5" + } + ] +} diff --git a/research/cubic-r24-general-frame/TASK.json b/research/cubic-r24-general-frame/TASK.json new file mode 100644 index 0000000000..e18d639052 --- /dev/null +++ b/research/cubic-r24-general-frame/TASK.json @@ -0,0 +1,102 @@ +{ + "schema_version": 1, + "task_id": "joint-query-controller", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "original_card": { + "id": "joint-query-controller", + "question": "Can a changed query demand or caller remove real work while satisfying native chronology and restoration?", + "starting_points": [ + "docs/research/current-priorities.md", + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md" + ], + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "acceptance_gate": "A source-bound arbitrary-input identity and legal producer/consumer boundary with the complete paid and productive target invoice, including restoration, ownership, native alignment and extra charges. Price under the actual current model; historical ceiling.py assumptions must be established before use. A favorable optimistic relaxation keeps a route open but is not a completed supplier. A scoped local result remains useful; expansion requires the family-level budget gate.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "first_experiment": "Choose an exact caller and a new demand/interface hypothesis. Read the scoped #5617/#5631/#5649/#5747 and #5720/#5745 objections before rebuilding an excluded schedule. Compare the complete matched source/consumer protocols including all retained helper outputs. For an active-mode injection, first check #5745: its canonical delivery claim repays the eight removed centre jobs. Audit that exact claim or change its channel/feedback hypothesis; do not repeat the same free-injection search. Stop if the full favorable budget fails or the required restored output is unobservable.", + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "overlap_terms": [ + "query demand", + "active mode", + "5720", + "5745", + "5747", + "caller" + ], + "existing_checks": [ + { + "scope": "PR #4166: author-checked installed producer/service/return/bridge connection; native-component comparison loses.", + "evidence": "research/qq16-caller-install/README.md", + "remaining": "Complete matched physical protocol bill, or changed source-compatible demand/circuit; no affordable supplier yet.", + "status": "author-checked", + "source_commit": "0b082d22a0e9a442d264ab0633e35ef26c790630", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "status": "reviewed", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + } + ] + }, + "scope_status": "changed", + "actual_scope": "Resolve r=24 in PR6653 Open next question 1: attain three weighted cube queries over Z[1/2] using general source frames, retain all 24 original children, and restore arbitrary dirty sources.", + "scope_change_reason": "A bounded source-specific coefficient/restoration side question of the joint-query-controller card, not its complete physical supplier acceptance gate. Unlike the preceding fixed-weight Pell family, this permits nonmonic directions and changes both source registers temporarily.", + "bottleneck_link": "Side result: resolves one missing three-versus-four query case through a genuinely changed source-frame search. The proof gives the complete symbolic event bill; all physical prices and caller overhead remain unknown.", + "budget_minutes": 60, + "stop_rule": "Stop after one new exact certificate, legal restoring program and independent replay; do not expand into a census or claim physical savings without a matched bill.", + "outcome": "partial", + "evidence": "PROOF.md: exact identity, rational query lower bound, literal schedule and symbolic invoice. CERTIFICATE.json and two independent exact checkers, each run normally and optimized. Source pins and mutation controls.", + "author": "apoursh", + "ai_assistance": "Substantial OpenAI Codex assistance, including separate search, theory audit and independent checker agents; no independent human or formal proof-kernel review claimed.", + "open_questions": [ + { + "question": "Do r=15,22,30,31 admit three dyadic queries with general source frames?", + "why_it_matters": "Would settle further cases explicitly left open by PR6653.", + "first_step": "Search primitive integer source rows using the exact node equation, checking actual weights after unnormalizing; do not require normalized slopes to be dyadic.", + "blocked_by": "Global dyadic coefficient integrality; finite search failure is not an obstruction." + }, + { + "question": "Does the complete r=24 repair reduce physical cost under one pinned backend?", + "why_it_matters": "Three queries and five shears can cost more than the 24 eager restoration shears they replace.", + "first_step": "Price the named-source query of weight -376832 and both dyadic b shears, then evaluate the full inequality in PROOF.md with all remaining overhead.", + "blocked_by": "Unpriced coefficient preparation, routing, precision, storage, dispatch and caller work." + } + ], + "family_decision": { + "decision": "narrow", + "boundary": "Three arbitrary dirty streams; 24 retained children; no intermediate observations or output feedback; both source streams restored; explicit SL2(Z[1/2]) source frames.", + "evidence_status": "author-checked with independent implementation by a second Codex agent", + "obligations": { + "coefficient_identity": "proved", + "rational_two_query_exclusion": "proved", + "three_query_five_shear_schedule": "constructively upper-bounded", + "physical_prices_and_complete_caller_invoice": "unknown" + }, + "stop": "One r24 certificate; no downstream expansion until a concrete price question or different missing implication is named." + } +} diff --git a/research/cubic-r24-general-frame/VERIFY.json b/research/cubic-r24-general-frame/VERIFY.json new file mode 100644 index 0000000000..f00b145e1b --- /dev/null +++ b/research/cubic-r24-general-frame/VERIFY.json @@ -0,0 +1,63 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/cubic-three-query-arities/CERTIFICATES.json", + "research/cubic-three-query-arities/README.md", + "research/dyadic-cubic-repair/PROOF.md" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 60, + "checks": "Exact elimination, source binding, symbolic dirty execution, event bill, rational lower-bound invariant and rejection controls" + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "-O", + "{package}/verify.py" + ], + "timeout_seconds": 60, + "checks": "Exact elimination, source binding, symbolic dirty execution, event bill, rational lower-bound invariant and rejection controls under optimized Python" + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/independent_check.py" + ], + "timeout_seconds": 60, + "checks": "Independent direct expansion, symbolic and literal dirty replay, and rejection controls" + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "-O", + "{package}/independent_check.py" + ], + "timeout_seconds": 60, + "checks": "Independent direct expansion, symbolic and literal dirty replay, and rejection controls under optimized Python" + } + ] +} diff --git a/research/cubic-r24-general-frame/independent_check.py b/research/cubic-r24-general-frame/independent_check.py new file mode 100644 index 0000000000..b12c3d2501 --- /dev/null +++ b/research/cubic-r24-general-frame/independent_check.py @@ -0,0 +1,166 @@ +#!/usr/bin/env python3 +"""Independent exact expansion and literal-program check for the r=24 repair. + +This checker imports neither the primary verifier nor its certificate. Its +hardcoded data are checked by direct polynomial expansion and literal source +updates. It is an independent implementation, not independent human review. +""" + +from fractions import Fraction as F +import json + + +ARITY = 24 +DEFECT_TERMS = ( + (F(-23, 1024), 11, 19), + (F(1679, 64), 1, 9), + (F(3749, 1024), 1, 25), +) + +# A shear adds coefficient times the other source. A query adds coefficient +# times the named source cubed to y. These are the literal appended operations +# after all 24 retained children have run. +PROGRAM = ( + ("shear", "a", F(1)), + ("query", "a", F(-3749, 1024)), + ("shear", "b", F(-11, 256)), + ("query", "b", F(-376832)), + ("shear", "b", F(11, 256)), + ("shear", "a", F(-16)), + ("query", "a", F(-1679, 64)), + ("shear", "a", F(-9)), +) + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def cube(a, b): + """Coefficients of (a*A+b*B)^3 in A^3,A^2*B,A*B^2,B^3 order.""" + return (a**3, 3 * a * a * b, 3 * a * b * b, b**3) + + +def add_scaled(left, right, coefficient): + return tuple(x + coefficient * y for x, y in zip(left, right)) + + +def check_identity(terms=DEFECT_TERMS, arity=ARITY): + expected = (F(-arity), F(0), F(0), F(0)) + for i in range(arity): + expected = add_scaled(expected, cube(F(1), F(i)), F(1)) + actual = (F(0),) * 4 + for weight, a, b in terms: + require(weight != 0, "zero defect weight") + require( + weight.denominator & (weight.denominator - 1) == 0, + "non-dyadic defect weight", + ) + actual = add_scaled(actual, cube(F(a), F(b)), weight) + require(actual == expected, f"defect coefficient mismatch: {actual} != {expected}") + return actual + + +def check_symbolic_program(program=PROGRAM, arity=ARITY): + # The incoming y is a separate untouched additive symbol Y. output tracks + # only the polynomial added to it, so this check applies to every dirty Y. + sources = {"a": (F(1), F(0)), "b": (F(0), F(1))} + output = (F(0),) * 4 + for _ in range(arity): + output = add_scaled(output, cube(*sources["a"]), F(1)) + sources["a"] = add_scaled(sources["a"], sources["b"], F(1)) + for kind, source, coefficient in program: + require(source in sources, "unknown source") + require( + coefficient.denominator & (coefficient.denominator - 1) == 0, + "non-dyadic program coefficient", + ) + if kind == "shear": + other = "b" if source == "a" else "a" + sources[source] = add_scaled(sources[source], sources[other], coefficient) + elif kind == "query": + output = add_scaled(output, cube(*sources[source]), coefficient) + else: + raise ValueError("unknown operation") + require(sources["a"] == (F(1), F(0)), "a not restored") + require(sources["b"] == (F(0), F(1)), "b not restored") + require(output == (F(arity), F(0), F(0), F(0)), "wrong eager output") + + +def run_literal(a, b, y, program=PROGRAM, arity=ARITY): + sources = {"a": F(a), "b": F(b)} + y = F(y) + for _ in range(arity): + y += sources["a"] ** 3 + sources["a"] += sources["b"] + for kind, source, coefficient in program: + if kind == "shear": + other = "b" if source == "a" else "a" + sources[source] += coefficient * sources[other] + elif kind == "query": + y += coefficient * sources[source] ** 3 + else: + raise ValueError("unknown operation") + return sources["a"], sources["b"], y + + +def rejected(label, callback): + try: + callback() + except ValueError: + return label + raise ValueError(f"negative control was accepted: {label}") + + +def replace_operation(index, operation): + return PROGRAM[:index] + (operation,) + PROGRAM[index + 1 :] + + +def run_checks(): + coefficients = check_identity() + check_symbolic_program() + require(sum(kind == "query" for kind, _, _ in PROGRAM) == 3, "query count") + require(sum(kind == "shear" for kind, _, _ in PROGRAM) == 5, "shear count") + # Include dirty sources and output, signs, odd denominators, zero sources, + # and dyadic values. These are corroboration of the polynomial identity. + inputs = ( + (0, 0, 7), (1, 0, -3), (0, 1, 11), (1, 1, 5), + (-2, 3, 7), (5, -4, -19), (F(1, 3), F(2, 5), F(-7, 11)), + (F(-13, 7), F(17, 9), F(23, 5)), + (F(7, 8), F(-9, 16), F(11, 32)), + (F(101, 13), F(5, 17), F(-29, 19)), + (F(-2, 3), 0, F(5, 7)), (0, F(-7, 5), F(-1, 3)), + ) + for a, b, y in inputs: + expected = (F(a), F(b), F(y) + ARITY * F(a) ** 3) + require(run_literal(a, b, y) == expected, f"dirty input failed: {(a, b, y)}") + + monic = ((F(-23, 1024), 1, 19),) + DEFECT_TERMS[1:] + perturbed = replace_operation(3, ("query", "b", F(-376831))) + wrong_sign = replace_operation(3, ("query", "b", F(376832))) + wrong_order = (PROGRAM[1], PROGRAM[0]) + PROGRAM[2:] + controls = [ + rejected("nonmonic form replaced by monic", lambda: check_identity(monic)), + rejected("omitted final a restoration", lambda: check_symbolic_program(PROGRAM[:-1])), + rejected("omitted b restoration", lambda: check_symbolic_program(PROGRAM[:4] + PROGRAM[5:])), + rejected("perturbed query weight", lambda: check_symbolic_program(perturbed)), + rejected("wrong query sign", lambda: check_symbolic_program(wrong_sign)), + rejected("query before its source shear", lambda: check_symbolic_program(wrong_order)), + rejected("wrong retained arity", lambda: check_symbolic_program(arity=23)), + rejected("omitted b query", lambda: check_symbolic_program(PROGRAM[:3] + PROGRAM[4:])), + ] + return { + "status": "pass", + "arity": ARITY, + "defect_coefficients": [str(value) for value in coefficients], + "cube_queries": 3, + "source_shears": 5, + "symbolic_dirty_restoration": "pass", + "dirty_rational_inputs": len(inputs), + "rejected_controls": controls, + } + + +if __name__ == "__main__": + print(json.dumps(run_checks(), indent=2)) diff --git a/research/cubic-r24-general-frame/verify.py b/research/cubic-r24-general-frame/verify.py new file mode 100644 index 0000000000..b206349705 --- /dev/null +++ b/research/cubic-r24-general-frame/verify.py @@ -0,0 +1,157 @@ +"""Exact symbolic replay of the r=24 general-frame repair. + +apoursh, with substantial OpenAI Codex assistance. Apache-2.0. +Standard library only; explicit checks remain active under Python -O. +""" +from copy import deepcopy +from fractions import Fraction as F +from hashlib import sha256 +import json +from math import isqrt +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parent.parent + + +def require(ok, message): + if not ok: + raise ValueError(message) + + +def dyadic(q): + return q.denominator & (q.denominator - 1) == 0 + + +def cube(row): + a, b = row + return [a**3, 3*a*a*b, 3*a*b*b, b**3] + + +def solve_weights(forms, target): + """Exact elimination; no predecessor weight formula is used.""" + columns = [cube([F(x) for x in row]) for row in forms] + matrix = [[columns[j][i] for j in range(3)] + [F(target[i])] + for i in range(3)] + for j in range(3): + pivot = next(i for i in range(j, 3) if matrix[i][j]) + matrix[j], matrix[pivot] = matrix[pivot], matrix[j] + scale = matrix[j][j] + matrix[j] = [x / scale for x in matrix[j]] + for i in range(3): + if i != j: + scale = matrix[i][j] + matrix[i] = [x - scale*y for x, y in zip(matrix[i], matrix[j])] + weights = [row[-1] for row in matrix] + require(sum(weights[j]*columns[j][3] for j in range(3)) == target[3], + "unmatched B^3 coefficient") + return weights + + +def replay(r, program): + """Exact polynomial output increment and source matrix after every event.""" + rows = [[F(1), F(0)], [F(0), F(1)]] + output = [F(0)] * 4 + for _ in range(r): + output = [x+y for x, y in zip(output, cube(rows[0]))] + rows[0] = [x+y for x, y in zip(rows[0], rows[1])] + trace, queries, shears = [], [], [] + for op, source, raw in program: + require(source in ("a", "b"), "unknown source") + i = 0 if source == "a" else 1 + k = F(raw) + require(k != 0 and dyadic(k), "nonzero dyadic event required") + if op == "shear": + rows[i] = [x+k*y for x, y in zip(rows[i], rows[1-i])] + shears.append((source, k)) + elif op == "query": + output = [x+k*y for x, y in zip(output, cube(rows[i]))] + queries.append((source, k, rows[i][:])) + else: + raise ValueError("unknown operation") + require(rows[0][0]*rows[1][1]-rows[0][1]*rows[1][0] == 1, + "source frame is not determinant one") + require(all(dyadic(x) for row in rows for x in row), "illegal source row") + trace.append(deepcopy(rows)) + return output, rows, trace, queries, shears + + +def endpoint_ok(r, program): + output, rows, *_ = replay(r, program) + return output == [r, 0, 0, 0] and rows == [[1, 0], [0, 1]] + + +def source_inputs_ok(blobs): + pins = json.loads((HERE / "SOURCES.json").read_text())["files"] + return all(sha256(blobs[row["path"]]).hexdigest() == row["sha256"] + for row in pins if row["usage"] == "input") + + +def main(): + pins = json.loads((HERE / "SOURCES.json").read_text())["files"] + blobs = {row["path"]: (ROOT / row["path"]).read_bytes() + for row in pins if row["usage"] == "input"} + require(source_inputs_ok(blobs), "live source bytes differ from pins") + for path in blobs: + changed = dict(blobs); changed[path] += b"\n" + require(not source_inputs_ok(changed), "source mutation accepted") + old = json.loads(blobs["research/cubic-three-query-arities/CERTIFICATES.json"]) + require(24 in old["no_certificate_in_box"], "source does not leave r24 open") + require(all(c["r"] != 24 for c in old["certificates"]), "source already has r24") + cert = json.loads((HERE / "CERTIFICATE.json").read_text()) + r = cert["arity"] + require(r == 24, "this certificate is scoped to arity 24") + target = [sum(cube((1, i))[j] for i in range(r)) for j in range(4)] + target[0] -= r + require(target == [0, 828, 12972, 76176], "defect anchor") + weights = solve_weights(cert["forms"], target) + require(weights == [F(x) for x in cert["defect_weights"]], "wrong weights") + require(all(w and dyadic(w) for w in weights), "illegal defect coefficient") + alpha, beta = cert["forms"][0] + require(F(beta, alpha) == F(19, 11) and not dyadic(F(beta, alpha)), + "nonmonic direction distinction") + # Reconstruct node 3 from discovery seeds via PR6653's node equation. + x, y, m, s1 = F(19, 11), F(9), F(47, 3), F(276) + require((m*(x+y)-s1-x*y)/(x+y-m) == 25, "third-node derivation") + program = cert["repair"] + output, rows, trace, queries, shears = replay(r, program) + require(output == [24, 0, 0, 0] and rows == [[1, 0], [0, 1]], + "symbolic arbitrary-input endpoint") + require(len(queries) == 3 and len(shears) == 5, "event inventory") + require(trace[4] == [[1, 25], [0, 1]], "dirty b restoration before reuse") + require(queries == [("a", F(-3749, 1024), [1, 25]), + ("b", F(-376832), [F(-11, 256), F(-19, 256)]), + ("a", F(-1679, 64), [1, 9])], "named-source query bill") + require(shears == [("a", F(1)), ("b", F(-11, 256)), + ("b", F(11, 256)), ("a", F(-16)), ("a", F(-9))], + "complete shear bill") + delta = 4*F(276)-3*F(47, 3)**2 + require(delta == F(1103, 3), "two-query invariant") + require(isqrt(delta.denominator)**2 != delta.denominator, "square denominator") + mutants = {} + p = deepcopy(program); p[3][2] = "376832"; mutants["middle sign"] = p + p = deepcopy(program); p[1][2] = "-3748/1024"; mutants["wrong weight"] = p + p = deepcopy(program); del p[4]; mutants["lost dirty b"] = p + p = deepcopy(program); del p[-1]; mutants["unrestored a"] = p + p = deepcopy(program); p[2], p[3] = p[3], p[2]; mutants["premature query"] = p + p = deepcopy(program); p[3][1] = "a"; mutants["wrong named source"] = p + p = deepcopy(program); del p[6]; mutants["omitted query"] = p + p = deepcopy(program); p[2][2] = "-11/128"; mutants["wrong frame"] = p + for name, mutant in mutants.items(): + require(not endpoint_ok(r, mutant), "accepted mutation: " + name) + require(not endpoint_ok(23, program), "wrong arity accepted") + bad = deepcopy(program); bad[2][2] = "-11/255" + try: + replay(r, bad) + except ValueError: + pass + else: + raise ValueError("non-dyadic event accepted") + print("PASS source pins and 3 source mutations; exact coefficient elimination") + print("PASS symbolic dirty endpoint, 3 queries / 5 shears, rational lower-bound invariant") + print("PASS 10 program/domain rejection controls") + print("PASS_CUBIC_R24_GENERAL_FRAME") + + +if __name__ == "__main__": + main()