diff --git a/research/pr7633-independent-recount/.gitattributes b/research/pr7633-independent-recount/.gitattributes new file mode 100644 index 0000000000..b13bbf03d0 --- /dev/null +++ b/research/pr7633-independent-recount/.gitattributes @@ -0,0 +1 @@ +inputs/** -text \ No newline at end of file diff --git a/research/pr7633-independent-recount/README.md b/research/pr7633-independent-recount/README.md new file mode 100644 index 0000000000..950605f6e0 --- /dev/null +++ b/research/pr7633-independent-recount/README.md @@ -0,0 +1,137 @@ +# Independent recount of the PR #7631 and #7633 words and invoices + +**No new κ. No frontier change. No supplier admission.** This package is an +independent finite audit of two successive open candidates by Clear1nsight: +[PR #7631](https://github.com/CrocSwap/integer-mult-bounds/pull/7631) at exact +head `2f1cc8c0f8c281afd2f99aeeeae6153e269f4721` (conditional κ ≥ 0.003666272802) +and [PR #7633](https://github.com/CrocSwap/integer-mult-bounds/pull/7633) at +exact head `8b885be4a553dea375303808fdfff52ed0d71019` (conditional +κ ≥ 0.003667193194322). The #7633 source word is byte-equal to the #7631 +candidate word, so one package covers both links. It applies the method of +[PR #7628](https://github.com/CrocSwap/integer-mult-bounds/pull/7628) and +[PR #7635](https://github.com/CrocSwap/integer-mult-bounds/pull/7635). + +## Why this check adds coverage + +Each PR ships a complete paid and target invoice for its word, but the invoice +is the previous invoice plus a declared change. This package binds both sides of +each change to the word bytes with separate counts that run in about two +seconds. `verify.py` imports no constructor, application or pricing engine from +the PRs. No audit of #7631 or #7633 was found among the open PRs on 2026-11-17. + +## Result + +All statements are about the six pinned files in `inputs/pr7633/`. Their bytes +equal the blobs at the PR heads (see [SOURCES.json](SOURCES.json)). The #7631 +candidate word and invoice equal the #7633 source word and invoice, byte for +byte. + +1. **Digests.** The canonical JSON digests of the #7631 candidate word + (`1ea66c26…`) and of the #7633 word (`4961e5e9…`) equal the two digests that + the #7633 README states. +2. **Chart chronology.** Each field is followed through the complete program of + all three words (77,373, 77,393 and 77,598 events). Each MOVE starts at the + current chart of its field. Each ADD, COPY and SCALE acts at the chart where + its operands are. Each INIT creates a dead owned field and each CLEAR removes + a live owned field at its current chart. The public fields end at the `final` + charts. +3. **Paid recount.** Rank law: `rank(a->b) = dim(A+B) - dim(A∩B)` over GF(2). + In all words each MOVE joins two nested frames and has a positive rank. With + `H(word)` the MOVE rank histogram, exactly `paid(invoice) = 17 · H(word) + K` + with the same `K = {1:384, 8:656, 9:32, 16:416, 24:416, 32:416, 40:416, 48:416, 56:416, 64:208}` + for all three words. This `K` equals the one of the #7612 and #7630 + recounts. + + | link | native MOVE change per call | MOVEs | paid positions | + |---|---|---|---| + | #7631 | `{2:-1, 3:-1, 5:+1}` | 6,251 to 6,250 | 110,043 to 110,026 | + | #7633 | `{3:-1}` | 6,250 to 6,249 | 110,026 to 110,009 | +4. **Target recount.** For each helper field (every public field that is not a + main, with the main set as #7630 defines it) the target rank is + `rank(final frame) - rank(initial frame)`. Exactly + `targets(invoice) = 17 · T(word) + K_T`, with the same + `K_T = {9:416, 17:416, 25:416, 33:416, 41:416, 49:416, 57:416, 65:416, 73:208, 137:208}` + for all three words. The #7631 link changes no helper target. The #7633 link + changes `initial[457]` from 3 to 281 and no other initial chart. Its helper + change per call is `{6:+1, 9:-1}`. Target positions stay 22,461 and the rank + surplus stays 1,424. +5. **Moment signs.** A separate 256-bit integer interval engine evaluates + `M(κ) = Σ (T_r - P_r) r^(1-κ)`. Its signs agree with the PRs at 14 points: + each candidate is positive at its claim and at its raw lower bracket, and + negative at its raw upper bracket (the brackets are 10^-34 wide). The #7633 + invoice is also positive at its tested point `0.00366719319432207` and at the + #7631 claim. Each older invoice is negative at the newer claim. The #7627 + value `0.003665731276` is positive for the #7631 source and for #7631. The + upper bounds of `dM/dκ` on `[0, 0.00376669]` are negative for all three + invoices. For #7631 and #7633 they are `-379433.91241361655` and + `-379338.0672489424`. These equal the values in the #7633 price file to all + printed digits, so the two engines agree. +6. **Tent test.** For each link the change in the moment is zero or positive for + every tariff `min(r, a)` and positive for some a. So each step is no worse + for any increasing concave tariff with `f(0) = 0`. +7. **Controls.** Eighteen semantic mutations reject (eight for #7631 and ten for + #7633): a growth-only rank law, one more paid unit, the old word with the new + invoice, the old helper targets with the new invoice, an undone rebirth of + field 457, an ADD at the wrong chart, a MOVE to another chart, a changed + frame, the old invoice at the new claim, and a point above the bracket. + +## What this does not establish + +- #7633 depends on a common whole-private-extent supplier U that the PR states + is not implemented, and on its own cold replay, which is open. This audit does + not touch either one. +- `K` and `K_T` are measured from the invoices. They are not derived from the + #7113 caller. +- The main set is the definition of #7630. It is not derived from the physical + caller. +- The ordinary bill is not recounted. The #7633 matched-ordinary record gives + 791,355,340 for its source and 791,537,376 for its candidate, so this step + adds 182,036. About 208 million of the 10^9 allowance remain. +- The 205 candidate CLEAR certificates, the exact rational replay, the native + and physical checks, the signed catalogue and the precision premises are not + replayed. +- Earlier links of the chain (#7625, #7626, #7627) are not recounted. The #7631 + source word is bound to its invoice here, but not to the #7627 word. +- The five framework assumptions remain as the PRs state them. A correct count + is not a supplier admission. + +## Reproduce + +From the repository root, Python 3.10 or later, standard library only: + +```sh +python3 scripts/research_package.py --package research/pr7633-independent-recount --check-only +python3 scripts/research_package.py --package research/pr7633-independent-recount +python3 -I -B research/pr7633-independent-recount/verify.py +``` + +Environment of the recorded run: CPython 3.13.9, Windows 11, about 2 s, with +the registered argv run directly. The package runner requires Python 3.12 for +the replay step, and this machine has no Python 3.12. **The Python 3.12 runner +replay is not run.** Canonical main at the start and before submission: +`e54523517d0f03e58352e647c403a5af3e525a57`, priority revision 8, checked +2026-11-17 UTC. + +## Open next questions + +The structured list is in [TASK.json](TASK.json). + +1. Recount the ordinary bills with the formula the PRs name. Blocker: that + formula lives in repository scripts that this audit did not read. +2. Implement or refute the common supplier U of #7633. Blocker: it needs the + #7113 caller and is outside a count audit. +3. Add the earlier links of the chain (#7625, #7626, #7627) to `verify.py`. + +## Credit + +The audited constructions, words, invoices and claims are by Clear1nsight +(#7631, #7633), on the role-457 mechanism of DreamingOfClouds (#7630), the +work of SYLforge (#7624, #7620) and the P104 lineage of Ali Romman, Hao Yan, +ToikY, Rohan Arun and their predecessors. The recursive invoice schema and the +pricing tools belong to their authors. The vendored files keep their Apache-2.0 +license. The task card `independent-moment` and the package tooling are by +Douglas Colkitt. + +This audit was prepared by fluorine with substantial Anthropic Claude +(Claude Code) assistance. New work is Apache-2.0. No independent human review +of this audit exists yet. diff --git a/research/pr7633-independent-recount/SOURCES.json b/research/pr7633-independent-recount/SOURCES.json new file mode 100644 index 0000000000..71052ec856 --- /dev/null +++ b/research/pr7633-independent-recount/SOURCES.json @@ -0,0 +1,90 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/pr7633-independent-recount/inputs/pr7633/word-7631-source.json.gz", + "usage": "input", + "git_blob": "cc049cc11439403f2ed057b8eb4970a27ead17db", + "sha256": "3b0947df9d291308279a00e009f9c1f845151b5b40f81960a53a2949cb44c9a9", + "origin": { + "pull_request": 7631, + "commit": "2f1cc8c0f8c281afd2f99aeeeae6153e269f4721", + "path": "research/p104-e4-direct-on7627/evidence/e4-native-qualification/PHYSICAL-SOURCE/word.json.gz" + }, + "pin": "head:677c0aa6cd18ad795f485943939e20b6744514c6:research/pr7633-independent-recount/inputs/pr7633/word-7631-source.json.gz" + }, + { + "path": "research/pr7633-independent-recount/inputs/pr7633/word-7631.json.gz", + "usage": "input", + "git_blob": "5a0a4220109044679d646ca2c28458faaeef7979", + "sha256": "736d475843e2ca53cad8a193ed582926e2659abaec40895a41d55efd4fca532f", + "origin": { + "pull_request": 7633, + "commit": "8b885be4a553dea375303808fdfff52ed0d71019", + "path": "research/p104-e1-role457-on7631/words/source.json.gz" + }, + "pin": "head:677c0aa6cd18ad795f485943939e20b6744514c6:research/pr7633-independent-recount/inputs/pr7633/word-7631.json.gz" + }, + { + "path": "research/pr7633-independent-recount/inputs/pr7633/word-7633.json.gz", + "usage": "input", + "git_blob": "c51b08bf0f7949996f2ce1696f3d0168c333185d", + "sha256": "49bd1b5527e5c0de1ba22101a167a66d0d7ab0fd6665569a2cb1648e71ed5ff0", + "origin": { + "pull_request": 7633, + "commit": "8b885be4a553dea375303808fdfff52ed0d71019", + "path": "research/p104-e1-role457-on7631/words/candidate.json.gz" + }, + "pin": "head:677c0aa6cd18ad795f485943939e20b6744514c6:research/pr7633-independent-recount/inputs/pr7633/word-7633.json.gz" + }, + { + "path": "research/pr7633-independent-recount/inputs/pr7633/invoice-7631-source.json", + "usage": "input", + "git_blob": "e2f3b50cb545c33468be7c3cd3428e48e4d06a60", + "sha256": "e9df1b46a4505848f1c03dffbaa4bda156c546bc5d3f2bce439d7052981c278f", + "origin": { + "pull_request": 7631, + "commit": "2f1cc8c0f8c281afd2f99aeeeae6153e269f4721", + "path": "research/p104-e4-direct-on7627/invoices/source.json" + }, + "pin": "head:677c0aa6cd18ad795f485943939e20b6744514c6:research/pr7633-independent-recount/inputs/pr7633/invoice-7631-source.json" + }, + { + "path": "research/pr7633-independent-recount/inputs/pr7633/invoice-7631.json", + "usage": "input", + "git_blob": "7bd52f16185951f831215fe97221b102cc412f0f", + "sha256": "b75347941e7545ccaf50f5607f39f743f88fd1313ec3b3de7e385633cac2bd40", + "origin": { + "pull_request": 7633, + "commit": "8b885be4a553dea375303808fdfff52ed0d71019", + "path": "research/p104-e1-role457-on7631/invoices/source.json" + }, + "pin": "head:677c0aa6cd18ad795f485943939e20b6744514c6:research/pr7633-independent-recount/inputs/pr7633/invoice-7631.json" + }, + { + "path": "research/pr7633-independent-recount/inputs/pr7633/invoice-7633.json", + "usage": "input", + "git_blob": "c17c558206dad21d30fdba8462fd54f8a3edb70d", + "sha256": "f0c0fb377df557197b391a80a918da1e37d2a2ed707d1b4971d881c2c441bc3b", + "origin": { + "pull_request": 7633, + "commit": "8b885be4a553dea375303808fdfff52ed0d71019", + "path": "research/p104-e1-role457-on7631/invoices/candidate.json" + }, + "pin": "head:677c0aa6cd18ad795f485943939e20b6744514c6:research/pr7633-independent-recount/inputs/pr7633/invoice-7633.json" + } + ] +} diff --git a/research/pr7633-independent-recount/TASK.json b/research/pr7633-independent-recount/TASK.json new file mode 100644 index 0000000000..013f3591c2 --- /dev/null +++ b/research/pr7633-independent-recount/TASK.json @@ -0,0 +1,111 @@ +{ + "schema_version": 1, + "task_id": "independent-moment", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "original_card": { + "id": "independent-moment", + "question": "Does a changed construction's serialized target/paid invoice independently support its claimed improvement?", + "starting_points": [ + "docs/research/current-priorities.md", + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "docs/research/recursive-invoice-preflight.md" + ], + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "acceptance_gate": "Demonstrate independence, source binding, positive cases and semantic failure controls. Name the existing checks and the missing coverage. More digits or another equivalent evaluation of an unchanged root is not by itself new verification coverage.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "first_experiment": "Independently recount one changed emitted word and its complete caller, importing no constructor or pricing engine. Include target losses, owned lifetimes, native orientation and extra charges. Check existing #5633/#5708/#5717/#5719 coverage to avoid duplicate audits and preserve its exact head. Stop after the chosen missing implication; a correct root alone is not supplier admission.", + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "overlap_terms": [ + "invoice", + "signed moment", + "productive target", + "independent recount" + ], + "existing_checks": [ + { + "scope": "PR #4088: mixed local/owner/phase ledger and moment reported.", + "evidence": "research/staged544-mixed-fourth-entry/README.md", + "remaining": "Independent binding of changed construction to paid histogram, distinct from full admission.", + "status": "author-checked", + "source_commit": "72d7efc181edb21806a878f174847c96dd410ab0", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4091: sharp pooled ceiling proposed for fixed THREE/FOUR words and inventory.", + "evidence": "research/staged-fourth-mixture-ceiling/README.md", + "remaining": "Validate dual, exhaustive pattern scope and exact source equivalence before applying to newer fills.", + "status": "author-checked", + "source_commit": "a29bdd8f56cd18b805917775cdec09ff935eddc4", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4067: paid (2,2) to (1,3) exchange and fixed OQ4 host reported.", + "evidence": "research/r437-two-window-carrier/README.md", + "remaining": "Independent full cost delta; remaining caller/precision/stock obligations are separate.", + "status": "author-checked", + "source_commit": "a95f11c52e3ca1e4c5171b3c20d8f4b0815aee2e", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "status": "reviewed", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + } + ] + }, + "scope_status": "refined", + "actual_scope": "Independent recount, at the exact open PR heads #7631 2f1cc8c0f8c281afd2f99aeeeae6153e269f4721 and #7633 8b885be4a553dea375303808fdfff52ed0d71019, of two successive links (the #7631 source word to the #7631 word, and that word to the #7633 word): (1) header and initial-chart changes, (2) the chart chronology of all three complete words, (3) the MOVE rank histograms and their relation to the declared 17-call paid invoices, (4) the helper target ranks and their relation to the declared target invoices, and (5) the signs of the declared complete moments at the claims, the raw brackets and the #7627 value. The canonical digests of the two #7633 words are compared with the ones its README states. No constructor, application or pricing engine of the PRs is imported.", + "scope_change_reason": "The first experiment of the card is applied to newer exact heads. No audit of #7633 or #7631 was found among the open PRs on 2026-11-17. The #7633 source word is byte-equal to the #7631 candidate word, so one package covers both links. #7633 builds on the role-457 mechanism of #7630 and carries a common whole-private-extent supplier premise that this audit does not touch.", + "bottleneck_link": "The complex supplier binds. #7631 and #7633 change paid MOVE ranks of the P104 word, and #7633 also changes one helper target. Each invoice is built from the previous one plus a declared change. This audit binds both sides of each change to the emitted word bytes.", + "budget_minutes": 60, + "stop_rule": "Stop after the word-to-invoice binding and the moment signs of the two links are resolved or one exact mismatch is found. Do not replay the native, signed, physical, ordinary, supplier or outer stages.", + "outcome": "completed", + "evidence": "verify.py passes on CPython 3.13.9 (Windows) in about 2 s: for both links paid = 17 x (MOVE rank histogram of the word) + one fixed caller histogram, equal to the ones of the #7612 and #7630 recounts; targets = 17 x (helper target histogram) + one fixed caller target histogram; the native deltas {2:-1,3:-1,5:+1} and {3:-1} and the helper delta {6:+1,9:-1} are recounted from the words; all three words have a legal chart chronology; the canonical digests equal the two that the #7633 README states; the moment signs agree with the PRs at 14 points; the derivative bounds equal the values in the #7633 price file; and 18 controls reject.", + "author": "fluorine", + "ai_assistance": "Prepared with substantial Anthropic Claude (Claude Code) assistance: task selection, verifier code, runs and text. No independent human review of the mathematics.", + "open_questions": [ + { + "question": "Recount the ordinary bills. The #7633 matched-ordinary record gives 791,355,340 (source) and 791,537,376 (candidate), so this step adds 182,036.", + "why_it_matters": "The moment does not depend on it, but the 10^9 allowance does. About 208 million remain.", + "first_step": "Count the route, scalar and odd-division items of the word with the formula the PRs name and compare with the stated totals.", + "blocked_by": "The formula lives in repository scripts that this audit did not read." + }, + { + "question": "Implement or refute the common whole-private-extent supplier U that the #7633 bound depends on.", + "why_it_matters": "#7633 states that U is not implemented. Without it the claim is conditional on an unproved supplier.", + "first_step": "Start with the quantifiers and costs in COMMON-U.json of #7633.", + "blocked_by": "This is outside a count audit and needs the #7113 caller." + }, + { + "question": "Extend the same recount to the earlier links of the chain (#7625, #7626, #7627) and tie the #7631 source word to the #7627 word.", + "why_it_matters": "Each link inherits the premises of the previous one. Only the last two links are bound to word bytes here.", + "first_step": "Fetch the words and invoices of those PRs and add them as links in verify.py.", + "blocked_by": "Their packages have other layouts that this audit did not read." + } + ] +} diff --git a/research/pr7633-independent-recount/VERIFY.json b/research/pr7633-independent-recount/VERIFY.json new file mode 100644 index 0000000000..8774bdadf9 --- /dev/null +++ b/research/pr7633-independent-recount/VERIFY.json @@ -0,0 +1,28 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/pr7633-independent-recount/inputs/pr7633/word-7631-source.json.gz", + "research/pr7633-independent-recount/inputs/pr7633/word-7631.json.gz", + "research/pr7633-independent-recount/inputs/pr7633/word-7633.json.gz", + "research/pr7633-independent-recount/inputs/pr7633/invoice-7631-source.json", + "research/pr7633-independent-recount/inputs/pr7633/invoice-7631.json", + "research/pr7633-independent-recount/inputs/pr7633/invoice-7633.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "-W", + "error", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Input pins and the canonical word digests stated by #7633; complete chart chronology of three words; GF(2) MOVE rank recount and 17-call paid split for two links; helper target recount and 17-call target split; moment signs, strict monotonicity and a tent-tariff test with an independent 256-bit interval engine; rejecting controls for each link." + } + ] +} diff --git a/research/pr7633-independent-recount/inputs/pr7633/invoice-7631-source.json b/research/pr7633-independent-recount/inputs/pr7633/invoice-7631-source.json new file mode 100644 index 0000000000..e2f3b50cb5 --- /dev/null +++ b/research/pr7633-independent-recount/inputs/pr7633/invoice-7631-source.json @@ -0,0 +1,47 @@ +{ + "contract": { + "ambient_rank": 145, + "boundary": "complete signed #7113 caller application with 17 native calls", + "model": "mixed-target-unnormalized-power-v1", + "rank_semantics": "H_r costs r^(1-C); debit surrendered productive fields" + }, + "paid": { + "1": 68027, + "16": 416, + "2": 16201, + "24": 416, + "3": 10523, + "32": 416, + "4": 5168, + "40": 416, + "48": 416, + "5": 6001, + "56": 416, + "6": 442, + "64": 208, + "7": 187, + "8": 758, + "9": 32 + }, + "schema": "integer-mult-recursive-invoice/v1", + "targets": { + "1": 306, + "137": 208, + "17": 416, + "2": 357, + "25": 416, + "3": 799, + "33": 416, + "4": 3825, + "41": 416, + "49": 416, + "5": 1360, + "57": 416, + "6": 731, + "65": 416, + "7": 323, + "73": 208, + "8": 544, + "9": 10888 + } +} diff --git a/research/pr7633-independent-recount/inputs/pr7633/invoice-7631.json b/research/pr7633-independent-recount/inputs/pr7633/invoice-7631.json new file mode 100644 index 0000000000..7bd52f1618 --- /dev/null +++ b/research/pr7633-independent-recount/inputs/pr7633/invoice-7631.json @@ -0,0 +1,47 @@ +{ + "contract": { + "ambient_rank": 145, + "boundary": "complete signed #7113 caller application with 17 native calls", + "model": "mixed-target-unnormalized-power-v1", + "rank_semantics": "H_r costs r^(1-C); debit surrendered productive fields" + }, + "paid": { + "1": 68027, + "16": 416, + "2": 16184, + "24": 416, + "3": 10506, + "32": 416, + "4": 5168, + "40": 416, + "48": 416, + "5": 6018, + "56": 416, + "6": 442, + "64": 208, + "7": 187, + "8": 758, + "9": 32 + }, + "schema": "integer-mult-recursive-invoice/v1", + "targets": { + "1": 306, + "137": 208, + "17": 416, + "2": 357, + "25": 416, + "3": 799, + "33": 416, + "4": 3825, + "41": 416, + "49": 416, + "5": 1360, + "57": 416, + "6": 731, + "65": 416, + "7": 323, + "73": 208, + "8": 544, + "9": 10888 + } +} diff --git a/research/pr7633-independent-recount/inputs/pr7633/invoice-7633.json b/research/pr7633-independent-recount/inputs/pr7633/invoice-7633.json new file mode 100644 index 0000000000..c17c558206 --- /dev/null +++ b/research/pr7633-independent-recount/inputs/pr7633/invoice-7633.json @@ -0,0 +1,47 @@ +{ + "contract": { + "ambient_rank": 145, + "boundary": "complete signed #7113 caller application with 17 native calls", + "model": "mixed-target-unnormalized-power-v1", + "rank_semantics": "H_r costs r^(1-C); debit surrendered productive fields" + }, + "paid": { + "1": 68027, + "16": 416, + "2": 16184, + "24": 416, + "3": 10489, + "32": 416, + "4": 5168, + "40": 416, + "48": 416, + "5": 6018, + "56": 416, + "6": 442, + "64": 208, + "7": 187, + "8": 758, + "9": 32 + }, + "schema": "integer-mult-recursive-invoice/v1", + "targets": { + "1": 306, + "137": 208, + "17": 416, + "2": 357, + "25": 416, + "3": 799, + "33": 416, + "4": 3825, + "41": 416, + "49": 416, + "5": 1360, + "57": 416, + "6": 748, + "65": 416, + "7": 323, + "73": 208, + "8": 544, + "9": 10871 + } +} diff --git a/research/pr7633-independent-recount/inputs/pr7633/word-7631-source.json.gz b/research/pr7633-independent-recount/inputs/pr7633/word-7631-source.json.gz new file mode 100644 index 0000000000..cc049cc114 Binary files /dev/null and b/research/pr7633-independent-recount/inputs/pr7633/word-7631-source.json.gz differ diff --git a/research/pr7633-independent-recount/inputs/pr7633/word-7631.json.gz b/research/pr7633-independent-recount/inputs/pr7633/word-7631.json.gz new file mode 100644 index 0000000000..5a0a422010 Binary files /dev/null and b/research/pr7633-independent-recount/inputs/pr7633/word-7631.json.gz differ diff --git a/research/pr7633-independent-recount/inputs/pr7633/word-7633.json.gz b/research/pr7633-independent-recount/inputs/pr7633/word-7633.json.gz new file mode 100644 index 0000000000..c51b08bf0f Binary files /dev/null and b/research/pr7633-independent-recount/inputs/pr7633/word-7633.json.gz differ diff --git a/research/pr7633-independent-recount/verify.py b/research/pr7633-independent-recount/verify.py new file mode 100644 index 0000000000..358753a5d3 --- /dev/null +++ b/research/pr7633-independent-recount/verify.py @@ -0,0 +1,524 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""Independent recount of the PR #7631 and #7633 words and invoices. + +Imports no constructor, application or pricing engine from the audited PRs. +Scope: finite checks on pinned bytes. Not a supplier admission. +""" +import argparse +import collections +import copy +import gzip +import hashlib +import json +import sys +from fractions import Fraction as Q +from pathlib import Path + +HERE = Path(__file__).absolute().parent +INPUTS = HERE / 'inputs' / 'pr7633' +HEAD_7631 = '2f1cc8c0f8c281afd2f99aeeeae6153e269f4721' +HEAD_7633 = '8b885be4a553dea375303808fdfff52ed0d71019' +# SHA256 of the vendored bytes. They must equal the PR head blobs. +PINS = { + 'word-7631-source.json.gz': + '3b0947df9d291308279a00e009f9c1f845151b5b40f81960a53a2949cb44c9a9', + 'word-7631.json.gz': + '736d475843e2ca53cad8a193ed582926e2659abaec40895a41d55efd4fca532f', + 'word-7633.json.gz': + '49bd1b5527e5c0de1ba22101a167a66d0d7ab0fd6665569a2cb1648e71ed5ff0', + 'invoice-7631-source.json': + 'e9df1b46a4505848f1c03dffbaa4bda156c546bc5d3f2bce439d7052981c278f', + 'invoice-7631.json': + 'b75347941e7545ccaf50f5607f39f743f88fd1313ec3b3de7e385633cac2bd40', + 'invoice-7633.json': + 'f0c0fb377df557197b391a80a918da1e37d2a2ed707d1b4971d881c2c441bc3b', +} +# Canonical JSON digests that the README of #7633 states for its two words. +STATED = { + 'word-7631.json.gz': + '1ea66c263faa51da704d7aae944f3371400afaf5df8a56904ab96319f6554e0e', + 'word-7633.json.gz': + '4961e5e9351fa532a51eb8ff2b534bab6acd50cfd35972027cc483810cf635c3', +} +CALLS = 17 +RANK_SURPLUS = 1424 +BIT_CAP = Q('0.00376669') +K_7627 = Q('0.003665731276') +CLAIM_7631 = Q('0.003666272802') +RAW_7631 = (Q(36662728030282446501616146236939, 10 ** 34), + Q(1833136401514122325080807311847, 5 * 10 ** 32)) +CLAIM_7633 = Q(1833596597161, 500000000000000) +TESTED_7633 = Q(366719319432207, 10 ** 17) +RAW_7633 = (Q(18335965971611647646010791187619, 5 * 10 ** 33), + Q(36671931943223295292021582375239, 10 ** 34)) +# Each link: the step from an old word to a new word. The expected changes are +# the PR's statements. This audit measures them and compares. +LINKS = [ + {'name': '#7631', 'old': 'word-7631-source.json.gz', + 'new': 'word-7631.json.gz', 'old_inv': 'invoice-7631-source.json', + 'new_inv': 'invoice-7631.json', 'rebirth': {}, + 'native_delta': {2: -1, 3: -1, 5: 1}, 'helper_delta': {}, + 'moves': (6251, 6250), 'paid': (110043, 110026), + 'claim': CLAIM_7631, 'bracket': RAW_7631, + 'points': [('#7631 at claim', 'new', CLAIM_7631, 1), + ('#7631 at lower bracket', 'new', RAW_7631[0], 1), + ('#7631 at upper bracket', 'new', RAW_7631[1], -1), + ('#7627 value, source', 'old', K_7627, 1), + ('#7627 value, #7631', 'new', K_7627, 1), + ('source at #7631 claim', 'old', CLAIM_7631, -1)]}, + {'name': '#7633', 'old': 'word-7631.json.gz', + 'new': 'word-7633.json.gz', 'old_inv': 'invoice-7631.json', + 'new_inv': 'invoice-7633.json', 'rebirth': {457: (3, 281)}, + 'native_delta': {3: -1}, 'helper_delta': {6: 1, 9: -1}, + 'moves': (6250, 6249), 'paid': (110026, 110009), + 'claim': CLAIM_7633, 'bracket': RAW_7633, + 'points': [('#7633 at claim', 'new', CLAIM_7633, 1), + ('#7633 at tested point', 'new', TESTED_7633, 1), + ('#7633 at lower bracket', 'new', RAW_7633[0], 1), + ('#7633 at upper bracket', 'new', RAW_7633[1], -1), + ('#7631 at its lower bracket', 'old', RAW_7631[0], 1), + ('#7631 at its upper bracket', 'old', RAW_7631[1], -1), + ('#7631 at #7633 claim', 'old', CLAIM_7633, -1), + ('#7633 at #7631 claim', 'new', CLAIM_7631, 1)]}, +] + + +class Reject(Exception): + pass + + +def require(ok, message): + if not ok: + raise Reject(message) + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def load_word(raw): + return json.loads(gzip.decompress(raw)) + + +# ---------------------------------------------------------------- GF(2) ranks + +def gf2_rank(vectors): + basis = {} + for v in vectors: + while v: + top = v.bit_length() - 1 + if top not in basis: + basis[top] = v + break + v ^= basis[top] + return len(basis) + + +def move_rank(frames, a, b): + """Rank dim(A+B) - dim(A meet B), and whether the two frames are nested.""" + ra, rb = gf2_rank(frames[a]), gf2_rank(frames[b]) + ru = gf2_rank(frames[a] + frames[b]) + return 2 * ru - ra - rb, ru == max(ra, rb) + + +def move_histogram(word): + frames = word['frames'] + hist = collections.Counter() + for e in word['program']: + if e[0] == 'MOVE': + r, nested = move_rank(frames, e[2], e[3]) + require(nested, 'a MOVE joins two frames that are not nested') + require(r > 0, 'a MOVE has rank zero') + hist[r] += 1 + return hist + + +def growth_only_histogram(word): + # Wrong law for the negative control: charge only dim(A+B) - dim(A). + frames = word['frames'] + hist = collections.Counter() + for e in word['program']: + if e[0] == 'MOVE': + r = gf2_rank(frames[e[2]] + frames[e[3]]) - gf2_rank(frames[e[2]]) + if r: + hist[r] += 1 + return hist + + +def caller_part(word_hist, invoice): + paid = {int(r): n for r, n in invoice['paid'].items()} + rest = collections.Counter(paid) + for r, n in word_hist.items(): + rest[r] -= CALLS * n + require(all(n >= 0 for n in rest.values()), 'paid is below the word count') + return {r: n for r, n in sorted(rest.items()) if n} + + +# ------------------------------------------------------- chart chronology + +def chronology(word): + """Follow the chart of each field through the complete program.""" + require(len(word['initial']) == word['public'] == len(word['final']), + 'public field header') + chart = dict(enumerate(word['initial'])) + owned = set() + nframes = len(word['frames']) + for i, e in enumerate(word['program']): + op = e[0] + where = '%s at event %d' % (op, i) + if op == 'MOVE': + require(len(e) == 5 and e[2] != e[3] and 0 <= e[3] < nframes, where) + require(chart.get(e[1]) == e[2], where + ': source chart') + require(e[4] is (e[1] in owned), where + ': owner flag') + chart[e[1]] = e[3] + elif op in ('ADD', 'COPY'): + require(len(e) == 5 and e[1] != e[2], where) + require(chart.get(e[1]) == e[4] == chart.get(e[2]), + where + ': operands are not at the stated chart') + elif op == 'SCALE': + require(len(e) == 4 and chart.get(e[1]) == e[3], where + ': chart') + elif op == 'INIT': + require(len(e) == 3 and e[1] not in chart, where + ': live field') + require(e[1] >= word['public'], where + ': public field') + chart[e[1]] = e[2] + owned.add(e[1]) + elif op == 'CLEAR': + require(len(e) == 3 and e[1] in owned, where + ': not owned') + require(chart[e[1]] == e[2], where + ': chart') + del chart[e[1]] + owned.remove(e[1]) + else: + raise Reject(where + ': unknown opcode') + require(not owned, 'an owned field stays live at the end') + require([chart[f] for f in range(word['public'])] == word['final'], + 'final charts') + return {'events': len(word['program']), 'fields': len(chart)} + + +# ------------------------------------------- exact interval moment engine + +BITS = 256 +ONE = 1 << BITS + + +def _atanh_inv(q): + """Integer bounds of atanh(1/q) * 2^BITS for an integer q >= 3.""" + lo = hi = 0 + j = 0 + while True: + den = (2 * j + 1) * q ** (2 * j + 1) + lo += ONE // den + hi += -(-ONE // den) + j += 1 + if den > ONE: + break + # Tail < next_term / (1 - q^-2) <= 2 * next_term, and next_term < 1 ulp. + return lo, hi + 2 + + +def log_table(top): + """ln(n) bounds from ln(n) = ln(n-1) + 2 atanh(1/(2n-1)).""" + table = {1: (0, 0)} + for n in range(2, top + 1): + a, b = _atanh_inv(2 * n - 1) + table[n] = (table[n - 1][0] + 2 * a, table[n - 1][1] + 2 * b) + return table + + +def _exp_bounds(y_lo, y_hi): + """Bounds of exp(y) * 2^BITS for 0 <= y < 8, y scaled by 2^BITS.""" + require(0 <= y_lo <= y_hi < 8 * ONE, 'exp domain') + lo, term = ONE, ONE + n = 0 + while term: + n += 1 + term = term * y_lo // (n * ONE) + lo += term + hi, term = ONE, ONE + n = 0 + while n < 32 or term > 1: + n += 1 + term = -(-term * y_hi // (n * ONE)) + hi += term + # n >= 32 > 2 * y_hi, so the tail is below the last term, which is <= 1. + return lo, hi + 2 + + +def moment_bounds(signed, kappa, logs): + """Bounds of sum_r signed[r] * r^(1-kappa), as exact rationals.""" + p = 1 - kappa + require(0 < p <= 1, 'exponent domain') + lo = hi = 0 + for r, s in signed.items(): + l_lo, l_hi = logs[r] + y_lo = l_lo * p.numerator // p.denominator + y_hi = -(-l_hi * p.numerator // p.denominator) + e_lo, e_hi = _exp_bounds(y_lo, y_hi) + lo += s * (e_lo if s > 0 else e_hi) + hi += s * (e_hi if s > 0 else e_lo) + return Q(lo, ONE), Q(hi, ONE) + + +def derivative_upper(signed, cap, logs): + """Upper bound of d/dkappa of the moment on the interval [0, cap].""" + total = 0 + for r, s in signed.items(): + if r == 1 or s == 0: + continue + l_lo, l_hi = logs[r] + if s > 0: + # -s ln(r) r^(1-kappa) is largest at kappa = cap. + e_lo = moment_bounds({r: 1}, cap, logs)[0] + total -= s * Q(l_lo, ONE) * e_lo + else: + # |s| ln(r) r^(1-kappa) is largest at kappa = 0. + total += -s * Q(l_hi, ONE) * r + return total + + +def signed_profile(invoice): + out = collections.Counter() + for r, n in invoice['targets'].items(): + out[int(r)] += n + for r, n in invoice['paid'].items(): + out[int(r)] -= n + return {r: s for r, s in out.items() if s} + + +def sign_at(signed, kappa, logs): + lo, hi = moment_bounds(signed, kappa, logs) + require(lo > 0 or hi < 0, 'moment sign is not resolved') + return 1 if lo > 0 else -1 + + + + +# ------------------------------------------------------------- recounts + +def diff(a, b): + d = collections.Counter(b) + d.subtract(a) + return {k: v for k, v in sorted(d.items()) if v} + + +def mains(word): + """Main fields as the PR defines them. Other public fields are helpers.""" + live = set(word['live']) + hosted = word['hosted'] + shifted = {r + 112 for r in live} + return live | shifted | set(hosted['X2']) | set(hosted['Y2']) + + +def helper_targets(word): + """Per call: rank(final frame) - rank(initial frame), for each helper.""" + ranks = [gf2_rank(f) for f in word['frames']] + main = mains(word) + out = collections.Counter() + for r in range(word['public']): + if r not in main: + d = ranks[word['final'][r]] - ranks[word['initial'][r]] + require(d > 0, 'helper %d has no productive rank' % r) + out[d] += 1 + return out + + +def target_rest(helpers, invoice): + """Targets left after the helpers of all calls. Word-independent.""" + rest = collections.Counter( + {int(r): n for r, n in invoice['targets'].items()}) + for r, n in helpers.items(): + rest[r] -= CALLS * n + require(all(n >= 0 for n in rest.values()), 'targets are below the count') + return {r: n for r, n in sorted(rest.items()) if n} + + +def uniform_gain(old_s, new_s): + """Smallest and largest gain over the tents min(r, a), a = 1 .. max rank.""" + d = collections.Counter(new_s) + d.subtract(old_s) + top = max(max(old_s), max(new_s)) + gains = [sum(s * min(r, a) for r, s in d.items()) + for a in range(1, top + 1)] + return min(gains), max(gains) + + + + +# ------------------------------------------------------------------ moments + +def check_moments(link, old_inv, new_inv): + invs = {'old': old_inv, 'new': new_inv} + for inv in invs.values(): + model = inv['contract']['model'] + require(model == 'mixed-target-unnormalized-power-v1', 'invoice model') + old, new = signed_profile(old_inv), signed_profile(new_inv) + profiles = {'old': old, 'new': new} + logs = log_table(max(max(old), max(new))) + for profile in profiles.values(): + lo, hi = moment_bounds(profile, Q(0), logs) + exact = sum(r * s for r, s in profile.items()) + tight = hi - lo < Q(1, 1 << 200) + require(lo <= exact <= hi and tight, 'engine self-test') + require(exact == RANK_SURPLUS, 'rank surplus') + require(link['bracket'][0] < link['bracket'][1] < BIT_CAP, 'bracket order') + for label, which, kappa, sign in link['points']: + require(sign_at(profiles[which], kappa, logs) == sign, label + ': sign') + slopes = [derivative_upper(x, BIT_CAP, logs) for x in (old, new)] + require(all(s < 0 for s in slopes), 'moment is not strictly decreasing') + low, high = uniform_gain(old, new) + require(low >= 0 and high > 0, 'not better for every tent tariff') + return {'points': [label for label, _, _, _ in link['points']], + 'derivative_upper_old': float(slopes[0]), + 'derivative_upper_new': float(slopes[1]), + 'tent_gain_min_max': [low, high]}, logs + + +# ------------------------------------------------------------------ controls + +def rejects(fn, *args): + try: + fn(*args) + except Reject: + return True + return False + + +def controls(link, old, new, old_inv, new_inv, logs): + seen = [] + + def control(name, ok): + require(ok, 'control did not reject: ' + name) + seen.append(name) + + h_old, h_new = move_histogram(old), move_histogram(new) + k_old, k_new = caller_part(h_old, old_inv), caller_part(h_new, new_inv) + t_new = target_rest(helper_targets(new), new_inv) + wrong = growth_only_histogram(new) + control('growth-only rank law', + rejects(caller_part, wrong, new_inv) + or caller_part(wrong, new_inv) != k_new) + bad = copy.deepcopy(new_inv) + bad['paid']['1'] += 1 + control('invoice paid unit', caller_part(h_new, bad) != k_new) + control('old word with new invoice', + rejects(caller_part, h_old, new_inv) + or caller_part(h_old, new_inv) != k_old) + if link['helper_delta']: + control('old helper targets with new invoice', + rejects(target_rest, helper_targets(old), new_inv) + or target_rest(helper_targets(old), new_inv) != t_new) + field, (before, _) = sorted(link['rebirth'].items())[0] + bad = copy.deepcopy(new) + bad['initial'][field] = before + control('rebirth undone', rejects(chronology, bad)) + index = next(i for i, e in enumerate(new['program']) if e[0] == 'ADD') + bad = copy.deepcopy(new) + bad['program'][index][4] += 1 + control('ADD at the wrong chart', rejects(chronology, bad)) + index = next(i for i, e in enumerate(new['program']) if e[0] == 'MOVE') + bad = copy.deepcopy(new) + event = bad['program'][index] + event[3] = (event[3] + 1) % len(bad['frames']) + control('MOVE to another chart', rejects(chronology, bad)) + move = next(e for e in new['program'] if e[0] == 'MOVE') + bad = copy.deepcopy(new) + bad['frames'][move[3]] = bad['frames'][move[3]] + [1 << 20] + control('changed frame', + rejects(move_histogram, bad) + or caller_part(move_histogram(bad), new_inv) != k_new) + control('old invoice at the new claim', + sign_at(signed_profile(old_inv), link['claim'], logs) == -1) + higher = link['bracket'][1] + Q(1, 10 ** 12) + control('new invoice above bracket', + sign_at(signed_profile(new_inv), higher, logs) == -1) + return seen + + +# ---------------------------------------------------------------------- main + +def recount(link, words, invs): + old, new = words[link['old']], words[link['new']] + old_inv, new_inv = invs[link['old_inv']], invs[link['new_inv']] + same = [k for k in old if k not in ('program', 'initial')] + require(old.keys() == new.keys() and all(old[k] == new[k] for k in same), + 'word headers differ beyond initial charts') + changed = {r: (a, b) for r, (a, b) in + enumerate(zip(old['initial'], new['initial'])) if a != b} + require(changed == link['rebirth'], 'initial charts') + events = [chronology(old)['events'], chronology(new)['events']] + h_old, h_new = move_histogram(old), move_histogram(new) + delta = diff(h_old, h_new) + require(delta == link['native_delta'], 'native MOVE rank delta') + require((sum(h_old.values()), sum(h_new.values())) == link['moves'], + 'native MOVE count') + k_old, k_new = caller_part(h_old, old_inv), caller_part(h_new, new_inv) + require(k_old == k_new, 'caller part of the paid profile changed') + ht_old, ht_new = helper_targets(old), helper_targets(new) + hdelta = diff(ht_old, ht_new) + require(hdelta == link['helper_delta'], 'helper target delta') + tk_old = target_rest(ht_old, old_inv) + tk_new = target_rest(ht_new, new_inv) + require(tk_old == tk_new, 'caller part of the target profile changed') + paid = [sum(x['paid'].values()) for x in (old_inv, new_inv)] + targets = [sum(x['targets'].values()) for x in (old_inv, new_inv)] + require(tuple(paid) == link['paid'] and targets[0] == targets[1], + 'invoice position counts') + return {'events': events, 'native_delta_per_call': delta, + 'helper_delta_per_call': hdelta, 'paid_positions': paid, + 'target_positions': targets, + 'initial_changes': {str(r): list(v) for r, v in changed.items()}, + 'moves': [dict(sorted(h_old.items())), + dict(sorted(h_new.items()))]}, (k_new, tk_new) + + +def audit(raw): + for name, pin in PINS.items(): + require(sha(raw[name]) == pin, 'input pin ' + name) + words, canon = {}, {} + for name in PINS: + if name.startswith('word-'): + words[name] = load_word(raw[name]) + canon[name] = sha(json.dumps(words[name], sort_keys=True, + separators=(',', ':')).encode()) + for name, digest in STATED.items(): + require(canon[name] == digest, 'canonical digest ' + name) + invs = {n: json.loads(raw[n]) for n in PINS if n.startswith('invoice-')} + report = {'canonical_word_digests': canon, 'links': {}} + callers = [] + for link in LINKS: + entry, callers_of = recount(link, words, invs) + moments, logs = check_moments(link, invs[link['old_inv']], + invs[link['new_inv']]) + entry['moments'] = moments + entry['controls'] = controls( + link, words[link['old']], words[link['new']], + invs[link['old_inv']], invs[link['new_inv']], logs) + report['links'][link['name']] = entry + callers.append(callers_of) + require(all(c == callers[0] for c in callers), 'caller parts differ') + report['caller_paid_part'] = callers[0][0] + report['caller_target_part'] = callers[0][1] + report['law'] = ('rank(a->b) = dim(A+B) - dim(A meet B) over GF(2); ' + 'all nested; paid = 17 H(word) + K; targets = 17 T(word) ' + '+ K_T') + return report + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.parse_args() + raw = {name: (INPUTS / name).read_bytes() for name in PINS} + report = audit(raw) + report['status'] = 'PASS_INDEPENDENT_RECOUNT_PR7631_PR7633_DECLARED_SCOPE' + report['scope'] = ('Finite recount of pinned bytes at PR heads ' + + HEAD_7631 + ' (#7631) and ' + HEAD_7633 + ' (#7633). ' + 'Not a native, physical, compiler or outer admission.') + print(json.dumps(report, indent=1, sort_keys=True)) + + +if __name__ == '__main__': + try: + main() + except Reject as error: + sys.exit('REJECT: %s' % error)