diff --git a/research/p104-double-preconditioned-handoff/CODE-BOUNDS.md b/research/p104-double-preconditioned-handoff/CODE-BOUNDS.md new file mode 100644 index 0000000000..6d6f8b02ff --- /dev/null +++ b/research/p104-double-preconditioned-handoff/CODE-BOUNDS.md @@ -0,0 +1,38 @@ +# Implementation bounds + +This contribution was produced by Nick Petalas. Apache-2.0. + +The executable domain is the two fixed dual pairs, one fixed source word and +one constructed handoff. No discovery search runs during verification. +The two new Python files use structured control flow without recursion. +Boundary programs have at most six events, boundary matrices have at most +five coordinates and inverse checks have at most twelve events. All proof +checks use explicit exceptions and remain enabled with `-O`. + +The complete word is bounded below 26,000 events with 744 formal coordinates, +a fixed source-frame catalogue and eight owned slots. The retained engines +enforce their source-specific operation, coordinate, frame and coefficient +contracts. Boundary controls perform eleven omission checks and two order +checks; whole-word controls perform exactly eight replays. Source inventory +has four entries. Both registered commands have 120-second timeouts. + +Managed Python and `Fraction` allocate during execution. This is a documented +deviation from fixed allocation; the finite dimensions, event counts and +coefficient domain bound the live state. No fixed-memory implementation or +measured peak allocation is claimed. One mutated word is replayed per control; +the finite input sizes also bound temporary copies. + +Authenticated predecessor code is compiled directly from bytes into three +explicit module names. This deliberate dynamic-loading deviation avoids stale +bytecode reads. `completion.py` is loaded the same way. The handoff constructor's +in-memory `basis` function is replaced once with the new explicit program. +The four dependency hashes are checked before any predecessor code executes. +No predecessor file, module source or receipt is changed. Their existing +implementation choices remain source-specific dependencies, not a new claim +of compliance or an unrelated refactoring target. + +Each new function is below 60 physical lines. Strong runtime contracts, +warning-strict normal and optimized execution, source compilation and whitespace +checks cover the touched code. Python's standard library supplies no static +type checker; no additional installed linter or proof kernel is assumed. +Receipts are generated on stdout and include hashes of package and input files. diff --git a/research/p104-double-preconditioned-handoff/PROOF.md b/research/p104-double-preconditioned-handoff/PROOF.md new file mode 100644 index 0000000000..90a3759a1d --- /dev/null +++ b/research/p104-double-preconditioned-handoff/PROOF.md @@ -0,0 +1,135 @@ +# Ordered cancellation in the concrete dual pairs + +This contribution was produced by Nick Petalas. Apache-2.0. +The dual pairs and column-unit formula are CubeJerry's PR6322, extending +unpaidmoon's PR6297 and Ali Romman's PR5611/5602. The new construction below +uses their exact scalar boundary contract. + +## The two noncommuting preconditioners + +Let `p=596`, and let `e_i` be a coordinate column. Work over `Z[1/2]`. +Retain the row and two columns + +``` +a = (5/16)e592^T + (5/16)e593^T + (5/8)e594^T + (3/8)e596^T, +u = -e592 + e593 + e594 + e596, +b = -e188 + u. +``` + +Both pairings `a u` and `a b` are one. These are boundary functionals and +directions, not assumed values of dirty registers. + +Set + +``` +S1 = I + e592 e593^T, +S2 = I + (1/2)e594 e592^T, +S = S2 S1. +``` + +Each shear fixes `e_p` and is invertible by negating its coefficient. +They do not commute: the product of the second nilpotent part with the first +is `(1/2)e594 e593^T`, whereas the reversed product is zero. + +First applying `S1` to either column cancels its 592 coordinate. Consequently +`S2` changes no column coordinate afterward. For `d` equal to `u` or `b`, + +``` +d' = S d = d + e592. +``` + +For the row, `S1^-1` cancels coordinate 593. The next right multiplication +by `S2^-1` cancels coordinate 592, since `(5/16) - (1/2)(5/8) = 0`. +Therefore + +``` +a' = a S^-1 = (5/8)e594^T + (3/8)e596^T. +``` + +The pivot coordinate of `d'` is still one and `a'd'=1`. Apply PR6322's +column-unit formula to get `R'` satisfying `a'R'=e_p^T` and `R'e_p=d'`. +Explicitly its first operation is `x596 -= (5/8)x594`, followed by the +unit injections from 596 to the nonpivot support of `d'`. + +Put `R=S^-1 R'=S1^-1 S2^-1 R'`. Then + +``` +a R = a' R' = e_p^T, +R e_p = S^-1 d' = d. +``` + +Thus the two inverse preconditioners must execute after `R'`, in the +order `S2^-1`, then `S1^-1`. This order is proof-relevant. Every factor is an +invertible coordinate ADD on arbitrary inputs. + +## Literal programs and complete tariff + +The source completion is the following six ADDs at frame 3: + +``` +x596 -= (5/8)x594 +x188 -= x596 +x593 += x596 +x594 += x596 +x594 -= (1/2)x592 +x592 -= x593 +``` + +The cut completion at frame 1053 omits only `x188 -= x596`. +The inverse of either completion reverses the list and negates every +coefficient. No SCALE, spare role, initialized register or new transport is +needed by these completions. + +For a reduced dyadic `c=n/d`, the retained scalar ADD allowance is +`A(c)=2(3+floor(log2|n|)+popcount(|n|)+log2 d)`. Hence + +``` +A(1) = 8, A(1/2) = 10, A(5/8) = 20. +source completion = 20 + 3*8 + 10 + 8 = 62, +cut completion = 20 + 2*8 + 10 + 8 = 54, +all four boundaries = 2*(62+54) = 232. +``` + +Inverse costs are identical because the tariff is insensitive to the sign. +All coefficients and inverse coefficients satisfy the retained +`|c|+1 < 2^16` bound. There are `2*(6+5)=22` ADDs. PR6322 already proves +that count minimal for these separately completed boundary maps, with arbitrary +ancillary roles. Its ADD lower bound is cited, not independently re-proved or +replayed here. No weighted optimum follows from it. + +## Whole-word application and claim boundary + +Use the same historical PR5580 source, cut 13762, pivot 596 and frames +`3 < 1053 < 127` as PR6297/6322. Let `P` and `Q` be its prefix and suffix, +let `W=QP`, and let `R_s`, `R_c` be the new source and cut completions. +The retained constructor checks the exact prefix/suffix equations +`vP=a` and `Qu=b` and the availability of all cut operands before inserting +the new programs. They give + +``` +e_p^T R_c^-1 P R_s = v P R_s = e_p^T, +R_s^-1 Q R_c e_p = R_s^-1 Q u = e_p. +``` + +Retire the original arbitrary pivot input at the cut and continue with a +fresh arbitrary input `z`. The output becomes +`R_s^-1 W R_s x - e_p x_p + e_p z`. +The source basis acts only on the independent `(3,127)` helper group, where +`W` is identity, and commutes with the main shear. Thus this equals +`W x - e_p x_p + e_p z`, with retired output `x_p`. Both input freedoms are +preserved. This is the credited coupled-handoff argument applied to the new +boundary maps, not a new general handoff theorem. + +The new word has 25,162 events, 736 public inputs and eight owned lifetimes +with peak one. Complete scalar allowance is `217428+232=217660`, using the +predecessor's source allowance as a comparison premise; both exact arithmetic +engines freshly enumerate the new word's complete allowance and endpoints. +They check all 744 formal columns and 553,536 coefficients. Paid profile is +`{1:2211,2:459,3:494,4:94,5:164,6:18,7:14}` and productive helper profile is +`{4:84,5:6,8:15,9:423}`, as in the predecessor handoff. + +This proves a legal scalar construction and its finite invoice, without a +new recursive moment, kappa or selected-frontier claim. No weighted optimum, +current-word transfer, native/caller admission, rounded precision/tape bound, +stock or uniform compiler proof is supplied. All five selected framework +assumptions remain. Independent human and formal proof-kernel review are unclaimed. diff --git a/research/p104-double-preconditioned-handoff/README.md b/research/p104-double-preconditioned-handoff/README.md new file mode 100644 index 0000000000..44f952d28b --- /dev/null +++ b/research/p104-double-preconditioned-handoff/README.md @@ -0,0 +1,86 @@ +# A 232-unit nonunit helper handoff + +Two ordered preconditioners reduce the concrete PR6322 handoff to **22 ADDs +and scalar allowance 232**. This saves 40 allowance units against its +26-ADD, 272-unit alternative, and 48 against its 22-ADD, 280-unit construction. +The complete new local word has 25,162 events and allowance 217,660. + +Claim type: scoped algebraic construction with exact finite corroboration. +The 22-ADD count matches the predecessor's proved minimum for four separately +completed boundaries. No weighted optimum or new kappa is claimed. + +The change answers [PR6322](https://github.com/CrocSwap/integer-mult-bounds/pull/6322) +Open next question 2 for its exact historical dual pairs. Its elementary +column-unit formula is a premise. The new step is the ordered pair of +preconditioners, their cheaper explicit completion and its whole-word use. +See [PROOF.md](PROOF.md) and [completion.py](completion.py). + +## Scope and evidence + +The constructor retains 736 independent public inputs, eight owned lifetimes, +peak owned storage one, the rank-9 to rank-5-plus-rank-4 split and the complete +paid profile. Two retained arithmetic engines check the **new** word on all +744 formal columns, including 553,536 endpoint coefficients. One uses rational +sparse rows and the other integer rows with binary denominators. Both are +checks using credited predecessor implementations. + +The verifier checks both boundary equations and their full inverses. It rejects +all eleven single forward-boundary gate omissions, both reversals of the +preconditioner order and eight whole-word coefficient, chart, ownership or +boundary faults. Its computed stdout receipt includes all source and package +hashes plus the deterministic candidate-word hash. It writes no receipt or +word into the checkout. + +[SOURCES.json](SOURCES.json) pins the four live inputs at canonical main +`7c49fe32c55de02c2c873655c804b16e4c3fef0a`. This includes the original PR5580 +word, Ali Romman's handoff constructor and primary scalar checker, and +CubeJerry's second arithmetic implementation. No predecessor scientific suite +is replayed as the deliverable. The bounded discovery search stopped when this +first reduction appeared; no exhaustive search conclusion is asserted. + +The selected record and all five framework assumptions remain unchanged. +This is a historical scalar boundary improvement. Native phase/implementation, +complete physical caller, stock, rounded precision/tape, compiler closure and +outer admission are unrun or inherited. The recursive paid and target profiles +are unchanged, so the scalar saving supplies no exponent gain. There is no +complete multiplication theorem or independent human or proof-kernel review. + +## Reproduce + +From the contribution checkout root, with Python 3.12 and its standard library: + +```sh +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -W error -B research/p104-double-preconditioned-handoff/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -O -W error -B research/p104-double-preconditioned-handoff/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/p104-double-preconditioned-handoff +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/p104-double-preconditioned-handoff --check-source-history --check-modes +``` + +Another CPython 3.12 executable can replace the local interpreter path. +Expected markers are `PASS_P104_ORDERED_HANDOFF inserted_events=22 +inserted_allowance=232`, `PASS_REGISTERED_RESEARCH_PACKAGE` and +`PASS_RESEARCH_COMMIT_BYTES`. Registered normal and optimized commands have +120-second bounds. [CODE-BOUNDS.md](CODE-BOUNDS.md) records implementation limits. + +## Open next questions + +Can allowance fall below 232 under these same boundary equations? A +coefficient-sensitive lower bound, including both inverses, would decide whether +this construction is optimal. The existing ADD-count bound does not do so. + +Does a current source word retain a compatible nonunit handoff? First extract +its exact prefix/suffix pair and available charts. Changed helper boundaries +and the complete native/caller bill block transfer of this historical saving. +Structured questions and the narrowed card scope are in [TASK.json](TASK.json). + +## Credit + +This contribution was produced by Nick Petalas. Apache-2.0. +CubeJerry PR6322 supplies the dual pairs, column-unit construction, ADD-count +minimum, lower-allowance alternative and separate arithmetic checker. +unpaidmoon PR6297 supplies the original concrete nonunit split. Ali Romman +PR5611/5602 supplies dyadic completion and the coupled handoff contract. +The retained source word and checker credit David Arias, Cinna Davis, +Gareth Davidson, Ali Romman and their P104/native/controller predecessors. +Their files and credit lines are unchanged. Elementary shears and the +rank-one handoff identity are classical or credited predecessor work. diff --git a/research/p104-double-preconditioned-handoff/SOURCES.json b/research/p104-double-preconditioned-handoff/SOURCES.json new file mode 100644 index 0000000000..3fa9b1623d --- /dev/null +++ b/research/p104-double-preconditioned-handoff/SOURCES.json @@ -0,0 +1,60 @@ +{ + "schema_version": 1, + "base_commit": "7c49fe32c55de02c2c873655c804b16e4c3fef0a", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a", + "sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/p104-coupled-helper-bases/construct.py", + "usage": "input", + "git_blob": "ef5936ca89d6502d7f6af1ce6903d8500c117401", + "sha256": "2360066b0a1390c60a86d9788ada1504478e7e48bbfe3fcdf27a5563379fc001" + }, + { + "path": "research/p104-coupled-helper-bases/inputs/pr5580-WORD.json.gz", + "usage": "input", + "git_blob": "9434855e7dad0d0236d23210b3e71a2b83a9ae64", + "sha256": "b2a98c4bd0dbe86c09e9d15ee060dcf1aab09dbef90aa1e2127676f4039f406b" + }, + { + "path": "research/p104-coupled-helper-bases/local.py", + "usage": "input", + "git_blob": "9556e86744e18efdd76263a36664830c695f1c0f", + "sha256": "5f0678c768544517780d3511995faf0d7062748e7e780c0adb5c4d9c2749a925" + }, + { + "path": "research/p104-unit-column-handoff/ALTERNATIVE-PROOF.md", + "usage": "provenance", + "git_blob": "c6eeb859855b06137ce3a5e85328ad33f7f54e99", + "sha256": "ee7a4afdefa422e0eaf541e5142022657dcc33b1c7789260d8c5bcd420d1aba6" + }, + { + "path": "research/p104-unit-column-handoff/PROOF.md", + "usage": "provenance", + "git_blob": "ab3c84e294623fae18b82e7812cc54d0d31c546f", + "sha256": "3ed7f534b6e557597529b076ca683a689bf12439338fb5d06f3d27171dad5da7" + }, + { + "path": "research/p104-unit-column-handoff/README.md", + "usage": "provenance", + "git_blob": "cae720d43e04c223dbddc459f8652df5fe6d6467", + "sha256": "4013fecd9229678970fb759a0e14f4467c585801be51ebfbe0f1e1c3b8a712e9" + }, + { + "path": "research/p104-unit-column-handoff/independent.py", + "usage": "input", + "git_blob": "3bc5528b21fa65a51243c3260caebbcfae188fb4", + "sha256": "f7a76321beb92dbd1151e59092b17e2240d7a3037bc6e90f10b8ba2b31ee5b6a" + } + ] +} diff --git a/research/p104-double-preconditioned-handoff/TASK.json b/research/p104-double-preconditioned-handoff/TASK.json new file mode 100644 index 0000000000..4069c6ac66 --- /dev/null +++ b/research/p104-double-preconditioned-handoff/TASK.json @@ -0,0 +1,130 @@ +{ + "schema_version": 1, + "task_id": "p104-side-correction", + "priority_revision": 8, + "base_commit": "7c49fe32c55de02c2c873655c804b16e4c3fef0a", + "original_card": { + "id": "p104-side-correction", + "question": "Can joint helper bases and a legal causal split improve the complete P104 productive/paid invoice?", + "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", + "research/p104-helper-subspace-splits/README.md", + "research/dyadic-helper-channel-capacity/README.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": "An exact arbitrary-input identity, source/target frame availability and restoration at the chosen cut, plus the complete channel+correction+idle/hosting bill or an explicit favorable bound. The native channel alone is not a supplier. A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "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": "Start with the selected #5599 emitted word and review pending #5718 distinct input/output bases plus #5717/#5719 coverage before claiming work. Pick one uncovered source word, helper group and cut region. Prove the arbitrary-input relation and legal entry/exit corrections, then compare full target and paid profiles. Reject if completion, owned lifetimes or consumer costs repay the gain. A static pairing rank alone is not a physical split.", + "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": [ + "P104", + "helper basis", + "helper split", + "5718", + "dyadic capacity" + ], + "existing_checks": [ + { + "scope": "PR #4133: literal-slot defect", + "evidence": "research/p104-literal-slot-defect/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "88666f1dee93fbd85b31fd5d6f91a219e111b5f4", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4136: uniform commutation gap", + "evidence": "research/p104-uniform-commutation-gap/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "281ce601a8be9db470de630759179c23e1dfaa88", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4140: uniform encoding gap", + "evidence": "research/p104-uniform-encoding-gap/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "de25c6525aa866962309df5d107b32d55e6e5628", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4153: source-chart shortcut exhausts its optimistic allowance", + "evidence": "research/p104-source-chart-shortcut/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "9123241fea53df77e51ffe30d9aca1625d4bf3a8", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4154: fiber-tag seam mismatch", + "evidence": "research/p104-fiber-tag-seam/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "4ffcdaee5d6255a9cea1fe53a5424435068089d0", + "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": "Reduce the four-boundary dyadic scalar allowance for the exact historical PR6322 nonunit helper handoff while preserving all arbitrary inputs, geometry and the paid/target profiles.", + "scope_change_reason": "The card concerns a complete P104 supplier. This is a scalar boundary contribution to the explicit PR6322 Open next question 2, with native/caller admission and all framework assumptions left open.", + "bottleneck_link": "Cheaper legal joint basis corrections reduce the ordinary-work bill of a helper target split. This historical local module does not change the recursive moment or selected kappa.", + "budget_minutes": 60, + "stop_rule": "Stop at the first exact lower-allowance construction, check both boundary equations and the complete modified local word, and submit without extending the search.", + "outcome": "completed", + "evidence": "PROOF.md; completion.py; verify.py emits a computed receipt bound to package and source hashes.", + "author": "Nick Petalas", + "ai_assistance": "Independent human and formal proof-kernel review are unclaimed.", + "open_questions": [ + { + "question": "Can the exact four-boundary allowance fall below 232 under the same dual-pair contract?", + "why_it_matters": "The construction matches the cited 22-ADD minimum but has no weighted optimality certificate.", + "first_step": "Derive a lower bound sensitive to coefficient tariffs, retaining both inverse boundary costs.", + "blocked_by": "No complete weighted circuit lower bound is supplied." + }, + { + "question": "Does a current source word retain a compatible nonunit handoff with these dual pairs?", + "why_it_matters": "The historical local gain cannot be transferred silently to newer P104 words.", + "first_step": "Bind one current candidate to its exact prefix/suffix pair, common charts and full caller invoice.", + "blocked_by": "Changed helper boundaries and complete native/caller, precision/tape and compiler obligations." + } + ], + "question_source": { + "pr": 6322, + "author": "CubeJerry", + "question": 2 + }, + "claim_url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19358965", + "playbook": "Autonomous local run" +} diff --git a/research/p104-double-preconditioned-handoff/VERIFY.json b/research/p104-double-preconditioned-handoff/VERIFY.json new file mode 100644 index 0000000000..6d5c296209 --- /dev/null +++ b/research/p104-double-preconditioned-handoff/VERIFY.json @@ -0,0 +1,39 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/p104-coupled-helper-bases/construct.py", + "research/p104-coupled-helper-bases/inputs/pr5580-WORD.json.gz", + "research/p104-coupled-helper-bases/local.py", + "research/p104-unit-column-handoff/independent.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Both exact dirty boundary identities and inverses, complete new local word in two arithmetic representations, full paid/target/scalar invoice, source hashes and omission/order/geometry/ownership controls." + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Both exact dirty boundary identities and inverses, complete new local word in two arithmetic representations, full paid/target/scalar invoice, source hashes and omission/order/geometry/ownership controls." + } + ] +} diff --git a/research/p104-double-preconditioned-handoff/completion.py b/research/p104-double-preconditioned-handoff/completion.py new file mode 100644 index 0000000000..dd5aae5bf0 --- /dev/null +++ b/research/p104-double-preconditioned-handoff/completion.py @@ -0,0 +1,54 @@ +"""Ordered dyadic preconditioners for the concrete helper handoff. + +This contribution was produced by Nick Petalas. Apache-2.0. +CubeJerry PR6322 supplies the dual pairs and column-unit completion; +unpaidmoon PR6297 and Ali Romman PR5602/5611 supply the handoff lineage. +""" +from fractions import Fraction as Q + +V = {592: Q(5, 16), 593: Q(5, 16), 594: Q(5, 8), 596: Q(3, 8)} +U = {592: Q(-1), 593: Q(1), 594: Q(1), 596: Q(1)} +B = {188: Q(-1), **U} + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def basis(a, b, pivot, frame): + """Complete exactly the two credited dual pairs, with arbitrary inputs.""" + require(a == V and pivot == 596, "fixed functional and pivot") + require((b == B and frame == 3) or (b == U and frame == 1053), + "fixed direction and available boundary chart") + events = [["ADD", 596, 594, "-5/8", frame]] + if b == B: + events.append(["ADD", 188, 596, "-1", frame]) + events.extend([ + ["ADD", 593, 596, "1", frame], + ["ADD", 594, 596, "1", frame], + ["ADD", 594, 592, "-1/2", frame], + ["ADD", 592, 593, "-1", frame], + ]) + return events + + +def inverse(events): + require(len(events) <= 6, "bounded boundary program") + return [[op, r, s, str(-Q(q)), frame] + for op, r, s, q, frame in reversed(events)] + + +def allowance(events): + require(len(events) <= 12, "bounded tariff input") + total = 0 + for op, r, s, text, frame in events: + q = Q(text) + n, d = abs(q.numerator), q.denominator + require(op == "ADD" and r != s and q != 0, "nonzero ADD") + require(d & (d - 1) == 0 and abs(q) + 1 < 2**16, + "retained dyadic coefficient contract") + require(type(frame) is int and frame >= 0, "chart index") + total += 2 * (3 + n.bit_length() - 1 + n.bit_count() + + d.bit_length() - 1) + return total diff --git a/research/p104-double-preconditioned-handoff/verify.py b/research/p104-double-preconditioned-handoff/verify.py new file mode 100644 index 0000000000..014cd4be4b --- /dev/null +++ b/research/p104-double-preconditioned-handoff/verify.py @@ -0,0 +1,182 @@ +#!/usr/bin/env python3 +"""Verify the new 22-ADD, 232-unit handoff; write no files. + +This contribution was produced by Nick Petalas. Apache-2.0. +Predecessor code is authenticated; only the new word receives full replay. +""" +from copy import deepcopy +from fractions import Fraction as Q +from hashlib import sha256 +from pathlib import Path +from types import ModuleType +import gzip +import json +import sys + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +SOURCE = "research/p104-coupled-helper-bases/" + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def load(path, name): + """Execute source bytes directly, without reading a bytecode cache.""" + module = ModuleType(name) + module.__file__ = str(path) + sys.modules[name] = module + exec(compile(path.read_bytes(), str(path), "exec"), module.__dict__) + return module + + +def sources(): + metadata = json.loads((HERE / "SOURCES.json").read_bytes()) + rows = [r for r in metadata["files"] if r["usage"] == "input"] + require(len(rows) == 4, "exact live dependency closure") + hashes = {} + for row in rows: + raw = (ROOT / row["path"]).read_bytes() + digest = sha256(raw).hexdigest() + require(digest == row["sha256"], "source bytes: " + row["path"]) + hashes[row["path"]] = digest + return hashes + + +def matrix(events, keys): + require(len(keys) <= 5 and len(events) <= 12, "small boundary domain") + index = {r: i for i, r in enumerate(keys)} + value = [[Q(i == j) for j in keys] for i in keys] + for op, r, s, q, frame in events: + require(op == "ADD" and r != s, "boundary ADD") + i, j = index[r], index[s] + value[i] = [x + Q(q) * y for x, y in zip(value[i], value[j], strict=True)] + return value + + +def boundary(c, a, b, events): + keys = sorted(set(a) | set(b)) + value = matrix(events, keys) + p = keys.index(596) + require([sum(a.get(r, 0) * value[i][j] for i, r in enumerate(keys)) + for j in range(len(keys))] == [Q(j == p) for j in range(len(keys))], + "row boundary") + require([value[i][p] for i in range(len(keys))] == [b.get(r, 0) for r in keys], + "column boundary") + require(matrix(events + c.inverse(events), keys) + == [[Q(i == j) for j in keys] for i in keys], "dirty inverse") + + +def rejection(function): + try: + function() + except ValueError as error: + return str(error) + raise ValueError("control accepted") + + +def boundary_checks(c): + results, controls = [], [] + for a, b, frame, cost in [(c.V, c.B, 3, 62), (c.V, c.U, 1053, 54)]: + events = c.basis(a, b, 596, frame) + boundary(c, a, b, events) + require(c.allowance(events) == c.allowance(c.inverse(events)) == cost, + "boundary and inverse tariff") + for i in range(len(events)): + mutant = events[:i] + events[i + 1:] + controls.append(rejection(lambda m=mutant: boundary(c, a, b, m))) + mutant = deepcopy(events) + # These two inverse preconditioners do not commute. + mutant[-1], mutant[-2] = mutant[-2], mutant[-1] + controls.append(rejection(lambda: boundary(c, a, b, mutant))) + results.append({"events": events, "allowance": cost}) + require(len(controls) == 13, "complete boundary omission/order controls") + require(2 * sum(r["allowance"] for r in results) == 232, "four-boundary tariff") + return results, controls + + +def construct(c): + local = load(ROOT / SOURCE / "local.py", "local") + builder = load(ROOT / SOURCE / "construct.py", "_ordered_handoff_builder") + word = json.loads(gzip.decompress((ROOT / SOURCE / "inputs/pr5580-WORD.json.gz").read_bytes())) + pairs = lambda values: [[r, str(q)] for r, q in sorted(values.items())] + step = {"kind": "coupled_handoff", "cut": 13762, "frame": 1053, + "group": [3, 127], "pivot": 596, "v": pairs(c.V), "u": pairs(c.U), + "source_functional": pairs(c.V), "output_direction": pairs(c.B)} + builder.basis = c.basis + candidate = builder.handoff(word, step) + require(len(candidate["program"]) == 25162, "22 inserted ADDs") + require(candidate["frames"] == word["frames"] and candidate["ports"] == word["ports"], + "retained geometry") + return candidate, local + + +def word_checks(candidate, local): + primary = local.replay(candidate) + other = load(ROOT / "research/p104-unit-column-handoff/independent.py", + "_ordered_handoff_integer_replay") + independent, snapshot = other.replay(candidate) + require(snapshot is None, "no unrequested checkpoint") + paid = {1: 2211, 2: 459, 3: 494, 4: 94, 5: 164, 6: 18, 7: 14} + helpers = {4: 84, 5: 6, 8: 15, 9: 423} + require(primary["paid"] == independent["paid"] == paid, "complete paid profile") + require(primary["helpers"] == independent["helpers"] == helpers, "complete target profile") + require(primary["real_scalar_allowance"] == independent["allowance"] == 217660, + "new complete scalar allowance") + require(independent["input_columns"] == 744 and independent["endpoint_coefficients"] == 553536, + "all independent coefficients") + require(independent["initialized"] == independent["cleared"] == 8 + and independent["peak_owned"] == 1, "owned lifetimes") + return primary, independent, other + + +def word_controls(candidate, engine): + results = [] + for kind in range(8): + mutant = deepcopy(candidate) + if kind == 0: + mutant["program"][0][-2] = "5/8" + elif kind == 1: + del mutant["program"][0] + elif kind == 2: + mutant["program"][0][-1] = 1053 + elif kind == 3: + mutant["initial"][735] = 3 + elif kind == 4: + mutant["final"][596] = 127 + elif kind == 5: + i = next(i for i, e in enumerate(mutant["program"]) if e[0] == "CLEAR") + del mutant["program"][i] + elif kind == 6: + mutant["program"].insert(0, ["INIT", 735, 1053]) + else: + mutant["program"][0][-2] = "1/3" + results.append({"case": kind, "rejection": rejection(lambda: engine.replay(mutant))}) + require(len(results) == 8, "whole-word semantic controls") + return results + + +def main(): + require(len(sys.argv) == 1, "no arguments; verifier writes nothing") + inputs = sources() + c = load(HERE / "completion.py", "_ordered_completion") + boundaries, omissions = boundary_checks(c) + candidate, local = construct(c) + primary, independent, engine = word_checks(candidate, local) + result = {"claim_type": "scoped construction with exact finite certificate", + "inserted_events": 22, "inserted_allowance": 232, + "boundaries": boundaries, "boundary_controls": omissions, + "primary": primary, "second_representation": independent, + "word_controls": word_controls(candidate, engine), "inputs_sha256": inputs, + "word_sha256": sha256(json.dumps(candidate, sort_keys=True, + separators=(",", ":")).encode()).hexdigest(), + "package_sha256": {p.name: sha256(p.read_bytes()).hexdigest() + for p in sorted(HERE.iterdir()) if p.is_file()}} + print(json.dumps(result, sort_keys=True)) + print("PASS_P104_ORDERED_HANDOFF inserted_events=22 inserted_allowance=232") + + +if __name__ == "__main__": + main()