diff --git a/research/fano-census-row-tables/BENCHMARK-python312.json b/research/fano-census-row-tables/BENCHMARK-python312.json new file mode 100644 index 0000000000..c40c3f89f6 --- /dev/null +++ b/research/fano-census-row-tables/BENCHMARK-python312.json @@ -0,0 +1,70 @@ +{ + "status": "PASS_IDENTICAL_COMPLETE_FANO_BENCHMARK", + "pairs": 3, + "seed": 91, + "samples": [ + { + "engine": "tables", + "seconds": 7.86429622899999, + "max_rss": 384080, + "receipt_sha256": "e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652", + "pair": 0, + "process_seconds": 7.95168831899997 + }, + { + "engine": "reference", + "seconds": 21.18855880000001, + "max_rss": 396540, + "receipt_sha256": "e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652", + "pair": 0, + "process_seconds": 21.228497876000006 + }, + { + "engine": "reference", + "seconds": 21.668193771999995, + "max_rss": 396544, + "receipt_sha256": "e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652", + "pair": 1, + "process_seconds": 21.709772429999987 + }, + { + "engine": "tables", + "seconds": 8.139907316999995, + "max_rss": 384348, + "receipt_sha256": "e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652", + "pair": 1, + "process_seconds": 8.190792449000014 + }, + { + "engine": "tables", + "seconds": 7.939002424000023, + "max_rss": 384352, + "receipt_sha256": "e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652", + "pair": 2, + "process_seconds": 8.00499437100001 + }, + { + "engine": "reference", + "seconds": 21.400470477, + "max_rss": 396536, + "receipt_sha256": "e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652", + "pair": 2, + "process_seconds": 21.444284257999982 + } + ], + "median_process_seconds": { + "reference": 21.444284257999982, + "tables": 8.00499437100001 + }, + "speedup": 2.678863127710244, + "python": "3.12.14 (main, Aug 25 2026, 14:00:49) [Clang 22.1.3 ]", + "platform": "Linux-6.18.55-x86_64-with-glibc2.41", + "rss_units": "KiB (Linux)", + "code_sha256": { + "adapter.py": "039399a24b16930a0a7a3c92a5034c2efbe64a0cf52e7bd063ba837d4d605449", + "kernel.py": "decc8e6a4331ffd28460056d49f06758c6fad721e0638ade90a7ee723c367458", + "benchmark.py": "c98692c2654e324ada4743c07a60b626f1880edd5f5b4fc23c7f37ffb773b127", + "SOURCES.json": "65130499f62653607112223322272030e57d7900dc1211944b94c8657e6a3963" + }, + "scope": "Whole PR3168 check, pins, route derivation, full census, Fano searches and controls; fresh processes, warm filesystem caches; no full supplier replay." +} diff --git a/research/fano-census-row-tables/BENCHMARK-python313.json b/research/fano-census-row-tables/BENCHMARK-python313.json new file mode 100644 index 0000000000..66e982765c --- /dev/null +++ b/research/fano-census-row-tables/BENCHMARK-python313.json @@ -0,0 +1,70 @@ +{ + "status": "PASS_IDENTICAL_COMPLETE_FANO_BENCHMARK", + "pairs": 3, + "seed": 91, + "samples": [ + { + "engine": "tables", + "seconds": 7.848937611999986, + "max_rss": 385980, + "receipt_sha256": "e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652", + "pair": 0, + "process_seconds": 7.889600482999981 + }, + { + "engine": "reference", + "seconds": 20.233156099999974, + "max_rss": 398308, + "receipt_sha256": "e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652", + "pair": 0, + "process_seconds": 20.27064412200002 + }, + { + "engine": "reference", + "seconds": 21.05224676199998, + "max_rss": 398304, + "receipt_sha256": "e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652", + "pair": 1, + "process_seconds": 21.089870213999916 + }, + { + "engine": "tables", + "seconds": 7.440832546000024, + "max_rss": 385980, + "receipt_sha256": "e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652", + "pair": 1, + "process_seconds": 7.481164362000072 + }, + { + "engine": "tables", + "seconds": 7.285256874000083, + "max_rss": 385988, + "receipt_sha256": "e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652", + "pair": 2, + "process_seconds": 7.326939702000004 + }, + { + "engine": "reference", + "seconds": 20.68424699400009, + "max_rss": 398308, + "receipt_sha256": "e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652", + "pair": 2, + "process_seconds": 20.72229164999999 + } + ], + "median_process_seconds": { + "reference": 20.72229164999999, + "tables": 7.481164362000072 + }, + "speedup": 2.7699286698280656, + "python": "3.13.5 (main, Aug 10 2026, 12:06:59) [GCC 14.2.0]", + "platform": "Linux-6.18.55-x86_64-with-glibc2.41", + "rss_units": "KiB (Linux)", + "code_sha256": { + "adapter.py": "039399a24b16930a0a7a3c92a5034c2efbe64a0cf52e7bd063ba837d4d605449", + "kernel.py": "decc8e6a4331ffd28460056d49f06758c6fad721e0638ade90a7ee723c367458", + "benchmark.py": "c98692c2654e324ada4743c07a60b626f1880edd5f5b4fc23c7f37ffb773b127", + "SOURCES.json": "65130499f62653607112223322272030e57d7900dc1211944b94c8657e6a3963" + }, + "scope": "Whole PR3168 check, pins, route derivation, full census, Fano searches and controls; fresh processes, warm filesystem caches; no full supplier replay." +} diff --git a/research/fano-census-row-tables/CLAIM.json b/research/fano-census-row-tables/CLAIM.json new file mode 100644 index 0000000000..344f4edcb3 --- /dev/null +++ b/research/fano-census-row-tables/CLAIM.json @@ -0,0 +1,56 @@ +{ + "assignment_seed": 91, + "random_source": "secrets.randbelow(100), operating-system randomness", + "track": "verification engineering", + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "claim_time_utc": "2026-10-17T17:49:00Z", + "expected_finish_utc": "2026-10-17T18:43:00Z", + "object": "PR3168 exact 17-coordinate reduced-triple route census; all 1,379,952 triples", + "hypothesis": "Per-invocation tables for exact GF(2) row actions reduce repeated matrix multiplication without changing any product key, relation or full Fano receipt.", + "method": "Precompute actual two-factor rows and exact right actions, retain full triple enumeration, exact packed-int equality and all original downstream controls.", + "deliverable": "Opt-in pinned adapter, equivalence argument, differential controls and alternating complete-check benchmarks.", + "stopping_rule": "Stop if full receipt or semantic controls differ, or complete-check runtime does not improve. No length-eight census or theorem extension.", + "candidates": [ + { + "task": "PR626 interval kernels", + "decision": "Rejected: matching logarithm/exp contributions #667/#672 already retained." + }, + { + "task": "Owner footprint representation", + "decision": "Rejected: #727 and owner-footprint-crosscheck plus t37-slice-bitmaps cover this mechanism." + }, + { + "task": "PR3168 reduced-triple row products", + "decision": "Selected: bounded costly exact workload; no matching acceleration surfaced." + } + ], + "diversification": "Seed 91 fixes candidate-test matrix stream and alternating benchmark first arm; object chosen after semantic overlap checks, not on seed alone.", + "coordination": "No pinned sprint issue (GitHub pinnedIssues empty). Local claim under user step 3. No Discussion mutation requested.", + "overlap": { + "open_pr_records": 253, + "discussion_records": 2017, + "complete_pagination": true, + "snapshot_utc": "2026-10-17T17:47:55.995857+00:00", + "queries": [ + "centre-seven-owner-fano-independent", + "relation_census", + "route product", + "matrix census", + "route census", + "reduced-triple", + "bytes.translate", + "permutation composition" + ], + "predecessors": [ + "#3097 centre-seven-owner-information-floor", + "#3168 centre-seven-owner-fano-independent", + "#3147 larger block floor (open; no extension attempted)" + ] + }, + "result": { + "status": "completed locally; publication pending", + "useful_result": "Exact row tables speed the unchanged complete PR3168 verifier by 2.68x (Python 3.12) and 2.77x (3.13), preserving all triple keys and the full receipt.", + "evidence": "VALIDATION.json; BENCHMARK-python312.json; BENCHMARK-python313.json", + "remaining": "Maintainer review, other-host performance; no new theorem, supplier or kappa." + } +} diff --git a/research/fano-census-row-tables/PROOF.md b/research/fano-census-row-tables/PROOF.md new file mode 100644 index 0000000000..231e0c7c13 --- /dev/null +++ b/research/fano-census-row-tables/PROOF.md @@ -0,0 +1,61 @@ +# Equality of row-table and direct matrix products + +Fix a dimension d and binary row matrices A, B and C. Encode a row r by +its nonnegative integer with bit j equal to coordinate j. The direct +reference product computes row i of AB as the XOR of rows B[j] for each +set bit j in A[i]. `row_action` computes that same expression: each loop +iteration removes exactly the least significant set bit, and XORs its +corresponding matrix row. The loop terminates after popcount(r) iterations. + +`prepare` computes AB for every ordered pair of distinct route indices. +It collects every row of those products in a finite sorted domain D. +For each right factor C and each row r in D it stores row_action(r,C). +Each reversed row list of AB is replaced by its indices in D. Thus every +lookup made by a reduced triple (a,b,c) is defined and equals the +corresponding row of (AB)C. No involution, route uniqueness, sparsity, +or expectation about the eventual relation histogram is used here. + +Every output row is less than 2^d, since XOR preserves that range. Starting +with zero and appending the rows in reverse order by +`key = (key << d) | row` is exactly the reference encoding +sum(row[i] * 2^(d*i)). This encoding is injective on d-by-d binary +matrices. It has no truncated fingerprint or probabilistic equality test. +The unsigned integer array stores individual rows; the product key is an +arbitrary-precision Python integer, so its 289 bits are retained for d=17. + +The domain a!=b and b!=c is unchanged. Each triple is inserted once, in the +same order as in the original census. Dictionary class membership therefore +agrees exactly. The class histogram, extraction of all pairs of distinct +words, reversal of the second triple and cyclic-reduction test are unchanged. +The returned total, histogram and relation-word set are consequently equal. +This includes duplicate matrices and classes of size greater than two. + +Tables are created inside each census and discarded afterwards. No successful +validation is cached between invocations. The adapter checks all live source +pins before loading the predecessor from authenticated source bytes. It then +replaces only that new module's `relation_census` function. Original route +derivation, active/spectator checks, pair uniqueness, relation multiplication, +symmetry, all Fano incidence and labelling searches, and the planted/missing +relation controls run unchanged. The entire canonical receipt must equal the +pinned predecessor receipt byte for byte. Default predecessor commands and +all frozen source bytes are unchanged. + +This is an algebraic equivalence argument for an implementation change, +supported by finite differential checks. It is not a proof-assistant theorem +or a formal proof of the multiplication bound. The original observation, +faithful representation and support-bound hypotheses remain inherited. + +## Work and storage + +For n routes, d rows and U distinct rows of the n(n-1) two-factor products, +preparation costs O(n^2 d^2 + n U d) bit-selection steps and O(n^2 d + n U) +stored row indices/actions. Product-key formation then uses d exact row +lookups per triple, instead of up to d^2 bit-selection steps plus packing. +The same n(n-1)^2 triples and all equality classes remain resident. + +For the actual input n=112, d=17 and U=18,388. The 2,059,456 table values +occupy 8,237,824 payload bytes on the measured four-byte unsigned-int array +implementation. Pair/domain dictionaries and the unchanged class dictionary +add overhead. Peak process memory is measured separately; the payload count +alone is not a whole-process memory claim. The method does not make an +unbounded larger-word census feasible and adds no length-eight coverage. diff --git a/research/fano-census-row-tables/README.md b/research/fano-census-row-tables/README.md new file mode 100644 index 0000000000..61db8458a2 --- /dev/null +++ b/research/fano-census-row-tables/README.md @@ -0,0 +1,115 @@ +# Exact row tables for the seven-owner Fano census + +**Verification tooling; no new bound, supplier or κ.** An opt-in adapter +accelerates Sudarsh Chaturvedi's PR3168 independent seven-owner verifier. It +replaces repeated binary matrix multiplication by exact per-invocation row +actions. Every one of the 1,379,952 reduced triples remains enumerated, with +full 289-bit product keys and the same complete canonical receipt. + +On this Linux host, three alternating fresh-process pairs under CPython +3.12.14 measured a median **21.44 → 8.00 seconds (2.68×)** for the complete +check. The scope includes input/source hashing, chart-swap route derivation, +the entire census, Fano incidence and labelling searches, and original +positive/negative controls. CPython 3.13.5 measured **20.72 → 7.48 seconds (2.77×)** in three further +alternating pairs. Raw samples and process memory are retained in +[BENCHMARK-python312.json](BENCHMARK-python312.json) and +[BENCHMARK-python313.json](BENCHMARK-python313.json). Timing is descriptive, +with no pass threshold. Filesystem caches were warm; the host was shared. + +## Reproduce + +From the repository root, Python 3.12+ and standard library only: + +```sh +python3 -I -B research/fano-census-row-tables/verify.py +``` + +Expected: `PASS_ALL_EXACT_TRIPLE_KEYS 1379952 rows 18388`, then +`PASS_FANO_ROW_TABLES e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652`. +This command compares **every actual product key** against the original +exact multiply/pack functions, then runs the complete table-backed check. +It checks the full committed PR3168 receipt byte for byte. + +```sh +python3 -I -B -m unittest discover -s research/fano-census-row-tables -p 'test_*.py' -v +python3 -I -B research/fano-census-row-tables/benchmark.py --pairs 3 --out /tmp/new-fano-benchmark.json +python3 scripts/research_package.py --package research/fano-census-row-tables +``` + +Expected: seven test groups; `PASS_IDENTICAL_COMPLETE_FANO_BENCHMARK`; and +successful registered replay. Use a fresh benchmark/output path. The benchmark +runs both complete engines in separate processes, alternating their order, +and checks every receipt. `adapter.py --engine reference` selects the original +engine; the default is `tables`. No existing command is changed. + +## Exactness, controls and limits + +[PROOF.md](PROOF.md) gives the row-action and injective packing argument. +The 12,432 ordered pairs reach 18,388 distinct rows. Tables store the exact +right action of each of the 112 routes on those rows. No intermediate row, +triple, equality class or relation is sampled or omitted. No successful +validation is cached across invocations. The existing pair uniqueness, +spectator block, involution, symmetry and relation-identity checks all remain. + +The complete result retains histogram `{1: 1379852, 2: 50}`, all 100 relation +words (50 braid edges), 30 labelled Fano planes, all 28 six-cycle constraints, +zero valid Fano labellings and the original planted/missing-relation controls. +Additional tests use a separate parity-of-dot-products oracle, exhaustive +small row domains, seed-91 dense 17-coordinate matrices, noncommuting factors, +duplicate/zero matrices and classes larger than two. Four corrupted kernels +are detected: lost high bit, reversed row order, wrong packing stride and a +wrong table entry. Same-size/same-mtime source mutation is rejected after +prior success; restoration works; missing sources and output reuse fail. +Tests also run with optimized Python. + +This is an implementation-equivalence contribution, not another independent +mathematical verification of the support-seven theorem. It inherits the +original observation model, faithful cover-group representation and earlier +support bound. It does not add support-eight or length-eight coverage, +physical acquisition/restoration accounting, supplier admission or a new κ. +The full selected cold replay, `make verify`, Lean and hosted CI were not run +for this isolated opt-in stage. All-size/compiler, realization, hosting, +precision/tape and analytic assumptions remain. + +## Sources and coordination + +Exact base: `463113d675af7410ac91d53a4fed51ec6494eb9a`. +[SOURCES.json](SOURCES.json) records live input SHA-256 and Git blob pins. +The source archive remains immutable and its member hashes are still checked +by the original chart-swap derivation. The selected context at this base is +PR1094, conditional κ = `836330098538459/500000000000000000`, with PR589/555 +bit ancestry; the selected-source inventory is unchanged. + +OS assignment seed **91** selected verification engineering. Three narrow +candidates, method, stopping rule and the local claim are in [CLAIM.json](CLAIM.json). +No pinned sprint coordination issue existed. Overlap checks covered 253 open +PRs and 2,017 Discussion records with complete pagination, plus local package +notes. PR3147's larger-block question is distinct and is not investigated here. +The ledger classifies #3097 and #3168 as partially reviewed archival intake; +this tool does not promote their theorem status. PR3168 source head is +`b8844f08d8832eb87f8a5725f50d9c5eaac953d8`; PR3097 source head is +`ef7a52f4b0acf7cc8c51f9d81274d106abeffa24`. A finite replay is not a formal +proof of the multiplication theorem. + +## Open next questions + +Should this become the PR3168 default after review? A feasible next step is +to review the exact row/packing argument and reproduce the all-product +comparison and complete benchmark on another host. Maintainer review is the +remaining adoption step. No extension of the research family is proposed. + +## Credit and license + +Sudarsh Chaturvedi (`Sudarsh3301`), with Claude assistance, supplied PR3168's +independent census, Fano searches and controls. Gonzalo Mier (`Gonzalo-Mier`) supplied PR3097's support-seven claim and first +census, prepared with OpenAI Codex assistance. The chart-swap derivation +and earlier block-repair result retain Ross Richardson and Aaron Wang/navinor +(PR2391) credit; ywz65 supplied the selected centre observation interface. +Rohan Arun, Jeremy Kothe, Hao Yan and the cumulative PR1094/589/555 supplier +lineage retain their original attribution. Douglas Colkitt supplied the +source-bound review and research-package infrastructure. + +This adapter, table engine, differential tests and benchmark were prepared by +**Charan**, with substantial **OpenAI Codex assistance** in design, code, +explanation, tests and handoff. No delegated or independent human review was +used. Apache-2.0. Frozen predecessor sources and notices remain unchanged. diff --git a/research/fano-census-row-tables/SOURCES.json b/research/fano-census-row-tables/SOURCES.json new file mode 100644 index 0000000000..705762f354 --- /dev/null +++ b/research/fano-census-row-tables/SOURCES.json @@ -0,0 +1,60 @@ +{ + "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/centre-block-repair-information/independent.py", + "usage": "input", + "git_blob": "d2db50ec7a595b1a1a87b7843fd5ca043c43fd25", + "sha256": "b298ff3902c14db11e4ed057259785efc185e8ae3bb39c0d1c432e2340ceb4ea" + }, + { + "path": "research/centre-seven-owner-fano-independent/RESULT.json", + "usage": "input", + "git_blob": "d9570834fc032dedaa59cdce1e9f9c60860b4ffd", + "sha256": "e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652" + }, + { + "path": "research/centre-seven-owner-fano-independent/SOURCES.json", + "usage": "input", + "git_blob": "6c0d566393b20bbd6dc75ffe972e5e655a4d9fb2", + "sha256": "47535c422290da8fae2613e2b167742ddc998d583f9631a5df1417a33cae0517" + }, + { + "path": "research/centre-seven-owner-fano-independent/verify.py", + "usage": "input", + "git_blob": "e2625e93fdc6f81d26f6c145555e0f42749652cd", + "sha256": "b2b7059f1faf2ebc0fbaf5b8a9cd1ce1c018de52dd33047ffea5e0a396c78be0" + }, + { + "path": "research/centre-block-repair-information/RESULT.json", + "usage": "input", + "git_blob": "1127acd01bf0f575cfd25d36797cf320e8f5ace1", + "sha256": "0a53e2ee6f31165a9fff6950f78e965c5fc12a648bd31dcca46c6bbe2a352915" + }, + { + "path": "research/centre-seven-owner-information-floor/RESULT.json", + "usage": "input", + "git_blob": "5b8e492269934de4a0e2186a4c93d68f51b389f9", + "sha256": "47788ad1342fa96389e5c34469ea91d3b74f4975d886858ed9e1e6f336a8affc" + }, + { + "path": "research/community-frontier1094-audit/selected-replay.tar.gz", + "usage": "input", + "git_blob": "c24daf067f9c543421d89ca2eeaa4eb78a57fb6f", + "sha256": "f1da80610bf33c58527f18ad63b4350d0b864e1d4486141ee17ac9bed4d529d6" + } + ] +} diff --git a/research/fano-census-row-tables/TASK.json b/research/fano-census-row-tables/TASK.json new file mode 100644 index 0000000000..702fefb6c1 --- /dev/null +++ b/research/fano-census-row-tables/TASK.json @@ -0,0 +1,61 @@ +{ + "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": "Opt-in exact row-action tables for the complete PR3168 support-seven verifier, preserving every reduced triple and the full canonical receipt.", + "scope_change_reason": "The replay-runtime card is narrowed to one archived independent verifier after rejecting duplicated interval and footprint optimization candidates.", + "bottleneck_link": "The 1,379,952-product relation census dominates this reusable finite support-seven check; accelerating it reduces the cost of exact reviews, without making or pricing a new construction.", + "budget_minutes": 60, + "stop_rule": "One exact row-table implementation. Stop on any product/receipt/control mismatch or no full-check improvement; do not extend the census or theorem.", + "outcome": "completed", + "evidence": "PASS_ALL_EXACT_TRIPLE_KEYS for 1,379,952 current products; complete registered Fano replay; seven semantic/failure test groups (normal/optimized Python 3.12 and normal 3.13); three alternating complete-check pairs per interpreter. BENCHMARK-python312.json and BENCHMARK-python313.json retain every timing.", + "author": "Charan", + "ai_assistance": "Substantial OpenAI Codex assistance in design, code, proof explanation, tests and handoff; no independent human review or delegated workers.", + "open_questions": [ + { + "question": "Should the table engine replace the direct product in the PR3168 checker after maintainer review?", + "why_it_matters": "A default change would reduce repeated finite-review cost; this opt-in package leaves frozen predecessors unchanged.", + "first_step": "Review PROOF.md, reproduce the exact all-triple comparison and complete same-input benchmark on another host.", + "blocked_by": "Maintainer review; no supplier or kappa obligation is discharged by this speedup." + } + ] +} diff --git a/research/fano-census-row-tables/VALIDATION.json b/research/fano-census-row-tables/VALIDATION.json new file mode 100644 index 0000000000..c2c693667d --- /dev/null +++ b/research/fano-census-row-tables/VALIDATION.json @@ -0,0 +1,51 @@ +{ + "status": "PASS_SCOPED_IMPLEMENTATION_EQUIVALENCE", + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "python": [ + "CPython 3.12.14", + "CPython 3.13.5" + ], + "platform": "Linux x86_64", + "registered_replay": "python3 scripts/research_package.py --package research/fano-census-row-tables", + "expected_markers": [ + "PASS_ALL_EXACT_TRIPLE_KEYS 1379952 rows 18388", + "PASS_FANO_ROW_TABLES e33a4809ad6ec2025aa46ecb5b2f9d790295379d4794bd911e0b67cf7e6aa652", + "PASS_REGISTERED_RESEARCH_PACKAGE research/fano-census-row-tables outcome=completed" + ], + "tests": { + "normal_python312": 7, + "optimized_python312": 7, + "normal_python313": 7, + "semantic_kernel_mutants_rejected": 4, + "source_drift": "same-size/same-mtime mutation after prior admission rejected, restoration accepted, missing input rejected", + "output_reuse": "existing output refused before replay, sentinel bytes preserved" + }, + "benchmarks": { + "python312": "BENCHMARK-python312.json", + "python313": "BENCHMARK-python313.json", + "pairs_each": 3, + "full_receipts_identical": true + }, + "orientation": "scripts/research_baseline.py passed; selected record/source/proof-supplement check passed; selected remains PR1094, not a pending title", + "profile": { + "command": "python3 -I -B -m cProfile -o /tmp/fano.prof research/centre-seven-owner-fano-independent/verify.py", + "total_profiled_seconds": 55.366, + "relation_census_cumulative_seconds": 48.731, + "limitation": "Profiling overhead; performance claims use unprofiled complete benchmarks." + }, + "not_run": [ + "full selected supplier cold replay", + "repository-wide make verify", + "Lean", + "hosted CI" + ], + "scope": "No new kappa or theorem claim; every exact triple key and complete original finite Fano receipt retained. Inherited observation/faithful-representation/support hypotheses and multiplication interfaces remain.", + "code_sha256": { + "kernel.py": "decc8e6a4331ffd28460056d49f06758c6fad721e0638ade90a7ee723c367458", + "adapter.py": "039399a24b16930a0a7a3c92a5034c2efbe64a0cf52e7bd063ba837d4d605449", + "verify.py": "af5a79c5de2ae4e9f120ec5c4e5a089fab8180136162dc7b0a8fb108730c196f", + "test_kernel.py": "0ea9526afc2b74e4cf26bf840a7a8cf31471a2dfa043f1eb368fc43b2bd984e3", + "benchmark.py": "c98692c2654e324ada4743c07a60b626f1880edd5f5b4fc23c7f37ffb773b127" + }, + "registered_replay_log_sha256": "14730f9c28f22ff74f90f4081766af3608fd355025329d7f160af7ca5c31151b" +} diff --git a/research/fano-census-row-tables/VERIFY.json b/research/fano-census-row-tables/VERIFY.json new file mode 100644 index 0000000000..2f313f3e5f --- /dev/null +++ b/research/fano-census-row-tables/VERIFY.json @@ -0,0 +1,44 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/centre-block-repair-information/RESULT.json", + "research/centre-block-repair-information/independent.py", + "research/centre-seven-owner-fano-independent/RESULT.json", + "research/centre-seven-owner-fano-independent/SOURCES.json", + "research/centre-seven-owner-fano-independent/verify.py", + "research/centre-seven-owner-information-floor/RESULT.json", + "research/community-frontier1094-audit/selected-replay.tar.gz" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "-m", + "unittest", + "discover", + "-s", + "{package}", + "-p", + "test_*.py", + "-v" + ], + "timeout_seconds": 60, + "checks": "Exact small/seeded GF(2) oracle comparisons, collisions and degenerate domains, matrix-order checks, invalid-input and semantic/source-failure controls." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 300, + "checks": "All 1,379,952 triple product keys equal the original exact multiplication; complete original Fano receipt and all original controls retained." + } + ] +} diff --git a/research/fano-census-row-tables/adapter.py b/research/fano-census-row-tables/adapter.py new file mode 100644 index 0000000000..cd961b641e --- /dev/null +++ b/research/fano-census-row-tables/adapter.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""Run the complete pinned PR3168 verifier with an opt-in census engine.""" +import argparse +import hashlib +import importlib.util +import json +from pathlib import Path +import sys +import types + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +SOURCE = ROOT / 'research/centre-seven-owner-fano-independent/verify.py' +EXPECTED = SOURCE.with_name('RESULT.json') + + +def load_kernel(): + spec = importlib.util.spec_from_file_location('fano_row_tables', HERE / 'kernel.py') + kernel = importlib.util.module_from_spec(spec) + spec.loader.exec_module(kernel) + return kernel + + +def check_pins(): + for row in json.loads((HERE / 'SOURCES.json').read_bytes())['files']: + if row['usage'] == 'input': + if hashlib.sha256((ROOT / row['path']).read_bytes()).hexdigest() != row['sha256']: + raise ValueError('source pin: ' + row['path']) + + +def reference(): + check_pins() + module = types.ModuleType('pinned_fano_reference') + module.__file__ = str(SOURCE) + exec(compile(SOURCE.read_bytes(), str(SOURCE), 'exec'), module.__dict__) + return module + + +def run(engine): + module = reference() + if engine == 'tables': + module.relation_census = load_kernel().relation_census + elif engine != 'reference': + raise ValueError('unknown engine') + result = module.canonical(module.build()) + if result != EXPECTED.read_bytes(): + raise ValueError('complete PR3168 receipt differs') + return result + + +def main(): + ap = argparse.ArgumentParser(description=__doc__) + ap.add_argument('--engine', choices=('reference', 'tables'), default='tables') + ap.add_argument('--output', type=Path) + args = ap.parse_args() + if args.output and args.output.exists(): + raise SystemExit('output exists') + result = run(args.engine) + if args.output: + with args.output.open('xb') as stream: + stream.write(result) + print('PASS_FANO_ROW_TABLES_COMPLETE_RECEIPT', args.engine) + + +if __name__ == '__main__': + main() diff --git a/research/fano-census-row-tables/benchmark.py b/research/fano-census-row-tables/benchmark.py new file mode 100644 index 0000000000..84e4a4e79b --- /dev/null +++ b/research/fano-census-row-tables/benchmark.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""Alternating fresh-process benchmarks of the same complete PR3168 check.""" +import argparse +import hashlib +import importlib.util +import json +from pathlib import Path +import platform +import resource +import statistics +import subprocess +import sys +import tempfile +import time + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] + + +def load_adapter(): + spec = importlib.util.spec_from_file_location('adapter', HERE / 'adapter.py') + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def main(): + ap = argparse.ArgumentParser(description=__doc__) + ap.add_argument('--pairs', type=int, default=3) + ap.add_argument('--out', type=Path) + ap.add_argument('--worker', choices=('reference', 'tables')) + args = ap.parse_args() + if args.worker: + adapter = load_adapter() + start = time.perf_counter() + result = adapter.run(args.worker) + seconds = time.perf_counter() - start + usage = resource.getrusage(resource.RUSAGE_SELF) + print(json.dumps(dict(engine=args.worker, seconds=seconds, + max_rss=usage.ru_maxrss, + receipt_sha256=hashlib.sha256(result).hexdigest()))) + return + if not 1 <= args.pairs <= 7 or args.out is None or args.out.exists(): + raise SystemExit('use 1..7 pairs and a fresh --out path') + samples = [] + for pair in range(args.pairs): + order = ('tables', 'reference') if (91 + pair) % 2 else ('reference', 'tables') + for engine in order: + start = time.perf_counter() + child = subprocess.run([sys.executable, '-I', '-B', str(Path(__file__).resolve()), + '--worker', engine], cwd=ROOT, capture_output=True, + text=True, check=True, timeout=300) + row = json.loads(child.stdout) + row.update(pair=pair, process_seconds=time.perf_counter() - start) + samples.append(row) + print(engine, row['process_seconds'], flush=True) + if len({x['receipt_sha256'] for x in samples}) != 1: + raise ValueError('complete receipts differ') + medians = {engine: statistics.median(x['process_seconds'] for x in samples if x['engine'] == engine) + for engine in ('reference', 'tables')} + files = ('adapter.py', 'kernel.py', 'benchmark.py', 'SOURCES.json') + result = dict(status='PASS_IDENTICAL_COMPLETE_FANO_BENCHMARK', pairs=args.pairs, + seed=91, samples=samples, median_process_seconds=medians, + speedup=medians['reference'] / medians['tables'], + python=sys.version, platform=platform.platform(), + rss_units='bytes' if sys.platform == 'darwin' else 'KiB (Linux)', + code_sha256={f: hashlib.sha256((HERE / f).read_bytes()).hexdigest() for f in files}, + scope='Whole PR3168 check, pins, route derivation, full census, Fano searches and controls; fresh processes, warm filesystem caches; no full supplier replay.') + with args.out.open('x') as stream: + stream.write(json.dumps(result, indent=2) + '\n') + print(result['status'], result['speedup']) + + +if __name__ == '__main__': + main() diff --git a/research/fano-census-row-tables/kernel.py b/research/fano-census-row-tables/kernel.py new file mode 100644 index 0000000000..26405f5321 --- /dev/null +++ b/research/fano-census-row-tables/kernel.py @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Exact GF(2) row-action tables for the PR3168 reduced-triple census. + +Charan, with substantial OpenAI Codex assistance. No persistent acceptance cache. +""" +from array import array +from collections import Counter + + +def row_action(row, matrix): + """XOR the selected rows; the row-vector action is linear over GF(2).""" + out = 0 + while row: + bit = row & -row + out ^= matrix[bit.bit_length() - 1] + row ^= bit + return out + + +def prepare(matrices, dimension=17): + if not 1 <= dimension <= 32: + raise ValueError('row tables require dimension 1..32') + m = [tuple(x) for x in matrices] + if any(len(x) != dimension or any(type(r) is not int or not 0 <= r < 1 << dimension + for r in x) for x in m): + raise ValueError('invalid GF(2) row matrix') + pairs = {(a, b): tuple(row_action(row, m[b]) for row in m[a]) + for a in range(len(m)) for b in range(len(m)) if a != b} + # Only rows reached by actual reduced pairs are needed; every later lookup + # is on one of these rows, by construction. No closed-form route assumption. + domain = sorted({row for ab in pairs.values() for row in ab}) + indices = {row: i for i, row in enumerate(domain)} + indexed = {pair: tuple(indices[row] for row in reversed(rows)) + for pair, rows in pairs.items()} + actions = [array('I', (row_action(row, right) for row in domain)) for right in m] + return indexed, actions, domain + + +def product_key(indexed_rows, action, dimension=17): + # Reverse row order makes this Horner encoding exactly sum(row[i] << d*i). + key = 0 + for i in indexed_rows: + key = (key << dimension) | action[i] + return key + + +def relation_census(matrices): + """Same full domain and exact dictionary keys as the pinned reference.""" + indexed, actions, _ = prepare(matrices) + classes = {} + n = len(matrices) + for a in range(n): + for b in range(n): + if a == b: + continue + rows = indexed[a, b] + for c in range(n): + if c != b: + classes.setdefault(product_key(rows, actions[c]), []).append((a, b, c)) + sizes = Counter(map(len, classes.values())) + relations = set() + for words in classes.values(): + for left in words: + for right in words: + if left != right: + a, b, c = left + d, e, f = right + w = (a, b, c, f, e, d) + if all(w[i] != w[(i + 1) % 6] for i in range(6)): + relations.add(w) + return sum(sizes[k] * k for k in sizes), sizes, relations diff --git a/research/fano-census-row-tables/test_kernel.py b/research/fano-census-row-tables/test_kernel.py new file mode 100644 index 0000000000..ecc2c8a444 --- /dev/null +++ b/research/fano-census-row-tables/test_kernel.py @@ -0,0 +1,135 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Semantic differential and mutation controls; standard-library unittest.""" +import hashlib +import importlib.util +import json +import os +from pathlib import Path +import random +import types +import unittest + +HERE = Path(__file__).resolve().parent + + +def load(name): + spec = importlib.util.spec_from_file_location(name, HERE / (name + '.py')) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +K = load('kernel') +A = load('adapter') +V = load('verify') + + +def dot_product(left, right, dimension): + """Independent parity-of-dot-products oracle (no row-selection XOR loop).""" + columns = [sum(((right[i] >> j) & 1) << i for i in range(dimension)) + for j in range(dimension)] + return tuple(sum(((row & col).bit_count() % 2) << j for j, col in enumerate(columns)) + for row in left) + + +class KernelTests(unittest.TestCase): + def test_exhaustive_small_actions(self): + for d in range(1, 5): + # Every row and every single-bit matrix, plus dense/zero matrices. + matrices = [tuple(0 for _ in range(d)), tuple((1 << d)-1 for _ in range(d))] + matrices += [tuple((1 << j) if i == k else 0 for i in range(d)) + for j in range(d) for k in range(d)] + for matrix in matrices: + for row in range(1 << d): + self.assertEqual(K.row_action(row, matrix), dot_product((row,), matrix, d)[0]) + + def test_seeded_full_width_and_packing(self): + rng = random.Random(91) + for _ in range(30): + matrices = [tuple(rng.randrange(1 << 17) for _ in range(17)) for _ in range(4)] + pairs, actions, _ = K.prepare(matrices) + for (a, b), indices in pairs.items(): + ab = dot_product(matrices[a], matrices[b], 17) + for c in range(4): + expected = dot_product(ab, matrices[c], 17) + key = sum(row << (17*i) for i, row in enumerate(expected)) + self.assertEqual(K.product_key(indices, actions[c]), key) + + def test_census_with_collisions_and_degenerate_domains(self): + ref = A.reference() + rng = random.Random(91) + identity = tuple(1 << i for i in range(17)) + examples = [[], [identity], [identity]*4, [(0,)*17]*4, + [tuple(rng.randrange(1 << 17) for _ in range(17)) for _ in range(7)]] + for matrices in examples: + self.assertEqual(K.relation_census(matrices), ref.relation_census(matrices)) + dense = examples[-1] + self.assertNotEqual(ref.mul(dense[0], dense[1]), ref.mul(dense[1], dense[0])) + self.assertEqual(K.relation_census(list(reversed(dense))), ref.relation_census(list(reversed(dense)))) + + def test_input_rejection(self): + for d in (0, 33): + with self.assertRaises(ValueError): K.prepare([], d) + for matrix in ((0,)*16, (-1,)+(0,)*16, (1 << 17,)+(0,)*16, (True,)+(0,)*16): + with self.assertRaises(ValueError): K.prepare([matrix]) + + def test_semantic_mutants(self): + ref = A.reference() + rng = random.Random(91) + matrices = [tuple(rng.randrange(1 << 17) for _ in range(17)) for _ in range(4)] + # Exercise the very differential checker used by verify.py. + for name, key in [('omit_high_bit', lambda ids, action: K.product_key(ids, action) & ((1 << 288)-1)), + ('wrong_row_order', lambda ids, action: K.product_key(tuple(reversed(ids)), action)), + ('wrong_stride', lambda ids, action: K.product_key(ids, action, 16))]: + mutant = types.SimpleNamespace(prepare=K.prepare, product_key=key) + with self.subTest(name=name), self.assertRaises(ValueError): + V.compare_products(ref, mutant, matrices) + def corrupted(m): + pairs, actions, domain = K.prepare(m) + actions[2][pairs[0, 1][0]] ^= 1 + return pairs, actions, domain + with self.assertRaises(ValueError): + V.compare_products(ref, types.SimpleNamespace(prepare=corrupted, product_key=K.product_key), matrices) + + def test_source_corruption(self): + # Same-size and same-timestamp drift after successful admission still + # fails: each call hashes current bytes, with no acceptance cache. + import tempfile + with tempfile.TemporaryDirectory() as directory: + original = A.ROOT, A.HERE + A.ROOT = A.HERE = root = Path(directory) + source = root / 'input.py' + source.write_bytes(b'x = 1\n') + pins = {'files': [{'path': 'input.py', 'usage': 'input', + 'sha256': hashlib.sha256(source.read_bytes()).hexdigest()}]} + (root / 'SOURCES.json').write_text(json.dumps(pins)) + try: + A.check_pins() + before = source.stat() + source.write_bytes(b'x = 2\n') + os.utime(source, ns=(before.st_atime_ns, before.st_mtime_ns)) + with self.assertRaisesRegex(ValueError, 'source pin: input.py'): + A.check_pins() + source.write_bytes(b'x = 1\n') + A.check_pins() + source.unlink() + with self.assertRaises(FileNotFoundError): A.check_pins() + finally: + A.ROOT, A.HERE = original + + def test_existing_output_refused(self): + import subprocess + import sys + import tempfile + with tempfile.TemporaryDirectory() as directory: + output = Path(directory) / 'receipt.json' + output.write_bytes(b'do not overwrite\n') + child = subprocess.run([sys.executable, '-I', '-B', str(HERE / 'adapter.py'), + '--output', str(output)], capture_output=True) + self.assertNotEqual(child.returncode, 0) + self.assertIn(b'output exists', child.stderr) + self.assertEqual(output.read_bytes(), b'do not overwrite\n') + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/research/fano-census-row-tables/verify.py b/research/fano-census-row-tables/verify.py new file mode 100644 index 0000000000..db577820fa --- /dev/null +++ b/research/fano-census-row-tables/verify.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""Check every actual triple key, then run the complete original Fano check.""" +import hashlib +import importlib.util +import json +from pathlib import Path + +HERE = Path(__file__).resolve().parent + + +def load_adapter(): + spec = importlib.util.spec_from_file_location('adapter', HERE / 'adapter.py') + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def compare_products(ref, kernel, matrices): + indexed, actions, domain = kernel.prepare(matrices) + checked = 0 + for a in range(len(matrices)): + for b in range(len(matrices)): + if a == b: + continue + ab = ref.mul(matrices[a], matrices[b]) + for c in range(len(matrices)): + if c != b: + actual = kernel.product_key(indexed[a, b], actions[c]) + expected = ref.pack(ref.mul(ab, matrices[c])) + if actual != expected: + raise ValueError(f'exact product differs at {(a, b, c)}') + checked += 1 + return checked, len(domain) + + +def main(): + adapter = load_adapter() + ref = adapter.reference() + matrices = [ref.to_rows(r) for r in ref.load_routes()] + checked, rows = compare_products(ref, adapter.load_kernel(), matrices) + if (checked, rows) != (1379952, 18388): + raise ValueError('actual domain changed') + print('PASS_ALL_EXACT_TRIPLE_KEYS', checked, 'rows', rows, flush=True) + result = adapter.run('tables') + print('PASS_FANO_ROW_TABLES', hashlib.sha256(result).hexdigest()) + + +if __name__ == '__main__': + main()