From c319093b5b96211e89165f4ad9dd0d20d5039414 Mon Sep 17 00:00:00 2001 From: Wentao Li Date: Thu, 15 Oct 2026 17:13:38 +0000 Subject: [PATCH] Research: general odd-kernel exclusion pattern for native DATA shear pairs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Answer triadic OQ2 / PR840 non-dyadic note: for every odd kernel q the fused three-query shear at a=±q·2^j admits odd moduli coprime to q with typed costs 4→3 / 24→18 / 4→2 and no improvement over dyadic. Certificate kernels {1,3,5,7,9,15}. No new kappa. Prepared by Wentao Li with substantial AI assistance. --- .../odd-kernel-query-pair/CERTIFICATE.json | 464 ++++++++++++++++++ research/odd-kernel-query-pair/NOTICE.md | 17 + research/odd-kernel-query-pair/PROOF.md | 69 +++ research/odd-kernel-query-pair/README.md | 83 ++++ research/odd-kernel-query-pair/SOURCES.json | 36 ++ research/odd-kernel-query-pair/TASK.json | 84 ++++ research/odd-kernel-query-pair/VERIFY.json | 54 ++ research/odd-kernel-query-pair/independent.py | 96 ++++ research/odd-kernel-query-pair/program.py | 207 ++++++++ .../odd-kernel-query-pair/test_package.py | 94 ++++ research/odd-kernel-query-pair/verify.py | 233 +++++++++ 11 files changed, 1437 insertions(+) create mode 100644 research/odd-kernel-query-pair/CERTIFICATE.json create mode 100644 research/odd-kernel-query-pair/NOTICE.md create mode 100644 research/odd-kernel-query-pair/PROOF.md create mode 100644 research/odd-kernel-query-pair/README.md create mode 100644 research/odd-kernel-query-pair/SOURCES.json create mode 100644 research/odd-kernel-query-pair/TASK.json create mode 100644 research/odd-kernel-query-pair/VERIFY.json create mode 100644 research/odd-kernel-query-pair/independent.py create mode 100644 research/odd-kernel-query-pair/program.py create mode 100644 research/odd-kernel-query-pair/test_package.py create mode 100644 research/odd-kernel-query-pair/verify.py diff --git a/research/odd-kernel-query-pair/CERTIFICATE.json b/research/odd-kernel-query-pair/CERTIFICATE.json new file mode 100644 index 0000000000..6968a06c7d --- /dev/null +++ b/research/odd-kernel-query-pair/CERTIFICATE.json @@ -0,0 +1,464 @@ +{ + "claimed_scope": "general odd kernel q: three-query fused native DATA shear at a=\u00b1q\u00b72^j on odd moduli coprime to q; typed costs 4\u21923 / 24\u219218 / 4\u21922; no new kappa", + "format": "odd-kernel-query-pair-certificate-v1", + "kernels": [ + 1, + 3, + 5, + 7, + 9, + 15 + ], + "no_new_kappa": true, + "per_kernel": { + "1": { + "admitted_probe_moduli": [ + 3, + 5, + 7, + 9, + 11, + 13, + 15, + 17, + 19, + 21, + 23, + 25, + 27, + 33, + 35, + 39, + 45, + 49, + 55, + 63, + 77, + 105 + ], + "baseline_invoice": { + "aligned_xor_scans": 4, + "child_volume_fraction_each": "1/3", + "child_width_fraction_each": "1/3", + "kernel": 1, + "ordered_affine_events": 24, + "ordinary_children": 4, + "persistent_private_rows": 0, + "query_powers": [ + -1, + 1, + 1, + -1 + ] + }, + "excluded_odd_primes": [], + "excluded_probe_moduli": [ + 2, + 4, + 6, + 8, + 10 + ], + "fused_invoice": { + "aligned_xor_scans": 2, + "child_volume_fraction_each": "1/3", + "child_width_fraction_each": "1/3", + "kernel": 1, + "ordered_affine_events": 18, + "ordinary_children": 3, + "persistent_private_rows": 0, + "query_powers": [ + -1, + 2, + -1 + ] + }, + "kernel": 1, + "modular_columns": 144, + "pattern": "odd modulus coprime to kernel", + "rational_columns": 36 + }, + "15": { + "admitted_probe_moduli": [ + 7, + 11, + 13, + 17, + 19, + 23, + 49, + 77 + ], + "baseline_invoice": { + "aligned_xor_scans": 4, + "child_volume_fraction_each": "1/3", + "child_width_fraction_each": "1/3", + "kernel": 15, + "ordered_affine_events": 24, + "ordinary_children": 4, + "persistent_private_rows": 0, + "query_powers": [ + -15, + 15, + 15, + -15 + ] + }, + "excluded_odd_primes": [ + 3, + 5 + ], + "excluded_probe_moduli": [ + 2, + 4, + 6, + 8, + 10, + 3, + 5, + 9, + 15, + 21, + 25, + 27, + 33, + 35, + 39, + 45, + 55, + 63, + 105 + ], + "fused_invoice": { + "aligned_xor_scans": 2, + "child_volume_fraction_each": "1/3", + "child_width_fraction_each": "1/3", + "kernel": 15, + "ordered_affine_events": 18, + "ordinary_children": 3, + "persistent_private_rows": 0, + "query_powers": [ + -15, + 30, + -15 + ] + }, + "kernel": 15, + "modular_columns": 144, + "pattern": "odd modulus coprime to kernel", + "rational_columns": 36 + }, + "3": { + "admitted_probe_moduli": [ + 5, + 7, + 11, + 13, + 17, + 19, + 23, + 25, + 35, + 49, + 55, + 77 + ], + "baseline_invoice": { + "aligned_xor_scans": 4, + "child_volume_fraction_each": "1/3", + "child_width_fraction_each": "1/3", + "kernel": 3, + "ordered_affine_events": 24, + "ordinary_children": 4, + "persistent_private_rows": 0, + "query_powers": [ + -3, + 3, + 3, + -3 + ] + }, + "excluded_odd_primes": [ + 3 + ], + "excluded_probe_moduli": [ + 2, + 4, + 6, + 8, + 10, + 3, + 9, + 15, + 21, + 27, + 33, + 39, + 45, + 63, + 105 + ], + "fused_invoice": { + "aligned_xor_scans": 2, + "child_volume_fraction_each": "1/3", + "child_width_fraction_each": "1/3", + "kernel": 3, + "ordered_affine_events": 18, + "ordinary_children": 3, + "persistent_private_rows": 0, + "query_powers": [ + -3, + 6, + -3 + ] + }, + "kernel": 3, + "modular_columns": 144, + "pattern": "odd modulus coprime to kernel", + "rational_columns": 36 + }, + "5": { + "admitted_probe_moduli": [ + 3, + 7, + 9, + 11, + 13, + 17, + 19, + 21, + 23, + 27, + 33, + 39, + 49, + 63, + 77 + ], + "baseline_invoice": { + "aligned_xor_scans": 4, + "child_volume_fraction_each": "1/3", + "child_width_fraction_each": "1/3", + "kernel": 5, + "ordered_affine_events": 24, + "ordinary_children": 4, + "persistent_private_rows": 0, + "query_powers": [ + -5, + 5, + 5, + -5 + ] + }, + "excluded_odd_primes": [ + 5 + ], + "excluded_probe_moduli": [ + 2, + 4, + 6, + 8, + 10, + 5, + 15, + 25, + 35, + 45, + 55, + 105 + ], + "fused_invoice": { + "aligned_xor_scans": 2, + "child_volume_fraction_each": "1/3", + "child_width_fraction_each": "1/3", + "kernel": 5, + "ordered_affine_events": 18, + "ordinary_children": 3, + "persistent_private_rows": 0, + "query_powers": [ + -5, + 10, + -5 + ] + }, + "kernel": 5, + "modular_columns": 144, + "pattern": "odd modulus coprime to kernel", + "rational_columns": 36 + }, + "7": { + "admitted_probe_moduli": [ + 3, + 5, + 9, + 11, + 13, + 15, + 17, + 19, + 23, + 25, + 27, + 33, + 39, + 45, + 55 + ], + "baseline_invoice": { + "aligned_xor_scans": 4, + "child_volume_fraction_each": "1/3", + "child_width_fraction_each": "1/3", + "kernel": 7, + "ordered_affine_events": 24, + "ordinary_children": 4, + "persistent_private_rows": 0, + "query_powers": [ + -7, + 7, + 7, + -7 + ] + }, + "excluded_odd_primes": [ + 7 + ], + "excluded_probe_moduli": [ + 2, + 4, + 6, + 8, + 10, + 7, + 21, + 35, + 49, + 63, + 77, + 105 + ], + "fused_invoice": { + "aligned_xor_scans": 2, + "child_volume_fraction_each": "1/3", + "child_width_fraction_each": "1/3", + "kernel": 7, + "ordered_affine_events": 18, + "ordinary_children": 3, + "persistent_private_rows": 0, + "query_powers": [ + -7, + 14, + -7 + ] + }, + "kernel": 7, + "modular_columns": 144, + "pattern": "odd modulus coprime to kernel", + "rational_columns": 36 + }, + "9": { + "admitted_probe_moduli": [ + 5, + 7, + 11, + 13, + 17, + 19, + 23, + 25, + 35, + 49, + 55, + 77 + ], + "baseline_invoice": { + "aligned_xor_scans": 4, + "child_volume_fraction_each": "1/3", + "child_width_fraction_each": "1/3", + "kernel": 9, + "ordered_affine_events": 24, + "ordinary_children": 4, + "persistent_private_rows": 0, + "query_powers": [ + -9, + 9, + 9, + -9 + ] + }, + "excluded_odd_primes": [ + 3 + ], + "excluded_probe_moduli": [ + 2, + 4, + 6, + 8, + 10, + 3, + 9, + 15, + 21, + 27, + 33, + 39, + 45, + 63, + 105 + ], + "fused_invoice": { + "aligned_xor_scans": 2, + "child_volume_fraction_each": "1/3", + "child_width_fraction_each": "1/3", + "kernel": 9, + "ordered_affine_events": 18, + "ordinary_children": 3, + "persistent_private_rows": 0, + "query_powers": [ + -9, + 18, + -9 + ] + }, + "kernel": 9, + "modular_columns": 144, + "pattern": "odd modulus coprime to kernel", + "rational_columns": 36 + } + }, + "primary_new_kernels": [ + 5, + 7, + 9, + 15 + ], + "probe_moduli": [ + 2, + 4, + 6, + 8, + 10, + 3, + 5, + 7, + 9, + 11, + 13, + 15, + 17, + 19, + 21, + 23, + 25, + 27, + 33, + 35, + 39, + 45, + 49, + 55, + 63, + 77, + 105 + ], + "typed_cost_improvement_over_dyadic": false +} diff --git a/research/odd-kernel-query-pair/NOTICE.md b/research/odd-kernel-query-pair/NOTICE.md new file mode 100644 index 0000000000..3d311ffb20 --- /dev/null +++ b/research/odd-kernel-query-pair/NOTICE.md @@ -0,0 +1,17 @@ +# Notice — research/odd-kernel-query-pair + +Prepared by Wentao Li (GitHub VictorLiwentao, X @Is__Victor) with substantial +AI assistance. New material is Apache-2.0 under the repository LICENSE. + +Predecessor credit: + +- Wentao Li / PR840 (`research/dyadic-query-pair`) — three-query dyadic fusion, + sharp minimum, typed costs, and the explicit non-dyadic exclusion note. +- Pending fork package `research/triadic-query-pair/` @ `77041f2d` — kernel-3 + specialization and OQ2 answered here; not vendored (absent from this fork + base). +- Karl Appel / applecrusher / PR521 — native unipotent ADDRESS query lowering. +- commdata2338 / PR677 — completed DATA-shear boundaries without a private row. +- Retained OpenAI tape / stream framework as cited by PR840. + +No independent human review is claimed. No selected frontier or kappa change. diff --git a/research/odd-kernel-query-pair/PROOF.md b/research/odd-kernel-query-pair/PROOF.md new file mode 100644 index 0000000000..0fe1b49513 --- /dev/null +++ b/research/odd-kernel-query-pair/PROOF.md @@ -0,0 +1,69 @@ +# Excluded-prime pattern for general odd-kernel native DATA shears + +This is a local recursive-interface construction and a scoped admission lemma. +Ordinary ADDRESS interchange and ordered affine tape streams remain premises. +There is no new supplier, kappa, or formal multiplication proof. + +It answers open question 2 of the pending +`research/triadic-query-pair/` package (fork tip `77041f2d`), which completes +PR840's non-dyadic note for kernel **3** and asks for the excluded-prime pattern +of a general odd kernel `q`. + +## Object + +Use the same six ADDRESS fields and unipotent push `h` as PR521/PR840: + +```text +s=(1,0,1,-1,0,-1)^T, r=(1,0,-1,-1,0,1)^T, +M(k)=I6+(k/4)s r^T, h = array permutation of M(1). +``` + +For each positive odd integer `q` and each `j ≥ 0`, `σ ∈ {±1}`, set +`a = σ·q·2^j`. The completed DATA endpoint is + +```text +F_a(x,y,z)=(x+(h^a+h^-a)y, y, z). +``` + +## Lowering and exclusion pattern + +The seven-event word of PR840/triadic applies verbatim for any nonzero integer +`k`, with diagonal units `1`, `c=k/4`, and `-1/c`. For `k = ±q·2^j` every +numerator/denominator odd part divides a power of `q`. Therefore the lowering +specializes to **every odd modulus coprime to `q`**. Equivalently: an odd +modulus is admitted iff it shares no odd prime factor with `q`; every even +modulus is excluded. When `q=1` this recovers PR840's all-odd-radix claim. +When `q=3` this recovers the pending triadic exclusions. + +## Completed pair fusion and typed costs + +The fused program is identical in form to PR840: + +```text +x <- h^-a x +x ^= y +x <- h^(2a) x +x ^= y +x <- h^-a x. +``` + +Relative to two separate completed shears, the fused word uses **three ordinary +children, eighteen affine events and two XOR scans**. These counts are +independent of `q`. No odd kernel improves the typed interface invoice over the +dyadic case; larger radical(`q`) only shrinks the admitted modulus set. + +## Three-query necessity + +The PR840 determinant argument applies for any nonzero integer unit power `a` +on an odd full-order orbit admitted by the lowering. This package treats that +written argument as inherited; finite Laurent/two-query corroboration for +kernel 3 remains in the triadic predecessor. + +## Evidence boundary + +The checker verifies, for kernels `{1,3,5,7,9,15}`, that the closed-form +admission predicate matches denominator invertibility on a fixed probe modulus +set, that rational and modular columns match `M(k)`, that +`M(-a)M(2a)M(-a)=I`, and that fused/baseline invoices are `3/18/2` versus +`4/24/4`. An independent module rebuilds the matrix identity without importing +`verify.py`. diff --git a/research/odd-kernel-query-pair/README.md b/research/odd-kernel-query-pair/README.md new file mode 100644 index 0000000000..27ce45449d --- /dev/null +++ b/research/odd-kernel-query-pair/README.md @@ -0,0 +1,83 @@ +# Excluded-prime pattern for general odd-kernel native DATA shears + +**Research construction / recursive interface; no new kappa.** Completes open +question 2 of the pending +[triadic-query-pair](https://github.com/VictorLiwentao/integer-mult-bounds/tree/cursor/triadic-query-pair-60b9) +package (`77041f2d`), itself the kernel-3 specialization of +[PR840](https://github.com/CrocSwap/integer-mult-bounds/pull/840) +(`research/dyadic-query-pair`). + +For every positive odd kernel `q`, the same three-query fusion at `a=±q·2^j` +attains the typed invoice below on every **odd modulus coprime to `q`**. Even +moduli and odd moduli sharing a prime with `q` are excluded. Typed costs do +**not** improve over the dyadic (`q=1`) case. + +```text +x <- h^-a x +x ^= y +x <- h^(2a) x +x ^= y +x <- h^-a x +``` + +| Complete cost item | Separate pair | Fused odd-kernel pair | +|---|---:|---:| +| Ordinary recursive children | 4 | 3 | +| Ordered affine events | 24 | 18 | +| Aligned XOR scans | 4 | 2 | +| Extra full private rows | 0 | 0 | + +Certificate kernels: `{1,3,5,7,9,15}` (dyadic recovery, triadic cross-check, and +primary new kernels `{5,7,9,15}`). Pattern: admitted ⇔ odd and +`gcd(modulus,q)=1`. + +## Reproduce + +Python 3.12, standard library only, from the repository root: + +```sh +python3.12 -I -B research/odd-kernel-query-pair/verify.py +python3.12 -I -O -B research/odd-kernel-query-pair/verify.py +python3.12 -I -B research/odd-kernel-query-pair/independent.py +python3.12 -I -B research/odd-kernel-query-pair/test_package.py +python3.12 -B scripts/research_package.py --package research/odd-kernel-query-pair +``` + +Expected: + +```text +PASS_ODD_KERNEL_QUERY_PAIR kernels=[1, 3, 5, 7, 9, 15] primary_new=[5, 7, 9, 15] children=4->3 affine=24->18 xor=4->2 no_typed_gain_over_dyadic ... no_new_kappa +PASS_INDEPENDENT_ODD_KERNEL_QUERY_PAIR kernels=[1, 3, 5, 7, 9, 15] ... no_new_kappa +PASS_ODD_KERNEL_QUERY_PAIR_PACKAGE_TESTS groups=6 +PASS_REGISTERED_RESEARCH_PACKAGE research/odd-kernel-query-pair outcome=completed +``` + +Default verify is read-only and compares a fresh rebuild to +[CERTIFICATE.json](CERTIFICATE.json). Use `--write` only to regenerate that +receipt. Admission uses `need()` (not `assert`); `-O` also passes. + +## Scope and overlap + +Base commit `0b1cccf86e2f5132ed286a26ef0a681a495740ea`. Direct predecessor: +PR840 / `research/dyadic-query-pair`. Complementary pending: triadic kernel-3 +package (OQ2 answered here; kernel-3 rows are cross-checks, not a competing +re-proof). Does not reopen leave-alone tooling through +[#2487](https://github.com/CrocSwap/integer-mult-bounds/pull/2487), pending +`mutable-source-789q-invoice`, or [#2643](https://github.com/CrocSwap/integer-mult-bounds/pull/2643) +(`seven-query-xor-floor`). + +## Open next questions + +1. Can an admitted BIT supplier host some small odd-kernel shear on moduli + coprime to `q` with a favorable fully charged bill versus the dyadic path? + First write one exact source-return boundary and charge routing, precision + and dispatch. +2. Do coefficient-table bit-sizes for larger `q` ever pay for themselves under + a concrete physical tariff despite identical typed child/XOR counts? + +## Credit + +Prepared by Wentao Li ([VictorLiwentao](https://github.com/VictorLiwentao), +[@Is__Victor](https://x.com/Is__Victor)) with substantial AI assistance, under +Apache-2.0. Credit PR840/PR521/PR677 and the pending triadic kernel-3 package. +No independent human review is claimed. No new kappa. diff --git a/research/odd-kernel-query-pair/SOURCES.json b/research/odd-kernel-query-pair/SOURCES.json new file mode 100644 index 0000000000..a71e6bc93a --- /dev/null +++ b/research/odd-kernel-query-pair/SOURCES.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea", + "files": [ + { + "path": "research/dyadic-query-pair/PROOF.md", + "usage": "input", + "git_blob": "aaba3e501de1f761c783ec7f0dc9307ef45ab5d7", + "sha256": "9a5ce93b866371189c797fbe8837c6a0bd22c5cf71ed84d60b9ae1c22a5ec83a" + }, + { + "path": "research/dyadic-query-pair/README.md", + "usage": "input", + "git_blob": "3988b2cb22f81be52ca00500e1576d9f52206dab", + "sha256": "9b37c24a1056fa495f12e322ba56f592494f6f34516b0112be0db3f5cd6883d4" + }, + { + "path": "research/dyadic-query-pair/CERTIFICATE.json", + "usage": "input", + "git_blob": "d201254cdd56e90471869caadaba5bc5eda8436c", + "sha256": "8267e9a468eca814b3b8641aae07ff71acadb303fd434ce3ef1984a258c69307" + }, + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "06c96f5579bb67ed1b86d334e78fbed7da6945f1", + "sha256": "6686ad58f1fbdbc87134a78901b60fd53a20d3984355e91defbbebc9e9fa8075" + } + ] +} diff --git a/research/odd-kernel-query-pair/TASK.json b/research/odd-kernel-query-pair/TASK.json new file mode 100644 index 0000000000..1834f1fb4e --- /dev/null +++ b/research/odd-kernel-query-pair/TASK.json @@ -0,0 +1,84 @@ +{ + "schema_version": 1, + "task_id": "connector-alphabet-change", + "priority_revision": 4, + "base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea", + "original_card": { + "id": "connector-alphabet-change", + "question": "Does one explicit extension of the connector alphabet offer a favorable completed budget?", + "starting_points": [ + "research/universal-connector-boundary/README.md", + "certificates/selected-result.json" + ], + "methods": [ + "Construct and charge a legal extra operation on a minimal instance.", + "Prove a target-specific bound after adding one specified operation family." + ], + "acceptance_gate": "State which fixed-alphabet premise changes and charge its implementation; do not declare it free.", + "first_step": { + "command": [ + "python3", + "-B", + "research/universal-connector-boundary/verify.py" + ], + "expected": "PASS_UNIVERSAL_CONNECTOR_BOUNDARY", + "inspect": "Reproduce the 945-pairing control, then read Exact interface to list the allowed calls.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Add exactly one legally priced operation and test a tiny dirty-input instance before enumerating larger cases.", + "bottleneck_link": "A new legal connector operation could change recursive interface cost; a larger census in the same alphabet is a separate side result.", + "allowed_variations": [ + "Choose one additional operation and a small source count for its first counterexample." + ], + "scope_change_triggers": [ + "Keeping the alphabet and only increasing the source count; record this as a changed assignment." + ], + "overlap_terms": [ + "universal connector", + "source-toggle", + "connector alphabet" + ] + }, + "scope_status": "changed", + "actual_scope": "Prove the excluded-prime admission pattern for general odd kernel q in the PR840 three-query fused native DATA shear (a=±q·2^j): odd moduli coprime to q; typed costs 4→3/24→18/4→2 with no improvement over dyadic; certificate for kernels {1,3,5,7,9,15}.", + "scope_change_reason": "The drawn connector-alphabet card is redirected to open question 2 of the pending triadic-query-pair package on the PR840 non-dyadic ADDRESS alphabet, which asks for the general-q exclusion pattern beyond kernel 3.", + "bottleneck_link": "A priced general odd-kernel native shear widens the paid query alphabet recursive BIT interfaces may use; exclusions are charged, and typed costs are shown not to improve with larger q.", + "budget_minutes": 60, + "stop_rule": "Stop after multi-kernel pattern census, invoice invariance, independent matrix identity, package tests; no supplier search.", + "outcome": "completed", + "evidence": "CERTIFICATE.json per-kernel admission/exclusion probes, invoices, rational/modular columns, M(-a)M(2a)M(-a)=I; independent closed-form replay.", + "author": "Wentao Li", + "ai_assistance": "Substantial AI assistance for derivation, implementation, checking and writing.", + "open_questions": [ + { + "question": "Can an admitted BIT supplier host some small odd-kernel shear on moduli coprime to q with a favorable fully charged bill versus the dyadic path?", + "why_it_matters": "Local child/XOR counts alone do not admit a supplier or change kappa.", + "first_step": "Trace one exact source-return boundary and price routing, precision and dispatch against the dyadic PR840 path.", + "blocked_by": "No such hosted instance is constructed here." + }, + { + "question": "Do coefficient-table bit-sizes for larger q ever pay for themselves under a concrete physical tariff despite identical typed child/XOR counts?", + "why_it_matters": "Larger kernels only shrink admitted moduli in this model; physical tables may still matter.", + "first_step": "Fix one j and compare compiled coefficient bit-lengths for q in {1,3,5,7} under a named tape cost.", + "blocked_by": "No physical tariff is attached here." + } + ], + "predecessors": [ + { + "pr": 840, + "credit": "Wentao Li; dyadic three-query fusion and non-dyadic exclusion note" + }, + { + "ref": "cursor/triadic-query-pair-60b9@77041f2d", + "credit": "Pending triadic kernel-3 package; OQ2 answered here" + }, + { + "pr": 521, + "credit": "Karl Appel / applecrusher; native ADDRESS query lowering" + }, + { + "pr": 677, + "credit": "commdata2338; completed DATA-shear boundaries" + } + ] +} diff --git a/research/odd-kernel-query-pair/VERIFY.json b/research/odd-kernel-query-pair/VERIFY.json new file mode 100644 index 0000000000..ff3b0d4d40 --- /dev/null +++ b/research/odd-kernel-query-pair/VERIFY.json @@ -0,0 +1,54 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/dyadic-query-pair/PROOF.md", + "research/dyadic-query-pair/README.md", + "research/dyadic-query-pair/CERTIFICATE.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Multi-kernel exclusion pattern, invoices, rational/modular columns, certificate match, source pins" + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Same admission under PYTHONOPTIMIZE via need()" + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/independent.py" + ], + "timeout_seconds": 60, + "checks": "Separate closed-form columns, product identity, admission pattern" + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/test_package.py" + ], + "timeout_seconds": 240, + "checks": "Corruption rejection and -O controls" + } + ] +} diff --git a/research/odd-kernel-query-pair/independent.py b/research/odd-kernel-query-pair/independent.py new file mode 100644 index 0000000000..530dd52a19 --- /dev/null +++ b/research/odd-kernel-query-pair/independent.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 +"""Independent closed-form checks for general odd-kernel query pairs. Apache-2.0.""" +from __future__ import annotations + +import importlib.util +import json +from fractions import Fraction +from math import gcd +from pathlib import Path + +ROOT = Path(__file__).resolve().parent +CHECKS = 0 + + +def need(ok, message): + global CHECKS + CHECKS += 1 + if not ok: + raise RuntimeError(message) + + +def load(): + spec = importlib.util.spec_from_file_location("okqp", ROOT / "program.py") + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def push(k): + s = (1, 0, 1, -1, 0, -1) + r = (1, 0, -1, -1, 0, 1) + c = Fraction(k, 4) + return tuple( + tuple((Fraction(1) if i == j else Fraction(0)) + c * s[i] * r[j] for j in range(6)) + for i in range(6) + ) + + +def mm(A, B): + return tuple( + tuple(sum(A[i][k] * B[k][j] for k in range(6)) for j in range(6)) + for i in range(6) + ) + + +def run_word(basis, word): + state = list(map(Fraction, basis)) + for event in word: + if event[0] == "child": + _, first, last = event + state[first], state[last] = state[last], state[first] + else: + _, target, diagonal, controls = event + state[target] = diagonal * state[target] + sum(c * state[i] for i, c in controls) + return tuple(state) + + +def main(): + prog = load() + cert = json.loads((ROOT / "CERTIFICATE.json").read_text()) + need(cert["no_new_kappa"] is True, "no new kappa") + need(cert["typed_cost_improvement_over_dyadic"] is False, "no typed gain") + + I = tuple(tuple(Fraction(i == j) for j in range(6)) for i in range(6)) + kernels = (1, 3, 5, 7, 9, 15) + columns = 0 + for kernel in kernels: + row = cert["per_kernel"][str(kernel)] + need(row["fused_invoice"]["ordinary_children"] == 3, "children") + need(row["baseline_invoice"]["ordinary_children"] == 4, "baseline children") + need(row["fused_invoice"]["aligned_xor_scans"] == 2, "xor") + need(row["baseline_invoice"]["aligned_xor_scans"] == 4, "baseline xor") + a = kernel + need(mm(mm(push(-a), push(2 * a)), push(-a)) == I, "product identity") + for k in (kernel, -kernel, 2 * kernel, -4 * kernel, 8 * kernel): + word = prog.address_word(k) + for col in range(6): + basis = tuple(1 if i == col else 0 for i in range(6)) + need(run_word(basis, word) == tuple(push(k)[i][col] for i in range(6)), "col") + columns += 1 + # Pattern: odd m coprime to kernel. + for m in (5, 7, 9, 15, 21, 25, 35): + expect = m % 2 == 1 and gcd(m, kernel) == 1 + need(prog.modulus_admits(k, m) is expect, f"pattern k={k} m={m}") + need(prog.modulus_admits_kernel(kernel, m) is expect, f"closed m={m}") + + print( + "PASS_INDEPENDENT_ODD_KERNEL_QUERY_PAIR " + f"kernels={list(kernels)} columns_checked={columns} " + f"controls={CHECKS} no_new_kappa" + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/odd-kernel-query-pair/program.py b/research/odd-kernel-query-pair/program.py new file mode 100644 index 0000000000..93699aec20 --- /dev/null +++ b/research/odd-kernel-query-pair/program.py @@ -0,0 +1,207 @@ +"""General odd-kernel native BIT query-pair compiler; VALUE addition is XOR. + +ADDRESS scalings use exact rationals specialized to odd residue rings coprime +to the odd kernel q. The child event is one ordinary full-row ADDRESS +interchange. This reference compiler does not implement the inherited tape +primitive. + +Kernel q=1 recovers PR840 (all odd moduli). Kernel q=3 recovers the pending +triadic package. This module parameterizes arbitrary odd q. +""" +from fractions import Fraction +from math import gcd + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def odd_kernel_power(j, sign=1, kernel=1): + """a = sign * kernel * 2^j for nonnegative j and positive odd kernel.""" + need(type(j) is int and j >= 0, "nonnegative dyadic index") + need(type(sign) is int and sign in (-1, 1), "integer sign") + need(type(kernel) is int and kernel > 0 and kernel % 2 == 1, "positive odd kernel") + return sign * kernel * (1 << j) + + +def odd_part(n): + n = abs(int(n)) + while n % 2 == 0 and n: + n //= 2 + return n + + +def odd_primes(n): + """Distinct odd prime factors of |n|.""" + n = odd_part(n) + primes = [] + p = 3 + while p * p <= n: + if n % p == 0: + primes.append(p) + while n % p == 0: + n //= p + p += 2 + if n > 1: + primes.append(n) + return tuple(primes) + + +def address_word(k): + """Seven events for M(k)=I+(k/4) s r^T; k nonzero integer.""" + need(type(k) is int and k != 0, "nonzero integer query power") + a = Fraction(k, 4) + return ( + ("affine", 2, Fraction(1), ((0, Fraction(-1)),)), + ("affine", 3, Fraction(1), ((0, Fraction(1)),)), + ("affine", 5, a, ((0, 1 + a), (2, -a), (3, -a))), + ("child", 0, 5), + ("affine", 2, Fraction(1), ((0, Fraction(1)),)), + ("affine", 3, Fraction(1), ((0, Fraction(-1)),)), + ("affine", 5, -1 / a, ((0, 1 / a - 1), (2, Fraction(1)), + (3, Fraction(1)))), + ) + + +def inverse_word(word): + result = [] + for event in reversed(word): + if event[0] == "child": + result.append(event) + else: + _, target, diagonal, controls = event + result.append( + ( + "affine", + target, + 1 / diagonal, + tuple((i, -c / diagonal) for i, c in controls), + ) + ) + return tuple(result) + + +def word_denominators(word): + dens = set() + for event in word: + if event[0] != "affine": + continue + dens.add(Fraction(event[2]).denominator) + for _, c in event[3]: + dens.add(Fraction(c).denominator) + return dens + + +def modulus_admits(k, modulus): + """Whether every diagonal/control denominator of the lowering inverts mod modulus.""" + need(type(modulus) is int and modulus >= 2, "modulus at least two") + if modulus % 2 == 0: + return False + dens = word_denominators(address_word(k)) + for d in dens: + if gcd(d, modulus) != 1: + return False + return True + + +def modulus_admits_kernel(kernel, modulus): + """Closed-form admission: odd modulus coprime to the odd kernel.""" + need(type(kernel) is int and kernel > 0 and kernel % 2 == 1, "odd kernel") + need(type(modulus) is int and modulus >= 2, "modulus") + return modulus % 2 == 1 and gcd(modulus, kernel) == 1 + + +def run_address(address, word, modulus=None): + need(len(address) >= 6, "six ADDRESS fields") + if modulus is None: + reduce = Fraction + state = list(map(Fraction, address)) + else: + need(type(modulus) is int and modulus >= 3 and modulus % 2 == 1, + "odd residue modulus at least three") + for dens in word_denominators(word): + need(gcd(dens, modulus) == 1, "denominator not invertible on this modulus") + need(all(type(x) is int for x in address), "integer residue coordinates") + + def reduce(value): + value = Fraction(value) + return value.numerator * pow(value.denominator, -1, modulus) % modulus + + state = [x % modulus for x in address] + for event in word: + if event[0] == "child": + _, first, last = event + state[first], state[last] = state[last], state[first] + else: + _, target, diagonal, controls = event + state[target] = reduce(diagonal) * state[target] + sum( + reduce(c) * state[i] for i, c in controls + ) + if modulus is not None: + state[target] %= modulus + return tuple(state) + + +def fused_program(j=0, sign=1, kernel=1): + a = odd_kernel_power(j, sign, kernel) + return ( + ("query", 0, -a), + ("xor", 0, 1), + ("query", 0, 2 * a), + ("xor", 0, 1), + ("query", 0, -a), + ) + + +def baseline_program(j=0, sign=1, kernel=1): + a = odd_kernel_power(j, sign, kernel) + return ( + ("query", 0, -a), + ("xor", 0, 1), + ("query", 0, a), + ("xor", 0, 1), + ("query", 0, a), + ("xor", 0, 1), + ("query", 0, -a), + ("xor", 0, 1), + ) + + +def invoice(program, kernel=None): + queries = [event[2] for event in program if event[0] == "query"] + words = [address_word(k) for k in queries] + out = { + "ordinary_children": len(queries), + "ordered_affine_events": sum(sum(e[0] == "affine" for e in w) for w in words), + "aligned_xor_scans": sum(e[0] == "xor" for e in program), + "persistent_private_rows": 0, + "query_powers": queries, + "child_volume_fraction_each": "1/3", + "child_width_fraction_each": "1/3", + } + if kernel is not None: + out["kernel"] = kernel + return out + + +def push_matrix(k): + """Closed form M(k)=I+(k/4) s r^T on six ADDRESS fields.""" + s = (1, 0, 1, -1, 0, -1) + r = (1, 0, -1, -1, 0, 1) + c = Fraction(k, 4) + return tuple( + tuple((Fraction(1) if i == j else Fraction(0)) + c * s[i] * r[j] for j in range(6)) + for i in range(6) + ) + + +def apply_matrix(matrix, vector): + return tuple( + sum(matrix[i][j] * Fraction(vector[j]) for j in range(6)) for i in range(6) + ) + + +def fused_query_powers(j, sign, kernel): + a = odd_kernel_power(j, sign, kernel) + return (-a, 2 * a, -a) diff --git a/research/odd-kernel-query-pair/test_package.py b/research/odd-kernel-query-pair/test_package.py new file mode 100644 index 0000000000..77fc81a58a --- /dev/null +++ b/research/odd-kernel-query-pair/test_package.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 +"""Package fault controls for odd-kernel query pairs. Wentao Li + AI, Apache-2.0.""" +from __future__ import annotations + +import json +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] + + +def need(ok, message): + if not ok: + raise SystemExit(f"FAIL_TEST: {message}") + + +def run(args, cwd=None): + return subprocess.run(args, cwd=cwd or ROOT, text=True, capture_output=True) + + +def main(): + proc = run([sys.executable, "-I", "-B", str(HERE / "verify.py")]) + need(proc.returncode == 0, proc.stderr + proc.stdout) + need("PASS_ODD_KERNEL_QUERY_PAIR" in proc.stdout, proc.stdout) + + proc = run([sys.executable, "-I", "-O", "-B", str(HERE / "verify.py")]) + need(proc.returncode == 0, "verify under -O: " + proc.stderr + proc.stdout) + + proc = run([sys.executable, "-I", "-B", str(HERE / "independent.py")]) + need(proc.returncode == 0, proc.stderr + proc.stdout) + need("PASS_INDEPENDENT_ODD_KERNEL_QUERY_PAIR" in proc.stdout, proc.stdout) + + with tempfile.TemporaryDirectory() as tmp: + tmp_path = Path(tmp) + pkg = tmp_path / "research" / "odd-kernel-query-pair" + shutil.copytree(HERE, pkg) + for rel in ( + "research/dyadic-query-pair/PROOF.md", + "research/dyadic-query-pair/README.md", + "research/dyadic-query-pair/CERTIFICATE.json", + "certificates/selected-result.json", + "docs/research/agent-task-catalog.json", + ): + dest = tmp_path / rel + dest.parent.mkdir(parents=True, exist_ok=True) + shutil.copy2(ROOT / rel, dest) + cert = json.loads((pkg / "CERTIFICATE.json").read_text()) + cert["typed_cost_improvement_over_dyadic"] = True + (pkg / "CERTIFICATE.json").write_text(json.dumps(cert, indent=2, sort_keys=True) + "\n") + proc = run([sys.executable, "-I", "-B", str(pkg / "verify.py")], cwd=tmp_path) + need(proc.returncode != 0, "corrupted certificate should fail") + + with tempfile.TemporaryDirectory() as tmp: + tmp_path = Path(tmp) + pkg = tmp_path / "research" / "odd-kernel-query-pair" + shutil.copytree(HERE, pkg) + for rel in ( + "research/dyadic-query-pair/PROOF.md", + "research/dyadic-query-pair/README.md", + "research/dyadic-query-pair/CERTIFICATE.json", + "certificates/selected-result.json", + "docs/research/agent-task-catalog.json", + ): + dest = tmp_path / rel + dest.parent.mkdir(parents=True, exist_ok=True) + shutil.copy2(ROOT / rel, dest) + target = tmp_path / "research/dyadic-query-pair/PROOF.md" + target.write_bytes(target.read_bytes() + b"\n") + proc = run([sys.executable, "-I", "-B", str(pkg / "verify.py")], cwd=tmp_path) + need(proc.returncode != 0, "source drift should fail") + + text = (HERE / "CERTIFICATE.json").read_text() + bad = text.replace('"no_new_kappa": true', '"no_new_kappa": true, "no_new_kappa": false', 1) + dup = [] + + def hook(items): + keys = [k for k, _ in items] + if len(keys) != len(set(keys)): + dup.append(True) + return dict(items) + + json.loads(bad, object_pairs_hook=hook) + need(dup, "duplicate key detector armed") + + print("PASS_ODD_KERNEL_QUERY_PAIR_PACKAGE_TESTS groups=6") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/odd-kernel-query-pair/verify.py b/research/odd-kernel-query-pair/verify.py new file mode 100644 index 0000000000..a7c00cbc3d --- /dev/null +++ b/research/odd-kernel-query-pair/verify.py @@ -0,0 +1,233 @@ +#!/usr/bin/env python3 +"""Exact evidence for the general odd-kernel query-pair pattern. Apache-2.0. + +Prepared by Wentao Li with substantial AI assistance. +Default verify is read-only. Admission uses need() (not assert); -O also passes. +""" +from __future__ import annotations + +import argparse +import hashlib +import json +import subprocess +from fractions import Fraction +from pathlib import Path + +ROOT = Path(__file__).resolve().parent +REPO = ROOT.parents[1] +CHECKS = 0 + +# Primary kernels beyond dyadic (1) and the pending triadic (3) cross-check. +KERNELS = (1, 3, 5, 7, 9, 15) +PRIMARY_NEW = (5, 7, 9, 15) +PROBE_MODULI = ( + 2, 4, 6, 8, 10, + 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 33, 35, 39, 45, 49, 55, 63, 77, 105, +) + + +def need(ok, message): + global CHECKS + CHECKS += 1 + if not ok: + raise RuntimeError(message) + + +def load_program(): + import importlib.util + + spec = importlib.util.spec_from_file_location("okqp", ROOT / "program.py") + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(",", ":")).encode() + + +def git_blob(path: str) -> str: + return subprocess.check_output( + ["git", "-C", str(REPO), "rev-parse", f"HEAD:{path}"], text=True + ).strip() + + +def check_sources(): + source = json.loads((ROOT / "SOURCES.json").read_text()) + need(source["schema_version"] == 1, "source schema") + need(isinstance(source["base_commit"], str) and len(source["base_commit"]) == 40, "base") + for row in source["files"]: + data = (REPO / row["path"]).read_bytes() + need(hashlib.sha256(data).hexdigest() == row["sha256"], f"sha256 {row['path']}") + need(git_blob(row["path"]) == row["git_blob"], f"blob {row['path']}") + return hashlib.sha256(canonical(source)).hexdigest() + + +def reject_duplicate_keys(text: str): + bad = [] + + def hook(items): + keys = [k for k, _ in items] + if len(keys) != len(set(keys)): + bad.append(True) + return dict(items) + + json.loads(text, object_pairs_hook=hook) + need(not bad, "duplicate JSON keys") + + +def mm(A, B): + return tuple( + tuple(sum(A[i][k] * B[k][j] for k in range(6)) for j in range(6)) + for i in range(6) + ) + + +def build_certificate(prog): + per_kernel = {} + for kernel in KERNELS: + # Invoice invariance. + base = prog.invoice(prog.baseline_program(0, 1, kernel), kernel) + fuse = prog.invoice(prog.fused_program(0, 1, kernel), kernel) + need(base["ordinary_children"] == 4 and fuse["ordinary_children"] == 3, "children") + need(base["ordered_affine_events"] == 24 and fuse["ordered_affine_events"] == 18, "affine") + need(base["aligned_xor_scans"] == 4 and fuse["aligned_xor_scans"] == 2, "xor") + + # Exclusion pattern vs closed form for fused powers at several j. + admitted = [] + excluded = [] + for modulus in PROBE_MODULI: + closed = prog.modulus_admits_kernel(kernel, modulus) + ok_all = True + for j, sign in ((0, 1), (0, -1), (1, 1), (2, -1), (3, 1)): + for k in prog.fused_query_powers(j, sign, kernel): + need(prog.odd_part(k) == kernel, "odd part equals kernel") + if prog.modulus_admits(k, modulus) != closed: + ok_all = False + break + if not ok_all: + break + need(ok_all, f"pattern mismatch kernel={kernel} m={modulus}") + if closed: + admitted.append(modulus) + else: + excluded.append(modulus) + + # Rational columns + selected modular specializations. + rational = modular = 0 + for j, sign in ((0, 1), (1, -1), (2, 1)): + for k in set(prog.fused_query_powers(j, sign, kernel)): + word = prog.address_word(k) + target = prog.push_matrix(k) + for col in range(6): + basis = tuple(int(i == col) for i in range(6)) + expected = tuple(target[i][col] for i in range(6)) + need(prog.run_address(basis, word) == expected, "rational column") + rational += 1 + for modulus in admitted[:4]: + got = prog.run_address(basis, word, modulus) + want = tuple( + int( + expected[i].numerator + * pow(expected[i].denominator, -1, modulus) + % modulus + ) + for i in range(6) + ) + need(got == want, f"modular k={k} m={modulus}") + modular += 1 + for modulus in excluded[:3]: + need(not prog.modulus_admits(k, modulus), "exclude") + try: + prog.run_address((1, 0, 0, 0, 0, 0), word, modulus) + except ValueError: + pass + else: + raise RuntimeError(f"excluded modulus {modulus} accepted") + + # Query product identity M(-a)M(2a)M(-a)=I. + a = prog.odd_kernel_power(0, 1, kernel) + I = tuple(tuple(Fraction(i == j) for j in range(6)) for i in range(6)) + need( + mm(mm(prog.push_matrix(-a), prog.push_matrix(2 * a)), prog.push_matrix(-a)) == I, + "query product", + ) + + per_kernel[str(kernel)] = { + "kernel": kernel, + "excluded_odd_primes": list(prog.odd_primes(kernel)), + "baseline_invoice": base, + "fused_invoice": fuse, + "admitted_probe_moduli": admitted, + "excluded_probe_moduli": excluded, + "rational_columns": rational, + "modular_columns": modular, + "pattern": "odd modulus coprime to kernel", + } + + # No typed-cost improvement over dyadic. + dyadic = per_kernel["1"]["fused_invoice"] + for kernel in PRIMARY_NEW: + fuse = per_kernel[str(kernel)]["fused_invoice"] + need(fuse["ordinary_children"] == dyadic["ordinary_children"], "children invariant") + need(fuse["ordered_affine_events"] == dyadic["ordered_affine_events"], "affine invariant") + need(fuse["aligned_xor_scans"] == dyadic["aligned_xor_scans"], "xor invariant") + + # Dyadic recovers all-odd admission among probes. + need( + set(per_kernel["1"]["admitted_probe_moduli"]) + == {m for m in PROBE_MODULI if m % 2 == 1}, + "dyadic admits every odd probe", + ) + need( + set(per_kernel["1"]["excluded_probe_moduli"]) + == {m for m in PROBE_MODULI if m % 2 == 0}, + "dyadic excludes exactly the even probes", + ) + + return { + "format": "odd-kernel-query-pair-certificate-v1", + "claimed_scope": ( + "general odd kernel q: three-query fused native DATA shear at a=±q·2^j " + "on odd moduli coprime to q; typed costs 4→3 / 24→18 / 4→2; no new kappa" + ), + "kernels": list(KERNELS), + "primary_new_kernels": list(PRIMARY_NEW), + "probe_moduli": list(PROBE_MODULI), + "per_kernel": per_kernel, + "typed_cost_improvement_over_dyadic": False, + "no_new_kappa": True, + } + + +def main(argv=None): + parser = argparse.ArgumentParser() + parser.add_argument("--write", action="store_true") + args = parser.parse_args(argv) + prog = load_program() + cert = build_certificate(prog) + pretty = json.dumps(cert, indent=2, sort_keys=True) + "\n" + reject_duplicate_keys(pretty) + path = ROOT / "CERTIFICATE.json" + if args.write: + path.write_text(pretty) + print("WROTE_CERTIFICATE", path) + else: + need(path.is_file(), "missing CERTIFICATE.json; pass --write once") + existing = path.read_text() + reject_duplicate_keys(existing) + need(json.loads(existing) == cert, "certificate drift") + sources = check_sources() + print( + "PASS_ODD_KERNEL_QUERY_PAIR " + f"kernels={list(KERNELS)} " + f"primary_new={list(PRIMARY_NEW)} " + f"children=4->3 affine=24->18 xor=4->2 " + f"no_typed_gain_over_dyadic " + f"sources={sources[:12]} checks={CHECKS} no_new_kappa" + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())