diff --git a/research/clifford-pauli-anchor/BENCHMARK.json b/research/clifford-pauli-anchor/BENCHMARK.json new file mode 100644 index 0000000000..dcb0857727 --- /dev/null +++ b/research/clifford-pauli-anchor/BENCHMARK.json @@ -0,0 +1,138 @@ +{ + "medians": { + "anchor": { + "audit_wall_seconds": 31.100221754000813, + "equality_engine_seconds": 0.32612274498751503, + "process_wall_seconds": 31.162376325000878 + }, + "cached": { + "audit_wall_seconds": 37.46667832699859, + "equality_engine_seconds": 6.721224512994013, + "process_wall_seconds": 37.53124580500116 + }, + "packed": { + "audit_wall_seconds": 39.74438383100096, + "equality_engine_seconds": 9.774096749983073, + "process_wall_seconds": 39.808734207999805 + } + }, + "platform": "Linux-7.2.8-200.fc44.x86_64-x86_64-with-glibc2.43", + "processes": "fresh, sequential; alternating orders; OS caches not flushed; shared host", + "python": "3.12.14 (main, Sep 1 2026, 14:16:52) [Clang 22.1.3 ]", + "rounds": 3, + "samples": [ + { + "audit_wall_seconds": 41.48234724699978, + "equality_engine_seconds": 10.138834029015925, + "mode": "packed", + "process_wall_seconds": 41.551688278001166, + "round": 0 + }, + { + "audit_wall_seconds": 37.985246696000104, + "equality_engine_seconds": 6.860120718009057, + "mode": "cached", + "process_wall_seconds": 38.04833538599996, + "round": 0 + }, + { + "audit_wall_seconds": 32.14846472099998, + "equality_engine_seconds": 0.32612274498751503, + "mode": "anchor", + "process_wall_seconds": 32.21189399399918, + "round": 0 + }, + { + "audit_wall_seconds": 31.100221754000813, + "equality_engine_seconds": 0.3309641259984346, + "mode": "anchor", + "process_wall_seconds": 31.162376325000878, + "round": 1 + }, + { + "audit_wall_seconds": 37.46667832699859, + "equality_engine_seconds": 6.6524566870321, + "mode": "cached", + "process_wall_seconds": 37.53124580500116, + "round": 1 + }, + { + "audit_wall_seconds": 39.636854862999826, + "equality_engine_seconds": 9.752910248998887, + "mode": "packed", + "process_wall_seconds": 39.700494374999835, + "round": 1 + }, + { + "audit_wall_seconds": 36.88609559100041, + "equality_engine_seconds": 6.721224512994013, + "mode": "cached", + "process_wall_seconds": 36.94726072999947, + "round": 2 + }, + { + "audit_wall_seconds": 30.54571194900018, + "equality_engine_seconds": 0.3232460919844016, + "mode": "anchor", + "process_wall_seconds": 30.610115636000046, + "round": 2 + }, + { + "audit_wall_seconds": 39.74438383100096, + "equality_engine_seconds": 9.774096749983073, + "mode": "packed", + "process_wall_seconds": 39.808734207999805, + "round": 2 + } + ], + "scope": "Complete retained PR3202 two-provider audit; native generation and full supplier admission excluded", + "semantic_identity": { + "anchor_engine_sha256": "5f57804b7b7c3b1d8d2ceeefc41e199504f4d60c39e84df887fa6b3cd66b8b71", + "call_multiset_sha256": "e39f695f2e4f1ca106fb3479417b795d691b8488dc2b37edd087e0ab8e54811f", + "calls": { + "accepted": 244, + "calls": 253, + "rejected": 9 + }, + "reference_result_sha256": "e059aa7e91a658e4bbf4d0b15be0bde7e3896c99aefb162e06e1003c1d220eb2", + "source_sha256": { + "research/clifford-state-performance/fast_state.py": "2fe087ba4558bd21ca49945dbedaa4047e4170e8fd4e2280701bb2f0481811b5", + "research/frontier1094-recipes-exact-seed76/clifford.py": "d5e42ddabd141b7bfbd70fe13908f3c3a06aeccebeab90623596bfb1988b97fb", + "research/packed-clifford-gate-tables/adapter.py": "b0d9ad3183416e1c2780e69ea4bea57afba8c20da3979f61a6430731b4a42599", + "research/pr3044-r2-native-slice/README.md": "86af5efaf6dddf337fb80d4e1a5058633ed93d3247f0a00650f43f7b344e3175", + "research/pr3044-r2-native-slice/RESULT.json": "289f8ce423d2fc60489bd0b3a7ee9d7ca68e3e23c93389f31eff4d938157ba7a", + "research/pr3044-r2-native-slice/SOURCES.json": "77da54e04b3d61cb436503ce8e9a6f7a0e11d0180fcc49d7eace65bb3e01f4f9", + "research/pr3044-r2-native-slice/data/base/CANONICAL-WORD.json.gz": "682e7b76fa51dfbfd7b7962ce1382317c8091f2cf14ae131f6b557de6475a6c0", + "research/pr3044-r2-native-slice/data/base/CLIFFORD-RECIPES.json.gz": "708bf689bf80265991cbe4b5916cf8a60522e74c674eb576c32932903f0c8ad0", + "research/pr3044-r2-native-slice/data/base/LOCAL-PROGRAMS.json.gz": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "research/pr3044-r2-native-slice/data/base/RESIDUAL-ADAPTERS.json.gz": "8faeab9752757c54ee0eef3df700a7c715c49d772d4c5dc545b11b80cecfd6b4", + "research/pr3044-r2-native-slice/data/extra/CANONICAL-WORD.json.gz": "94e9a36aa0068024ccfceae4f6cb166ad33c5d460921e3e8e5df511eca0e6295", + "research/pr3044-r2-native-slice/data/extra/CLIFFORD-RECIPES.json.gz": "bff42748de313838c5dd82772c56a8154750db3e3746d4c792e875c15f38ca08", + "research/pr3044-r2-native-slice/data/extra/LOCAL-PROGRAMS.json.gz": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "research/pr3044-r2-native-slice/data/extra/RESIDUAL-ADAPTERS.json.gz": "da4f5fe1bdd515d29674cd098f6773c34a63061a49dcd1946f393b8f881723dd", + "research/pr3044-r2-native-slice/verify.py": "004a0bc6787cea330f401ab8b3f26bbe72499004e0ecb0ba09234ec6d2ada874", + "research/rank7-shared-restore-fanin/evidence/NATIVE-RECEIPT.json": "3dce85d535c34dd5755b7a7828b9706cd38198aa99e849dc0f166ac4e7ea47df", + "research/rank7-shared-restore-fanin/evidence/SOURCE-MANIFEST.json": "4f52f55eb311319a7e8ac7de7f4e9cc45e36166270db42c21c955c96a2e0639c", + "research/rank7-shared-restore-fanin/evidence/WORD-base.json.gz": "08e7e10e49053b97b7ae8a7e93f085ade519f3d270ed54b9c0c3a19236a4d267", + "research/rank7-shared-restore-fanin/evidence/WORD-extra.json.gz": "9c625893f09e46688fc650e1d65d05a416b504e2dcffe5fefdc4181c6de22479", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_adapters.py": "c5907050a9a7fa36d4fcba3ad4fe440d1bec2063360c095013891785ba65c3ce", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_emit.py": "99b59a6fa3feda86785e4225157dcb1a6169d256cec4f5e0acc9cea7a701df76", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_gauss.py": "0884b14d6d77cde419a3c773ad9b21d0d18de1e6e20e6b6d5add458ed32ba4cb", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_phases.py": "9d1a620e26715f4c42fd0347ecc14ef5a4a9031867869b64e8bae4d8526a821e", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_transport.py": "9818e08b819310b40f1441b89be8c4369584a5b3fa5dfe9b86b1df9a7f5d6a76", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/vendor/clifford/clifford_exact.py": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + } + }, + "speedup_over": { + "cached": { + "audit_wall_seconds": 1.2047077549271423, + "equality_engine_seconds": 20.609493254606704, + "process_wall_seconds": 1.2043768874869367 + }, + "packed": { + "audit_wall_seconds": 1.2779453518169253, + "equality_engine_seconds": 29.970607386974052, + "process_wall_seconds": 1.277461442376015 + } + } +} diff --git a/research/clifford-pauli-anchor/NOTICE.md b/research/clifford-pauli-anchor/NOTICE.md new file mode 100644 index 0000000000..19f1706604 --- /dev/null +++ b/research/clifford-pauli-anchor/NOTICE.md @@ -0,0 +1,34 @@ +# Attribution and retained sources + +New comparator, integration, controls, benchmark and documentation: Tekalign +(@tekuuu), with substantial OpenAI Codex assistance. Apache-2.0. + +`vendor/pr3202/` retains twelve files verbatim from 24kHandsome1201's +PR3202, commit `259043321323717b7e816d6be38ad5e1f0b69b4c`. Its original README, +code attribution, native receipts and source manifest are unchanged. These +files are necessary to replay the current R2 caller and its exact artifacts; +they are not newly generated native evidence. See `SOURCES.json` for every +source path, blob and SHA256 digest. The upstream repository's Apache-2.0 +license applies. + +Sagar Thakrar (@thakrarsagar), PR1781, supplies the separate packed exact +Clifford kernel and its gate conventions. The default packed oracle remains +unchanged. The comparator criterion (signed Pauli tableau plus one exact +column) is established Clifford algebra, also used by the retained native +producer; its discovery is not claimed here. Credit icekylinx, Jeremy Kothe, +Mason Hale and the original Clifford/native implementation lineage. + +ywz65, PR2638, supplies the existing opt-in cached-table packed comparator used +as a stronger benchmark baseline. Charles Bethin (@cbethin), PR662, supplies +its table recurrences. The new engine's bounded immutable table implementation +uses the same known binary recurrences, independently coded for this engine. +Ali Romman/#1029 and Tekalign/#2768 are predecessors for sparse exact state +evaluation and current native replay tooling, respectively. + +The R2 construction and its audits retain Nick Petalas/#3044, Jeremy Kothe, +Marius-Paul Dumitrean/#2979, Hiroki Kumazaki/#3146, Cinna Davis and the full +geometry, extraction, ownership and native lineage listed in the retained +README. This package does not assume independent approval of those sources. + +Substantial AI assistance was used for algebra, implementation, testing and +writing. No independent human or proof-assistant review is claimed. diff --git a/research/clifford-pauli-anchor/PROOF.md b/research/clifford-pauli-anchor/PROOF.md new file mode 100644 index 0000000000..cb71e12328 --- /dev/null +++ b/research/clifford-pauli-anchor/PROOF.md @@ -0,0 +1,153 @@ +# Exact Clifford equality from signed Pauli action and one anchor + +The complete criterion below is established Clifford algebra, already used by +the retained native producer's tableau and zero-column check. This package +does not claim its discovery. It implements the criterion separately for +Sagar Thakrar's PR1781 gate grammar, then substitutes that comparator into +24kHandsome1201's source-bound PR3202 audit. The intended contribution is +measured verification engineering, with exact coverage preserved. + +## Domain and conventions + +Basis labels are `x in F_2^n`, bit zero first. The implementation accepts +`1 <= n <= 9`; its current caller uses `n=9`. Gates are chronological: + +- `P(G)|x> = |Gx>` for an invertible binary row matrix `G`. +- `X(b)|x> = |x+b>`. +- `D(Q,a)|x> = i^q(x)|x>`, where + `q(x)=sum_j a_j x_j + 2 sum_{j = i^(p+2 z dot y)|y+x>`. +Its full phase modulo four is stored. Discarding that phase is unsound. + +## Signed conjugation rules + +The initial list consists of `X(e_j)` and `Z(e_j)` for every coordinate. +For each gate `A` replace every stored Pauli by `A W A^*`. Chronological +updates therefore produce the generator images under the complete word. + +| Gate | Updated `(p,x,z)` | +|---|---| +| `P(G)` | `(p, Gx, G^(-T)z)` | +| `X(b)` | `(p+2 z dot b, x, z)` | +| `PH(k)` | `(p,x,z)` | +| `D(Q,a)` | `(p+q(x), x, z+B x)` | +| `C(v,s)`, if `z dot v=0` | `(p,x,z)` | +| `C(v,s)`, if `z dot v=1` | `(p-s, x+v, z)` | + +Phases are reduced modulo four and binary coordinates modulo two. Here `B` +is symmetric with diagonal `a_j mod 2` and off-diagonal entries the strict +upper-triangle coefficients of `Q`, reflected across the diagonal. + +For the diagonal gate, direct expansion gives + +``` +q(y+x)-q(y) = q(x) + 2 (Bx) dot y (mod 4), +``` + +which proves the stated rule. For `C`, put `T=X(v)`. A Pauli either commutes +or anticommutes with `T`. The commuting case is unchanged. In the other case, +expanding `((1+s i)I+(1-s i)T) W ((1-s i)I+(1+s i)T)/4` +gives `-s i T W`, which is exactly the last row. These derivations determine +the signs; they are not inferred by ignoring global phases in a tableau. + +## Why the comparison covers every input + +Let `U,V` be two accepted words. Suppose their **signed** images of every +`X(e_j)` and `Z(e_j)` agree. Then `V^* U` commutes with all those generators. +Commuting with all `Z(e_j)` forces its matrix to be diagonal: distinct basis +labels have distinct joint sign eigenvalues. Commuting also with all +`X(e_j)` makes its diagonal entries equal along every edge of the binary +cube. That cube is connected, so `V^* U=lambda I` and `U=lambda V`. + +The additional equality `U|0>=V|0>` forces `lambda=1`, since `V|0>` is +nonzero. Thus the signed generator images plus **one exact anchor vector** +are a necessary and sufficient test of operator equality, including global +phase. At nine axes, this covers all 512 input basis columns and every complex +linear combination without constructing those 512 columns individually. + +This relies on the validated Clifford gate grammar. It is not a method for +checking arbitrary linear operators from 18 generators and one sample. +Nor is it a polynomial-time implementation claim: the anchor representation +can contain `2^n` amplitudes. The implemented domain is bounded at nine axes. + +## Exact anchor arithmetic and table reuse + +`anchor` starts with `{0: (1,0)}`. Its state is a sparse Gaussian-integer +numerator vector with common denominator `2^k`, where `k` is the number of +`C` gates already applied. Permutations, translations and fourth-root phases +preserve that denominator. Each `C` applies its literal numerator formula +and increments `k`; exact zeros are removed. No rounding, floating point, +norm tolerance or projective normalization occurs. + +Two anchors are compared after multiplication to the common denominator +`2^max(k,l)`. Python integers do not overflow. Equality tests retain every +nonzero coordinate, including the possibility that coordinate zero itself +vanishes; testing just the scalar amplitude at coordinate zero would not +suffice. + +The bounded 64-entry cache contains only immutable gate tables. For a binary +permutation, `Gx=G(x-e_j)+G e_j` at the least set bit `j`. For a quadratic +phase, `q(x)=q(x-e_j)+a_j+2 sum_{k != j} B_jk x_k`. These are the known +binary recurrences used by Charles Bethin/#662 and ywz65/#2638, coded here +for the comparator's gate representation. Keys include dimension and every +operand. Caller-owned lists are frozen before use. No new acceptance-result +or state-vector cache is introduced. The retained audit's own full-circuit +deduplication is unchanged. + +## Current-caller integration and limitations + +`replay.py` authenticates all 25 source/input files before running any retained +code, copies the captured bytes into a fresh private snapshot, and loads the +unchanged PR3202 verifier with one explicit installation statement immediately +after its kernel initialization. The source anchor must occur exactly once. +The hook substitutes only `same_operator`; all source/event binding, canonical +frame construction, both orientations, the scalar restoration control, recipe +coverage, wrapper chronology and sixteen semantic mutants per provider remain. + +Three modes run that identical caller: original packed kernel; the existing +#2638 table-cached packed kernel; and the new comparator. Every mode must +reproduce the entire original result. The benchmark also matches the multiset +of actual circuit pairs and Boolean decisions, with multiplicity. It uses +fresh serial processes and alternates order. Timing has no acceptance threshold. + +The nested predecessor result retains its historical kernel hash; the enclosing +receipt separately identifies the actual mode, new engine, transformed verifier +and all captured source hashes. Its inherited `512`-column fields describe +the operator domain covered, not an assertion that the new engine explicitly +simulated 512 input columns. Native generation is outside this retained-artifact +benchmark; the source artifacts are authenticated on every replay. + +This does not expand PR3202's scientific coverage, implement a fast recursive +multiplier, certify a supplier, or establish a new kappa. Native operations +outside the slice, physical ownership, complete cleanup, precision/tape and +outer/all-size obligations remain as in the predecessor. + +## Executed failure and differential checks + +`controls.py` uses the unchanged packed matrix implementation as an oracle +on 96 deterministic circuits (seed 86), dimensions one through four. It checks +`U P = image(P) U` for all generators on every input column: 480 signed Pauli +images and 4,704 matrix-column relations. It separately checks each complete +anchor vector and 480 comparator decisions, including adjoints and faults. +The small-dimensional computations are finite evidence for the implementation; +the preceding argument supplies the all-input implication for valid words. + +Two controls expose the respective blind spots. `PH(1)` has identity Pauli +action but a different anchor. A nontrivial diagonal character fixes `|0>` +but changes a signed Pauli image. Its unsigned Pauli labels are unchanged, +so the latter control also detects dropping signs. Invalid gate, singular +matrix and mutable-cache-key controls fail explicitly under optimized Python. + +Tekalign (@tekuuu), with substantial OpenAI Codex assistance. Apache-2.0. +No independent human or proof-kernel review is claimed. diff --git a/research/clifford-pauli-anchor/README.md b/research/clifford-pauli-anchor/README.md new file mode 100644 index 0000000000..645731637c --- /dev/null +++ b/research/clifford-pauli-anchor/README.md @@ -0,0 +1,147 @@ +# Faster exact Clifford comparisons in the current R2 audit + +**Verification tooling; no new kappa or supplier admission.** The new +comparator accelerates the exact equality stage of PR3202's complete retained +two-provider native-slice audit by **29.97x** over its original packed kernel +and **20.61x** over the existing table-cached kernel. The entire audit improves +by **1.28x / 1.20x**, respectively; its other checks are unchanged. + +The insight is to use a complete algebraic description instead of constructing +every matrix column. For these Clifford operators, signed action on the 18 +Pauli generators determines the operator up to a scalar. One whole exact +anchor column fixes that scalar, including global phase. This criterion is +already used by the native producer and is not a new theorem here. The +contribution is a separate exact implementation, its source-bound integration +into the current independent audit, and measured coverage-preserving gains. + +## Same-input measurements + +Three samples per engine, each in a fresh serial Python 3.12.14 process, +alternating order on the same shared Linux host: + +| Engine | Equality-stage median | Complete audit median | +|---|---:|---:| +| Original PR1781 packed kernel | 9.774 s | 39.744 s | +| PR2638 cached-table packed kernel | 6.721 s | 37.467 s | +| Signed Pauli action + exact anchor | **0.326 s** | **31.100 s** | + +All nine runs reproduce the **entire predecessor result** and the same +multiset of **253 circuit-pair decisions: 244 acceptances and 9 rejections**. +Every source binding, both orientations, scalar restoration control, wrapper +chronology check and all sixteen semantic mutants per provider remain enabled. +The source audit's existing full-circuit deduplication is unchanged. + +[BENCHMARK.json](BENCHMARK.json) retains every sample, process-level timing, +source and engine hashes, complete-result digest and circuit/decision digest. +OS caches were not flushed; there is no timing threshold in CI. The whole-audit +measurements include authentication and isolated snapshot setup. They exclude +native artifact generation, full supplier replay and integer multiplication. +The 30x number describes the equality stage, not the complete audit. + +## What remains exact + +[engine.py](engine.py) validates the complete gate words, propagates signed +Pauli images and evaluates `U|0>` with sparse Gaussian integers over powers +of two. It uses no floating-point tolerance, random probes or projective +phase normalization. The [proof](PROOF.md) derives each gate rule and the +complete comparison criterion. The API supports one through nine axes; +the actual caller uses nine, hence a 512-dimensional input space. + +[controls.py](controls.py) checks the new representation against the original +packed matrix engine on 96 deterministic circuits in dimensions one through +four. It verifies all 480 signed generator images through 4,704 full matrix +column relations, every anchor, and 480 comparison decisions. Two explicit +controls show that Pauli action alone misses global phase and the zero-input +column alone misses a nontrivial character. Invalid gates and singular matrices +are rejected; mutating a cached operand changes the comparison result. These +controls also run under optimized Python. + +Only immutable gate tables are cached, at most 64 entries. No new result or +state-vector cache is introduced. A small differential corpus is evidence for +the implementation; the written Clifford argument supplies all-input coverage. +It is not a proof-kernel verification or an independent human review. + +## Reproduce and use + +From the repository root, Python 3.12 and the standard library: + +```sh +python3.12 -B scripts/research_package.py --package research/clifford-pauli-anchor +``` + +Expected markers are `PASS_CLIFFORD_PAULI_ANCHOR`, `PASS_ANCHOR_EXPORT` and +`PASS_REGISTERED_RESEARCH_PACKAGE ... outcome=completed`. The registered +checks also run a complete optimized replay from a Git-free export in a path +with spaces, and reject changes to a live kernel, retained recipe and verifier. + +Direct opt-in replay of the complete unchanged R2 audit: + +```sh +python3 -I -B research/clifford-pauli-anchor/replay.py --mode anchor +``` + +Use `--mode packed` or `--mode cached` for the two reference engines. +An optional `--output FRESH.json` saves the full companion receipt. +Normal commands do not regenerate or modify any source artifact. + +To repeat the same-input benchmark (about six minutes on this host): + +```sh +python3.12 -I -B research/clifford-pauli-anchor/benchmark.py \ + --rounds 3 --output /tmp/anchor-benchmark-fresh.json +``` + +For another caller, the drop-in function is `engine.same_operator(a,b,n=9)`. +Before adoption, pin its gate grammar and replay its complete existing +controls. The frozen/default project engines are unchanged. + +## Source and scope boundary + +Base: `463113d675af7410ac91d53a4fed51ec6494eb9a`, priority revision 6. +Pending dependency PR3202: +`259043321323717b7e816d6be38ad5e1f0b69b4c`. Twelve necessary files from that +package are retained verbatim under `vendor/pr3202/`, including its README. +Their original paths, commit, Git blob IDs and SHA256 digests are recorded in +`SOURCES.json`'s `vendored_files` and checked before execution. The generic +runner checks the main-history pins; it does not require the pending PR's +Git objects to exist in a fresh checkout. Direct replay needs no Git/network. + +All thirteen live input paths are declared for CI invalidation. `replay.py` +captures and authenticates those plus the twelve retained files before any +predecessor code executes. It installs exactly one comparator hook in a +private copy of the verifier; source/event reconstruction and all its failure +predicates stay unchanged. The complete result and snapshot immutability are +checked afterward. Changes to captured scientific inputs or predecessor +executable sources require an explicit pin update and revalidation; hashes are not a security +boundary against changing both evidence and its pins. + +The companion receipt distinguishes the executed comparator from the +historical kernel hash inside the retained result. Its inherited 512-column +fields denote the covered operator domain, not 512 individually simulated +columns in the new engine. The comparison covers every complex input under +the validated gate grammar. + +This does not extend PR3202's scientific scope. Full cleanup, other native +operations, physical ownership, precision/tape, the all-size compiler and +supplier/outer admission are not established here. Concurrent PR3208 +(`87d63a82defff1ffeea173743106fb97903cbbd6`) supplies a separate R2 cleanup +audit; it is not included in these measurements or certified by this package. +PR3209 optimizes JSON parsing in a different T16 caller. Both are complementary +work. The selected certificate and frozen predecessors are unchanged. + +## Open next questions and credit + +The [structured handoff](TASK.json) suggests testing a larger native cone +against its existing fastest engine, and profiling the R2 audit's remaining +source/event and mutant-copy costs. No larger-caller speedup is claimed here. +[Canonical claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/2612#discussioncomment-19002067). + +Credit Sagar Thakrar/#1781 for the independent packed oracle and conventions; +ywz65/#2638 and Charles Bethin/#662 for the cached baseline and table recurrences; +24kHandsome1201/#3202 for the current audit; the original native producer for +the complete tableau/column criterion; and Nick Petalas, Jeremy Kothe, +Marius-Paul Dumitrean, Hiroki Kumazaki and the retained construction lineage. +[NOTICE.md](NOTICE.md) and the retained README give the fuller attribution. + +New work is by Tekalign (@tekuuu), with substantial OpenAI Codex assistance +in algebra, implementation, measurement, checking and writing. Apache-2.0. diff --git a/research/clifford-pauli-anchor/RESULT.json b/research/clifford-pauli-anchor/RESULT.json new file mode 100644 index 0000000000..33c1d5bbf5 --- /dev/null +++ b/research/clifford-pauli-anchor/RESULT.json @@ -0,0 +1,52 @@ +{ + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "call_multiset_sha256": "e39f695f2e4f1ca106fb3479417b795d691b8488dc2b37edd087e0ab8e54811f", + "controls": { + "cache_operand_mutation_rejected": true, + "circuits": 96, + "differential_comparisons": 480, + "invalid_gates_rejected": 8, + "matrix_column_relations": 4704, + "phase_only_and_column_only_blindness_controls": 2, + "seed": 86, + "signed_pauli_images": 480 + }, + "coverage": "Exact equality on the 512-dimensional operator domain, via signed Pauli action and one whole anchor column; not 512 explicitly simulated input columns.", + "decisions": { + "accepted": 244, + "calls": 253, + "rejected": 9 + }, + "dependency_pr3202": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "formal_kernel_proof": false, + "new_kappa": false, + "reference_result_sha256": "e059aa7e91a658e4bbf4d0b15be0bde7e3896c99aefb162e06e1003c1d220eb2", + "source_sha256": { + "research/clifford-state-performance/fast_state.py": "2fe087ba4558bd21ca49945dbedaa4047e4170e8fd4e2280701bb2f0481811b5", + "research/frontier1094-recipes-exact-seed76/clifford.py": "d5e42ddabd141b7bfbd70fe13908f3c3a06aeccebeab90623596bfb1988b97fb", + "research/packed-clifford-gate-tables/adapter.py": "b0d9ad3183416e1c2780e69ea4bea57afba8c20da3979f61a6430731b4a42599", + "research/pr3044-r2-native-slice/README.md": "86af5efaf6dddf337fb80d4e1a5058633ed93d3247f0a00650f43f7b344e3175", + "research/pr3044-r2-native-slice/RESULT.json": "289f8ce423d2fc60489bd0b3a7ee9d7ca68e3e23c93389f31eff4d938157ba7a", + "research/pr3044-r2-native-slice/SOURCES.json": "77da54e04b3d61cb436503ce8e9a6f7a0e11d0180fcc49d7eace65bb3e01f4f9", + "research/pr3044-r2-native-slice/data/base/CANONICAL-WORD.json.gz": "682e7b76fa51dfbfd7b7962ce1382317c8091f2cf14ae131f6b557de6475a6c0", + "research/pr3044-r2-native-slice/data/base/CLIFFORD-RECIPES.json.gz": "708bf689bf80265991cbe4b5916cf8a60522e74c674eb576c32932903f0c8ad0", + "research/pr3044-r2-native-slice/data/base/LOCAL-PROGRAMS.json.gz": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "research/pr3044-r2-native-slice/data/base/RESIDUAL-ADAPTERS.json.gz": "8faeab9752757c54ee0eef3df700a7c715c49d772d4c5dc545b11b80cecfd6b4", + "research/pr3044-r2-native-slice/data/extra/CANONICAL-WORD.json.gz": "94e9a36aa0068024ccfceae4f6cb166ad33c5d460921e3e8e5df511eca0e6295", + "research/pr3044-r2-native-slice/data/extra/CLIFFORD-RECIPES.json.gz": "bff42748de313838c5dd82772c56a8154750db3e3746d4c792e875c15f38ca08", + "research/pr3044-r2-native-slice/data/extra/LOCAL-PROGRAMS.json.gz": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "research/pr3044-r2-native-slice/data/extra/RESIDUAL-ADAPTERS.json.gz": "da4f5fe1bdd515d29674cd098f6773c34a63061a49dcd1946f393b8f881723dd", + "research/pr3044-r2-native-slice/verify.py": "004a0bc6787cea330f401ab8b3f26bbe72499004e0ecb0ba09234ec6d2ada874", + "research/rank7-shared-restore-fanin/evidence/NATIVE-RECEIPT.json": "3dce85d535c34dd5755b7a7828b9706cd38198aa99e849dc0f166ac4e7ea47df", + "research/rank7-shared-restore-fanin/evidence/SOURCE-MANIFEST.json": "4f52f55eb311319a7e8ac7de7f4e9cc45e36166270db42c21c955c96a2e0639c", + "research/rank7-shared-restore-fanin/evidence/WORD-base.json.gz": "08e7e10e49053b97b7ae8a7e93f085ade519f3d270ed54b9c0c3a19236a4d267", + "research/rank7-shared-restore-fanin/evidence/WORD-extra.json.gz": "9c625893f09e46688fc650e1d65d05a416b504e2dcffe5fefdc4181c6de22479", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_adapters.py": "c5907050a9a7fa36d4fcba3ad4fe440d1bec2063360c095013891785ba65c3ce", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_emit.py": "99b59a6fa3feda86785e4225157dcb1a6169d256cec4f5e0acc9cea7a701df76", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_gauss.py": "0884b14d6d77cde419a3c773ad9b21d0d18de1e6e20e6b6d5add458ed32ba4cb", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_phases.py": "9d1a620e26715f4c42fd0347ecc14ef5a4a9031867869b64e8bae4d8526a821e", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_transport.py": "9818e08b819310b40f1441b89be8c4369584a5b3fa5dfe9b86b1df9a7f5d6a76", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/vendor/clifford/clifford_exact.py": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + }, + "status": "PASS_CLIFFORD_PAULI_ANCHOR" +} diff --git a/research/clifford-pauli-anchor/SOURCES.json b/research/clifford-pauli-anchor/SOURCES.json new file mode 100644 index 0000000000..4bb592d91e --- /dev/null +++ b/research/clifford-pauli-anchor/SOURCES.json @@ -0,0 +1,198 @@ +{ + "schema_version": 1, + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "67f085acd86acd7d4e03922d9cf4b26bca66fed5", + "sha256": "47b42433f5a85809a3aadd29c2c339da2c6ed728e4f7762df6b88bccb7874cf0" + }, + { + "path": "research/clifford-state-performance/fast_state.py", + "usage": "input", + "git_blob": "5d546d8a05f6025d58a5133fa0d67ce134993013", + "sha256": "2fe087ba4558bd21ca49945dbedaa4047e4170e8fd4e2280701bb2f0481811b5" + }, + { + "path": "research/frontier1094-recipes-exact-seed76/clifford.py", + "usage": "input", + "git_blob": "6f1e6a38febde7eb7a7341d317522e6650d84408", + "sha256": "d5e42ddabd141b7bfbd70fe13908f3c3a06aeccebeab90623596bfb1988b97fb" + }, + { + "path": "research/packed-clifford-gate-tables/adapter.py", + "usage": "input", + "git_blob": "b99342ac6e4853048a87cc9fa7d31caf998f9af0", + "sha256": "b0d9ad3183416e1c2780e69ea4bea57afba8c20da3979f61a6430731b4a42599" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/NATIVE-RECEIPT.json", + "usage": "input", + "git_blob": "9b7c498ed6f92be5f1c4a85a1f25427788647fc1", + "sha256": "3dce85d535c34dd5755b7a7828b9706cd38198aa99e849dc0f166ac4e7ea47df" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/SOURCE-MANIFEST.json", + "usage": "input", + "git_blob": "ff42fd06f9ede0e1a717766232e283005336f935", + "sha256": "4f52f55eb311319a7e8ac7de7f4e9cc45e36166270db42c21c955c96a2e0639c" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/WORD-base.json.gz", + "usage": "input", + "git_blob": "51b0b3c912565b7e12b3a2f8a3c0ccd37290206b", + "sha256": "08e7e10e49053b97b7ae8a7e93f085ade519f3d270ed54b9c0c3a19236a4d267" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/WORD-extra.json.gz", + "usage": "input", + "git_blob": "23915f0bec7533ce0658cac8c7ae2069873efe4b", + "sha256": "9c625893f09e46688fc650e1d65d05a416b504e2dcffe5fefdc4181c6de22479" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_transport.py", + "usage": "input", + "git_blob": "08248542b18864c94a5ac050c8669f68519838e1", + "sha256": "9818e08b819310b40f1441b89be8c4369584a5b3fa5dfe9b86b1df9a7f5d6a76" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_emit.py", + "usage": "input", + "git_blob": "6d47f63ab7a533941b3881bbfd3ae4dac5f76932", + "sha256": "99b59a6fa3feda86785e4225157dcb1a6169d256cec4f5e0acc9cea7a701df76" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_phases.py", + "usage": "input", + "git_blob": "99f351785ebca5fbf3336bedcd7b48bac9c255e5", + "sha256": "9d1a620e26715f4c42fd0347ecc14ef5a4a9031867869b64e8bae4d8526a821e" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_adapters.py", + "usage": "input", + "git_blob": "82beaa9c1d13bcd5f79d0a5e10e8a10733eac347", + "sha256": "c5907050a9a7fa36d4fcba3ad4fe440d1bec2063360c095013891785ba65c3ce" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_gauss.py", + "usage": "input", + "git_blob": "1ff29dfb244e2114de8e586a450ae9fb70308d58", + "sha256": "0884b14d6d77cde419a3c773ad9b21d0d18de1e6e20e6b6d5add458ed32ba4cb" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/vendor/clifford/clifford_exact.py", + "usage": "input", + "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + } + ], + "dependency_heads": { + "PR3202": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "scientific_base": "463113d675af7410ac91d53a4fed51ec6494eb9a" + }, + "vendored_files": [ + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/verify.py", + "usage": "vendored", + "git_blob": "0ed4963416541b4da6f1b726cba18dc737c66412", + "sha256": "004a0bc6787cea330f401ab8b3f26bbe72499004e0ecb0ba09234ec6d2ada874", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/verify.py" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/SOURCES.json", + "usage": "vendored", + "git_blob": "71f2c61df0340a3e71d918fb371bc5e88eab3f13", + "sha256": "77da54e04b3d61cb436503ce8e9a6f7a0e11d0180fcc49d7eace65bb3e01f4f9", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/SOURCES.json" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/RESULT.json", + "usage": "vendored", + "git_blob": "87f87bc4bbc549611889a956f53a01c2dbd29d39", + "sha256": "289f8ce423d2fc60489bd0b3a7ee9d7ca68e3e23c93389f31eff4d938157ba7a", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/RESULT.json" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/README.md", + "usage": "vendored", + "git_blob": "b05efddf13cb67c7db7b0612ac18b537811872c7", + "sha256": "86af5efaf6dddf337fb80d4e1a5058633ed93d3247f0a00650f43f7b344e3175", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/README.md" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/base/CANONICAL-WORD.json.gz", + "usage": "vendored", + "git_blob": "3958b8cf77b86b98d7a35ed0f4d2590f7de2b27f", + "sha256": "682e7b76fa51dfbfd7b7962ce1382317c8091f2cf14ae131f6b557de6475a6c0", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/base/CANONICAL-WORD.json.gz" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/base/LOCAL-PROGRAMS.json.gz", + "usage": "vendored", + "git_blob": "9ad65235dc846be16cddab2cf1839d24229de663", + "sha256": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/base/LOCAL-PROGRAMS.json.gz" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/base/CLIFFORD-RECIPES.json.gz", + "usage": "vendored", + "git_blob": "0591c6af1b744520e7f6a07303420c055ee9ae0e", + "sha256": "708bf689bf80265991cbe4b5916cf8a60522e74c674eb576c32932903f0c8ad0", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/base/CLIFFORD-RECIPES.json.gz" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/base/RESIDUAL-ADAPTERS.json.gz", + "usage": "vendored", + "git_blob": "3e154660a1ca7904703447280214a5c14957568f", + "sha256": "8faeab9752757c54ee0eef3df700a7c715c49d772d4c5dc545b11b80cecfd6b4", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/base/RESIDUAL-ADAPTERS.json.gz" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/extra/CANONICAL-WORD.json.gz", + "usage": "vendored", + "git_blob": "c2c7a69938dcb2b2cbd390739bc027447ed6cb4c", + "sha256": "94e9a36aa0068024ccfceae4f6cb166ad33c5d460921e3e8e5df511eca0e6295", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/extra/CANONICAL-WORD.json.gz" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/extra/LOCAL-PROGRAMS.json.gz", + "usage": "vendored", + "git_blob": "9ad65235dc846be16cddab2cf1839d24229de663", + "sha256": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/extra/LOCAL-PROGRAMS.json.gz" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/extra/CLIFFORD-RECIPES.json.gz", + "usage": "vendored", + "git_blob": "887f5bfc36d382e81e2f945f5dcc5c1bf2be7233", + "sha256": "bff42748de313838c5dd82772c56a8154750db3e3746d4c792e875c15f38ca08", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/extra/CLIFFORD-RECIPES.json.gz" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/extra/RESIDUAL-ADAPTERS.json.gz", + "usage": "vendored", + "git_blob": "3cb1e2927f406b18a635c6170ab73078b24b36e1", + "sha256": "da4f5fe1bdd515d29674cd098f6773c34a63061a49dcd1946f393b8f881723dd", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/extra/RESIDUAL-ADAPTERS.json.gz" + } + ] +} diff --git a/research/clifford-pauli-anchor/TASK.json b/research/clifford-pauli-anchor/TASK.json new file mode 100644 index 0000000000..aac896c2bc --- /dev/null +++ b/research/clifford-pauli-anchor/TASK.json @@ -0,0 +1,132 @@ +{ + "schema_version": 1, + "task_id": "replay-runtime", + "priority_revision": 6, + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "original_card": { + "id": "replay-runtime", + "question": "Can one measured replay bottleneck be sped up without dropping coverage?", + "starting_points": [ + "scripts/run_isolated_tests.py", + "scripts/verify_replay_coverage.py", + "certificates/selected-result.json" + ], + "methods": [ + "Profile one isolated replay and optimize the measured bottleneck.", + "Design source-bound reuse with explicit dependency invalidation and negative controls." + ], + "acceptance_gate": "Report before/after wall time on the same fixture, retained checks and invalidation behavior.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read the selected reproduction command and choose a single replay stage for profiling.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Measure one unchanged fixture, preserve check coverage, and test one optimization with invalidation controls.", + "bottleneck_link": "Faster trustworthy replays increase review throughput and let mechanism candidates be checked sooner.", + "allowed_variations": [ + "Profile one stage or design one source-bound cache boundary." + ], + "scope_change_triggers": [ + "Skipping coverage or comparing different fixtures to claim speedup." + ], + "overlap_terms": [ + "replay runtime", + "cache invalidation", + "isolated tests" + ] + }, + "scope_status": "refined", + "actual_scope": "Accelerate the exact equality engine inside the complete retained PR3202 two-provider native-slice audit, using independently implemented signed Pauli action plus an exact anchor vector; compare the original and existing table-cached kernels on identical circuits.", + "scope_change_reason": "The runtime card is narrowed to the current R2 native equality stage. The established Clifford criterion and the existing producer are credited; no new semantic admission coverage is claimed.", + "bottleneck_link": "Independent native audits execute hundreds to thousands of complete phase-sensitive Clifford comparisons. A sound faster comparator makes those audits and negative controls cheaper while leaving their source/event/ownership boundaries explicit.", + "budget_minutes": 60, + "stop_rule": "Session 2026-10-17T17:39Z to 18:39Z; stop if full equality or meaningful measured wall-time gain fails. Reserve at least the final 15 minutes for verification and handoff. Benchmark only the existing retained two-provider slice; do not expand its missing cleanup or supplier obligations.", + "outcome": "completed", + "evidence": "PROOF.md gives the complete comparator criterion and literal gate rules. BENCHMARK.json records nine fresh serial runs over the same 253 comparisons and unchanged complete result. RESULT.json records exact input hashes, decisions and independent full-matrix controls.", + "author": "Tekalign (@tekuuu)", + "ai_assistance": "Substantial OpenAI Codex assistance in proof adaptation, independent comparator code, source integration, tests, measurements and writing. The criterion is predecessor mathematics; no independent human or proof-kernel review is claimed.", + "open_questions": [ + { + "question": "Should a caller with thousands of native classes adopt the same comparator after source-bound replay?", + "why_it_matters": "The R2 audit already spends most remaining time outside equality; larger native cones may benefit more from the measured 20.6x gain over the cached equality engine.", + "first_step": "Pin the exact PR3208 cleanup or PR3038 native-cone caller and gate grammar, install same_operator only in an isolated snapshot, compare every result/control and benchmark the whole caller against its fastest existing engine.", + "blocked_by": "No whole-cone or producer-generation speedup is measured here; caller-specific schema and cache invalidation must remain intact." + }, + { + "question": "What now dominates the unchanged R2 audit outside exact equality?", + "why_it_matters": "Its remaining source/event and semantic-control work limits the whole-audit gain to about 1.28x over the original, despite a 30x equality-stage improvement.", + "first_step": "Profile source/event binding and full mutant-copy work on the identical fixture, retaining every mutant and failure predicate.", + "blocked_by": "No optimization or timing attribution of those remaining components is claimed in this package." + } + ], + "assignment": { + "seed": 86, + "randomness": "operating-system CSPRNG via secrets.randbelow(100)", + "track": "verification engineering", + "task": "replay-runtime" + }, + "candidates_considered": [ + { + "object": "PR3202 R2 exact native comparison stage", + "decision": "chosen: current source-bound caller, slow packed equality; independently implement a complete compact criterion rather than only caching tables" + }, + { + "object": "T740 complete fill serialization/authentication", + "decision": "deferred: would improve IO and formatting cost rather than the shared native equality engine" + }, + { + "object": "selected full-checker gate tables", + "decision": "not repeated: ywz65/#2638 already covers the optimization and supplies the stronger baseline here" + } + ], + "coordination": { + "claim": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2612#discussioncomment-19002067", + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "priorities_revision": 6, + "metadata_coverage": { + "open_prs": 251, + "closed_prs": 2630, + "fresh_discussion_refresh": "TLS handshake timeout; used complete 2004-record snapshot from 17:30 UTC plus fresh last-eight comments in #2612 and last-twelve handoffs in #1166" + }, + "overlap": "PR3202 caller head is unchanged. Concurrent PR3208 (87d63a82defff1ffeea173743106fb97903cbbd6) now audits R2 full cleanup separately; that audit is not benchmarked here. PR3209 (8c62e5f52f1d172bb8c95e795449205015bb5143) optimizes JSON parsing in a different T16 audit. Other current claims audit mixed entrances and private frees. This package changes only the comparison engine for the retained PR3202 slice. #1781, #2638, #662, #1029 and #2768 are credited predecessors.", + "submission_refresh": { + "canonical_main": "463113d675af7410ac91d53a4fed51ec6494eb9a (unchanged, fetched at 18:07 UTC)", + "open_prs": { + "records": 262, + "complete_pagination": true, + "fetched_at": "2026-10-17T18:07:11Z" + }, + "closed_prs": { + "records": 2630, + "complete_pagination": true, + "fetched_at": "2026-10-17T17:42:50Z" + }, + "discussions": { + "records": 2004, + "complete_pagination": true, + "fetched_at": "2026-10-17T17:30:12Z" + }, + "targeted_refresh": "Fresh last-twelve comments each in #2612 and #1166 at 18:07 UTC; current PR3202/3208/3209 heads and bodies; open issues list contains #913 only.", + "limitations": "New whole-Discussion refresh failed with TLS handshake timeout; new whole closed-PR pagination timed out. Used the dated complete snapshots above and fresh targeted reads. Search covers metadata and available local notes, not all PR diffs or unpublished work; no novelty certificate." + } + }, + "verification_scope": { + "actual_operator_comparisons": 253, + "accepted": 244, + "rejected": 9, + "providers": 2, + "coverage": "All-input operator equality on dimension 512, inferred from complete signed Pauli images and one whole exact anchor column. This is not sparse random-column sampling. Existing native/source/event controls remain unchanged.", + "unresolved": "Not established by this package: native operations outside the retained slice, full cleanup, physical ownership, supplier, precision/tape, all-size/compiler and outer admission. Concurrent PR3208 separately audits R2 cleanup; its evidence is not incorporated here." + }, + "validation": { + "registered_replay": "PASS_REGISTERED_RESEARCH_PACKAGE on CPython 3.12.14, including both commands and optimized Git-free export; 2026-10-17T18:06Z", + "cross_version": "CPython 3.14.7 Git-free export, optimized complete replay and three source corruption controls passed; 2026-10-17T18:06Z", + "publication_source_check": "All 12 retained files equal git-show bytes at pinned PR3202 head. All 25 input digests, comparison decisions and full-result digests agree across RESULT and nine-run BENCHMARK; engine hash matches measured source.", + "orientation_limitation": "The optional selected research_baseline.py check could not run because the sparse checkout omitted research/complex-sw4-frame8. No selected cold replay or selected-baseline PASS is claimed. All three exact caller baselines and the required package checks ran successfully." + } +} diff --git a/research/clifford-pauli-anchor/VERIFY.json b/research/clifford-pauli-anchor/VERIFY.json new file mode 100644 index 0000000000..ddcd3a48c6 --- /dev/null +++ b/research/clifford-pauli-anchor/VERIFY.json @@ -0,0 +1,43 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/clifford-state-performance/fast_state.py", + "research/frontier1094-recipes-exact-seed76/clifford.py", + "research/packed-clifford-gate-tables/adapter.py", + "research/rank7-shared-restore-fanin/evidence/NATIVE-RECEIPT.json", + "research/rank7-shared-restore-fanin/evidence/SOURCE-MANIFEST.json", + "research/rank7-shared-restore-fanin/evidence/WORD-base.json.gz", + "research/rank7-shared-restore-fanin/evidence/WORD-extra.json.gz", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_transport.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_emit.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_phases.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_adapters.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_gauss.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/vendor/clifford/clifford_exact.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Complete retained R2 audit with all original controls, exact result and call-multiset receipt; independent full-matrix Pauli/anchor checks and invalidation controls." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/test_package.py" + ], + "timeout_seconds": 180, + "checks": "Three source corruption controls and complete optimized replay from a Git-free export in a path with spaces." + } + ] +} diff --git a/research/clifford-pauli-anchor/benchmark.py b/research/clifford-pauli-anchor/benchmark.py new file mode 100644 index 0000000000..db469190bb --- /dev/null +++ b/research/clifford-pauli-anchor/benchmark.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +"""Fresh serial process benchmarks of the identical complete R2 audit. +Tekalign / OpenAI Codex, Apache-2.0. No acceptance timing threshold. +""" +import argparse +import json +from pathlib import Path +import platform +import statistics +import subprocess +import sys +import tempfile +import time + +PACKAGE = Path(__file__).resolve().parent + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--rounds', type=int, default=3) + parser.add_argument('--output', type=Path, required=True) + args = parser.parse_args() + if args.output.exists() or not 1 <= args.rounds <= 9: + raise ValueError('fresh output and 1..9 rounds required') + rows = [] + reference = None + orders = [('packed', 'cached', 'anchor'), ('anchor', 'cached', 'packed'), + ('cached', 'anchor', 'packed')] + with tempfile.TemporaryDirectory(prefix='anchor-benchmark-') as directory: + for trial in range(args.rounds): + for mode in orders[trial % len(orders)]: + target = Path(directory) / f'{trial}-{mode}.json' + command = [sys.executable, '-I', '-B', str(PACKAGE / 'replay.py'), + '--mode', mode, '--output', str(target)] + start = time.perf_counter() + process = subprocess.run(command, capture_output=True, text=True, timeout=180) + elapsed = time.perf_counter() - start + if process.returncode: + raise ValueError(process.stdout + process.stderr) + result = json.loads(target.read_bytes()) + semantic = {k: result[k] for k in ('reference_result_sha256', 'call_multiset_sha256', + 'calls', 'source_sha256', 'anchor_engine_sha256')} + if reference is None: + reference = semantic + elif semantic != reference: + raise ValueError('benchmark inputs, decisions or complete audit differ') + rows.append({'round': trial, 'mode': mode, 'process_wall_seconds': elapsed, + 'audit_wall_seconds': result['wall_seconds'], + 'equality_engine_seconds': result['engine_seconds']}) + print(process.stdout.strip(), flush=True) + medians = {mode: {field: statistics.median(x[field] for x in rows if x['mode'] == mode) + for field in ('process_wall_seconds', 'audit_wall_seconds', 'equality_engine_seconds')} + for mode in orders[0]} + report = {'scope': 'Complete retained PR3202 two-provider audit; native generation and full supplier admission excluded', + 'python': sys.version, 'platform': platform.platform(), 'rounds': args.rounds, + 'processes': 'fresh, sequential; alternating orders; OS caches not flushed; shared host', + 'semantic_identity': reference, 'samples': rows, 'medians': medians, + 'speedup_over': {mode: {field: medians[mode][field] / medians['anchor'][field] + for field in medians[mode]} for mode in ('packed', 'cached')}} + with args.output.open('x') as stream: + json.dump(report, stream, sort_keys=True, indent=2) + stream.write('\n') + print('PASS_SAME_INPUT_R2_BENCHMARK', json.dumps(report['speedup_over'], sort_keys=True)) + + +if __name__ == '__main__': + main() diff --git a/research/clifford-pauli-anchor/controls.py b/research/clifford-pauli-anchor/controls.py new file mode 100644 index 0000000000..be69a270f0 --- /dev/null +++ b/research/clifford-pauli-anchor/controls.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python3 +"""Independent matrix checks of every signed Pauli image and anchor. +Tekalign / OpenAI Codex, Apache-2.0. Oracle: Sagar Thakrar's packed kernel. +""" +import json +from pathlib import Path +import random +import types + +PACKAGE = Path(__file__).resolve().parent + + +def load(path, name): + m = types.ModuleType(name) + m.__file__ = str(path) + exec(compile(path.read_bytes(), str(path), 'exec'), m.__dict__) + return m + + +def check(): + R = load(PACKAGE / 'replay.py', 'source_replay') + E = load(PACKAGE / 'engine.py', 'anchor_controls_engine') + raw = R.capture()[R.KERNEL] + C = R.module(raw, 'packed_oracle', R.KERNEL) + rng = random.Random(86) + circuits = paulis = matrix_columns = comparisons = 0 + for n in range(1, 5): + C.N_AXES, C.DIM = n, 1 << n + for _ in range(24): + word = [] + for _ in range(12): + kind = rng.choice(('P', 'D', 'C', 'X', 'PH')) + if kind == 'P': + rows = [1 << j for j in range(n)] + if n > 1: + for _ in range(2 * n): + a, b = rng.sample(range(n), 2) + rows[a] ^= rows[b] + g = (kind, rows) + elif kind == 'D': + g = (kind, [rng.randrange(1 << n) for _ in range(n)], [rng.randrange(4) for _ in range(n)]) + elif kind == 'C': + g = (kind, rng.randrange(1, 1 << n), rng.choice((-1, 1))) + else: + g = (kind, rng.randrange(4 if kind == 'PH' else 1 << n)) + word.append(g) + frozen = E.freeze(word, n) + k = C.c_gates(word) + cols = C.columns(C.run(word, C.radix(k)), C.radix(k)) + state, denominator = E.anchor(frozen, n) + R.need(state == cols.get(0, {}) and denominator == k, 'anchor/full-matrix disagreement') + for index, (p, x, z) in enumerate(E.pauli_action(frozen, n)): + x0, z0 = (1 << index, 0) if index < n else (0, 1 << (index - n)) + for column in range(1 << n): + # Check U P = image(P) U directly on EVERY input column. + left = {y: E.rotate(v, 2 * ((column & z0).bit_count() % 2)) + for y, v in cols[column ^ x0].items()} + right = {y ^ x: E.rotate(v, p + 2 * ((y & z).bit_count() % 2)) + for y, v in cols[column].items()} + R.need(left == right, 'signed Pauli image disagrees with full matrix') + matrix_columns += 1 + paulis += 1 + before = json.dumps(word) + for other in (word, word + C.adjoint(word), [], word + [('PH', 1)], word + [('X', 1)]): + R.need(E.same_operator(word, other, n) == C.same_operator(word, other), 'differential comparator') + comparisons += 1 + R.need(json.dumps(word) == before, 'input mutation') + circuits += 1 + identity = E.freeze([], 2) + phase = E.freeze([('PH', 1)], 2) + character = E.freeze([('D', [0, 0], [2, 0])], 2) + R.need(E.pauli_action(identity, 2) == E.pauli_action(phase, 2) and + not E.same_operator([], [('PH', 1)], 2), 'Pauli-only phase blindness control') + R.need(E.anchor(identity, 2) == E.anchor(character, 2) and + not E.same_operator([], [('D', [0, 0], [2, 0])], 2), 'zero-column-only blindness control') + bad = [('T', 0), ('C', 0, 1), ('C', 1, 0), ('PH', True), ('X', 4), + ('P', [1, 1]), ('D', [0, 0], [0, 4]), ('PH', 1, 2)] + for gate in bad: + try: + E.same_operator([('X', 1), gate], [], 2) + except ValueError: + pass + else: + raise ValueError('invalid gate accepted: ' + repr(gate)) + # Cache keys include full immutable operands; caller mutation cannot reuse an old gate. + mutable = [('D', [0, 0], [0, 0])] + R.need(E.same_operator(mutable, [], 2), 'cache positive') + mutable[0][2][0] = 2 + R.need(not E.same_operator(mutable, [], 2), 'cache operand mutation') + R.need(E.tables.cache_info().currsize <= 64, 'bounded gate cache') + return {'seed': 86, 'circuits': circuits, 'signed_pauli_images': paulis, + 'matrix_column_relations': matrix_columns, 'differential_comparisons': comparisons, + 'invalid_gates_rejected': len(bad), 'phase_only_and_column_only_blindness_controls': 2, + 'cache_operand_mutation_rejected': True} + + +if __name__ == '__main__': + print(json.dumps(check(), sort_keys=True)) diff --git a/research/clifford-pauli-anchor/engine.py b/research/clifford-pauli-anchor/engine.py new file mode 100644 index 0000000000..a34243c16b --- /dev/null +++ b/research/clifford-pauli-anchor/engine.py @@ -0,0 +1,160 @@ +#!/usr/bin/env python3 +"""Exact signed-Pauli action and an absolute phase anchor, for 1..9 axes. + +Tekalign (@tekuuu), substantial OpenAI Codex assistance, Apache-2.0. +The complete tableau-plus-column criterion predates this implementation. +Gate conventions follow Sagar Thakrar's PR1781 kernel; bounded binary table +recurrences follow the credited PR662/2638 approach, independently coded here. +""" +from functools import lru_cache + + +def require(ok, message): + if not ok: + raise ValueError(message) + + +def parity(x): + return x.bit_count() & 1 + + +def inverse(rows): + n = len(rows) + a = [r | 1 << (n + j) for j, r in enumerate(rows)] + for j in range(n): + k = next((k for k in range(j, n) if a[k] >> j & 1), None) + require(k is not None, 'singular P gate') + a[k], a[j] = a[j], a[k] + for k in range(n): + if k != j and a[k] >> j & 1: + a[k] ^= a[j] + return tuple(r >> n for r in a) + + +def apply(rows, x): + return sum(parity(r & x) << j for j, r in enumerate(rows)) + + +def freeze(circuit, n): + require(type(n) is int and 1 <= n <= 9, 'axis domain 1..9') + require(isinstance(circuit, (list, tuple)), 'circuit sequence') + out = [] + for g in circuit: + require(isinstance(g, (list, tuple)) and len(g) > 0, 'gate sequence') + kind = g[0] + require(type(kind) is str and kind in ('P', 'D', 'C', 'X', 'PH'), 'unsupported gate') + require(len(g) == (3 if kind in ('D', 'C') else 2), 'gate arity') + if kind in ('P', 'D'): + require(isinstance(g[1], (list, tuple)) and len(g[1]) == n and + all(type(r) is int and 0 <= r < 1 << n for r in g[1]), 'binary rows') + if kind == 'P': + out.append((kind, tuple(g[1]))) + else: + require(isinstance(g[2], (list, tuple)) and len(g[2]) == n and + all(type(a) is int and 0 <= a < 4 for a in g[2]), 'Z4 linear coefficients') + out.append((kind, tuple(g[1]), tuple(g[2]))) + elif kind == 'C': + require(type(g[1]) is int and 0 < g[1] < 1 << n and + type(g[2]) is int and g[2] in (-1, 1), 'C gate domain') + out.append(tuple(g)) + else: + require(type(g[1]) is int and 0 <= g[1] < (4 if kind == 'PH' else 1 << n), 'offset/phase domain') + out.append(tuple(g)) + # Validate both complete words even if their early tableaus will differ. + for g in out: + tables(g, n) + return tuple(out) + + +@lru_cache(maxsize=64) +def tables(g, n): + """Immutable gate tables only; never cache states or equality decisions.""" + kind = g[0] + if kind == 'P': + inv = inverse(g[1]) + inv_transpose = tuple(sum(((inv[j] >> i) & 1) << j for j in range(n)) for i in range(n)) + cols = [apply(g[1], 1 << j) for j in range(n)] + table = [0] * (1 << n) + for x in range(1, 1 << n): + j = (x & -x).bit_length() - 1 + table[x] = table[x ^ (1 << j)] ^ cols[j] + return tuple(table), inv_transpose + if kind == 'D': + q, a = g[1:] + # The legacy semantics read only the strict upper triangle of Q. + cross = tuple((q[j] & ~((1 << (j + 1)) - 1)) | + sum(((q[i] >> j) & 1) << i for i in range(j)) for j in range(n)) + derivative = tuple(cross[j] | ((a[j] & 1) << j) for j in range(n)) + table = [0] * (1 << n) + for x in range(1, 1 << n): + bit = x & -x + j, y = bit.bit_length() - 1, x ^ bit + table[x] = (table[y] + a[j] + 2 * parity(cross[j] & y)) % 4 + return tuple(table), derivative + return () + + +def pauli_action(word, n): + """Images of X_j then Z_j, in the convention i^p X^x Z^z.""" + images = [(0, 1 << j, 0) for j in range(n)] + [(0, 0, 1 << j) for j in range(n)] + for g in word: + kind = g[0] + updated = [] + for p, x, z in images: + if kind == 'P': + permutation, inv_t = tables(g, n) + x, z = permutation[x], apply(inv_t, z) + elif kind == 'D': + phases, derivative = tables(g, n) + p, z = p + phases[x], z ^ apply(derivative, x) + elif kind == 'X': + p += 2 * parity(z & g[1]) + elif kind == 'C' and parity(z & g[1]): + p, x = p - g[2], x ^ g[1] + updated.append((p % 4, x, z)) + images = updated + return tuple(images) + + +def rotate(value, k): + a, b = value + return ((a, b), (-b, a), (-a, -b), (b, -a))[k % 4] + + +def anchor(word, n): + """U|0>, as a sparse Gaussian-integer vector divided by 2^k.""" + state, k = {0: (1, 0)}, 0 + for g in word: + kind = g[0] + if kind == 'P': + perm = tables(g, n)[0] + state = {perm[x]: v for x, v in state.items()} + elif kind == 'X': + state = {x ^ g[1]: v for x, v in state.items()} + elif kind in ('D', 'PH'): + phases = tables(g, n)[0] if kind == 'D' else None + state = {x: rotate(v, phases[x] if phases is not None else g[1]) for x, v in state.items()} + else: + q, s = g[1:] + out = {} + for x in state.keys() | {x ^ q for x in state}: + a, b = state.get(x, (0, 0)) + c, d = state.get(x ^ q, (0, 0)) + v = (a - s * b + c + s * d, s * a + b - s * c + d) + if v != (0, 0): + out[x] = v + state, k = out, k + 1 + return state, k + + +def same_operator(first, second, n=9): + """Exact operator equality, including global phase; no sampling.""" + a, b = freeze(first, n), freeze(second, n) + if pauli_action(a, n) != pauli_action(b, n): + return False + (v, k), (w, ell) = anchor(a, n), anchor(b, n) + if v.keys() != w.keys(): + return False + K = max(k, ell) + return all((v[x][0] << (K - k), v[x][1] << (K - k)) == + (w[x][0] << (K - ell), w[x][1] << (K - ell)) for x in v) diff --git a/research/clifford-pauli-anchor/replay.py b/research/clifford-pauli-anchor/replay.py new file mode 100644 index 0000000000..c1c31353fd --- /dev/null +++ b/research/clifford-pauli-anchor/replay.py @@ -0,0 +1,133 @@ +#!/usr/bin/env python3 +"""Opt-in replay of the unchanged PR3202 audit with one comparator substitution. + +Tekalign / OpenAI Codex, Apache-2.0. Original audit: 24kHandsome1201. +Packed kernel: Sagar Thakrar. Cached baseline: ywz65 and Charles Bethin. +""" +import argparse +import hashlib +import json +from pathlib import Path +import tempfile +import time +import types + +PACKAGE = Path(__file__).resolve().parent +ROOT = PACKAGE.parents[1] +ORIGINAL = 'research/pr3044-r2-native-slice/' +KERNEL = 'research/frontier1094-recipes-exact-seed76/clifford.py' +CACHED = 'research/packed-clifford-gate-tables/adapter.py' +TABLES = 'research/clifford-state-performance/fast_state.py' +VENDOR = 'research/clifford-pauli-anchor/vendor/pr3202/' + + +def need(ok, reason): + if not ok: + raise ValueError(reason) + + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(',', ':')).encode() + + +def digest(raw): + return hashlib.sha256(raw).hexdigest() + + +def capture(root=ROOT): + manifest = json.loads((PACKAGE / 'SOURCES.json').read_bytes()) + found = {} + for row in manifest['files'] + manifest['vendored_files']: + path = row['path'] + if row['usage'] != 'input' and not path.startswith(VENDOR): + continue + raw = (root / path).read_bytes() + need(digest(raw) == row['sha256'], 'source drift: ' + path) + blob = b'blob ' + str(len(raw)).encode() + b'\0' + raw + need(hashlib.sha1(blob, usedforsecurity=False).hexdigest() == row['git_blob'], 'source blob') + target = ORIGINAL + path[len(VENDOR):] if path.startswith(VENDOR) else path + need(target not in found, 'duplicate snapshot destination') + found[target] = raw + need(len(found) == 25, 'complete snapshot inventory') + return found + + +def module(raw, name, path): + obj = types.ModuleType(name) + obj.__file__ = str(path) + exec(compile(raw, str(path), 'exec'), obj.__dict__) + return obj + + +def run(mode='anchor'): + need(mode in ('packed', 'cached', 'anchor'), 'engine mode') + start = time.perf_counter() + sources = capture() + new_engine_raw = (PACKAGE / 'engine.py').read_bytes() + new_engine = module(new_engine_raw, 'pauli_anchor_engine', PACKAGE / 'engine.py') + cached = module(sources[CACHED], 'credited_cached_adapter', ROOT / CACHED) + counts = {'calls': 0, 'accepted': 0, 'rejected': 0} + call_inputs = [] + engine_seconds = 0.0 + def install(kernel): + if mode == 'cached': + p, d = cached.table_functions(sources[TABLES]) + kernel._permutation_table, kernel._phase_table = p, d + exec(compile(cached.transform(sources[KERNEL]), KERNEL, 'exec'), kernel.__dict__) + compare = new_engine.same_operator if mode == 'anchor' else kernel.same_operator + def checked(a, b): + nonlocal engine_seconds + before = time.perf_counter() + result = compare(a, b) + engine_seconds += time.perf_counter() - before + call_inputs.append(digest(canonical([a, b, result]))) + counts['calls'] += 1 + counts['accepted' if result else 'rejected'] += 1 + return result + kernel.same_operator = checked + with tempfile.TemporaryDirectory(prefix='pauli-anchor-') as directory: + snapshot = Path(directory) + for path, raw in sources.items(): + target = snapshot / path + target.parent.mkdir(parents=True, exist_ok=True) + target.write_bytes(raw) + raw = sources[ORIGINAL + 'verify.py'] + anchor = " exec(compile(blobs[KERNEL], KERNEL, 'exec'), kernel.__dict__)" + text = raw.decode() + need(text.count(anchor) == 1, 'unique comparator installation anchor') + changed = text.replace(anchor, anchor + '\n _install_comparator(kernel)').encode() + verifier = types.ModuleType('source_bound_r2_audit') + verifier.__file__ = str(snapshot / ORIGINAL / 'verify.py') + verifier._install_comparator = install + exec(compile(changed, verifier.__file__, 'exec'), verifier.__dict__) + result = verifier.compute(snapshot / ORIGINAL / 'data') + expected = json.loads(sources[ORIGINAL + 'RESULT.json']) + need(canonical(result) == canonical(expected), 'complete predecessor result mismatch') + for path, raw in sources.items(): + need((snapshot / path).read_bytes() == raw, 'snapshot mutation') + return {'mode': mode, 'reference_result': result, 'reference_result_sha256': digest(canonical(result)), + 'calls': counts, 'executed_verifier_sha256': digest(changed), + 'call_multiset_sha256': digest(canonical(sorted(call_inputs))), + 'anchor_engine_sha256': digest(new_engine_raw), + 'source_sha256': {p: digest(b) for p, b in sorted(sources.items())}, + 'engine_seconds': engine_seconds, 'wall_seconds': time.perf_counter() - start, + 'reference_kernel_field': 'The unchanged nested result names the loaded source kernel; execution mode and comparator source are recorded separately here.'} + + +def main(): + ap = argparse.ArgumentParser(description=__doc__) + ap.add_argument('--mode', choices=('packed', 'cached', 'anchor'), default='anchor') + ap.add_argument('--output', type=Path) + args = ap.parse_args() + need(args.output is None or not args.output.exists(), 'output already exists') + result = run(args.mode) + if args.output: + with args.output.open('x') as f: + json.dump(result, f, sort_keys=True, indent=2) + f.write('\n') + print('PASS_R2_EXACT_COMPARATOR', args.mode, 'calls=' + str(result['calls']), + 'wall_seconds=' + str(round(result['wall_seconds'], 3))) + + +if __name__ == '__main__': + main() diff --git a/research/clifford-pauli-anchor/test_package.py b/research/clifford-pauli-anchor/test_package.py new file mode 100644 index 0000000000..d5722a7086 --- /dev/null +++ b/research/clifford-pauli-anchor/test_package.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +"""Source corruption and clean export controls; no Git/network needed. +Tekalign / OpenAI Codex, Apache-2.0. +""" +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile +import types + +PACKAGE = Path(__file__).resolve().parent +ROOT = PACKAGE.parents[1] + + +def load_replay(path): + module = types.ModuleType('exported_anchor_replay') + module.__file__ = str(path) + exec(compile(path.read_bytes(), str(path), 'exec'), module.__dict__) + return module + + +def main(): + manifest = json.loads((PACKAGE / 'SOURCES.json').read_bytes()) + with tempfile.TemporaryDirectory(prefix='anchor export ') as directory: + root = Path(directory) + target = root / PACKAGE.relative_to(ROOT) + shutil.copytree(PACKAGE, target, ignore=shutil.ignore_patterns('__pycache__')) + for row in manifest['files']: + if row['usage'] == 'input': + destination = root / row['path'] + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(ROOT / row['path'], destination) + replay = load_replay(target / 'replay.py') + captured = replay.capture() + if len(captured) != 25 or (root / '.git').exists(): + raise ValueError('clean complete source export') + # Mutate a live engine, a retained recipe and retained checker independently. + mutants = [root / replay.KERNEL, target / 'vendor/pr3202/data/base/CLIFFORD-RECIPES.json.gz', + target / 'vendor/pr3202/verify.py'] + for file in mutants: + original = file.read_bytes() + file.write_bytes(original + b'\n') + try: + replay.capture() + except ValueError as error: + if 'source drift:' not in str(error): + raise + else: + raise ValueError('source corruption accepted') + file.write_bytes(original) + if replay.capture() != captured: + raise ValueError('export restoration') + command = [sys.executable, '-I', '-O', '-B', str(target / 'verify.py')] + process = subprocess.run(command, cwd=root, text=True, capture_output=True, timeout=120) + if process.returncode or 'PASS_CLIFFORD_PAULI_ANCHOR' not in process.stdout: + raise ValueError(process.stdout + process.stderr) + print('PASS_ANCHOR_EXPORT source_mutants=3 optimized_full_replay=1') + + +if __name__ == '__main__': + main() diff --git a/research/clifford-pauli-anchor/vendor/pr3202/README.md b/research/clifford-pauli-anchor/vendor/pr3202/README.md new file mode 100644 index 0000000000..b05efddf13 --- /dev/null +++ b/research/clifford-pauli-anchor/vendor/pr3202/README.md @@ -0,0 +1,151 @@ +# PR3044 R2: independent native slice and residual wrappers + +This package follows [PR3146's released next question](https://github.com/CrocSwap/integer-mult-bounds/pull/3146): +independently interpret the native phase/residual-adapter boundary of Nick +Petalas's R2 shared restore. It checks the actual **base and extra** providers +of [PR3044](https://github.com/CrocSwap/integer-mult-bounds/pull/3044), head +`1f922b25abff2d7fd87fa5b29619160862a06b59`, as archived at canonical main +`997e6a9ca7b4f95d50e366f61412fd640d72a88a`. + +**Result:** the three changed native child recipes, four ordinary source +endpoint adapters, and all **54 used residual recipes per provider** satisfy +their exact operator identities on all 512 complex coordinates, including +global phase, in both orientations. The emitted tail and final steps and every +residual wrapper's owner, side and phase agree with independently reconstructed +source boundaries. This is a finite, scoped verification result. It supplies +no new construction, kappa, physical realization or supplier admission. + +## Missing coverage and independence + +PR3044 already checks rational R1/R2 equality, frame charges and a complete +release using its native engine. Hiroki Kumazaki's PR3146 independently runs +that release and adds separate local/binding checks, while explicitly leaving +native semantics dependent on the inherited engine. + +The new `verify.py` does not import the producer, lowering compiler, original +R2 evaluator or frame tracer. Its new source/event binding uses explicit finite +binary spans and sparse rational rows. For native arithmetic it **reuses**, with +an exact source pin, Sagar Thakrar's separately implemented +[`clifford.py`](../frontier1094-recipes-exact-seed76/clifford.py). That established +stdlib kernel interprets primitive circuits as packed Gaussian-integer matrices +with a proved non-aliasing radix. This package does not claim a new kernel or +independence from that auditor. Hand calibrations cover C squared, inverse and +global-phase sensitivity. New fault controls test the changed boundary. + +The eight retained native artifacts were freshly regenerated using the original +six source-bound engine files. All eight raw artifact hashes matched PR3044's +published native receipt in the recorded environment. Generation and checking +are distinct: producer PASS messages establish no independent native identity. +The default verifier authenticates the complete artifacts, then interprets +their selected semantic payloads itself. JSON artifacts are gzip-compressed for +storage; their uncompressed original bytes are authenticated. Existing `.gz` +artifacts retain their original bytes. + +## Exact scope and argument + +Write W = span(256,128,64,34,17,11,4), E = +span(256,128,64,34,16,10,4,1), and F for the full nine-dimensional frame. +R2 forms X40 − 2 X54 at W, serves the X18 and X22 consumers at E, then +restores X40 at F. The changed native trace, using zero-based restore indices, +is: + +| Restore index | Register | Transition | Charged rank | +|---|---|---|---| +| 163 | X40 | W → E | 1 | +| 203 | X40 | E → F | 1 | +| 203 | X54 | W → F | 2 | + +For each serialized child, the checker proves `L F_r R = T_new T_old^-1` +with every phase retained, and proves that composing the two rank-one recipes +equals the rank-two recipe. A componentwise rational scalar commutes with the +common frame operator. Provided the unchanged native operations realize their +declared frame maps, these identities validate the changed R2 lowering in +physical coordinates. The full 204-gate scalar tail is compared with the +reconstructed R1 control on all 632 arbitrary input columns in both orientations. +This corroborates the earlier scalar check and connects it to the native slice. + +The four named registers are ordinary sources, with source endpoint adapters +and FULL exits, **not residual-wrapped helpers**. Their source endpoint identities +are separately checked. The current source maps also determine every wrapped +helper. For each of the 54 used residual recipes the checker proves +`L^-1 T_terminal T_entrance^-1 R^-1 = F_width`; the inverse-transpose orientation +uses complex conjugation of these unitary frame operators. All emitted pre/post +wrapper occurrences must have the correct helper, side, entrance/terminal IDs +and phase. This validates wrapper identities and placement; it does not prove +that every intervening native operation realizes its declared reference map. + +The source A/B frame trace is reconstructed from word data. A separate scan of +the emitted prefix checks frame transition chronology and its tail entrance. +Prefix native phase semantics are an explicit premise. No end-to-end physical +executor or all-register native theorem is inferred from these checks. + +## Reproduction + +From the repository root, Python 3.12, standard library only: + +```sh +python3 -B scripts/research_package.py --package research/pr3044-r2-native-slice +python3 -I -O -B research/pr3044-r2-native-slice/verify.py +``` + +The registered command reads source-bound saved artifacts; it does not generate +them. Its semantic controls operate **after authentication**, requiring each +mutant to fail the named semantic predicate. They cover both fan-in signs, +the rank-two charge, phase order, source frame chronology, dirty restoration, +an extra observer, ordinary source exits, wrapper side/owner and post-cleanup ordering, child phase/rank/ +translation and residual phase/translation. `RESULT.json` records exact counts. + +Optional producer regeneration requires NumPy (the recorded run used 2.3.5): + +```sh +python3 -B research/pr3044-r2-native-slice/reproduce.py --output /tmp/r2-native-fresh +``` + +Use a new output directory. This runs four inherited stages sequentially for +each provider, then compares every proof-relevant JSON field with the +authenticated retained artifacts. Container bytes may differ with Python/zlib; +payload equality is the portable regeneration gate. The full PR3044/3146 +13-stage source/admission/outer replay was not repeated here. See +`ENVIRONMENT.json` and `evidence/` for this session's exact generation evidence. + +## Limits + +Other native child recipes, warp semantics, full-frame cleanup semantics, +physical owner geometry/stock, precision/tape, caller contracts, all-size +compilation, analytic transfer and universal block-energy obligations remain. +The earlier all-input and complete-release results retain their original +evidence status. No selected-frontier record or predecessor file is changed. + +## Open next questions + +1. Extend the native interpretation to the remaining R2 dependency cone, + especially the full-frame inverse cleanup and its private buffers. Begin + with the authenticated `LOCAL-PROGRAMS` and the source restore-to-cleanup + mapping. The gap is the complete physical map, not artifact availability. +2. Independently check the physical executor's use of the serialized native + records and their actual owner locations. Begin with these three child events + and the current hosted template. Exact recipe identities alone do not + discharge executor, routing or ownership contracts. + +Structured scope, original card, overlap coverage and next steps are in +`TASK.json`. This answers a specific historical handoff; it makes no claim to +the newest unreviewed candidate or exclusive novelty. Metadata/discussion +coverage does not include unpublished work or every historical diff. + +## Credit + +24kHandsome1201 with substantial OpenAI Codex assistance for analysis, code, +execution and writing. No independent human or proof-kernel review is claimed. +Nick Petalas contributed R2, its finite checks and original release; Jeremy +Kothe contributed R1 and the literal rewrite/cleanup machinery; Marius-Paul +Dumitrean contributed the joint rank-7 words/allocation; Hiroki Kumazaki supplied +the external cold replay and this handoff. Sagar Thakrar supplied the reused +independent exact kernel. The earlier V45 event-binding audit is credited for +the source-to-native audit approach; its checker is not imported. + +Credit also Cinna Davis, DreamingOfClouds, icekylinx, chafreaky, Mason Hale, +Jeremy Diviney, Yiyang Lu, Tekalign, Ross Richardson and the retained native, +geometry and owner lineage. Existing notices remain in their source packages, +including [PR3015 credits](../rank7-shared-restore-fanin/vendor/PR3015-CREDITS.md) +and [notice](../rank7-shared-restore-fanin/vendor/PR3015-NOTICE). +Code and generated data retain Apache-2.0 licensing. diff --git a/research/clifford-pauli-anchor/vendor/pr3202/RESULT.json b/research/clifford-pauli-anchor/vendor/pr3202/RESULT.json new file mode 100644 index 0000000000..87f87bc4bb --- /dev/null +++ b/research/clifford-pauli-anchor/vendor/pr3202/RESULT.json @@ -0,0 +1,239 @@ +{ + "kernel_sha256": "d5e42ddabd141b7bfbd70fe13908f3c3a06aeccebeab90623596bfb1988b97fb", + "providers": { + "base": { + "events": { + "backward": { + "changed_climbs": [ + [ + 163, + [ + "climb", + "cleanup_tail", + 40, + 254, + 250, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 40, + 250, + 1, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 54, + 254, + 1, + 2 + ] + ] + ], + "events": 22748, + "final_events": 425, + "tail_events": 328, + "wrapper_occurrences": 390 + }, + "forward": { + "changed_climbs": [ + [ + 163, + [ + "climb", + "cleanup_tail", + 40, + 254, + 250, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 40, + 250, + 1, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 54, + 254, + 1, + 2 + ] + ] + ], + "events": 22748, + "final_events": 425, + "tail_events": 328, + "wrapper_occurrences": 390 + } + }, + "native": { + "changed_child_recipes": 3, + "native_columns_each": 512, + "orientations": 2, + "phase_included": true, + "residual_recipes": 54, + "source_endpoint_recipes": 4 + }, + "rejected_controls": [ + "forward fan-in sign", + "dual fan-in sign", + "rank-two child undercharge", + "tail phase substitution", + "wrapper side", + "dual wrapper owner", + "post wrappers before cleanup", + "source exit frame", + "missing dirty restoration", + "extra fan-in observer", + "prefix wrong source frame", + "native global phase", + "native translation", + "native child rank", + "residual global phase", + "residual translation" + ], + "scalar_control": { + "columns_per_orientation": 632, + "restore_gates": 204 + } + }, + "extra": { + "events": { + "backward": { + "changed_climbs": [ + [ + 163, + [ + "climb", + "cleanup_tail", + 40, + 254, + 250, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 40, + 250, + 1, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 54, + 254, + 1, + 2 + ] + ] + ], + "events": 22748, + "final_events": 425, + "tail_events": 328, + "wrapper_occurrences": 390 + }, + "forward": { + "changed_climbs": [ + [ + 163, + [ + "climb", + "cleanup_tail", + 40, + 254, + 250, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 40, + 250, + 1, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 54, + 254, + 1, + 2 + ] + ] + ], + "events": 22748, + "final_events": 425, + "tail_events": 328, + "wrapper_occurrences": 390 + } + }, + "native": { + "changed_child_recipes": 3, + "native_columns_each": 512, + "orientations": 2, + "phase_included": true, + "residual_recipes": 54, + "source_endpoint_recipes": 4 + }, + "rejected_controls": [ + "forward fan-in sign", + "dual fan-in sign", + "rank-two child undercharge", + "tail phase substitution", + "wrapper side", + "dual wrapper owner", + "post wrappers before cleanup", + "source exit frame", + "missing dirty restoration", + "extra fan-in observer", + "prefix wrong source frame", + "native global phase", + "native translation", + "native child rank", + "residual global phase", + "residual translation" + ], + "scalar_control": { + "columns_per_orientation": 632, + "restore_gates": 204 + } + } + }, + "scope": "R2 tail/final binding, three native children, four source endpoints, all used residual recipes and placement. Other native phases, physical owners, full cleanup semantics and supplier/outer theorem remain outside this audit.", + "status": "PASS_PR3044_R2_NATIVE_SLICE" +} diff --git a/research/clifford-pauli-anchor/vendor/pr3202/SOURCES.json b/research/clifford-pauli-anchor/vendor/pr3202/SOURCES.json new file mode 100644 index 0000000000..71f2c61df0 --- /dev/null +++ b/research/clifford-pauli-anchor/vendor/pr3202/SOURCES.json @@ -0,0 +1,84 @@ +{ + "schema_version": 1, + "base_commit": "997e6a9ca7b4f95d50e366f61412fd640d72a88a", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "67f085acd86acd7d4e03922d9cf4b26bca66fed5", + "sha256": "47b42433f5a85809a3aadd29c2c339da2c6ed728e4f7762df6b88bccb7874cf0" + }, + { + "path": "research/frontier1094-recipes-exact-seed76/clifford.py", + "usage": "input", + "git_blob": "6f1e6a38febde7eb7a7341d317522e6650d84408", + "sha256": "d5e42ddabd141b7bfbd70fe13908f3c3a06aeccebeab90623596bfb1988b97fb" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/NATIVE-RECEIPT.json", + "usage": "input", + "git_blob": "9b7c498ed6f92be5f1c4a85a1f25427788647fc1", + "sha256": "3dce85d535c34dd5755b7a7828b9706cd38198aa99e849dc0f166ac4e7ea47df" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/SOURCE-MANIFEST.json", + "usage": "input", + "git_blob": "ff42fd06f9ede0e1a717766232e283005336f935", + "sha256": "4f52f55eb311319a7e8ac7de7f4e9cc45e36166270db42c21c955c96a2e0639c" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/WORD-base.json.gz", + "usage": "input", + "git_blob": "51b0b3c912565b7e12b3a2f8a3c0ccd37290206b", + "sha256": "08e7e10e49053b97b7ae8a7e93f085ade519f3d270ed54b9c0c3a19236a4d267" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/WORD-extra.json.gz", + "usage": "input", + "git_blob": "23915f0bec7533ce0658cac8c7ae2069873efe4b", + "sha256": "9c625893f09e46688fc650e1d65d05a416b504e2dcffe5fefdc4181c6de22479" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_transport.py", + "usage": "input", + "git_blob": "08248542b18864c94a5ac050c8669f68519838e1", + "sha256": "9818e08b819310b40f1441b89be8c4369584a5b3fa5dfe9b86b1df9a7f5d6a76" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_emit.py", + "usage": "input", + "git_blob": "6d47f63ab7a533941b3881bbfd3ae4dac5f76932", + "sha256": "99b59a6fa3feda86785e4225157dcb1a6169d256cec4f5e0acc9cea7a701df76" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_phases.py", + "usage": "input", + "git_blob": "99f351785ebca5fbf3336bedcd7b48bac9c255e5", + "sha256": "9d1a620e26715f4c42fd0347ecc14ef5a4a9031867869b64e8bae4d8526a821e" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_adapters.py", + "usage": "input", + "git_blob": "82beaa9c1d13bcd5f79d0a5e10e8a10733eac347", + "sha256": "c5907050a9a7fa36d4fcba3ad4fe440d1bec2063360c095013891785ba65c3ce" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_gauss.py", + "usage": "input", + "git_blob": "1ff29dfb244e2114de8e586a450ae9fb70308d58", + "sha256": "0884b14d6d77cde419a3c773ad9b21d0d18de1e6e20e6b6d5add458ed32ba4cb" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/vendor/clifford/clifford_exact.py", + "usage": "input", + "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + } + ] +} diff --git a/research/clifford-pauli-anchor/vendor/pr3202/data/base/CANONICAL-WORD.json.gz b/research/clifford-pauli-anchor/vendor/pr3202/data/base/CANONICAL-WORD.json.gz new file mode 100644 index 0000000000..3958b8cf77 Binary files /dev/null and b/research/clifford-pauli-anchor/vendor/pr3202/data/base/CANONICAL-WORD.json.gz differ diff --git a/research/clifford-pauli-anchor/vendor/pr3202/data/base/CLIFFORD-RECIPES.json.gz b/research/clifford-pauli-anchor/vendor/pr3202/data/base/CLIFFORD-RECIPES.json.gz new file mode 100644 index 0000000000..0591c6af1b Binary files /dev/null and b/research/clifford-pauli-anchor/vendor/pr3202/data/base/CLIFFORD-RECIPES.json.gz differ diff --git a/research/clifford-pauli-anchor/vendor/pr3202/data/base/LOCAL-PROGRAMS.json.gz b/research/clifford-pauli-anchor/vendor/pr3202/data/base/LOCAL-PROGRAMS.json.gz new file mode 100644 index 0000000000..9ad65235dc Binary files /dev/null and b/research/clifford-pauli-anchor/vendor/pr3202/data/base/LOCAL-PROGRAMS.json.gz differ diff --git a/research/clifford-pauli-anchor/vendor/pr3202/data/base/RESIDUAL-ADAPTERS.json.gz b/research/clifford-pauli-anchor/vendor/pr3202/data/base/RESIDUAL-ADAPTERS.json.gz new file mode 100644 index 0000000000..3e154660a1 Binary files /dev/null and b/research/clifford-pauli-anchor/vendor/pr3202/data/base/RESIDUAL-ADAPTERS.json.gz differ diff --git a/research/clifford-pauli-anchor/vendor/pr3202/data/extra/CANONICAL-WORD.json.gz b/research/clifford-pauli-anchor/vendor/pr3202/data/extra/CANONICAL-WORD.json.gz new file mode 100644 index 0000000000..c2c7a69938 Binary files /dev/null and b/research/clifford-pauli-anchor/vendor/pr3202/data/extra/CANONICAL-WORD.json.gz differ diff --git a/research/clifford-pauli-anchor/vendor/pr3202/data/extra/CLIFFORD-RECIPES.json.gz b/research/clifford-pauli-anchor/vendor/pr3202/data/extra/CLIFFORD-RECIPES.json.gz new file mode 100644 index 0000000000..887f5bfc36 Binary files /dev/null and b/research/clifford-pauli-anchor/vendor/pr3202/data/extra/CLIFFORD-RECIPES.json.gz differ diff --git a/research/clifford-pauli-anchor/vendor/pr3202/data/extra/LOCAL-PROGRAMS.json.gz b/research/clifford-pauli-anchor/vendor/pr3202/data/extra/LOCAL-PROGRAMS.json.gz new file mode 100644 index 0000000000..9ad65235dc Binary files /dev/null and b/research/clifford-pauli-anchor/vendor/pr3202/data/extra/LOCAL-PROGRAMS.json.gz differ diff --git a/research/clifford-pauli-anchor/vendor/pr3202/data/extra/RESIDUAL-ADAPTERS.json.gz b/research/clifford-pauli-anchor/vendor/pr3202/data/extra/RESIDUAL-ADAPTERS.json.gz new file mode 100644 index 0000000000..3cb1e2927f Binary files /dev/null and b/research/clifford-pauli-anchor/vendor/pr3202/data/extra/RESIDUAL-ADAPTERS.json.gz differ diff --git a/research/clifford-pauli-anchor/vendor/pr3202/verify.py b/research/clifford-pauli-anchor/vendor/pr3202/verify.py new file mode 100644 index 0000000000..0ed4963416 --- /dev/null +++ b/research/clifford-pauli-anchor/vendor/pr3202/verify.py @@ -0,0 +1,487 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""Source-bound R2 native slice; no native producer code is imported.""" +import argparse +import copy +from fractions import Fraction +import gzip +import hashlib +import json +from pathlib import Path +import types + +PACKAGE = Path(__file__).resolve().parent +ROOT = PACKAGE.parents[1] +SOURCE = 'research/rank7-shared-restore-fanin/evidence/' +KERNEL = 'research/frontier1094-recipes-exact-seed76/clifford.py' +W = [256, 128, 64, 34, 17, 11, 4] +E = [256, 128, 64, 34, 16, 10, 4, 1] +FULL = [256, 128, 64, 32, 16, 8, 4, 2, 1] +PHASES = ['zero_frame_precondition', 'entry_adapters', 'A', 'centers', 'B', + 'cleanup_tail', 'final', 'exit_adapters', 'full_frame_cleanup', 'done'] +FILES = ('CANONICAL-WORD.json.gz', 'LOCAL-PROGRAMS.json.gz', + 'CLIFFORD-RECIPES.json', 'RESIDUAL-ADAPTERS.json') + + +def need(ok, reason): + if not ok: + raise ValueError(reason) + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def unique(pairs): + out = dict(pairs) + need(len(out) == len(pairs), 'duplicate JSON key') + return out + + +def parse(raw): + need(len(raw) <= 16 * 1024 * 1024, 'artifact capacity') + return json.loads(raw, object_pairs_hook=unique) + + +def read(path): + raw = path.read_bytes() + return parse(gzip.decompress(raw) if path.suffix == '.gz' else raw) + + +def pin_inputs(): + blobs = {} + for row in read(PACKAGE / 'SOURCES.json')['files']: + if row['usage'] == 'input': + raw = (ROOT / row['path']).read_bytes() + need(sha(raw) == row['sha256'], 'source pin: ' + row['path']) + blobs[row['path']] = raw + required = {KERNEL, SOURCE + 'NATIVE-RECEIPT.json', SOURCE + 'SOURCE-MANIFEST.json', + SOURCE + 'WORD-base.json.gz', SOURCE + 'WORD-extra.json.gz'} + need(required <= set(blobs), 'required source inventory') + return blobs + + +def artifacts(blobs, tag, data): + receipt = parse(blobs[SOURCE + 'NATIVE-RECEIPT.json'])['providers'][tag] + need(sha(blobs[SOURCE + f'WORD-{tag}.json.gz']) == receipt['word_sha256'], 'provider word binding') + out = {} + for name in FILES: + path = data / tag / (name if name.endswith('.gz') else name + '.gz') + raw = path.read_bytes() + original = raw if name.endswith('.gz') else gzip.decompress(raw) + need(sha(original) == receipt['complete_native_files']['local/' + name], + 'native artifact binding: ' + tag + '/' + name) + out[name] = parse(gzip.decompress(original) if name.endswith('.gz') else original) + return out + + +def span(rows): + out = {0} + for x in rows: + need(type(x) is int and 0 < x < 512 and x not in out, 'independent binary frame') + out |= {y ^ x for y in out} + return frozenset(out) + + +def regs(g): + need(g[0] in ('add', 'scale'), 'restore gate kind') + need(len(g) == (6 if g[0] == 'add' else 5), 'restore gate schema') + return g[1:3] if g[0] == 'add' else g[1:2] + + +def frame_boundaries(word, canonical): + """Read source frame labels, independently of the emitted prefix.""" + need((word['report']['h'], word['report']['v'], word['report']['R']) == (9, 112, 480), 'source domain') + need((canonical['h'], canonical['v'], canonical['R']) == (9, 112, 408) + and canonical['ports'] == word['ports'], 'canonical domain and source ports') + kept = [r for r in range(704) if r not in word['removed']] + need(len(kept) == 632 and kept[224:] == canonical['helper_origin'], 'compact map') + frames = canonical['frames'] + spaces = [span(f) for f in frames] + need(len(set(spaces)) == len(spaces), 'unique canonical frames') + ids = {s: i for i, s in enumerate(spaces)} + starts = {r: [word['ports'][r]] if r < 112 else [] for r in kept} + starts.update({int(r): f for r, f in word['start_extra'].items()}) + need([ids[span(starts[r])] for r in kept] == canonical['start'], 'source entrances') + finals = {r: FULL for r in kept} + for r in range(112, 224): + p = word['ports'][r - 112] + need(spaces[canonical['final'][r]] == frozenset(x for x in range(512) if (x & p).bit_count() % 2 == 0), + 'target terminal frame') + finals[r] = frames[canonical['final'][r]] + finals.update({int(r): f for r, f in word['helper_final'].items()}) + need([ids[span(finals[r])] for r in kept] == canonical['final'], 'source terminals') + state = {r: ids[span(starts[r])] for r in kept} + + def move(r, target): + f = ids[span(target)] + need(spaces[state[r]] <= spaces[f], 'source monotone frame') + state[r] = f + + for g in word['A']: + if g[0] == 'warp': + need(state[g[1]] == ids[span(g[3])], 'A warp boundary') + state[g[1]] = ids[span(g[4])] + else: + for r in regs(g): + move(r, g[-1]) + warps = {} + for pos, r, _columns, old, new in word['warps']: + warps.setdefault(pos, []).append((r, old, new)) + for i in range(len(word['B']) + 1): + for r, old, new in warps.get(i, []): + need(state[r] == ids[span(old)], 'B warp boundary') + state[r] = ids[span(new)] + if i < len(word['B']): + for r in regs(word['B'][i]): + move(r, word['B'][i][-1]) + return kept, ids, [state[r] for r in kept] + + +def scalar(g, mapping, backward): + operands = [['L', mapping[r]] for r in regs(g)] + a, b = g[-3:-1] + need(type(a) is int and type(b) is int and a and b, 'nonzero rational scalar') + if backward and g[0] == 'add': + operands.reverse() + a = -a + elif backward: + a, b = b, a + return [g[0], *operands, a, b] + + +def expected_tail(word, canonical, kept, ids, boundary, backward): + state = boundary.copy() + mapping = {r: i for i, r in enumerate(kept)} + frames = canonical['frames'] + spaces = [span(f) for f in frames] + out, touched = [], [] + for i, g in enumerate(word['restore']): + f = ids[span(g[-1])] + for old_r in regs(g): + r = mapping[old_r] + old = state[r] + need(spaces[old] <= spaces[f], 'tail monotone frame') + if old != f: + event = ['climb', 'cleanup_tail', r, old, f, len(frames[f]) - len(frames[old])] + out.append(event) + if old_r in (40, 54) and i >= 162: + touched.append([i, event]) + state[r] = f + out.append(['scalar', scalar(g, mapping, backward), f]) + final = [] + for r, f in enumerate(canonical['final']): + old = state[r] + need(spaces[old] <= spaces[f], 'final monotone frame') + if old != f: + final.append(['climb', 'final', r, old, f, len(frames[f]) - len(frames[old])]) + return out, final, touched + + +def bind_events(word, canonical, programs): + kept, ids, boundary = frame_boundaries(word, canonical) + frames = canonical['frames'] + wrapped = [r for r in range(224, len(kept)) if canonical['start'][r] != 0 or canonical['final'][r] != 1] + keys = [str(canonical['start'][r]) if canonical['final'][r] == 1 else + f"{canonical['start'][r]}:{canonical['final'][r]}" for r in wrapped] + need(set(programs) == {'forward', 'backward'}, 'both emitted orientations') + report = {} + for orientation, stream in programs.items(): + need(len(stream) <= 50000, 'event capacity') + phases, sections = [], {} + cursor = canonical['start'].copy() + spaces = [span(f) for f in frames] + for event in stream: + need(type(event) is list and event, 'event schema') + if event[0] == 'phase': + phases.append(event[1]) + need(phases == PHASES[:len(phases)], 'phase order') + sections[event[1]] = [] + if event[1] == 'cleanup_tail': + need(cursor == boundary, 'emitted/source tail entrance') + else: + need(phases, 'event before phase') + sections[phases[-1]].append(event) + if phases[-1] in PHASES[:5]: + if event[0] == 'climb': + _, phase, r, old, new, rank = event + need(phase == phases[-1] and cursor[r] == old and spaces[old] < spaces[new] + and rank == len(frames[new]) - len(frames[old]), 'prefix climb chronology') + cursor[r] = new + elif event[0] == 'warp': + _, role, _op, old, new = event + need(role[0] == 'L' and cursor[role[1]] == old, 'prefix warp chronology') + cursor[role[1]] = new + need(phases == PHASES, 'complete phases') + tail, final, touched = expected_tail(word, canonical, kept, ids, boundary, orientation == 'backward') + need(sections['cleanup_tail'] == tail, 'exact source tail event sequence') + need(sections['final'] == final, 'exact final event sequence') + expected_wrappers = [] + for side in ('pre', 'post'): + for r in wrapped: + a, b = canonical['start'][r], canonical['final'][r] + expected_wrappers.append(['entry_adapters' if side == 'pre' else 'full_frame_cleanup', + ['residual_adapter', side, r, a] + ([b] if b != 1 else [])]) + actual = [[phase, e] for phase in PHASES for e in sections[phase] if e[0] == 'residual_adapter'] + need(actual == expected_wrappers, 'residual wrapper owner/side/phase binding') + post = [e for phase, e in expected_wrappers if phase == 'full_frame_cleanup'] + need(sections['full_frame_cleanup'][-len(post):] == post, 'post wrappers after complete cleanup') + entry_all = [] + for r, a in enumerate(canonical['start']): + b = canonical['final'][r] + entry_all.append(['residual_adapter', 'pre', r, a] + ([b] if b != 1 else []) + if r in wrapped else ['adapter', 'old_to_new', r, a]) + need(sections['entry_adapters'] == entry_all, 'complete entry adapter phase') + for r in (18, 22, 40, 54): + need(r not in wrapped and canonical['final'][r] == 1, 'R2 ordinary source boundary') + entry = [e for e in sections['entry_adapters'] if e[0] == 'adapter' and e[2] == r] + exit_ = [e for e in sections['exit_adapters'] if e[0] == 'adapter' and e[2] == r] + need(entry == [['adapter', 'old_to_new', r, canonical['start'][r]]] and + exit_ == [['adapter', 'new_to_old', r, 1]], 'ordinary source adapter binding') + need([(i, e[2], frames[e[3]], frames[e[4]], e[5]) for i, e in touched] == + [(163, 40, W, E, 1), (203, 40, E, FULL, 1), (203, 54, W, FULL, 2)], + 'exact changed native climbs') + report[orientation] = {'events': len(stream), 'tail_events': len(tail), + 'final_events': len(final), 'changed_climbs': touched, 'wrapper_occurrences': len(actual)} + return report, sorted(set(keys)), ids + + +def restore_control(word): + gates = word['restore'] + need(len(gates) == 204, 'R2 restore length') + literals = {162: ['add', 40, 54, -2, 1, W], 163: ['add', 18, 40, 1, 1, E], + 175: ['add', 22, 40, 1, 1, E], 176: ['add', 22, 45, -1, 1, E], + 203: ['add', 40, 54, 2, 1, FULL]} + need(all(gates[i] == g for i, g in literals.items()), 'R2 literal boundaries') + need([i for i, g in enumerate(gates) if i >= 162 and set(regs(g)) & {40, 54}] == + [162, 163, 175, 203], 'exclusive fan-in source contacts') + old = copy.deepcopy(gates[:162] + gates[163:203]) + old.insert(163, ['add', 18, 54, -2, 1, E]) + old.insert(177, ['add', 22, 54, -2, 1, E]) + kept = [r for r in range(704) if r not in word['removed']] + + def matrix(gs, backward): + rows = {r: {r: Fraction(1)} for r in kept} + for g in gs: + if g[0] == 'scale': + q = Fraction(g[2], g[3]) + q = 1 / q if backward else q + rows[g[1]] = {j: q * x for j, x in rows[g[1]].items()} + else: + dst, src = g[1:3] + q = Fraction(g[3], g[4]) + if backward: + dst, src, q = src, dst, -q + for j, x in list(rows[src].items()): + value = rows[dst].get(j, 0) + q * x + if value: + rows[dst][j] = value + else: + rows[dst].pop(j, None) + return rows + for backward in (False, True): + need(matrix(gates, backward) == matrix(old, backward), 'R1/R2 arbitrary-input equality') + return {'columns_per_orientation': len(kept), 'restore_gates': len(gates)} + + +def dual(circuit): + result = copy.deepcopy(circuit) + for i, g in enumerate(result): + if g[0] == 'C': + result[i] = (g[0], g[1], -g[2]) + elif g[0] == 'D': + result[i] = (g[0], g[1], [(-a) % 4 for a in g[2]]) + elif g[0] == 'PH': + result[i] = (g[0], -g[1] % 4) + else: + need(g[0] in ('P', 'X'), 'dual native gate') + return result + + +def decode(kernel, rec): + need(type(rec['rank']) is int and 0 <= rec['rank'] <= 9, 'native rank domain') + need(kernel.well_formed(rec['left']), 'left monomial schema') + if rec['rank'] == 0: + need(rec['right'] is None, 'rank-zero right factor') + return kernel.monomial(rec['left']) + need(kernel.well_formed(rec['right']), 'right monomial schema') + return kernel.monomial(rec['right']) + kernel.fourier(rec['rank']) + kernel.monomial(rec['left']) + + +def check_recipe(kernel, rec, old, new, cache): + need(rec['rank'] == len(new) - len(old), 'recipe rank difference') + key = json.dumps([rec, old, new], sort_keys=True) + actual = decode(kernel, rec) + if key not in cache: + expected = kernel.adjoint(kernel.canonical_frame(old)) + kernel.canonical_frame(new) + need(kernel.same_operator(actual, expected), 'native phase-exact operator') + need(kernel.same_operator(dual(actual), dual(expected)), 'dual phase-exact operator') + cache.add(key) + return actual + + +def semantics(kernel, canonical, recipes, adapters, keys, ids, cache): + frames = canonical['frames'] + children = {(r['old'], r['new']): r for r in recipes['children']} + need(len(children) == len(recipes['children']), 'unique child recipe keys') + circuits = [] + for old, new in ((W, E), (E, FULL), (W, FULL)): + key = (ids[span(old)], ids[span(new)]) + need(key in children, 'changed child recipe coverage') + circuits.append(check_recipe(kernel, children[key], old, new, cache)) + need(kernel.same_operator(circuits[0] + circuits[1], circuits[2]), 'split/fused native equality') + need(kernel.same_operator(dual(circuits[0] + circuits[1]), dual(circuits[2])), 'dual split/fused equality') + need(set(adapters['recipes']) == set(keys), 'exact used residual recipe inventory') + for key in keys: + rec = adapters['recipes'][key] + a, b = rec['frame'], rec.get('terminal', 1) + need(key == (str(a) if b == 1 else f'{a}:{b}'), 'residual recipe key') + need(rec['vectors'] == frames[a] and rec['entrance_rank'] == len(frames[a]), 'residual entrance metadata') + if b != 1: + need(rec['terminal_vectors'] == frames[b] and rec['terminal_rank'] == len(frames[b]), + 'residual terminal metadata') + check_recipe(kernel, rec, frames[a], frames[b], cache) + wrapped_key = 'wrapped:' + json.dumps([rec, frames[a], frames[b]], sort_keys=True) + if wrapped_key not in cache: + sequence = (kernel.adjoint(kernel.monomial(rec['right'])) + + kernel.adjoint(kernel.canonical_frame(frames[a])) + kernel.canonical_frame(frames[b]) + + kernel.adjoint(kernel.monomial(rec['left']))) + need(kernel.same_operator(sequence, kernel.fourier(rec['rank'])), 'inverse residual wrapper order') + need(kernel.same_operator(dual(sequence), kernel.fourier(rec['rank'], -1)), 'dual residual wrapper order') + cache.add(wrapped_key) + for r in (18, 22, 40, 54): + matches = [x for x in recipes['endpoint_adapters'] if x['role'] == 'source' and x['port'] == r] + need(len(matches) == 1, 'source endpoint recipe coverage') + rec = matches[0] + need(rec['rank'] == 0 and rec['frame'] == canonical['start'][r], 'source endpoint rank/frame') + reference = [('C', canonical['ports'][r], -1)] + kernel.canonical_frame(frames[rec['frame']]) + actual = decode(kernel, rec) + need(kernel.same_operator(actual, reference), 'source endpoint phase') + need(kernel.same_operator(dual(actual), dual(reference)), 'dual source endpoint phase') + return {'changed_child_recipes': 3, 'residual_recipes': len(keys), 'source_endpoint_recipes': 4, + 'native_columns_each': 512, 'orientations': 2, 'phase_included': True} + + +def audit(kernel, word, data, cache): + canonical, programs, recipes, adapters = (data[n] for n in FILES) + events, keys, ids = bind_events(word, canonical, programs) + return {'events': events, 'scalar_control': restore_control(word), + 'native': semantics(kernel, canonical, recipes, adapters, keys, ids, cache)} + + +def failure_controls(kernel, word, data): + """Mutate semantic payloads after authentication, so hash checks cannot mask bugs.""" + rejected = [] + + def reject(name, mutate, predicate, reason): + w, d = copy.deepcopy(word), copy.deepcopy(data) + mutate(w, d) + need(w != word or d != data, 'nonvacuous mutant: ' + name) + try: + predicate(w, d) + except ValueError as exc: + need(str(exc) == reason, 'wrong rejection for ' + name + ': ' + str(exc)) + rejected.append(name) + else: + raise ValueError('semantic mutant accepted: ' + name) + + event_check = lambda w, d: bind_events(w, d[FILES[0]], d[FILES[1]]) + def event(d, orientation, predicate): + return next(e for e in d[FILES[1]][orientation] if predicate(e)) + + reject('forward fan-in sign', lambda w, d: event(d, 'forward', lambda e: e[:1] == ['scalar'] and + e[1] == ['add', ['L', 40], ['L', 54], -2, 1])[1].__setitem__(3, 2), + event_check, 'exact source tail event sequence') + reject('dual fan-in sign', lambda w, d: event(d, 'backward', lambda e: e[:1] == ['scalar'] and + e[1] == ['add', ['L', 54], ['L', 40], 2, 1])[1].__setitem__(3, -2), + event_check, 'exact source tail event sequence') + reject('rank-two child undercharge', lambda w, d: event(d, 'forward', lambda e: + e[:3] == ['climb', 'cleanup_tail', 54] and e[-1] == 2).__setitem__(5, 1), + event_check, 'exact source tail event sequence') + reject('tail phase substitution', lambda w, d: event(d, 'forward', lambda e: + e == ['phase', 'cleanup_tail']).__setitem__(1, 'final'), event_check, 'phase order') + reject('wrapper side', lambda w, d: event(d, 'forward', lambda e: + e[:2] == ['residual_adapter', 'post']).__setitem__(1, 'pre'), + event_check, 'residual wrapper owner/side/phase binding') + reject('dual wrapper owner', lambda w, d: event(d, 'backward', lambda e: + e[:2] == ['residual_adapter', 'pre']).__setitem__(2, 40), + event_check, 'residual wrapper owner/side/phase binding') + def early_post(w, d): + stream = d[FILES[1]]['forward'] + i = next(i for i, e in enumerate(stream) if e[:2] == ['residual_adapter', 'post']) + j = next(i for i, e in enumerate(stream) if e == ['phase', 'full_frame_cleanup']) + block = stream[i:-1] + del stream[i:-1] + stream[j + 1:j + 1] = block + reject('post wrappers before cleanup', early_post, event_check, 'post wrappers after complete cleanup') + reject('source exit frame', lambda w, d: event(d, 'forward', lambda e: + e[:3] == ['adapter', 'new_to_old', 40]).__setitem__(3, 0), + event_check, 'ordinary source adapter binding') + reject('missing dirty restoration', lambda w, d: w['restore'].pop(), + lambda w, d: restore_control(w), 'R2 restore length') + reject('extra fan-in observer', lambda w, d: w['restore'][180].__setitem__(2, 54), + lambda w, d: restore_control(w), 'exclusive fan-in source contacts') + reject('prefix wrong source frame', lambda w, d: event(d, 'forward', lambda e: + e[0] == 'climb' and e[3] != 0).__setitem__(3, 0), event_check, 'prefix climb chronology') + + wid = data[FILES[0]]['frames'].index(W) + def child(d): + return next(x for x in d[FILES[2]]['children'] if (x['old'], x['new']) == (wid, 1)) + def phase(rec): + rec['left']['phase'] = (rec['left']['phase'] + 1) % 4 + child_check = lambda w, d: check_recipe(kernel, child(d), W, FULL, set()) + reject('native global phase', lambda w, d: phase(child(d)), child_check, 'native phase-exact operator') + reject('native translation', lambda w, d: child(d)['left'].__setitem__('offset', child(d)['left']['offset'] ^ 1), + child_check, 'native phase-exact operator') + reject('native child rank', lambda w, d: child(d).__setitem__('rank', 1), child_check, 'recipe rank difference') + key = sorted(data[FILES[3]]['recipes'])[0] + def residual_check(w, d): + rec = d[FILES[3]]['recipes'][key] + frames = d[FILES[0]]['frames'] + check_recipe(kernel, rec, frames[rec['frame']], frames[rec.get('terminal', 1)], set()) + reject('residual global phase', lambda w, d: phase(d[FILES[3]]['recipes'][key]), + residual_check, 'native phase-exact operator') + reject('residual translation', lambda w, d: d[FILES[3]]['recipes'][key]['right'].__setitem__('offset', + d[FILES[3]]['recipes'][key]['right']['offset'] ^ 1), residual_check, 'native phase-exact operator') + return rejected + + +def compute(data_path): + blobs = pin_inputs() + kernel = types.ModuleType('r2_independent_clifford') + exec(compile(blobs[KERNEL], KERNEL, 'exec'), kernel.__dict__) + need(kernel.same_operator([('C', 1, 1), ('C', 1, 1)], [('X', 1)]), 'hand C squared calibration') + need(kernel.same_operator([('C', 3, 1), ('C', 3, -1)], []), 'hand inverse calibration') + need(not kernel.same_operator([('PH', 1)], []), 'global phase sensitivity calibration') + cache, providers = set(), {} + for tag in ('base', 'extra'): + word = parse(gzip.decompress(blobs[SOURCE + f'WORD-{tag}.json.gz'])) + data = artifacts(blobs, tag, data_path) + providers[tag] = audit(kernel, word, data, cache) + providers[tag]['rejected_controls'] = failure_controls(kernel, word, data) + need(pin_inputs() == blobs, 'source changed during check') + return {'status': 'PASS_PR3044_R2_NATIVE_SLICE', 'providers': providers, + 'kernel_sha256': sha(blobs[KERNEL]), + 'scope': 'R2 tail/final binding, three native children, four source endpoints, all used residual ' + 'recipes and placement. Other native phases, physical owners, full cleanup semantics ' + 'and supplier/outer theorem remain outside this audit.'} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--emit', action='store_true') + parser.add_argument('--data', type=Path, default=PACKAGE / 'data') + args = parser.parse_args() + result = compute(args.data) + if args.emit: + print(json.dumps(result, indent=2, sort_keys=True)) + else: + need(result == read(PACKAGE / 'RESULT.json'), 'saved result differs') + print(result['status']) + + +if __name__ == '__main__': + try: + main() + except (ValueError, KeyError, TypeError, IndexError, OSError) as exc: + raise SystemExit('FAIL: ' + str(exc)) from None diff --git a/research/clifford-pauli-anchor/verify.py b/research/clifford-pauli-anchor/verify.py new file mode 100644 index 0000000000..b4844357c0 --- /dev/null +++ b/research/clifford-pauli-anchor/verify.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +"""Full opt-in replay, independent controls and exact receipt comparison. +Tekalign / OpenAI Codex, Apache-2.0. +""" +import argparse +import json +from pathlib import Path +import types + +PACKAGE = Path(__file__).resolve().parent + + +def load(name): + path = PACKAGE / (name + '.py') + obj = types.ModuleType('anchor_' + name) + obj.__file__ = str(path) + exec(compile(path.read_bytes(), str(path), 'exec'), obj.__dict__) + return obj + + +def calculate(): + replay = load('replay') + result = replay.run('anchor') + checks = load('controls').check() + return {'status': 'PASS_CLIFFORD_PAULI_ANCHOR', + 'base_commit': '463113d675af7410ac91d53a4fed51ec6494eb9a', + 'dependency_pr3202': '259043321323717b7e816d6be38ad5e1f0b69b4c', + 'reference_result_sha256': result['reference_result_sha256'], + 'call_multiset_sha256': result['call_multiset_sha256'], 'decisions': result['calls'], + 'source_sha256': result['source_sha256'], 'controls': checks, + 'coverage': 'Exact equality on the 512-dimensional operator domain, via signed Pauli action and one whole anchor column; not 512 explicitly simulated input columns.', + 'new_kappa': False, 'formal_kernel_proof': False} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--emit-result', action='store_true') + args = parser.parse_args() + result = calculate() + if args.emit_result: + print(json.dumps(result, indent=2, sort_keys=True)) + else: + expected = json.loads((PACKAGE / 'RESULT.json').read_bytes()) + if json.dumps(result, sort_keys=True) != json.dumps(expected, sort_keys=True): + raise ValueError('stored result mismatch') + print('PASS_CLIFFORD_PAULI_ANCHOR calls=253 accepted=244 rejected=9 matrix_controls=4704') + + +if __name__ == '__main__': + main()