From b0d4342772acf661a249daa9fd36d53c9a7ef1ed Mon Sep 17 00:00:00 2001 From: CubeJerry <80299683+CubeJerry@users.noreply.github.com> Date: Fri, 30 Oct 2026 17:02:52 +0800 Subject: [PATCH] Independently certify PR6167 numerical compiler premises Reconstruct the higher-moment and logarithmic-majorant conditions with integer square-root intervals. Certify the changed minimum complement power 1013, preserve the published recipe and add source/receipt rejection controls. No new kappa. Prepared for @CubeJerry with substantial OpenAI Codex assistance. Apache-2.0. --- research/p104-6167-compiler-audit/README.md | 243 +++++++++++ research/p104-6167-compiler-audit/RESULT.json | 116 ++++++ .../p104-6167-compiler-audit/SOURCES.json | 60 +++ research/p104-6167-compiler-audit/TASK.json | 165 ++++++++ .../p104-6167-compiler-audit/VALIDATION.md | 55 +++ research/p104-6167-compiler-audit/VERIFY.json | 67 +++ .../test_boundaries.py | 80 ++++ research/p104-6167-compiler-audit/verify.py | 390 ++++++++++++++++++ 8 files changed, 1176 insertions(+) create mode 100644 research/p104-6167-compiler-audit/README.md create mode 100644 research/p104-6167-compiler-audit/RESULT.json create mode 100644 research/p104-6167-compiler-audit/SOURCES.json create mode 100644 research/p104-6167-compiler-audit/TASK.json create mode 100644 research/p104-6167-compiler-audit/VALIDATION.md create mode 100644 research/p104-6167-compiler-audit/VERIFY.json create mode 100644 research/p104-6167-compiler-audit/test_boundaries.py create mode 100644 research/p104-6167-compiler-audit/verify.py diff --git a/research/p104-6167-compiler-audit/README.md b/research/p104-6167-compiler-audit/README.md new file mode 100644 index 0000000000..19e88c832d --- /dev/null +++ b/research/p104-6167-compiler-audit/README.md @@ -0,0 +1,243 @@ +# Independent integer audit of the PR6167 compiler application + +**Result: every numerical hypothesis of the published PR6167 compiler recipe +passes an independent integer/rational check. No new κ.** The earlier PR6030 +complement-capacity power 1012 does **not** carry over: for PR6167 the least +integer power satisfying that inequality at θ̄ = 63/64 is **1013**. The published +recipe uses 1024 and remains valid. The sufficient rank is still +`N = 2^65807000000000`, with first passing grid index `j = 47005`. + +This is a numerical application audit, not a new compiler theorem or supplier +admission. It answers the compiler-reconstruction part of PR6214's open question, +complementing PR6245's outer-arithmetic check. The selected PR6030 record, +κ = 0.003125804, is unchanged. + +## Sources and the new coverage + +Base: canonical main `2485805a6d47f36ea83ddde6327d453ac82d44dc`, priority revision 8. +Every live input has its full Git blob and SHA256 in [SOURCES.json](SOURCES.json). +The first three source heads below are ancestors of this base, and the consumed +files were compared byte for byte with their original heads. + +| Source | Exact head | Coverage retained / added here | +|---|---|---| +| Ali Romman, [PR6167](https://github.com/CrocSwap/integer-mult-bounds/pull/6167) | `564a076b113621a93edc4e39968ee4e4a8c9caf0` | Construction, complete invoice and compiler recipe are the audited inputs. Their correctness is not regenerated here. | +| Matarener, [PR6214](https://github.com/CrocSwap/integer-mult-bounds/pull/6214) | `ee8b66c91510b1ff4e5d28be8c6567810b4b3d01` | Word/native/caller audit, decimal funding and threshold endpoint tests. This package closes the independently reconstructed numerical compiler conditions, including complement capacity and initial range. | +| JosieElliston, [PR6109](https://github.com/CrocSwap/integer-mult-bounds/pull/6109) | `729842c7a3ea54d5f8a17bfb20dd528fd8d736a5` | Complete numerical compiler binding for the older PR6030 invoice, using directed Decimal intervals. Its theorem map and first-grid argument retain credit; its source-specific headroom is not transferred. | +| AAAmirinu, concurrent [PR6245](https://github.com/CrocSwap/integer-mult-bounds/pull/6245) | `8cb302579050454a05ebd77ac7c981e84a9dcb8e` | All 54 strict and four functional outer checks; explicitly excludes the compiler threshold. Read for overlap and credit, not used as a replay input or assumed merged. | + +The [higher-moment theorem](../higher-moment-strictification/README.md), sections +2 and 4, and its [finite-precompilation contract](../higher-moment-strictification/vendor/FINITE-PRECOMPILATION.md) +are pinned verbatim. Their native, allocation and compiler hypotheses remain +assumptions. `pricing.py` is hash-bound as the exact audited recipe but is never +imported, compiled or executed. The independent receipt is compared for its six +invoice totals; that is reuse of its recorded evidence, not a fresh word replay. + +## Exact result and theorem binding + +Let `T_s = Σ T_r r^s`, `P_s = Σ P_r r^s`, and `B = Σ T_r`. +The input has 13,444 productive fields, 66,762 paid calls, paid rank mass 240,152 +and productive rank mass 240,912. The raw largest target rank is `m = 145`. +Take + +``` +C = 62573/20000000 = 0.003128650, t = 1-C, +u = 1/7, v = 1024, c = 16, b = 17, +reserve = 10^-12, decay = 125/128, block = 128, +κ = 625729/200000000, d = (C-κ)/7 = 1/1400000000. +``` + +Here `b` is the completion-floor base, not the outer ledger's similarly named +parameter. After chronological product, paid completion and splitting, the +ambient rank is `M = 145^1024`, maximum paid rank is at most `R = 16^1024`, +and minimum target rank is at least `K = 17^1024`. The estimates use these +conservative bounds even if an actual extreme is smaller. + +| Written numerical premise | Independently checked result | +|---|---| +| §2 parameter range | `0 < C < 1`, `u ≥ C`, `t+u ≥ 1`, `1 < c < b < m`, positive integer `v` | +| `α = P_t / T_t < 1-reserve` | `α < 0.999999997959146219726397364395` | +| `γ = P_(t+u)/(c^u T_t) < decay` | `γ < 0.975668301934073053974603857756` | +| `δ = B b/(c^C T_t) < decay` | `δ < 0.950630412060446606438487179897` | +| Complete paid charge after splitting | `α^v + 2γ^v + 2δ^v < 1048576000976562501/1048576001073741824 < 1` | +| §4 exit exponent below `θ̄ = 63/64` | `16^64 < 17^63` | +| Shifted logarithm condition | `2 (16^1024)^64 ≤ (145^1024)^63` | +| Complement capacity | `(63/64)^1024 < η = t M^(t-1)` | +| Initial range | `M^(1-t) < 2^1024` (its value is between `8403417.41150323478` and `8403417.41150323479`) | +| Uniform exponent gap | `uniform = κ+6d = 4380109/1400000000`; for `z = 1-uniform`, `z-t = d > 0` | +| Sufficient threshold | `(1+H)^1024 < 2^47005`, `H = 1400000000 × 47005`; the preceding grid point fails | +| Rank above the base range | `H > 8v` and `145 < 2^8`, so `2^H > M` | + +All four new exact enclosures for α, γ, δ and η fit strictly inside or on the +source's printed 30-place rational intervals. Full rational endpoints, positive +slack certificates and control results are in [RESULT.json](RESULT.json). +Neither rounded display decimals nor agreement with a second receipt decides +acceptance: all acceptance comparisons use exact rational endpoints. + +For the complete split bound, `(125/128)^128 < 1/16` and `v/128 = 8` bound each +tail by `2^-32`. Bernoulli's inequality gives +`(1-reserve)^v ≤ 1/(1+v reserve)`. Hence the displayed bound includes both the +original paid tail and every permitted per-owner completion tail. Its exact +slack is `97179323/1048576001073741824`. The theorem's completion and physical +implementation contracts are inherited; this inequality does not create them. + +### The changed complement-power boundary + +The new exact capacity satisfies + +``` +0.0000001186268991750197874499859942379249 + < η < +0.0000001186268991750197874499859942379250. +``` + +Exact integer-power comparisons establish + +``` +(63/64)^1013 < η < (63/64)^1012. +``` + +Since `0 < 63/64 < 1`, **1013 is the least integer power for this complement +inequality**. PR6109's old 1012 passes for its PR6030 inputs but fails here. +This is a changed numerical premise, not a flaw in either published recipe. +The uniform rank and logarithmic power have not been optimized or replaced. + +For the fixed published power 1024 and grid step 1,400,000,000, put +`g(j) = j ln 2 - 1024 ln(1+1400000000 j)`. Then `g(0)=0`, `g'(0)<0`, +`g''(j)>0`, and `g(j)` tends to infinity. Thus it has exactly one positive +zero and its positive integer values form a final ray. The two exact integer +signs at 47004 and 47005 prove first-grid status. This argument and the same +unchanged grid value already occur in PR6109; they are corroborated, not claimed +as a new discovery or a minimum native program. + +## Why the new arithmetic enclosures are rigorous + +The implementation uses Python integers, `Fraction`, and `isqrt`. It imports +no repository executable and calls no floating-point, Decimal, logarithm or +exponential routine. This deliberately differs from the two author moment +engines and the prior Decimal audit. + +For integer `r ≥ 1` and rational nonnegative exponent `e`, split `e = q+f`, +`q` integer and `0 ≤ f < 1`. Truncate the binary expansion of `f` after +`L = 160` places, writing + +``` +f = Σ_(j=1)^L bit_j 2^-j + h, 0 ≤ h < 2^-L. +``` + +Use scale `S = 2^256`. If `a/S ≤ x ≤ b/S`, monotonicity and the exact integer +square-root definitions give + +``` +floor(sqrt(a S))/S ≤ sqrt(x) ≤ ceil(sqrt(b S))/S. +``` + +Starting with `[rS,rS]`, successive applications therefore enclose every +`r^(2^-j)`. Multiply the factors selected by the exponent bits, rounding each +positive fixed-point product down on the lower side and up on the upper side. +An induction on processed bits proves an enclosure of the truncated power. +The omitted exponent is **not** discarded: convexity of `r^h` on `[0,1]` gives + +``` +1 ≤ r^h ≤ 1+(r-1)h. +``` + +Multiplication by this exact tail interval and by the exact integer `r^q` +proves the final enclosure. Negative exponents use reciprocal endpoints in +reverse order. Positive interval sums, products and quotients are rational +operations with no rounding. These arguments prove the enclosing algorithm; +the finite oracle below checks its implementation rather than substituting +for the argument. + +Repeated-square-root enclosure is classical and already present in arkfx's +[PR706 package](../pr626-root-moment/README.md) and Ross Richardson's +[mixed-overhead package](../centre-sharing-mixed-overhead/README.md). Those +methods retain credit. No code from them is copied or executed here. The new +contribution is this fixed-source compiler audit and its exact certificate, +not the invention of integer-root arithmetic. + +## Reproduce and falsify + +CPython 3.12, standard library only, from the repository root: + +```sh +python3.12 -B scripts/research_package.py --package research/p104-6167-compiler-audit +``` + +Expected final line: `PASS_REGISTERED_RESEARCH_PACKAGE` for this package. +The normal and optimized scientific runs each report +`PASS_P104_6167_COMPILER_AUDIT`, 4,100 arithmetic oracle cases, 18 semantic +controls, minimum complement power 1013 and grid index 47005. + +The direct scientific command is `python3 -I -B research/p104-6167-compiler-audit/verify.py`. +It recomputes and compares the entire committed receipt; `--write` is an explicit +regeneration mode. It never regenerates source inputs. The registered boundary +commands additionally execute a temporary Git-free copy with empty `PATH`. + +- **Independent arithmetic oracle:** 3,780 instances with bases 1 through 20, + denominator 1 through 9 and numerator -2d through 2d. Raise both rational + endpoints to the reduced integer denominator and compare with the exact + corresponding integer power. This oracle uses neither roots nor logarithms. +- **Coarse arithmetic:** 320 cases deliberately use only 8 fixed-point bits and + 3 exponent bits, including non-dyadic and negative exponents. Seed 78 rotates + their order; all cases run. Two explicit examples show why a floor-only upper + root and an omitted exponent tail are invalid. +- **Semantic failures:** 18 pinned-reason controls cover insufficient tail + offset/reserve, weak decay, nonseparated ranks, bad exit exponent, false gap, + false rank encoding, incomplete decay blocks, preceding/later threshold + claims, omitted rank-145 targets, confusing ambient rank with dimension 512, + power 1012 and four forged intervals. One mutation replaces one paid rank-1 + and rank-3 pair by two rank-2 jobs: count and rank mass stay unchanged, but the + exact moment reserve fails. Its lower bound proves failure, rather than merely + failing to certify success. +- **Parser and file boundaries:** four arithmetic/parser rejections, seven + separately corrupted actual input files, and one corrupted committed receipt. + Each direct CLI failure must have the expected reason and print no success. + +The fixed oracle domain is completely enumerated; there is no candidate search, +solver exclusion, performance claim or numerical root optimization. Source +corruption tests use only temporary copies. Actual commands and remaining +verification limits are recorded in [VALIDATION.md](VALIDATION.md). + +## Scope and remaining assumptions + +The audited proposition is: **the pinned PR6167 invoice and recipe satisfy the +numerical hypotheses of the two pinned written theorems**. Conditional on those +theorems and their physical premises, the recorded uniform rank has the stated +leaf-count saving. We do not re-prove either compiler theorem, generate its +integer batches, construct the enormous uniform word, recount the scalar word, +replay native maps, execute the physical caller or recompute outer rows. + +All five selected framework assumptions remain: `native_all_columns`, +`owned_erasure`, `compiler`, `precision_tape`, and `analytic_recovery`. +The direct invoice totals match the independent receipt, but totals alone +cannot establish word validity. No human peer review, proof-kernel acceptance, +complete rounded multiplier, supplier admission or selected-frontier change is +claimed. **No new κ.** + +## Open next questions + +1. Bind actual controller batches to the §4 source-size, exit and complement + premises, with owners, integer multiplicities and suspended-parent chronology + explicit. A small separated unit and its finite scheduler are a feasible + starting point; extending it to the actual all-size P104 contract remains + blocked by the inherited compiler/native interface. +2. A maintainer can reconcile this exact-source numerical coverage with PR6214's + construction audit and PR6245's outer check. Compare the pinned heads and + uncovered physical assumptions before any admission. These packages do not + themselves authorize a new selected result. + +## Attribution + +Prepared for **@CubeJerry** with substantial **OpenAI Codex assistance** in +proof analysis, implementation, checking and writing. No subagents or human +reviewers were used. Apache-2.0. + +Credit Ali Romman (#6167/#5827 and the pricing lineage), DreamingOfClouds +(#6144/#6030/#5907), Matarener (#6214/#5960), JosieElliston (#6109), AAAmirinu +(#6245), zxv and Cao Yifan (moment/compiler bounds), Jacob Alan Sussman +(productive recursion and finite precompilation), Cinna Davis (controller), +pinterbanget (#4425 majorant review), arkfx and Ross Richardson (earlier +integer-root methods), and all native, BIT, outer and analytic contributors +retained in the pinned source packages. The formulas and predecessor theorem +map are credited; the arithmetic implementation here is separately written. diff --git a/research/p104-6167-compiler-audit/RESULT.json b/research/p104-6167-compiler-audit/RESULT.json new file mode 100644 index 0000000000..cbd0d31bf3 --- /dev/null +++ b/research/p104-6167-compiler-audit/RESULT.json @@ -0,0 +1,116 @@ +{ + "arithmetic_controls": { + "coarse_rounding_oracle_cases": 320, + "integer_power_oracle_cases": 3780, + "rejections": { + "base_zero": "positive_integer_base", + "bool_histogram_count": "positive_histogram_entry", + "duplicate_json": "duplicate_json_key", + "noncanonical_rank": "canonical_rank" + }, + "unsound_rounding_demonstrations": 2 + }, + "certified_intervals": { + "alpha": { + "decimal_lower": "0.9999999979591462197263973643946873795407", + "decimal_upper": "0.9999999979591462197263973643946873795408", + "lower": "1575566293682563552191939535377030143678609628494773771438469056255870025455854831357171257479896431324302295669011872821689712640000000/1575566296898063985288034785836193121779969083609025916392249378216598390328051661067634438043404598566811044149869879659908422419550191", + "upper": "393891573420640888047984883844257535919652407126736202515746461850132826955432284643138219808694893641491172819751284661749312257549791/393891574224515996322008696459048280444992270896885324939000616910167105428248752828927684195762382435778937587773480773416386560000000" + }, + "delta": { + "decimal_lower": "0.9506304120604466064384871798961072835396", + "decimal_upper": "0.9506304120604466064384871798961072835397", + "lower": "1997486637194706858321381906272435604058066419775774625945673964405453203215147564639296273311061757186166155124811995856800309366548952056315096988448334211153862425946054982772483183199614758713760804382735874273721001027133990863074652122683864514560000000000000/2101223158709228260001690646397337951318003609139019382922710136155331219771053383205222830755073928184718338143865620586280190956898825616490190339525834107264493743502739780351063286670128903362823417909369252809282720509210918255254223952669180926106705879813643", + "upper": "23940060052910317827448783322577732193305891402849611888218472819060325980822257925422771617948823785872667196287539171488466737569568473969668106351894593536/25183351751835254430408030151594992164840479297982288619632797916866106340017931062291644071539851852517649878030162788810661882792496138930440940921410308425" + }, + "eta": { + "decimal_lower": "0.0000001186268991750197874499859942379249", + "decimal_upper": "0.0000001186268991750197874499859942379250", + "lower": "823734695041866234591005497755367888393306930816156276059917348526338151946949825416341540270591337027065994724401586217871736832/6943911547637642550632314882458744920242682925720927780234821293651596920468606720969308480330931722210230934085893598105547117820173125", + "upper": "3005984799930309013248933063709387407040751341878031450228529558273613860075208704/25339824448208313396977151220986591478603136137051297449905618130277864714553774736328125" + }, + "gamma": { + "decimal_lower": "0.9756683019340730539746038577555286191179", + "decimal_upper": "0.9756683019340730539746038577555286191180", + "lower": "96643850105249636889382964154081614150247580278808556527542148999659270247818477248266940468881469368912752228179693412450333493931459068175022154649999635999681828443397853059656786833160862002514809099232407085036024618358582413290282897653274760970240000000/99054002178478034376690201643784281650384716229269698639862626989257722520845802334507959189215005784156050293149308344021441558532774491395554662261608371867098882401749249228230122522872156470296284181086900862131678851643436791251584772750538291511215484463", + "upper": "5655690348302054345810809961184135390531913372073560129925617380641701915879294972816244945741588287510854283489411009654785622505069628488750686702438679788388352/5796734747957626448197300060010776519657176343461683890817750683769432989329717047444730930382017113620669802736526192283039555209020642024620601446721423788515625" + }, + "initial": { + "decimal_lower": "8403417.4115032347830755683796771057785630747867", + "decimal_upper": "8403417.4115032347830755683796771057785630747875", + "lower": "973049258811199234443922606885885112778360427662769822076375736202670005038864949875/115792089237316195423570985008687907853269984665640564039457584007913129639936", + "upper": "11110258476220228081011703811933991872388292681153484448375714069842555072749770753550893568529490755536369494537429756968875388512277/1322111937580497197903830616065542079656809365928562438569297590548811582472622691650378420879430569695182424050046716608512000" + } + }, + "invoice": { + "max_paid_rank": 72, + "max_target_rank": 145, + "paid_calls": 66762, + "paid_rank_mass": 240152, + "productive_fields": 13444, + "rank_mass_surplus": 760 + }, + "least_complement_power": 1013, + "method": { + "arithmetic": "integers, Fraction and isqrt only; no predecessor code execution", + "exponent_bits": 160, + "fixed_point_bits": 256 + }, + "normalized_paid_upper": "1048576000976562501/1048576001073741824", + "parameters": { + "C": "62573/20000000", + "H": 65807000000000, + "N": "2^65807000000000", + "b": 17, + "block": 128, + "c": 16, + "decay": "125/128", + "gap": "1/1400000000", + "j": 47005, + "kappa": "625729/200000000", + "p": 1024, + "reserve": "1/1000000000000", + "theta": "63/64", + "u": "1/7", + "uniform": "4380109/1400000000", + "v": 1024 + }, + "scope": "PR6167 numerical compiler application only. Source theorems, word-to-invoice, native/caller/outer and all five framework assumptions are inherited. No new kappa.", + "semantic_controls": { + "N_changed": "rank_encoding", + "b_changed": "separated_rank_bases", + "decay_changed": "tail_decay_block", + "forged_alpha": "published_interval_alpha", + "forged_delta": "published_interval_delta", + "forged_eta": "published_interval_eta", + "forged_gamma": "published_interval_gamma", + "gap_changed": "compiler_gap", + "later_grid_not_first": "threshold_predecessor", + "missing_main_targets": "paid_moment_reserve", + "p_changed": "complement_capacity", + "previous_grid_point": "threshold_pass", + "qubit_dimension_as_ambient": "complement_capacity", + "reserve_changed": "paid_moment_reserve", + "same_mass_paid_redistribution": "paid_moment_reserve", + "theta_changed": "exit_exponent", + "u_changed": "higher_moment_sigma", + "v_changed": "whole_decay_blocks" + }, + "source_sha256": { + "research/higher-moment-strictification/README.md": "ebe80b68ff026ce90f71f274c31744f4c0b36132d15ebb7e39cf2d5df4df270d", + "research/higher-moment-strictification/vendor/FINITE-PRECOMPILATION.md": "4cb32f6b8e388ecf6ed41b5bbdeeb4539cb40c8424f194974afea58f7e0921e8", + "research/p104-6030-compiler-binding/README.md": "f41f6ce26e9fb06753ba3bdbb5fed966da895f4df34101d10e0ecafa75cf420c", + "research/p104-retained-operand-descent/RESULT.json": "cffec38f3a5ab0bf5ee1bcd15b2e7bf8bcfd711b57ee57de8ec0fea0c5a823df", + "research/p104-retained-operand-descent/pricing.py": "bba1611b05b6cc35279aa1667dcc62ce0e7f27f0ba21f20eb68244fa772e0ae7", + "research/p104-retained-operand-independent-audit/README.md": "b6d80a665c8e01c3f6e570940be529333d8e3e8a3e6f7db1c3482107f08d8338", + "research/p104-retained-operand-independent-audit/RESULT.json": "43584fe082728dc192ea5d0ff51d521502769d91d2b4280e0dd0006bd6c5090a" + }, + "status": "PASS_P104_6167_COMPILER_AUDIT", + "strict_lower_slacks": { + "alpha_reserve_slack": "2510878802186872801932714799465252548405325406726116467922172743299707190876128798856995503469037507454957553668997815067739976917/1230911169451612488506277176434525876390600846552766640434376927844272204463277352590399013111757445111809179961792127416926208000000000000", + "complement_slack": "4557445650619073190471275875380271637382807253108676666019948338188832610227203406675625023706581527804462832076046191177478144100094387042858594357656593222599919604436580385500565089027596319661697274973469837883848016963013697484489693025549802759239398867905882857052987690969007469805033806860836928705996295277207951660894190393126583299112141395177279154338189210455117614055902676279206654330958257234081048305872449316645041134023272559105250864263577282493902507944213973998550806655710304341977754420822142937838859034127704160816647229382269931404610760484456053920651207380474218141883642938277199401913982272807259694255733411498210202126818660808287498009683380018404898727029740308518663528237909721658203304968023562658447892855689018675250715466025932460872127744013599445274165346992449734878492547176662038027495104502900220822394126590961652638600425310181965297364175066088204456356825883705458978867706273780081770934438959452889242486257949368420255376377295297743123880702796102249640395455744286099824647553469083302255146700742587756816936549318576316117841521305550974338188967536907131726121814665439648582331957160348546470855072699085782150729261237889110941850628020668936360685683259666395959069862393477009837957294462869258607553017332628097897323859308434637584593803938582327342602273859275635477133459018352128964360912358119729981363405538849188734808258607345533062018713674979121802934212717856345889959710517668331531799625984960707218551243964437369176418446285205717760486160593517824550018710719393355270314058949493738099369951079089962674903965526846799254187346882665204784762527025923200506549651453501051146246547529756190252025631748075699712514617203662362287015776671826778737917917431086007112547961793302925224839199219538804886805101489733721866357382778303431124947023663520078875328004393171384666653897020025819087502461564291750563175410179102538840849163416903757477869677310994206693823523507284997260248425335628987/234367582126231103624915025076899678926430436319168137491085896279401443842348927099473671398600403217453655364557356001862546091586367292042709193894131813539509057082566408475327650444257782063358496142140794471743141287453442293455081426513728326202123807806394563771985520683020466793820673651367073183389291996079800956072189172551530959563117318582741344484961812533339062782281805321965137011710965970196914434394661503104478439816285957762180198598575666768760383338893803061769414512374775403917431206027876546901071650515035237960030748255468208111601762664140759174772618523589856286262982961788489461258836198137757079870743976085324608739277468653988902172402517880799471539128250403232818289693461683420827333623667419499470775849864215112239531683379509774342406154624399035349226049113658467990687636233632587595093963177686691627005158503025151089166125941065675399375863222475950598557835828622711527923247415959253831563563977219423638607524626853603653569988121648704040780420020822955881022440761411465465126353567302299123556602122516281631261847273900760825236310480079594152111369462686717175514294099211537272245190642167766818224517546386123187714404519061893925110042463031202051301377859625654227708002471275767699235560967501397631075668987990757497081093223134055101306850234615956547318359331889746911593915030605756709063647135970544447796036880084836126137839431416461072173366830439809367818783147151390107980519420998977954621175300926063843454297250760960355704733512672195578690898547681451679116238629847431293635693332659315244032311740592427815667156933790720932785926455224903234353013289109693579044192454345614062768337743887887171069340845193373316363286615200359659776265537121484563973806828612357948637631839619997370547814623607986914265204388802260099833430321970302213733498060694805936045943064260008236443163260963929839268795158474780665499685706497792631636123799684306319659841847372579918774574243334800499108155447097971179520000", + "complete_split_slack": "97179323/1048576001073741824", + "delta_slack": "83591282206886121887559503659424299861905812683035755762135218768541566956992368332340741845032036973004833628965334650808992940157252698187600002133780580517/3223469024234912567092227859404158997099581350141732943312998133358861611522295175973330441157101037122259184387860836967764720997439505783096440437940519478400", + "gamma_slack": "663478912040349760878832469777734969062131307294789721739810749041278433664874410112013242828838401194377055421164799567384720478667806517487282928026960650744069/741982047738576185369254407681379394516118571963095538024672087522487422634203782072925559088898190543445734750275352612229063066754642179151436985180342244930000000" + } +} diff --git a/research/p104-6167-compiler-audit/SOURCES.json b/research/p104-6167-compiler-audit/SOURCES.json new file mode 100644 index 0000000000..012a6a592e --- /dev/null +++ b/research/p104-6167-compiler-audit/SOURCES.json @@ -0,0 +1,60 @@ +{ + "schema_version": 1, + "base_commit": "2485805a6d47f36ea83ddde6327d453ac82d44dc", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a", + "sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/higher-moment-strictification/README.md", + "usage": "input", + "git_blob": "0a736ca89e1eafb73a30e1f2589cc45e6b5f76c3", + "sha256": "ebe80b68ff026ce90f71f274c31744f4c0b36132d15ebb7e39cf2d5df4df270d" + }, + { + "path": "research/higher-moment-strictification/vendor/FINITE-PRECOMPILATION.md", + "usage": "input", + "git_blob": "4badb40f0919c515823cb07e44c6470d4d6469ca", + "sha256": "4cb32f6b8e388ecf6ed41b5bbdeeb4539cb40c8424f194974afea58f7e0921e8" + }, + { + "path": "research/p104-6030-compiler-binding/README.md", + "usage": "input", + "git_blob": "64d062e56789b26ba335b70b498b7933ab3a253c", + "sha256": "f41f6ce26e9fb06753ba3bdbb5fed966da895f4df34101d10e0ecafa75cf420c" + }, + { + "path": "research/p104-retained-operand-descent/RESULT.json", + "usage": "input", + "git_blob": "9d78529c1ac43faef6b3dff6e4b1262d89a86b40", + "sha256": "cffec38f3a5ab0bf5ee1bcd15b2e7bf8bcfd711b57ee57de8ec0fea0c5a823df" + }, + { + "path": "research/p104-retained-operand-descent/pricing.py", + "usage": "input", + "git_blob": "cd8220ca7a393f03341f08a93b9d1287f0bb3689", + "sha256": "bba1611b05b6cc35279aa1667dcc62ce0e7f27f0ba21f20eb68244fa772e0ae7" + }, + { + "path": "research/p104-retained-operand-independent-audit/README.md", + "usage": "input", + "git_blob": "3e3015f2b248e59116816ff39399a224bf715dde", + "sha256": "b6d80a665c8e01c3f6e570940be529333d8e3e8a3e6f7db1c3482107f08d8338" + }, + { + "path": "research/p104-retained-operand-independent-audit/RESULT.json", + "usage": "input", + "git_blob": "f32e4da3ad0335abb896f37065cc1f36c2f80a9c", + "sha256": "43584fe082728dc192ea5d0ff51d521502769d91d2b4280e0dd0006bd6c5090a" + } + ] +} diff --git a/research/p104-6167-compiler-audit/TASK.json b/research/p104-6167-compiler-audit/TASK.json new file mode 100644 index 0000000000..bfda2a4f06 --- /dev/null +++ b/research/p104-6167-compiler-audit/TASK.json @@ -0,0 +1,165 @@ +{ + "schema_version": 1, + "task_id": "independent-moment", + "priority_revision": 8, + "base_commit": "2485805a6d47f36ea83ddde6327d453ac82d44dc", + "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": "changed", + "actual_scope": "Independent exact integer/rational reconstruction of every numerical higher-moment and logarithmic-majorant compiler premise for PR6167, source 564a076b113621a93edc4e39968ee4e4a8c9caf0. No outer/native/caller replay.", + "scope_change_reason": "Handoff in PR6214 and concurrent PR6245 leaves compiler reconstruction open. PR6109 covers PR6030 with Decimal intervals; this checks changed PR6167 moments using a distinct repeated-square-root fixed-point proof, with no predecessor executable imports.", + "bottleneck_link": "Numerical premises linking the changed complete mixed-target invoice to its uniform supplier must hold independently before conditional admission.", + "budget_minutes": 120, + "stop_rule": "At most 24 minutes orientation; finish the fixed-source numerical audit or report a precise failed condition; no root optimization or supplier expansion. Reserve final 30 minutes for verification and publication.", + "outcome": "completed", + "evidence": "README.md arithmetic proof and theorem binding; verify.py; deterministic exact RESULT.json; VALIDATION.md.", + "author": "@CubeJerry", + "ai_assistance": "Substantial OpenAI Codex assistance; no subagents.", + "open_questions": [ + { + "question": "Do the P104 controller actual integer batches satisfy the source-size, exit and complement premises at every compiled rank?", + "why_it_matters": "This numerical audit instantiates the written inequalities but does not discharge the selected compiler assumption.", + "first_step": "Bind one explicit small separated mixed unit and its integer lockstep scheduler to the recurrence in FINITE-PRECOMPILATION.md section 5. Preserve owner identity, batches and chronology.", + "blocked_by": "A source-bound constructive all-size interface proof remains distinct from moment and threshold arithmetic." + }, + { + "question": "Can the PR6167 scientific admission combine this numerical compiler check with PR6214 and PR6245 without transferring uncovered assumptions?", + "why_it_matters": "Archive intake and passing local checks do not change the selected frontier.", + "first_step": "Maintainer review of exact source heads and the three packages coverage; compare the inequality-to-theorem table before any admission.", + "blocked_by": "Maintainer authorization and all five inherited framework assumptions." + } + ], + "seed": 78, + "method_seed": "9f84af37c558ba3174ee8b2e5c4ba54b", + "coordination": { + "claim_status": "LOCAL-ONLY", + "reason": "Only open Issue913 exists, unrelated to coordination; connected GitHub plugin has no Discussion mutation capability and no gh CLI is installed. No reservation issue created.", + "claimed_at_utc": "2026-10-30T08:39:09.118063+00:00", + "expires_at_utc": "2026-10-30T10:39:09.118063+00:00", + "base_commit": "2485805a6d47f36ea83ddde6327d453ac82d44dc", + "priority_revision": 8, + "selected": "PR6030; kappa=781451/250000000", + "canonical_handoff": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19285465", + "expected_deliverable": "Standalone stdlib integer/rational checker, analytic justification, certificate and semantic rejection controls.", + "candidate_tasks": [ + "PR6167 compiler hypotheses via independent integer bounds (chosen)", + "Owned-erasure approximate residual COPY boundary", + "P104 approximate projector all-column error contract" + ], + "nearest_work": [ + { + "pr": 6109, + "scope": "Same compiler formulas, older PR6030 invoice, Decimal interval implementation; retain credit.", + "head": "729842c7a3ea54d5f8a17bfb20dd528fd8d736a5" + }, + { + "pr": 6214, + "head": "ee8b66c91510b1ff4e5d28be8c6567810b4b3d01", + "scope": "Independent word/native/caller/Decimal funding and integer endpoint checks; numerical compiler reconstruction left open." + }, + { + "pr": 6245, + "head": "8cb302579050454a05ebd77ac7c981e84a9dcb8e", + "scope": "Independent outer arithmetic; compiler threshold explicitly excluded." + } + ], + "initial_overlap": { + "checked_at_utc": "2026-10-30T08:48:08.720500+00:00", + "open_pr_bodies": 314, + "open_pr_pages": 4, + "local_note_inventory": "Git-object search of all 8722 base HEAD README/TASK note paths for compiler threshold, retained-operand and integer square root; 33 matching paths surfaced, with relevant compiler and arithmetic-method packages read. This is not a full scientific review of every match.", + "discussions": "Start-here1163 and newest visible page of1166 read; no full Discussion pagination or posting access.", + "tool_limit": "find_overlap --refresh lacked gh, then could not finish writing on a full checkout disk. Sparse checkout freed space; offline helper passed for 686/8722 notes. The complete immutable Git-object search and live plugin PR pages supplement that incomplete helper.", + "all_state_PR_search": "compiler + threshold, 35 most recently updated matches; PR6109,6214,6245 relevant. No novelty guarantee." + }, + "presubmission_refresh": { + "checked_at_utc": "2026-10-30T08:56:34.913717+00:00", + "canonical_main": "2485805a6d47f36ea83ddde6327d453ac82d44dc", + "priority_revision": 8, + "changed_guidance": [], + "selected_record_unchanged": true, + "bounded_overlap": "Live all-state PR searches for compiler+6167 and 1013, plus newest visible 1166 page. Existing overlap remains #6214/#6245 and #6109; no matching new compiler package found within this bounded coverage." + }, + "completion": { + "updated_at_utc": "2026-10-30T09:01:29.787505+00:00", + "status": "DONE: scoped numerical audit; publication target below, remote verification reported in PR handoff", + "result": "All PR6167 numerical compiler hypotheses pass independently; complement inequality minimum power is 1013, so the older 1012 does not transfer. Published 1024 and j=47005 remain valid. No new kappa.", + "branch": "research/p104-compiler-independent-20261030-78", + "artifact": "https://github.com/CubeJerry/integer-mult-bounds/tree/research/p104-compiler-independent-20261030-78/research/p104-6167-compiler-audit", + "posting": "No coordination Issue or Discussion write capability; this local claim/finding is published with the package." + } + } +} diff --git a/research/p104-6167-compiler-audit/VALIDATION.md b/research/p104-6167-compiler-audit/VALIDATION.md new file mode 100644 index 0000000000..4060ef5e3e --- /dev/null +++ b/research/p104-6167-compiler-audit/VALIDATION.md @@ -0,0 +1,55 @@ +# Validation record + +Environment: Linux, CPython 3.12.14, standard library only. Exact base: +`2485805a6d47f36ea83ddde6327d453ac82d44dc`. + +Completed during development: + +- Selected metadata orientation: `python3 -B scripts/research_selected_baseline.py` + passed `PASS_RESEARCH_BASELINE_BINDINGS_ONLY`. This was not a selected cold replay. +- Direct normal scientific replay passed: 4,100 arithmetic cases, 18 semantic + controls, four parser/arithmetic rejections, power boundary 1013, j=47005. +- Registered normal and optimized scientific commands passed with the same + complete recomputed receipt, before adding the file-boundary commands. +- Direct file-boundary test passed: one Git-free positive, seven actual + source-byte corruptions and one output-receipt corruption. +- The five consumed files attributed to PR6167/PR6214/PR6109 matched their + original Git-head blobs byte for byte; all three heads are ancestors of base. +- Metadata and source-pin check passed. + +One initial control expected the equal-mass paid mutation to reach the printed +interval comparison. It correctly failed earlier at the actual moment-reserve +condition. The test was corrected to require that precise reason and an exact +lower bound proving the exhausted reserve. No scientific condition was weakened. + +Publication-stage registered replay, committed-byte/ancestry check, official +export and remote tree confirmation are recorded below when executed. No +selected cold replay, full native/caller rerun, hosted CI, human review or +proof-kernel acceptance is claimed. + +The complete four-command registered replay subsequently passed in normal and +optimized modes: two scientific replays and two file-boundary replays. Each +scientific run verified the same exact receipt; each boundary run passed one +Git-free positive and rejected seven corrupted source files plus one corrupted +receipt. AST inspection found only standard-library imports, no float literals +and no assertion statements in the scientific verifier. + +Publication verification: + +- `python3 -B scripts/check_research_commit.py --package research/p104-6167-compiler-audit --check-source-history` + passed for all 15 package/input files and the base-history pin. +- Official export and integrity check passed for those 15 files. A separate + export (16 files including its manifest), marked read-only, passed scientific + and boundary commands in both normal and optimized modes with empty PATH and + no Git repository. Every exported byte was unchanged after execution. +- The final code edit makes all text I/O explicitly UTF-8; the full registered + replay passed again with the same mathematical receipt. No platform other + than Linux/CPython 3.12.14 was tested. +- Canonical main was fetched again and remained + `2485805a6d47f36ea83ddde6327d453ac82d44dc`; all eight checked guidance/selected + paths were unchanged. Refreshed live overlap retained the same scoped handoff. + +The public commit and complete root-tree equality are confirmed separately in +its PR handoff, after publication; this file does not predict a remote commit +hash. Hosted CI was not launched or claimed. The scientific source pins and +selected record remain unchanged. diff --git a/research/p104-6167-compiler-audit/VERIFY.json b/research/p104-6167-compiler-audit/VERIFY.json new file mode 100644 index 0000000000..3ef63b67bd --- /dev/null +++ b/research/p104-6167-compiler-audit/VERIFY.json @@ -0,0 +1,67 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/higher-moment-strictification/README.md", + "research/higher-moment-strictification/vendor/FINITE-PRECOMPILATION.md", + "research/p104-6030-compiler-binding/README.md", + "research/p104-retained-operand-descent/RESULT.json", + "research/p104-retained-operand-descent/pricing.py", + "research/p104-retained-operand-independent-audit/README.md", + "research/p104-retained-operand-independent-audit/RESULT.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Exact fixed-source compiler hypotheses, integer-power oracle, 18 semantic controls and deterministic rational receipt." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Same complete check under optimized Python; no assert-dependent acceptance." + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/test_boundaries.py" + ], + "timeout_seconds": 120, + "checks": "Actual Git-free direct replay, seven corrupted source files and corrupted output receipt; exact rejection reasons." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-W", + "error", + "-B", + "{package}/test_boundaries.py" + ], + "timeout_seconds": 120, + "checks": "Actual Git-free direct replay, seven corrupted source files and corrupted output receipt; exact rejection reasons." + } + ] +} diff --git a/research/p104-6167-compiler-audit/test_boundaries.py b/research/p104-6167-compiler-audit/test_boundaries.py new file mode 100644 index 0000000000..ad5d7c5b54 --- /dev/null +++ b/research/p104-6167-compiler-audit/test_boundaries.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 +"""Actual CLI rejection tests on a temporary Git-free source export. + +Prepared for @CubeJerry with substantial OpenAI Codex assistance. Apache-2.0. +""" +from hashlib import sha256 +from pathlib import Path +import json +import os +import shutil +import subprocess +import sys +import tempfile + + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +PACKAGE = HERE.relative_to(ROOT) + + +def require(ok, reason): + if not ok: + raise SystemExit("FAIL_BOUNDARY_CONTROL: " + reason) + + +def main(): + manifest = json.loads((HERE / "VERIFY.json").read_text(encoding="utf-8")) + inputs = manifest["inputs"] + original = {p: (ROOT / p).read_bytes() for p in inputs} + with tempfile.TemporaryDirectory(prefix="p104-compiler-controls-") as temp: + root = Path(temp) + package = root / PACKAGE + package.mkdir(parents=True) + for name in ("verify.py", "VERIFY.json", "SOURCES.json", "RESULT.json"): + shutil.copyfile(HERE / name, package / name) + for name, data in original.items(): + dest = root / name + dest.parent.mkdir(parents=True, exist_ok=True) + dest.write_bytes(data) + env = dict(os.environ, PATH="") + env.pop("PYTHONOPTIMIZE", None) + argv = [sys.executable, "-I", "-B"] + if sys.flags.optimize: + argv.append("-O") + argv.append(str(package / "verify.py")) + + def invoke(reason=None): + result = subprocess.run(argv, cwd=root, env=env, capture_output=True, + text=True, timeout=60, check=False) + if reason is None: + require(result.returncode == 0 and "PASS_P104_6167_COMPILER_AUDIT" in result.stdout, + "positive export: " + result.stderr[-500:]) + else: + require(result.returncode != 0 and reason in result.stderr, + "expected " + reason + "; got " + result.stderr[-500:]) + require("PASS_P104_6167_COMPILER_AUDIT" not in result.stdout, + "failure printed success") + + invoke() + for name, data in original.items(): + path = root / name + path.write_bytes(data + b"\n") + invoke("source_hash:" + name) + path.write_bytes(data) + receipt = package / "RESULT.json" + saved = receipt.read_bytes() + mutated = json.loads(saved) + mutated["parameters"]["H"] += 1 + receipt.write_text(json.dumps(mutated), encoding="utf-8") + invoke("receipt_matches_recomputation") + receipt.write_bytes(saved) + require(all(sha256((root / p).read_bytes()).digest() == sha256(data).digest() + for p, data in original.items()), "controls restored their temporary inputs") + print(json.dumps({"status": "PASS_P104_COMPILER_BOUNDARIES", + "git_free_positive": 1, "source_byte_rejections": len(inputs), + "receipt_rejections": 1, "optimized": bool(sys.flags.optimize)}, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/p104-6167-compiler-audit/verify.py b/research/p104-6167-compiler-audit/verify.py new file mode 100644 index 0000000000..24af2bb0a1 --- /dev/null +++ b/research/p104-6167-compiler-audit/verify.py @@ -0,0 +1,390 @@ +#!/usr/bin/env python3 +"""Independent integer/rational compiler application check for PR6167. + +No predecessor code, floats, Decimal, logarithm or exponential is executed. +Prepared for @CubeJerry with substantial OpenAI Codex assistance. Apache-2.0. +See README.md for the arithmetic proof, predecessor credit and precise scope. +""" +from copy import deepcopy +from fractions import Fraction as F +from functools import lru_cache +from hashlib import sha256 +from math import isqrt +from pathlib import Path +import argparse +import json + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +SOURCE = "research/p104-retained-operand-descent/RESULT.json" +AUDIT = "research/p104-retained-operand-independent-audit/RESULT.json" +THEOREM = "research/higher-moment-strictification/README.md" +PRECOMPILE = "research/higher-moment-strictification/vendor/FINITE-PRECOMPILATION.md" +MARKER = "PASS_P104_6167_COMPILER_AUDIT" +SCALE_BITS, EXPONENT_BITS = 256, 160 + + +class Rejection(ValueError): + pass + + +def require(ok, code): + if not ok: + raise Rejection(code) + + +def strict_json(raw): + def pairs(items): + result = {} + for key, value in items: + require(key not in result, "duplicate_json_key") + result[key] = value + return result + return json.loads(raw, object_pairs_hook=pairs) + + +def add(a, b): + return a[0] + b[0], a[1] + b[1] + + +def mul(a, b): + require(a[0] >= 0 and b[0] >= 0, "nonnegative_intervals") + return a[0] * b[0], a[1] * b[1] + + +def div(a, b): + require(a[0] >= 0 and b[0] > 0, "positive_interval_divisor") + return a[0] / b[1], a[1] / b[0] + + +def exact(x): + return F(x), F(x) + + +def ceil_div(a, b): + return -(-a // b) + + +def ceil_sqrt(n): + q = isqrt(n) + return q + (q * q != n) + + +@lru_cache(maxsize=None) +def power(base, exponent, scale_bits=SCALE_BITS, exponent_bits=EXPONENT_BITS): + """Outward fixed-point roots plus a convex bound on the exponent tail.""" + require(type(base) is int and base >= 1, "positive_integer_base") + require(type(scale_bits) is int and scale_bits >= 2, "scale_bits") + require(type(exponent_bits) is int and exponent_bits >= 1, "exponent_bits") + exponent = F(exponent) + if exponent < 0: + lo, hi = power(base, -exponent, scale_bits, exponent_bits) + return 1 / hi, 1 / lo + whole = exponent.numerator // exponent.denominator + fraction = exponent - whole + if base == 1 or not fraction: + return exact(base ** whole) + scale = 1 << scale_bits + bits = (fraction.numerator << exponent_bits) // fraction.denominator + tail = fraction - F(bits, 1 << exponent_bits) + require(0 <= tail < F(1, 1 << exponent_bits), "exponent_tail") + root_lo = root_hi = base * scale + product_lo = product_hi = scale + for index in range(exponent_bits): + root_lo = isqrt(root_lo * scale) + root_hi = ceil_sqrt(root_hi * scale) + if bits & (1 << (exponent_bits - 1 - index)): + product_lo = product_lo * root_lo // scale + product_hi = ceil_div(product_hi * root_hi, scale) + factor = base ** whole + return (F(factor * product_lo, scale), + F(factor * product_hi, scale) * (1 + (base - 1) * tail)) + + +def histogram(raw): + require(type(raw) is dict and raw, "histogram_object") + result = {} + for rank, count in raw.items(): + require(type(rank) is str and rank.isdecimal() and str(int(rank)) == rank, + "canonical_rank") + require(int(rank) > 0 and type(count) is int and count > 0, + "positive_histogram_entry") + result[int(rank)] = count + return result + + +def moment(hist, exponent): + result = exact(0) + for rank, count in sorted(hist.items()): + result = add(result, mul(exact(count), power(rank, exponent))) + return result + + +def decimal_bound(q, digits, upper=False): + """Outward decimal printing using integers only.""" + unit = 10 ** digits + n = ceil_div(q.numerator * unit, q.denominator) if upper else q.numerator * unit // q.denominator + sign = "-" if n < 0 else "" + n = abs(n) + return f"{sign}{n // unit}.{n % unit:0{digits}d}" + + +def enclosure(value): + return {"lower": str(value[0]), "upper": str(value[1]), + "decimal_lower": decimal_bound(value[0], 40), + "decimal_upper": decimal_bound(value[1], 40, True)} + + +def parameters(cost): + st, co = cost["strictification"], cost["compiler"] + return {"C": F(st["tested"]), "kappa": F(cost["kappa"]), + "u": F(st["tail_offset"]), "v": st["power"], + "c": st["cutoff"], "b": st["floor"], + "reserve": F(st["reserve"]), "decay": F(st["tail_decay"]), + "block": st["tail_block"], "theta": F(co["theta"]), + "p": co["logarithm_power"], "gap": F(co["gap"]), + "uniform": F(co["uniform_saving"]), "H": co["H"], + "j": co["integer_test_exponent"], "N": co["N"]} + + +def hypotheses(T, P, par, ambient=None): + """Instantiate sections 2 and 4 of the written theorem, not pricing.py.""" + C, u, v, c, b = (par[k] for k in ("C", "u", "v", "c", "b")) + t, m = 1 - C, max(T) if ambient is None else ambient + require(0 < C < 1, "saving_range") + require(u >= C and t + u >= 1, "higher_moment_sigma") + require(all(type(x) is int and x >= 1 for x in (v, c, b, m)), "integer_ranks") + require(1 < c < b < m, "separated_rank_bases") + reserve, decay, block = (par[k] for k in ("reserve", "decay", "block")) + require(0 < reserve < 1 and 0 < decay < 1, "tail_constants") + require(type(block) is int and block > 0 and v % block == 0, "whole_decay_blocks") + target = moment(T, t) + alpha = div(moment(P, t), target) + gamma = div(moment(P, t + u), mul(power(c, u), target)) + delta = div(exact(sum(T.values()) * b), mul(power(c, C), target)) + require(alpha[1] < 1 - reserve, "paid_moment_reserve") + require(gamma[1] < decay, "original_paid_tail") + require(delta[1] < decay, "completion_tail") + require(decay ** block < F(1, 16), "tail_decay_block") + normalized = 1 / (1 + v * reserve) + 4 * F(1, 16) ** (v // block) + require(normalized < 1, "complete_split_budget") + theta, p = par["theta"], par["p"] + require(0 < theta < 1 and type(p) is int and p > 0, "majorant_parameters") + a, d = theta.numerator, theta.denominator + require(c ** d < b ** a, "exit_exponent") + require(2 ** (d - a) * c ** (v * d) <= m ** (v * a), "shifted_exit") + eta = mul(exact(t), power(m, -v * C)) + require(theta ** p < eta[0], "complement_capacity") + initial = power(m, v * C) + require(initial[1] < 2 ** p, "initial_range") + gap, kappa, uniform = (par[k] for k in ("gap", "kappa", "uniform")) + require(0 < kappa < uniform < C < 1, "saving_order") + require(gap == C - uniform == (C - kappa) / 7, "compiler_gap") + require(gap.numerator == 1, "unit_fraction_grid") + step = gap.denominator + H, j = par["H"], par["j"] + require(type(H) is int and type(j) is int and j > 1 and H == step * j, "threshold_grid") + require(par["N"] == f"2^{H}", "rank_encoding") + require((H + 1) ** p < 2 ** j, "threshold_pass") + require((step * (j - 1) + 1) ** p >= 2 ** (j - 1), "threshold_predecessor") + # g(j)=j ln2-p ln(1+step*j): g(0)=0, g'(0)<0, g''>0. + # These hypotheses plus the two exact signs prove first-grid status. + require(p * step > 1, "threshold_convexity") + require(H > 8 * v and m < 2 ** 8, "threshold_above_ambient") + return {"alpha": alpha, "gamma": gamma, "delta": delta, "eta": eta, + "initial": initial, "normalized": normalized, + "complete_split_slack": 1 - normalized, + "alpha_reserve_slack": 1 - reserve - alpha[1], + "gamma_slack": decay - gamma[1], "delta_slack": decay - delta[1], + "complement_slack": eta[0] - theta ** p} + + +def bind(cost, other): + T, P, par = histogram(cost["targets"]), histogram(cost["paid"]), parameters(cost) + require(par["C"] == F(62573, 20000000) and par["kappa"] == F(625729, 200000000), + "pr6167_parameter_identity") + required = {"u": F(1, 7), "v": 1024, "c": 16, "b": 17, + "reserve": F(1, 10**12), "decay": F(125, 128), "block": 128, + "theta": F(63, 64), "p": 1024} + require(all(par[key] == value for key, value in required.items()), "pr6167_compiler_recipe") + totals = {"productive_fields": sum(T.values()), "paid_calls": sum(P.values()), + "paid_rank_mass": sum(r * n for r, n in P.items()), + "rank_mass_surplus": sum(r * n for r, n in T.items()) - sum(r * n for r, n in P.items()), + "max_paid_rank": max(P), "max_target_rank": max(T)} + require(totals == other["layer2_invoice"]["6167"], "independent_invoice_receipt") + require((totals["productive_fields"], totals["paid_calls"], totals["rank_mass_surplus"]) + == (13444, 66762, 760), "pr6167_invoice_totals") + for key in ("productive_fields", "paid_calls", "rank_mass_surplus"): + require(totals[key] == cost[key], "author_invoice_totals") + found = hypotheses(T, P, par) + for key in ("alpha", "gamma", "delta", "eta"): + shown = (cost["compiler"] if key == "eta" else cost["strictification"])[key] + require(F(shown["lower"]) <= found[key][0] <= found[key][1] <= F(shown["upper"]), + "published_interval_" + key) + require(found["normalized"] == F(cost["strictification"]["normalized_paid_upper"]), + "published_complete_budget") + return T, P, par, totals, found + + +def source_pins(root=ROOT): + manifest = strict_json((HERE / "SOURCES.json").read_text(encoding="utf-8")) + inputs = [row for row in manifest["files"] if row.get("usage") == "input"] + expected = strict_json((HERE / "VERIFY.json").read_text(encoding="utf-8"))["inputs"] + require({r["path"] for r in inputs} == set(expected), "input_manifest_coverage") + pins = {} + for row in inputs: + digest = sha256((root / row["path"]).read_bytes()).hexdigest() + require(digest == row["sha256"], "source_hash:" + row["path"]) + pins[row["path"]] = digest + return pins + + +def rejection(name, expected, call, controls): + try: + call() + except Rejection as exc: + require(str(exc) == expected, "wrong_control_reason:" + name + ":" + str(exc)) + controls[name] = expected + else: + raise Rejection("accepted_control:" + name) + + +def arithmetic_controls(seed=78): + # A distinct oracle: integer raising of interval endpoints, not roots/logs. + count = 0 + for base in range(1, 21): + for denominator in range(1, 10): + for numerator in range(-2 * denominator, 2 * denominator + 1): + e = F(numerator, denominator) + lo, hi = power(base, e) + exact_power = F(base) ** e.numerator + require(0 < lo <= hi and lo ** e.denominator <= exact_power <= hi ** e.denominator, + "integer_power_oracle") + count += 1 + # Low precision deliberately exercises rounding and non-dyadic tails. + # The seed changes order, not the coverage or novelty claim. + low_count = 0 + bases = list(range(2, 18)) + bases = bases[seed % len(bases):] + bases[:seed % len(bases)] + for base in bases: + for denominator in (3, 5, 7, 11): + for numerator in (-2, -1, 1, 2, 4): + e = F(numerator, denominator) + lo, hi = power(base, e, 8, 3) + require(lo ** e.denominator <= F(base) ** e.numerator <= hi ** e.denominator, + "coarse_integer_power_oracle") + low_count += 1 + sqrt_lo, sqrt_hi = power(2, F(1, 2), 4, 1) + require(sqrt_lo**2 < 2 < sqrt_hi**2, "floor_root_is_not_upper") + tail_lo, tail_hi = power(2, F(1, 3), 8, 1) + require(tail_lo == 1 and tail_lo**3 < 2 < tail_hi**3, + "discarded_exponent_tail_is_unsound") + controls = {} + rejection("base_zero", "positive_integer_base", lambda: power(0, F(1, 2)), controls) + rejection("bool_histogram_count", "positive_histogram_entry", lambda: histogram({"1": True}), controls) + rejection("noncanonical_rank", "canonical_rank", lambda: histogram({"01": 2}), controls) + rejection("duplicate_json", "duplicate_json_key", lambda: strict_json('{"x":1,"x":2}'), controls) + return {"integer_power_oracle_cases": count, "coarse_rounding_oracle_cases": low_count, + "unsound_rounding_demonstrations": 2, "rejections": controls} + + +def semantic_controls(cost, other, T, P, par, found): + controls = {} + def altered_parameter(key, value, code): + altered = dict(par, **{key: value}) + rejection(key + "_changed", code, lambda: hypotheses(T, P, altered), controls) + altered_parameter("u", F(1, 10000), "higher_moment_sigma") + altered_parameter("reserve", F(1, 10**8), "paid_moment_reserve") + altered_parameter("decay", F(127, 128), "tail_decay_block") + altered_parameter("theta", F(45, 46), "exit_exponent") + altered_parameter("gap", 2 * par["gap"], "compiler_gap") + altered_parameter("b", par["c"], "separated_rank_bases") + altered_parameter("N", "2^65807000000001", "rank_encoding") + altered_parameter("v", 1023, "whole_decay_blocks") + altered = dict(par, j=par["j"] - 1, H=par["H"] - par["gap"].denominator, + N=f'2^{par["H"] - par["gap"].denominator}') + rejection("previous_grid_point", "threshold_pass", lambda: hypotheses(T, P, altered), controls) + altered = dict(par, j=par["j"] + 1, H=par["H"] + par["gap"].denominator, + N=f'2^{par["H"] + par["gap"].denominator}') + rejection("later_grid_not_first", "threshold_predecessor", lambda: hypotheses(T, P, altered), controls) + without_main = {r: n for r, n in T.items() if r != 145} + rejection("missing_main_targets", "paid_moment_reserve", + lambda: hypotheses(without_main, P, par), controls) + rejection("qubit_dimension_as_ambient", "complement_capacity", + lambda: hypotheses(T, P, par, ambient=512), controls) + p_min = 1 + while par["theta"] ** p_min >= found["eta"][0]: + p_min += 1 + require(par["theta"] ** (p_min - 1) > found["eta"][1], "least_power_certified") + altered_parameter("p", p_min - 1, "complement_capacity") + for key in ("alpha", "gamma", "delta", "eta"): + changed = deepcopy(cost) + section = "compiler" if key == "eta" else "strictification" + changed[section][key] = {"lower": "0", "upper": "1/1000000000000000000000000000000000000000000000000"} + rejection("forged_" + key, "published_interval_" + key, + lambda changed=changed: bind(changed, other), controls) + changed = deepcopy(cost) + # Same count and rank mass: a mere aggregate-receipt check cannot catch it. + changed["paid"]["1"] -= 1 + changed["paid"]["2"] += 2 + changed["paid"]["3"] -= 1 + changed_alpha = div(moment(histogram(changed["paid"]), 1 - par["C"]), + moment(T, 1 - par["C"])) + require(changed_alpha[0] > 1 - par["reserve"], "mutant_really_exhausts_reserve") + rejection("same_mass_paid_redistribution", "paid_moment_reserve", + lambda: bind(changed, other), controls) + return controls, p_min + + +def theorem_binding(): + text = (ROOT / THEOREM).read_text(encoding="utf-8") + for fragment in ("u >= C, sigma = t+u >= 1,", "alpha = P_t / T_t,", + "gamma_u = P_(t+u) / (c^u T_t),", "delta = B b / (c^C T_t).", + "alpha^v + 2 gamma_u^v + 2 delta^v,", "2^(b−a) r_max^b <= m^a,", + "theta_bar^p < eta = t m^(t−1),", "m^(1−t) < 2^p.", + "(1+H)^p < 2^((z−t)H)"): + require(fragment in text, "theorem_statement_fragment") + text = (ROOT / PRECOMPILE).read_text(encoding="utf-8") + require('Put `m=max{k:W_k>0}`, `k_min=min{k:W_k>0}`, and' in text + and '`r_max=max{r_j}`. Require `r_max