From 98b9f9e1b96940c0c405638afa974e378436fc55 Mon Sep 17 00:00:00 2001 From: Mihir Srivastava Date: Wed, 21 Oct 2026 19:44:00 -0700 Subject: [PATCH] Derive chronological batch widths and reject pooled exit divisibility --- .../chronological-batch-width/.gitattributes | 1 + research/chronological-batch-width/README.md | 265 +++++++++ .../chronological-batch-width/RESULT.json | 166 ++++++ .../chronological-batch-width/SOURCES.json | 18 + research/chronological-batch-width/TASK.json | 187 +++++++ .../chronological-batch-width/VENDOR.json | 34 ++ .../chronological-batch-width/VERIFY.json | 28 + research/chronological-batch-width/batches.py | 181 +++++++ .../vendor/direct-flow-README.md | 496 +++++++++++++++++ .../vendor/direct-flow-RESULT.json | 505 ++++++++++++++++++ .../chronological-batch-width/vendor/flow.py | 198 +++++++ .../vendor/p7-RESULT.json | 296 ++++++++++ research/chronological-batch-width/verify.py | 236 ++++++++ 13 files changed, 2611 insertions(+) create mode 100644 research/chronological-batch-width/.gitattributes create mode 100644 research/chronological-batch-width/README.md create mode 100644 research/chronological-batch-width/RESULT.json create mode 100644 research/chronological-batch-width/SOURCES.json create mode 100644 research/chronological-batch-width/TASK.json create mode 100644 research/chronological-batch-width/VENDOR.json create mode 100644 research/chronological-batch-width/VERIFY.json create mode 100644 research/chronological-batch-width/batches.py create mode 100644 research/chronological-batch-width/vendor/direct-flow-README.md create mode 100644 research/chronological-batch-width/vendor/direct-flow-RESULT.json create mode 100644 research/chronological-batch-width/vendor/flow.py create mode 100644 research/chronological-batch-width/vendor/p7-RESULT.json create mode 100644 research/chronological-batch-width/verify.py diff --git a/research/chronological-batch-width/.gitattributes b/research/chronological-batch-width/.gitattributes new file mode 100644 index 0000000000..fa1385d99a --- /dev/null +++ b/research/chronological-batch-width/.gitattributes @@ -0,0 +1 @@ +* -text diff --git a/research/chronological-batch-width/README.md b/research/chronological-batch-width/README.md new file mode 100644 index 0000000000..c85304a601 --- /dev/null +++ b/research/chronological-batch-width/README.md @@ -0,0 +1,265 @@ +# Chronological batch divisibility in the direct mixed compiler + +**Result:** the fixed chronological flow in [PR #4436](https://github.com/CrocSwap/integer-mult-bounds/pull/4436) +admits a smaller, explicitly computable productive width. For prescribed smaller +supplier widths, the formula below gives the **least common replication factor +under the stated batching policy**. A histogram-only relaxation can fail: an +actual rank-12 toy flow accepts multiplier 175 in aggregate but needs 700 at +one parent-round cut. + +At raw p7 rank 1,000, the new productive width has **2,524 bits**, versus +**17,504 bits** for #4436's nested construction. The old width is an integer +multiple of the new one; the reduction factor has 14,981 bits. The normalized +rank-one leaf cost is exactly unchanged at every checked rank. This is a +conditional batching lemma and finite accounting result, **with no new kappa**. +It does not establish a smaller asymptotic width order or a practical algorithm. + +## 1. Source and the missing question + +The audited source is zxv's #4436 at +`56003680aee2871773de408e5f01cc5dd46b144c`, sections 2–3 and open question 3. +It realizes Sussman's integer lockstep construction with overlapping ranks, +pays unmatched exits, and chooses `a_n = B_(n-1)`, `B_n = a_n S_n` so every +smaller width divides the replication factor. Its original LCM freedom is +explicit predecessor work. The addition here is the exact batch-by-batch +gcd/LCM criterion, its chronological counterexample and a source-bound finite +construction using it recursively. + +All target ranks are at least 2; `m` is their maximum; every paid rank is +positive and below `m`. Keep the source's default height +`G = floor(log_(k_min)(floor(n/m)))`, complete source census, native word and +parent-round order. Only the replication factor changes. The input profile +is the frozen p7 native invoice, not a new audit of its physical correctness. +`VENDOR.json` binds four exact source files by URL, commit, Git blob and SHA256. +They are retained locally for Git-free replay; no unmerged Git object or +network is needed by the scientific verifier. + +The all-column, arbitrary-input, spectator, whole-job adapter, routing and +owned-state contracts of the source remain hypotheses. Equal ranks alone +do not implement a physical adapter. Native work and physical routing remain +paid under those contracts. + +## 2. Batching policy and least replication factor + +Let `S_s` be the source-job count at rank `s`, and `S = sum_s S_s` the total +source count at ambient rank `n`. The prescribed completed program of each +smaller rank `e` has productive width `B_e > 0`. Put `B_0 = 1` and give a +zero-rank complement zero cost. + +The allowed batching policy is: + +1. Before the flow, group **all source complements** by rank `n-s`. These + act on distinct original arrays before any enters the chronological flow. + Each group has `a S_s` arrays after common replication by `a`. +2. At **one parent-round cut in one path class**, group equal-rank unmatched + exits across that class's units. Complete every group before returning + from that cut. A cut with `q` exits of rank `e` has `a q` arrays. + Separate paths or paid positions are separate cuts, even when their + ranks and multipliers agree. +3. Match and resume native calls exactly as in #4436. Replicated copies of + a given class run in lockstep. No unfinished job is pooled with a later + cut; no extra productive input is credited. + +Record batches `(e,q)`: complements have `(n-s,S_s)` and exits have their +**per-cut** counts. For this finite list define + +```text +a_n = lcm over batches (e,q) of B_e / gcd(B_e,q), +B_n = S * a_n. +``` + +**Lemma.** These widths are valid under the inherited source contracts, and +`a_n` is the least positive replication factor for this policy and the +prescribed smaller widths. + +**Proof.** A whole rank-`e` supplier invocation handles `B_e` arrays. +Partitioning `a q` arrays into whole invocations is possible exactly when +`B_e | a q`. With `g = gcd(B_e,q)`, coprimality of `B_e/g` and `q/g` +makes this equivalent to `(B_e/g) | a`. All conditions hold exactly when +their LCM divides `a`, proving necessity, sufficiency and minimality. +Every recursive rank is below `n`: the source proves `0 < s <= n` and +`0 < e < n`. Strong induction therefore supplies every invoked program. +Complements run first; every exit finishes before its parent resumes. +The same disjoint inputs, owners, adapters and completed endpoints as +the source give a full rank-`n` transform on `a_n S` productive arrays. +No fractional invocation is used. QED. + +Minimality is **local to this policy and the chosen smaller library**. +It does not optimize earlier libraries jointly, permit fractional suppliers, +vary replication independently between classes, or optimize every schedule +and physical implementation. New widths need not be nested or monotone. + +## 3. Counting the chronological cuts + +`batches.py` is a new multiplicative-polynomial implementation. Let `F_h(c)` +count ordered target words of length `h` with product `c`, with `W_k` +distinguishable copies of target rank `k`. Then + +```text +F_0(1) = 1, +F_h(c) = sum_k W_k F_(h-1)(c/k), +``` + +where noninteger quotients contribute zero. This equals the sum of the +source's multinomial counts over exponent vectors with the same product. +Product collisions are summed. Only products at most `floor(n/m)` need +storage, since all target factors are at least 2. + +At depth `d` and path multiplier `rho`, a present parent supplies +`F_(G-d)(c)` units when `m rho c <= n`. At a rank-`r` paid position the +child demands the subset of Pascal terms with `m rho r c/k <= n`. For +a present parent, demand is at most supply. A positive difference is the +per-cut batch at rank `rho r c`; an absent parent is supplied by new sources. +At depth `G`, each present class contains one unit, so each paid position +has a **single** exit before replication. + +Equal-`rho` paths may be compressed for counting. The stored `copies` field +counts occurrences, including repeated paid positions. It multiplies the +total exit and cost census but **never the per-cut batch size** in the LCM. +The checker independently enumerates literal ordered target words and paid +positions in 101 fixtures, comparing complete source/exit counts and the +multiset of cuts. Target ranks 2, 4 and 8 exercise product collisions. + +## 4. Cost preservation and inherited width bound + +Write `P_e` for the complete rank-one leaf count of a width-`B_e` supplier. +Complement groups contribute `sum_s (a S_s/B_(n-s)) P_(n-s)` leaves; +exit groups contribute `sum_cuts (a q/B_e) P_e`, with all occurrences +retained. Dividing by `B_n = a S` gives the predecessor's exact recurrence: + +```text +L(n) = [sum_s S_s L(n-s) + sum_e E_e L(e)] / S. +``` + +The factor `a` cancels. With the same base `B_e=1, P_e=e` for `e 0 and v > 0 + for k, v in histogram.items()), 'positive integer histogram') + require(type(n) is int and 2 <= min(targets) <= max(targets) <= n + and max(paid) < max(targets), 'strict rank contract') + + +def polynomial_layers(targets, cap, height): + """Coefficient of each product in an ordered target word of length h.""" + layers = [{1: 1}] + for _ in range(height): + following = Counter() + for c, count in layers[-1].items(): + for k, multiplicity in targets.items(): + if c*k <= cap: + following[c*k] += count*multiplicity + layers.append(dict(following)) + return layers + + +def direct_flow(targets, paid, n): + validate(targets, paid, n) + m, kmin = max(targets), min(targets) + cap, height, least = n//m, 0, 1 + while least*kmin <= cap: + height += 1 + least *= kmin + layers = polynomial_layers(targets, cap, height) + + def units(depth, rho): + return {c: q for c, q in layers[height-depth].items() if rho*c <= cap} + + def demand(depth, rho): + result = Counter() + for c, q in units(depth, rho).items(): + for k, w in targets.items(): + result[c*k] += w*q + return result + + sources = Counter(demand(0, 1)) + exits, boundary = Counter(), Counter() + cuts = [] + paths = {1: 1} + unit_count = column_mass = matched = 0 + for depth in range(height+1): + next_paths = Counter() + for rho, path_count in sorted(paths.items()): + supply = units(depth, rho) + unit_count += path_count*sum(supply.values()) + column_mass += path_count*sum(rho*c*q for c, q in supply.items()) + for r, occurrences in sorted(paid.items()): + child_rho = rho*r + copies = path_count*occurrences + if depth == height: + local = Counter({child_rho: supply.get(1, 0)}) + else: + child = demand(depth+1, child_rho) + local = Counter() + for c in supply.keys() | child.keys(): + have, want = supply.get(c, 0), child.get(c, 0) + if have: + require(want <= have, 'Pascal containment') + matched += copies*min(have, want) + if have > want: + local[child_rho*c] += have-want + boundary[child_rho*c] += copies*(have-want) + elif want > have: + sources[child_rho*c] += copies*(want-have) + if child_rho <= cap: + next_paths[child_rho] += copies + for e, q in sorted(local.items()): + if q: + # copies counts separate chronological calls. It MUST + # NOT multiply q in the divisibility constraint. + cuts.append({'depth': depth, 'rho': rho, 'paid_rank': r, + 'rank': e, 'count': q, 'copies': copies}) + exits[e] += copies*q + paths = next_paths + sources, exits, boundary = +sources, +exits, +boundary + require(sources and all(n < m*s <= m*n for s in sources), 'source bounds') + require(all(0 < e < n for e in exits), 'strict exit descent') + mass = lambda h: sum(k*q for k, q in h.items()) + require(mass(sources)-mass(exits) == (mass(targets)-mass(paid))*column_mass, + 'rank-one conservation') + return {'sources': sources, 'exits': exits, 'boundary_exits': boundary, + 'cuts': cuts, 'height': height, 'units': unit_count, + 'column_mass': column_mass, 'matched_jobs': matched} + + +def requirements(flow, n, pooled_exits=False): + """Rank/count batches: all complements first, then one exit per cut.""" + rows = [(n-s, count) for s, count in flow['sources'].items()] + if pooled_exits: + rows += list(flow['exits'].items()) + else: + rows += [(c['rank'], c['count']) for c in flow['cuts']] + return rows + + +def multiplier(widths, rows): + result = 1 + for rank, count in rows: + require(type(rank) is int and 0 <= rank < len(widths), 'smaller rank') + require(type(count) is int and count > 0, 'positive batch count') + width = widths[rank] + require(type(width) is int and width > 0, 'positive supplier width') + result = lcm(result, width//gcd(width, count)) + return result + + +def check_batches(widths, rows, replication): + require(type(replication) is int and replication > 0, 'positive replication') + require(all(replication*q % widths[r] == 0 for r, q in rows), + 'whole chronological batch') + + +def compile_widths(targets, paid, maximum): + """Compare least cut-feasible widths with #4436's nested construction.""" + m = max(targets) + widths, nested = [1]*m, [1]*m + leaves, old_leaves = list(range(m)), list(range(m)) + counters = {'compiled_ranks': 0, 'batch_constraints': 0, 'strict_width_gains': 0} + first_pooled_failure = None + rows_out = [] + prior_cap, flow = None, None + for n in range(m, maximum+1): + if n//m != prior_cap: + flow = direct_flow(targets, paid, n) + prior_cap = n//m + rows = requirements(flow, n) + a = multiplier(widths, rows) + check_batches(widths, rows, a) + source_count = sum(flow['sources'].values()) + width, old_width = a*source_count, nested[-1]*source_count + require(old_width % width == 0, 'new width divides old nested width') + # The exact same cut constraints are enforced for the old construction. + check_batches(nested, rows, nested[-1]) + # rows contains one representative of each repeated exit cut; leaf + # accounting must retain all of those repetitions. + total = sum(a*q//widths[n-s]*leaves[n-s] for s, q in flow['sources'].items()) + total += sum(a*c['count']//widths[c['rank']]*leaves[c['rank']]*c['copies'] + for c in flow['cuts']) + old_a = nested[-1] + old_total = sum(old_a*q//nested[n-s]*old_leaves[n-s] + for s, q in flow['sources'].items()) + old_total += sum(old_a*c['count']//nested[c['rank']]*old_leaves[c['rank']]*c['copies'] + for c in flow['cuts']) + require(total*old_width == old_total*width, 'unchanged normalized leaf cost') + pooled_a = multiplier(widths, requirements(flow, n, pooled_exits=True)) + if pooled_a < a and first_pooled_failure is None: + bad = next(c for c in flow['cuts'] if pooled_a*c['count'] % widths[c['rank']]) + first_pooled_failure = {'n': n, 'pooled_multiplier': pooled_a, + 'chronological_multiplier': a, + 'cut': bad, 'child_width': widths[bad['rank']]} + widths.append(width); nested.append(old_width) + leaves.append(total); old_leaves.append(old_total) + counters['compiled_ranks'] += 1 + counters['batch_constraints'] += len(rows) + counters['strict_width_gains'] += width < old_width + rows_out.append((n, a, width, total)) + return {'widths': widths, 'nested_widths': nested, 'leaves': leaves, + 'nested_leaves': old_leaves, 'counters': counters, + 'first_pooled_failure': first_pooled_failure, 'rows': rows_out} diff --git a/research/chronological-batch-width/vendor/direct-flow-README.md b/research/chronological-batch-width/vendor/direct-flow-README.md new file mode 100644 index 0000000000..3be00f754b --- /dev/null +++ b/research/chronological-batch-width/vendor/direct-flow-README.md @@ -0,0 +1,496 @@ +# Direct mixed flow and explicit compiler size: a partial research checkpoint + +**Publication authorized by the user on October 21, 2026.** This is a partial +compiler/resource checkpoint; the direct exponent gate remains open. + +The target is a structural successor to +[PR4433](https://github.com/CrocSwap/integer-mult-bounds/pull/4433): remove the +tensor/padding step needed by overlapping ranks and control the complete +finite compiler's size. The user requested a significance target twice the +previous contribution. That is an ambitious scope target, not a numerical +measurement or a claim that it has been achieved. + +Two results are established under the source native-word hypotheses: + +1. A **finite chronological integer flow** works when paid ranks overlap + target ranks, provided `max paid < ambient`. It retains and pays every + unmatched job as an exit. All recursive ranks decrease. This gives a + finite uniform compiler, **without a proved near-root saving**. +2. Choosing **nested divisible widths** gives `B_N <= exp(O(N log N))`. + Exact rank-one accounting also bounds raw instances, owned centers, + routing slots and the source finite-constant envelopes. This batching + choice preserves the normalized leaf cost and therefore applies to the + already supported PR4433 supplier. + +The main exponent target remains open. Exact compilation at rank 1,000 on +the raw p7 profile fails the desired saving. That finite failure is not an +asymptotic obstruction, and it does not invalidate PR4433's separated recipe. +No new κ, selected frontier, native admission or physical runtime is claimed. + +## 1. Source boundary and decision + +The starting point is Jacob Alan Sussman's multinomial lockstep construction, +retained by PR4359. Its separated proof requires `r_max < k_min` so every +parent output is consumed. PR4416 and PR4433 instead repair the raw p7 +overlap by chronological products, paid completion and splitting. + +Retain the four native hypotheses of +[FINITE-PRECOMPILATION.md](vendor/FINITE-PRECOMPILATION.md): a correct +all-column arbitrary-input word, disjoint splitting with complete spectators, +permitted and priced whole-job adapters, and finite-program closure with +owned initialization/erasure. Equal rank alone does not supply an adapter. +Changed finite combinatorics do not independently admit those hypotheses. + +**Continue, with two separate gates.** The finite-flow gate is now proved and +checked. The exponent gate requires a new uniform estimate on the complete +complement-plus-exit recurrence. Do not expand a search solely because a +moment root is favorable. The size theorem is useful independently, since +the predecessor leaves productive width and owned-instance counts implicit. + +| Obligation | Evidence / remaining work | +| --- | --- | +| Integer matching with overlapping ranks | Proved below; literal and merged replays agree | +| Chronological return and strictly smaller exits | Proved under `r_max < m`; no cross-round matching | +| Source complements and full uniform output | Source integer-batch induction, with nested divisible widths | +| Direct near-root saving | **Open**; rank 1,000 fails; no global conclusion | +| Productive width, rank-one leaves, raw instances, owned centers | Explicit bounds below, with exact finite controls | +| Routing slots, encoded records and source finite-constant envelopes | Counted below in the stated grammar; physical implementations retain their own tariffs | +| Native all-column, physical, analytic, precision and recovery premises | Inherited; no full replay or new admission | + +## 2. Partially matched integer lockstep flow + +Let positive integer target multiplicities be W_k, chronological paid rounds +have ranks r_j, and let + +``` +2 <= k_min <= m=max(k), 1 <= r_max < m. +``` + +The paid word may have `r_max >= k_min`. At a fixed integer top rank n>=m, +put + +``` +c(a) = product_k k^a_k, +u(a) = multinomial(|a|;a) product_k W_k^a_k, +R(rho) = {a : m*rho*c(a) <= n}, +G = floor(log_(k_min)(floor(n/m))). +``` + +For every paid-round path s of length d<=G with multiplier rho_s, instantiate +u(a) units at column rho_s*c(a), for every point a in R(rho_s) of degree +G−d. This is the source class construction. For a parent class with +multiplier rho, its rank-r round supplies u(b) jobs at point b when b is +present. The child demand at that point is + +``` +D(b) = sum over eligible (b−e_k) of W_k*u(b−e_k). +``` + +The complete Pascal sum is u(b). Therefore: + +- If the parent point b exists, `0 <= D(b) <= u(b)`. Route D(b) of the + **whole** issued jobs to the child. Complete the remaining u(b)−D(b) + jobs as paid exits, at their actual rank `e=r*rho*c(b)`. +- If the parent point is absent, supply the child demand with new distinct + top input arrays. These are source jobs, not copies of issued data. +- At depth G, every point has degree zero; all paid jobs are exits. + +No fractional jobs, cloned productive inputs or uncharged discarded requests +are introduced. Within each point, choose a fixed enumeration of parent +jobs and target slots and match their first D(b) elements. The rest have +explicit endpoints and remain on their actual owners. + +### Sources and exits + +At the root, every demanded point has degree G+1, so it is outside R(1). +Its rank s is in `(n/m,n]`. A non-root source has no parent point, hence +`m*rho_parent*c(b)>n`; its rank is `r*rho_parent*c(b)>r*n/m>=n/m`. +Its eligible child target ensures s<=n. Thus every source is a positive +job in `(n/m,n]`. + +Every exit belongs to an actual parent unit, so + +``` +e <= r_max*n/m < n. +``` + +This holds for the new premature exits as well as leaf exits. A premature +exit has at least one omitted Pascal term, with +`m*r*rho*c(b)/k > n`; consequently `e > k_min*n/m`. These are large exits +near the upper boundary. They cannot be assigned the old bound +`r_max*(n/m)^theta` with theta<1. That lost estimate is the exponent issue. + +### Chronology and arbitrary inputs + +Run all scalar steps of a class in their specified order. At paid position +j, issue that position for every unit, partition its whole issued jobs into +matched and unmatched slots, finish all unmatched exits and the entire child +class, restore adapters, and only then resume position j+1. The child takes +incoming jobs from this one parent round plus its new top sources. It never +waits for a later round of a suspended parent. The finite class depth is G; +all complement and exit calls have rank below n, so their uniform programs +are already available by strong induction. + +Distinct slots in one class have distinct physical fields. Routing fewer +parent slots than the original full-Pascal construction preserves this +property. Arbitrary-input native correctness permits correlated values, +including current owned-center contents; it does not permit field aliasing +or extra productive credit. Each unit has its own owned identities and +retains them until its word clears them. These requirements are unchanged. + +### Exact potential and count identities + +Let S_s and E_e be integer source and exit inventories, U the unit count, +and Qcol the sum of the units' positive integer column multiplicities. +Cancellation of matched jobs gives, exactly at rank one, + +``` +sum_s S_s*s − sum_e E_e*e = Delta * Qcol, +Delta = sum_k W_k*k − sum_j r_j. +``` + +At any real exponent t, the corresponding identity is + +``` +sum_s S_s*s^t − sum_e E_e*e^t + = (T_t−P_t) * sum_units column^t. +``` + +Thus a favorable raw t-moment survives as a superpotential. It does **not** +by itself pay the source complements. Writing W=sum W_k and P=number of +paid rounds, complete untruncated layer counts give + +``` +U <= sum_(d=0..G) P^d W^(G−d) <= (W+P+1)^(G+1), +S := sum_s S_s <= W*U, +sum_e E_e <= P*U. +``` + +The source package's separated case is unchanged: no premature exits occur. +The verifier compares it with the byte-identical predecessor literal replay. + +## 3. Nested divisible widths and complete count bounds + +Use the ordinary base B_n=1, P_n=n below m, with B_0=1 and P_0=0. For n>=m +choose the replication factor and productive width + +``` +a_n = B_(n−1), B_n = a_n*S_n. +``` + +Every earlier width B_e divides B_(n−1), by induction. Therefore every +source-complement batch and exit batch is an integer number of smaller +uniform programs. This is a concrete choice within the source compiler's +existing denominator-clearing freedom; no optimum is claimed. Its previous +option to use an LCM is retained as predecessor context. + +As in the source compiler, each of the a_n*S_n original arrays first gets +its disjoint complementary job, then its one source job through the flow. +All exits are completed by smaller uniform programs. The result is a full +rank-n transform on every original array. Owned storage is excluded from B_n. + +The normalized leaf count satisfies the **same exact recurrence** for any +valid replication choice: + +``` +L(n) = (1/S_n) * [sum_s S_s L(n−s) + sum_e E_e L(e)]. +``` + +Changing the replication factors changes width and total counts equally. +It does not spend supplier saving or alter any outer parameter. + +For a fixed final N and h=G(N), all n<=N satisfy + +``` +S_n <= C_N := W*(W+P+1)^(h+1), +B_N = product_(n=m..N) S_n <= C_N^N. +``` + +Since h=O(log N), **log B_N=O(N log N)** for a fixed mixed rule. Repeatedly +multiplying all previous widths is unnecessary. This bounds one explicit +realization; the original compiler did not require that inefficient choice. + +If Delta>0, telescope rank-one mass over the fully expanded uniform program: + +``` +B_N*N − P_N = Delta * Qcol_N, +U_N <= Qcol_N <= B_N*N/Delta. +``` + +All raw columns are positive integers, which gives the middle inequality. +Thus paid leaves and raw instances have the same `exp(O(N log N))` bound. +With one owned center per raw unit, the center count is at most U_N. A rule +with O_local distinct owned banks per invocation instead gets O_local*U_N. +Extra router scratch must be counted separately. + +### Routing and word description + +Count one routing slot for every source, every exit, every unit target slot +and every unit paid position. At one flow its count is at most +`2*(W+P)*U`. The same bound telescopes over all recursive calls, because +each call contributes its own local unit instances. Exact compilation checks +this identity alongside widths and leaves. + +In the macro grammar that records a whole-job adapter, inverse adapter or +whole-field move as one record, a slot can be handled with at most sixteen +records: up to two whole-job conjugations and their inverses, park/load/ +return/reorder moves, and explicit scratch initialization and erasure. +Allocate separate owned scratch for those moves when needed; no zero-cost +routing or free copying is assumed. Let A bound the fixed unit's complete +nonrecursive record count, owned operations and scalar coefficient heights. +The final weighted record allowance satisfies the conservative bound + +``` +R_bar <= A*U_N + 32*(W+P)*U_N + P_N + <= (A+32*(W+P)+1)*B_N*N, for Delta>=1. +``` + +R_bar bounds both the macro count and the sum of scalar-height and native +record allowances. Every owned bank has an explicit initialization record, +so total allocated owned banks can also be bounded by R_bar; the sharper +raw-center bound remains separate. This is a **description/record bound**, +not a new tariff for executing a +general matrix or permutation. A Gaussian monomial adapter's dense binary +address matrix and quadratic phase have O(N^2) descriptor bits. Explicit role indices add O(log B_N) +bits. Thus an encoding of this finite word still has +`exp(O(N log N))` bits for a fixed unit and its finite coefficient alphabet. +If physical expansion of one adapter needs F(N) native records, multiply +the routing term by its actual F(N). That physical implementation, coefficient +heights and tape costs remain separately priced native obligations. They +are not set to zero by the macro bound. + +## 4. Applying the size result to PR4433 + +The new nested widths may be used in the separated compiler of PR4433. +Its normalized L(n), ambient N, uniform saving and outer ledger remain +unchanged. Therefore this application does not need the still-open direct +exponent lemma. + +With `v=150`, `H=349300000000`, `N=2^H`, the completed mixed rule has + +``` +W = 7688^150 < 2^1950, +P <= 131115^150 + 7688^150*15^150 < 2^2701, +W+P+1 < 2^2702. +``` + +The bound on P counts every original and completion call by its positive +rank mass; splitting preserves that mass. Since k_min>=2, h<=H. Set + +``` +D = 1950 + 2702*(H+1) = 943808600004652. +``` + +There is consequently a realization of the same proposed conditional +κ=0.00268647 supplier satisfying + +``` +B_N < 2^(D * 2^H), +P_N < B_N * 2^H. +``` + +More finely, after expanding every product, padding, split and compiler call +back to the raw p7 word, that word has surplus 608. Product/completion/split +boundaries cancel, so + +``` +B_N*N − P_N = 608 * sum_raw_p7_instances column, +U_raw <= (B_N*N − P_N)/608. +``` + +This is also an explicit bound on raw p7 center banks under the safe +one-center-per-instance allocation. These are large upper bounds, not +emitted words, smallest widths or practical precision estimates. They replace +one implicit part of the source finite-constant prescription. The native +adapter bodies, analytic transfer and physical costs retain their original +conditions; a closed bound for the source's finite-constant prescription is +given next, without a new physical runtime or exact-recovery threshold. + +### A closed envelope for the source finite constants + +The exported THREE-base native word has exactly 22,633 records in each +orientation. Source-bound counting retains all 15 copies, the literal p7 +controller, scalar allowance 2,490,856, every productive/paid/contact/helper/ +idle slot, and all routing and owned operations. A raw macro allowance is + +``` +A_raw = 15*8*(decompressed native JSON bytes) + + 8*(literal controller JSON bytes) + + 32*(2490856 + all declared slots + 15*22633) < 2^40. +``` + +The payload-bit terms overcount the coefficient literals and full local +descriptors, including both orientations. The 32-per-slot term overcounts +whole-job normalizers and inverses, field movements, initialization and +erasure. It is a bound on the declared source word in this grammar, not +independent verification of its functional correctness or physical tariffs. + +For the chronological v-fold product, its number of raw p7 invocations is + +``` +U_v = sum_(i=0..v−1) 7688^(v−1−i)*55998^i < 2^2392. +``` + +At every product level retain the whole-job matching wrappers. A conservative +product allowance is + +``` +A_product <= (2^40 + 32*v*(7688+55998+1))*U_v + 32*v*55998^v. +``` + +Add 32 records for every final paid call, completion role and original paid +position. Counting paid calls by their rank mass gives + +``` +A_completed <= A_product + + 32*(131115^v + 7688^v*15^v + 7688^v + 55998^v). +``` + +A dense local binary map/quadratic phase and role index fit in +`64*(121^v)^2` bits per such record. The verifier checks the integer bound +`A_completed * 64*(121^v)^2 < 2^5000`. Thus **A=2^5000** is a valid weighted +record/description allowance for this fixed completed unit. It includes all +source coefficients and owned operations, with a large deliberate overcount. +No instruction list of the completed product is emitted. + +Since `A+32*(W+P)+1 < 2^5001`, use the envelope + +``` +R_bar < 2^(D*2^H + H + 5001). +``` + +Apply the existing source finite-constant prescription to the **newly expanded +word**. With Z=B_N+owned banks, G its scalar coefficient envelope, and P_N +its rank-one leaves, we have `Z<=2*R_bar`, `G<=8*R_bar`, `P_N<=R_bar` and +`N<=R_bar`. Therefore + +``` +E = 64*(Z+N+P_N+G+1)^3 + < 2^(3*D*2^H + 3*H + 15021), +B_constant = P_N+E, +C0 = 32*N*B_constant^2 + < 2^(6*D*2^H + 7*H + 30049) + < 2^(8*D*2^H). +``` + +The last comparison uses `2^H>=H+1` and an exact polynomial integer check +on D and H. These are explicit, very loose upper bounds for the inherited +semantic precision/stock constants, conditional on that source prescription +and its admitted native record implementations. The exact numerical outer +input threshold, prime exclusions and physical tape costs remain separate. + +## 5. Exact finite checks and the open exponent gate + +The verifier uses no floating-point acceptance tests. It checks: + +- Nine literal/merged flows at ranks 20, 40 and 80: a separated control, + strict overlap `{2:1,5:1} <- {1:2,4:1}`, and Sussman's open equality + example `{2:4,3:1} <- {1:6,2:2}`. Every whole input and exit agrees. +- The separated control agrees with the unchanged Sussman literal replay. +- Complete nested-width compilations through rank 100 on both overlap + examples, checking every recursive batch, routing count and rank identity. +- Raw p7 through rank 1,000: **880 exact nonbase compilations**. B_1000 has + 17,504 bits; the saved receipt binds all large computed integers by their + unsigned big-endian hashes, avoiding enormous decimal dumps. +- Removing premature exits violates mass conservation. Removing batch + replication fails integer divisibility. Allowing a paid rank equal to + the ambient rank is rejected because strict rank descent is unavailable. + +For raw p7 at rank 1,000, exact arithmetic gives + +``` +L(1000) > 990 > 1000^(1−0.00268647). +``` + +The second comparison is elementary and exact: `ln(2)>2/3` from its first +atanh term and `1000>2^9` give `ln(1000)>6`. Then +`1000^κ > 1+6κ > 100/99`. No log approximation is used in this rejection. +This checks one finite failure and keeps it distinct from the infinite-rank +question. + +The missing lemma is a uniform bound on the **whole** recurrence. For some +fixed p and sufficiently large n, one would need, for example, + +``` +sum_e E_e e^t (1+log2(e))^p + + sum_s S_s (n−s)^t (1+log2(n−s))^p + <= S_n n^t (1+log2(n))^p, +``` + +with zero-rank terms defined separately and a correctly funded base range. +The premature exits have rank proportional to n. Their logarithmic factors +cannot use the old fixed theta<1 power contraction. A raw moment advantage +alone does not prove this inequality. + +Exploratory `approximate_leaves` in flow.py evaluates the recurrence in +floating point and is deliberately excluded from verification. A bounded +run through 20,000 ranks found saving about 0.000827 for the default height; +varying the height did not approach 0.00268647 there. This is local search +evidence, not a lower bound or a reason to enlarge the same scan. A better +boundary estimate or a changed flow is the next research obligation. + +## 6. Reproduction and provenance + +Python 3.12, standard library only: + +```sh +python3.12 -B research/direct-mixed-flow/verify.py +python3.12 -B scripts/research_package.py --package research/direct-mixed-flow --check-only +python3.12 -B scripts/research_package.py --package research/direct-mixed-flow +``` + +Use `verify.py --out /absolute/new/result.json` for a fresh receipt. +[RESULT.json](RESULT.json) contains exact flows, integer compilation hashes, +symbolic size bounds and negative controls. `flow.py` is the new algorithm; +the verifier independently compares its merged and literal traversal outputs. +Those are two internal implementations, not an independent mathematical review. + +Canonical base is `12fa8c5c844be21bfefb38a19503fbd867a11244`, priority revision +7. SOURCES.json pins orientation metadata. VENDOR.json separately binds eleven +unchanged exports by commit, full path, Git blob and SHA256. Their bytes and +notices are preserved; direct replay needs no foreign Git objects. The source +theorem and earlier finite compiler remain attributed hypotheses, not new work. + +Local validation used Python 3.12.8 on macOS arm64. The registered replay, +metadata/pin check and committed-byte preflight passed. A separate Git-free +copy passed with `python3.12 -I -O -B verify.py`; changed-native-source and +changed-receipt controls both rejected. Replay uses exact integer arithmetic +and source hashes, with no network or foreign Git objects. The repository is +shallow, so a full source-history preflight was not attempted. No Lean, Docker, +full native/all-column admission, physical adapter expansion or historical +suite was run. Independent mathematical acceptance remains open. + +The overlap refresh at 18:48 UTC covered 538 open PR bodies and 3,280 +discussion/comment records, with complete reported pagination. Specific +searches for direct overlapping-rank compilers, Pascal matching and nested +widths found no matching public item in that scope; this is not a novelty +certificate. Existing PR4433 supplies the fixed-rank application, and the +source theorem explicitly leaves the unseparated exponent open. No Discussion +claim or PR has been posted for this partial checkpoint. + +## Open next questions + +1. **Close or refute the direct exponent gate for this capped flow.** Start + with a proved bound on premature-exit potential relative to the actual + complement capacity. This decides whether the flow can replace the + tensor/padding layer. A larger rank scan is not a uniform proof. +2. **Independently admit the physical expansions and precision prescription.** + Audit the conservative A allowance against the actual native caller and + bind every adapter's physical implementation, row movements and recovery + exclusions. The encoded constants above use the inherited semantics; + description size is not a physical execution tariff. +3. **Tighten the constructive width.** The nested product is an explicit + upper bound, not an optimized LCM. A useful next step would control prime + valuations of the actual source counts; another arbitrary batching choice + would not by itself establish a smaller physical supplier. + +Prepared by zxv with substantial OpenAI Codex assistance in research, code +and writing. No subagents or independent human mathematical review were +used. New material is Apache-2.0. The integer lockstep/Pascal construction +and original open unseparated question are Jacob Alan Sussman's work, retained +at upstream `wht-power-saving-lean` commit +`563b4e6e913625637f36ba7869bf5fcd0dd4975a`; its LICENSE and NOTICE are included. +PR4359 supplies the native finite-precompilation bridge and p7 predecessor +lineage. PR4416's p7 product/padding is @1337isnot1337's work. PR4433 supplies +the unchanged sufficient rank. Their original contributor credit remains +in the authenticated exports. diff --git a/research/chronological-batch-width/vendor/direct-flow-RESULT.json b/research/chronological-batch-width/vendor/direct-flow-RESULT.json new file mode 100644 index 0000000000..e657f58b5a --- /dev/null +++ b/research/chronological-batch-width/vendor/direct-flow-RESULT.json @@ -0,0 +1,505 @@ +{ + "direct_exponent_theorem_established": false, + "exact_p7_direct_compilation": { + "column_mass": { + "bits": 17497, + "unsigned_big_endian_sha256": "0f2b521412ca3f565d734c244b1cf42b8c7d49ef1e61af197ec97b2605078a3c" + }, + "leaves_per_array": { + "lower": "24890741110487842821/25000000000000000", + "upper": "995629644419513712841/1000000000000000000" + }, + "n": 1000, + "nested_batch_checks": 880, + "paid_above_99_percent_linear": true, + "paid_rank_one_leaves": { + "bits": 17514, + "unsigned_big_endian_sha256": "1f28a559d21f0df473b67fef0c37eb57144955250234a44c998bd837d1e8f3d6" + }, + "productive_width": { + "bits": 17504, + "unsigned_big_endian_sha256": "49727d4435d62a4a84b79cf2451d374a5bb98234cbe460ec0b0ef3da77c8c9e6" + }, + "rank_one_surplus": 608, + "raw_instances": { + "bits": 17497, + "unsigned_big_endian_sha256": "0f5ce7310a89be0835b71681538c3e2e57134d2690ff663b8bc1cd10938b9c7f" + }, + "routing_slots": { + "bits": 17514, + "unsigned_big_endian_sha256": "98bde80b4a7bc886645e82f3b9e730545da94beddcbec4e98ce88e1c44a39242" + }, + "source_count_upper": 31182789153672, + "target_failure": { + "kappa": "268647/100000000", + "proved": "L(1000) > 990 > 1000^(1-kappa)", + "scope": "This particular finite rank fails; no asymptotic impossibility claim." + }, + "width_exponent_envelope": 45000 + }, + "exact_toy_compilations": [ + { + "column_mass": { + "bits": 438, + "unsigned_big_endian_sha256": "f469278cd8f6190ffe6a1ae190299a8d183d1675d4280087d107e5d7016aee25" + }, + "leaves_per_array": { + "lower": "63955485748643768733/1000000000000000000", + "upper": "31977742874321884367/500000000000000000" + }, + "n": 100, + "nested_batch_checks": 96, + "paid_above_99_percent_linear": false, + "paid_rank_one_leaves": { + "bits": 439, + "unsigned_big_endian_sha256": "7df4f5875466fa21b225c2b60317e60536fdededbe8473d18fe5fb3fb057bb6f" + }, + "productive_width": { + "bits": 433, + "unsigned_big_endian_sha256": "35f12bcc6000b703565e2f120e8077641f744909e8ec163921775b2b0c139254" + }, + "rank_one_surplus": 1, + "raw_instances": { + "bits": 436, + "unsigned_big_endian_sha256": "12b6d174870cd23fd40ad1f4ff56df629ed813fabbbfcf143a914bfdd875609d" + }, + "routing_slots": { + "bits": 439, + "unsigned_big_endian_sha256": "4034ff94efe1f1ab70575b300eebbd2469e9065861c4f2570a59256c47170f74" + }, + "source_count_upper": 15552, + "width_exponent_envelope": 1400 + }, + { + "column_mass": { + "bits": 1007, + "unsigned_big_endian_sha256": "f04dcf1684cd1a5f5708102f230375fb43cd08135626ac91b22478876e21c63e" + }, + "leaves_per_array": { + "lower": "65003740439870989333/1000000000000000000", + "upper": "32501870219935494667/500000000000000000" + }, + "n": 100, + "nested_batch_checks": 98, + "paid_above_99_percent_linear": false, + "paid_rank_one_leaves": { + "bits": 1008, + "unsigned_big_endian_sha256": "1302eac01cf514d2855c821612c64c9d38a6c9ff55f12115f72bf34a9906b9d5" + }, + "productive_width": { + "bits": 1002, + "unsigned_big_endian_sha256": "398043f007044ec4c1ba14eda89bf66b48733ce7a22bb855a3bc17a4665b5952" + }, + "rank_one_surplus": 1, + "raw_instances": { + "bits": 1006, + "unsigned_big_endian_sha256": "ebd327c71dde99fefa5afb70ef8ad5b207723935abb8bed0473a95d67e73fbe7" + }, + "routing_slots": { + "bits": 1010, + "unsigned_big_endian_sha256": "23f8f6398dbe8fe43a321ff79a6c52edfee5c4de97ff2852a6cdcc6c127e7cd7" + }, + "source_count_upper": 37647680, + "width_exponent_envelope": 2600 + } + ], + "existing_supplier_size_bounds": { + "D": 943808600004652, + "H": 349300000000, + "N": "2^349300000000", + "compiled_record_upper": "R < 2^(D*2^H + H + 5001)", + "completed_unit_description_upper": "2^5000", + "kappa": "268647/100000000", + "owned_p7_center_bound": "one per raw instance; <= B_N * 2^H / 608", + "paid_leaf_bound": "P_N < B_N * 2^H", + "physical_scope": "Encoded whole-job adapter/move records. Their permitted physical implementation and tariffs remain inherited, separately priced premises.", + "raw_macro_allowance_upper": "2^40", + "raw_macro_and_payload_allowance": 319592968, + "raw_native_record_counts": { + "backward": 22633, + "forward": 22633 + }, + "raw_p7_instance_bound": "U_raw <= (B_N * 2^H - P_N)/608", + "routing_macro_record_bound": "R <= (A + 32*(W+P) + 1) * B_N * N; A < 2^5000", + "routing_slot_bound": "slots <= 2*(W+P)*V, V completed-unit instances", + "source_C0_upper": "C0 < 2^(8*D*2^H)", + "source_precision_E_upper": "E < 2^(3*D*2^H + 3*H + 15021)", + "width_bound": "B_N < 2^(D * 2^H)", + "winning_uniform_word_materialized": false + }, + "finite_flows": [ + { + "flow": { + "all_sources_above_n_over_m": true, + "boundary_exits": {}, + "column_mass": 18, + "exits": { + "1": 16, + "2": 16, + "4": 4 + }, + "height": 1, + "matched_jobs": 18, + "minimum_source": 9, + "n": 20, + "rank_one_surplus": 2, + "source_count": 9, + "sources": { + "12": 4, + "16": 1, + "9": 4 + }, + "unit_count_upper": 9, + "units": 9 + }, + "literal_classes": 7, + "paid": { + "1": 4, + "2": 2 + }, + "rule": "separated-control", + "targets": { + "3": 2, + "4": 1 + } + }, + { + "flow": { + "all_sources_above_n_over_m": true, + "boundary_exits": {}, + "column_mass": 180, + "exits": { + "1": 64, + "2": 96, + "4": 48, + "8": 8 + }, + "height": 2, + "matched_jobs": 132, + "minimum_source": 12, + "n": 40, + "rank_one_surplus": 2, + "source_count": 42, + "sources": { + "12": 16, + "16": 4, + "24": 8, + "27": 8, + "32": 2, + "36": 4 + }, + "unit_count_upper": 63, + "units": 58 + }, + "literal_classes": 43, + "paid": { + "1": 4, + "2": 2 + }, + "rule": "separated-control", + "targets": { + "3": 2, + "4": 1 + } + }, + { + "flow": { + "all_sources_above_n_over_m": true, + "boundary_exits": {}, + "column_mass": 244, + "exits": { + "1": 64, + "2": 96, + "4": 48, + "8": 8 + }, + "height": 2, + "matched_jobs": 162, + "minimum_source": 27, + "n": 80, + "rank_one_surplus": 2, + "source_count": 27, + "sources": { + "27": 8, + "36": 12, + "48": 6, + "64": 1 + }, + "unit_count_upper": 63, + "units": 63 + }, + "literal_classes": 43, + "paid": { + "1": 4, + "2": 2 + }, + "rule": "separated-control", + "targets": { + "3": 2, + "4": 1 + } + }, + { + "flow": { + "all_sources_above_n_over_m": true, + "boundary_exits": { + "16": 1 + }, + "column_mass": 28, + "exits": { + "1": 8, + "16": 5, + "4": 12 + }, + "height": 2, + "matched_jobs": 8, + "minimum_source": 5, + "n": 20, + "rank_one_surplus": 1, + "source_count": 14, + "sources": { + "10": 2, + "20": 5, + "5": 4, + "8": 3 + }, + "unit_count_upper": 19, + "units": 11 + }, + "literal_classes": 13, + "paid": { + "1": 2, + "4": 1 + }, + "rule": "strict-overlap", + "targets": { + "2": 1, + "5": 1 + } + }, + { + "flow": { + "all_sources_above_n_over_m": true, + "boundary_exits": { + "32": 5 + }, + "column_mass": 132, + "exits": { + "1": 16, + "16": 12, + "32": 5, + "4": 32 + }, + "height": 3, + "matched_jobs": 40, + "minimum_source": 10, + "n": 40, + "rank_one_surplus": 1, + "source_count": 30, + "sources": { + "10": 8, + "16": 3, + "20": 10, + "25": 4, + "40": 5 + }, + "unit_count_upper": 65, + "units": 35 + }, + "literal_classes": 40, + "paid": { + "1": 2, + "4": 1 + }, + "rule": "strict-overlap", + "targets": { + "2": 1, + "5": 1 + } + }, + { + "flow": { + "all_sources_above_n_over_m": true, + "boundary_exits": { + "40": 4, + "64": 5 + }, + "column_mass": 872, + "exits": { + "1": 32, + "16": 80, + "4": 80, + "40": 4, + "64": 29 + }, + "height": 4, + "matched_jobs": 132, + "minimum_source": 20, + "n": 80, + "rank_one_surplus": 1, + "source_count": 106, + "sources": { + "20": 36, + "25": 8, + "32": 15, + "40": 10, + "50": 8, + "80": 29 + }, + "unit_count_upper": 211, + "units": 119 + }, + "literal_classes": 121, + "paid": { + "1": 2, + "4": 1 + }, + "rule": "strict-overlap", + "targets": { + "2": 1, + "5": 1 + } + }, + { + "flow": { + "all_sources_above_n_over_m": true, + "boundary_exits": {}, + "column_mass": 322, + "exits": { + "1": 216, + "2": 216, + "4": 72, + "8": 8 + }, + "height": 2, + "matched_jobs": 512, + "minimum_source": 8, + "n": 20, + "rank_one_surplus": 1, + "source_count": 128, + "sources": { + "12": 48, + "18": 10, + "8": 64, + "9": 6 + }, + "unit_count_upper": 129, + "units": 128 + }, + "literal_classes": 73, + "paid": { + "1": 6, + "2": 2 + }, + "rule": "source-open-equality", + "targets": { + "2": 4, + "3": 1 + } + }, + { + "flow": { + "all_sources_above_n_over_m": true, + "boundary_exits": {}, + "column_mass": 4362, + "exits": { + "1": 1296, + "16": 16, + "2": 1728, + "4": 864, + "8": 192 + }, + "height": 3, + "matched_jobs": 5040, + "minimum_source": 16, + "n": 40, + "rank_one_surplus": 1, + "source_count": 670, + "sources": { + "16": 256, + "18": 84, + "24": 256, + "27": 6, + "36": 68 + }, + "unit_count_upper": 1157, + "units": 1142 + }, + "literal_classes": 585, + "paid": { + "1": 6, + "2": 2 + }, + "rule": "source-open-equality", + "targets": { + "2": 4, + "3": 1 + } + }, + { + "flow": { + "all_sources_above_n_over_m": true, + "boundary_exits": {}, + "column_mass": 55372, + "exits": { + "1": 7776, + "16": 480, + "2": 12960, + "32": 32, + "4": 8640, + "8": 2880 + }, + "height": 4, + "matched_jobs": 45088, + "minimum_source": 27, + "n": 80, + "rank_one_surplus": 1, + "source_count": 3572, + "sources": { + "27": 36, + "32": 1024, + "36": 744, + "48": 1280, + "54": 96, + "72": 392 + }, + "unit_count_upper": 9881, + "units": 9732 + }, + "literal_classes": 4681, + "paid": { + "1": 6, + "2": 2 + }, + "rule": "source-open-equality", + "targets": { + "2": 4, + "3": 1 + } + } + ], + "new_code_sha256": { + "flow.py": "460f0b0262d7b6880973f46240b3fff1e9f04601fa1d658dda18688b1e26575a", + "verify.py": "9ae067eadf17ff9d97737805eb642a69375a5ff2ddb08988fef59aa0771f9b7c" + }, + "rejected_mutations": [ + "whole integer subprogram batches", + "finite direct-flow rank contract" + ], + "schema": "partial-direct-mixed-flow-and-finite-size/1", + "scope": "New finite matching/scheduling and batching/size bounds. The direct near-root exponent is open. Existing conditional endpoint and native/physical hypotheses remain inherited; no new kappa.", + "source_sha256": { + "research/direct-mixed-flow/vendor/FINITE-PRECOMPILATION.md": "4cb32f6b8e388ecf6ed41b5bbdeeb4539cb40c8424f194974afea58f7e0921e8", + "research/direct-mixed-flow/vendor/P7-FACTOR.json": "6f96f6be5d8441f71cbe6ebb1657c69b543eb085b848b92b591b7ac01d6e6598", + "research/direct-mixed-flow/vendor/SUSSMAN-LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "research/direct-mixed-flow/vendor/SUSSMAN-NOTICE": "8289a4ba75efe5da7bd2e389b951155ff74b3bf49b38ace0906a1e5205c7cd6e", + "research/direct-mixed-flow/vendor/THREE-base-FULL-IDENTITY-NATIVE.json.gz": "c54b0a3e129d28e6dbf74fa731fc3bb70fe3c6705f07256750fbecddcc842d39", + "research/direct-mixed-flow/vendor/higher-moment-README.md": "ebe80b68ff026ce90f71f274c31744f4c0b36132d15ebb7e39cf2d5df4df270d", + "research/direct-mixed-flow/vendor/higher-moment-RESULT.json": "ad79e3c0459e7b495a0ca34010553b12147779a007389e1695cc1336f123c156", + "research/direct-mixed-flow/vendor/p7-NATIVE.md": "26bf9312cdb496b1113c9ddd8aa0fa922ed9e480005703212942af358394183d", + "research/direct-mixed-flow/vendor/p7-RESULT.json": "9b814be97e3b45fcc28eafa8a65694897a7387f71a14d44796c6aadf303d7fab", + "research/direct-mixed-flow/vendor/theorem-1g.md": "c4a96c55c2509ff36e8bc6bddaaf6a8b1a34a5d794e4e09ac5214c82b51510e6", + "research/direct-mixed-flow/vendor/tree_flow.py": "750782f6d1cc0a9fff8a768899f3f4c62a7efdf0696d8b5a5d640b1836f5ab72" + }, + "status": "PASS_PARTIAL_DIRECT_FLOW_AND_SIZE_BOUNDS" +} diff --git a/research/chronological-batch-width/vendor/flow.py b/research/chronological-batch-width/vendor/flow.py new file mode 100644 index 0000000000..07175cd6e1 --- /dev/null +++ b/research/chronological-batch-width/vendor/flow.py @@ -0,0 +1,198 @@ +#!/usr/bin/env python3 +"""Capped whole-integer lockstep flow, retaining unmatched jobs as paid exits. + +Generalizes Jacob Alan Sussman's separated multinomial construction. +zxv with substantial OpenAI Codex assistance. Apache-2.0. +This is a finite flow, not a theorem that it attains the mixed-root saving. +""" +from collections import Counter +from functools import lru_cache +from math import comb, prod + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +class Flow: + def __init__(self, targets, paid, n, extra_height=0, height_base=None): + self.T, self.P, self.n = dict(targets), dict(paid), n + self.K = tuple(sorted(targets)) + self.m, self.kmin, self.rmax = max(targets), min(targets), max(paid) + need(2 <= self.kmin <= self.m and self.rmax < self.m <= n, + 'finite direct-flow rank contract') + need(all(isinstance(v, int) and v > 0 for x in (targets, paid) + for v in x.values()), 'positive integer inventories') + self.cap = n//self.m + self.height_base = self.kmin if height_base is None else height_base + need(isinstance(self.height_base, int) and self.height_base >= 2, 'integer height base') + self.G, least = 0, 1 + while least*self.height_base <= self.cap: + self.G += 1 + least *= self.height_base + need(isinstance(extra_height, int) and extra_height >= 0, 'nonnegative extra height') + self.G += extra_height + self.zero = (0,)*len(self.K) + + @lru_cache(None) + def column(self, a): + return prod(k**v for k, v in zip(self.K, a)) + + @lru_cache(None) + def points(self, height, cap): + """(a, u(a)) at fixed degree; exact multinomial integer weights.""" + result = {} + + def visit(i, remaining, c, weight, a): + if i == len(self.K): + if remaining == 0 and c <= cap: + result[a] = weight + return + k, w = self.K[i], self.T[self.K[i]] + for count in range(remaining+1): + new_c = c*k**count + if new_c > cap: + break + visit(i+1, remaining-count, new_c, + weight*comb(remaining, count)*w**count, a+(count,)) + + if cap >= 1: + visit(0, height, 1, 1, ()) + return result + + @lru_cache(None) + def units(self, depth, rho): + return self.points(self.G-depth, self.cap//rho) + + @lru_cache(None) + def demand(self, depth, rho): + result = Counter() + for a, count in self.units(depth, rho).items(): + for i, k in enumerate(self.K): + b = list(a) + b[i] += 1 + result[tuple(b)] += count*self.T[k] + return result + + def merged(self): + sources, exits, boundary = Counter(), Counter(), Counter() + units = columns = 0 + matched = 0 + path_counts = Counter({1:1}) + for b, count in self.demand(0, 1).items(): + sources[self.column(b)] += count + for depth in range(self.G+1): + following = Counter() + for rho, paths in path_counts.items(): + batch = self.units(depth, rho) + units += paths*sum(batch.values()) + columns += paths*sum(count*rho*self.column(a) for a, count in batch.items()) + for rank, repetitions in self.P.items(): + new_rho = rho*rank + copies = paths*repetitions + if depth == self.G: + need(set(batch) <= {self.zero}, 'leaf degree zero') + exits[new_rho] += copies*batch.get(self.zero, 0) + continue + child = self.demand(depth+1, new_rho) + if new_rho <= self.cap: + following[new_rho] += copies + for b in set(batch) | set(child): + supply, demand = batch.get(b, 0), child.get(b, 0) + e = new_rho*self.column(b) + consumed = min(supply, demand) + matched += copies*consumed + if supply > demand: + exits[e] += copies*(supply-demand) + boundary[e] += copies*(supply-demand) + elif demand > supply: + need(supply == 0, 'Pascal demand cannot exceed present supply') + sources[e] += copies*(demand-supply) + path_counts = following + sources, exits, boundary = +sources, +exits, +boundary + need(sources and all(1 <= s <= self.n for s in sources), + 'all sources are positive and fit parent') + if self.height_base <= self.kmin: + need(all(self.n < self.m*s for s in sources), 'default top source bound') + need(all(1 <= e < self.n and self.m*e <= self.rmax*self.n for e in exits), + 'all paid exits strictly smaller than parent') + need(all(self.m*e > self.kmin*self.n for e in boundary), + 'premature exits have a failed boundary term') + mass = lambda h: sum(k*v for k, v in h.items()) + surplus = mass(self.T)-mass(self.P) + need(mass(sources)-mass(exits) == surplus*columns, + 'exact rank-one telescoping identity') + W, P = sum(self.T.values()), sum(self.P.values()) + bound = sum(P**d*W**(self.G-d) for d in range(self.G+1)) + need(units <= bound and sum(sources.values()) <= W*units, + 'full integer unit/source count bounds') + return {'n': self.n, 'height': self.G, 'sources': sources, 'exits': exits, + 'boundary_exits': boundary, 'units': units, 'column_mass': columns, + 'source_count': sum(sources.values()), 'matched_jobs': matched, + 'minimum_source': min(sources), 'all_sources_above_n_over_m': + all(self.n < self.m*s for s in sources), + 'rank_one_surplus': surplus, 'unit_count_upper': bound} + + def literal(self, paid_word, class_limit=200000): + """Every round returns before the next; no merging of round paths.""" + need(Counter(paid_word) == Counter(self.P), 'literal paid word matches invoice') + sources, exits = Counter(), Counter() + classes = 0 + + def process(depth, rho, incoming): + nonlocal classes + classes += 1 + need(classes <= class_limit, 'literal replay class limit') + wanted = self.demand(depth, rho) + need(all(v <= wanted.get(b, 0) for b, v in incoming.items()), + 'all incoming whole jobs fit child slots') + for b, count in wanted.items(): + missing = count-incoming.get(b, 0) + if missing: + sources[rho*self.column(b)] += missing + batch = self.units(depth, rho) + for rank in paid_word: + new_rho = rho*rank + if depth == self.G: + for a, count in batch.items(): + exits[new_rho*self.column(a)] += count + continue + child = self.demand(depth+1, new_rho) + passed = Counter() + for b, count in batch.items(): + consumed = min(count, child.get(b, 0)) + if consumed: + passed[b] = consumed + if count > consumed: + exits[new_rho*self.column(b)] += count-consumed + # All unconsumed exits and this entire child return at this + # paid position, before any later parent round is issued. + process(depth+1, new_rho, passed) + + process(0, 1, Counter()) + return {'sources': +sources, 'exits': +exits, 'classes': classes} + + +def approximate_leaves(targets, paid, maximum, checkpoints, extra_height=0, height_base=None): + """Exploratory floating point recurrence; never an acceptance certificate.""" + m = max(targets) + leaves = list(map(float, range(maximum+1))) + saved = {} + previous_cap = None + for n in range(m, maximum+1): + cap = n//m + if cap != previous_cap: + recipe = Flow(targets, paid, n, extra_height, height_base).merged() + source, exit = recipe['sources'], recipe['exits'] + count = recipe['source_count'] + exit_charge = sum(v*leaves[e] for e, v in exit.items()) + previous_cap = cap + leaves[n] = (sum(v*leaves[n-s] for s, v in source.items())+exit_charge)/count + if n in checkpoints: + from math import log + saved[n] = {'leaves_approx': leaves[n], + 'effective_saving_approx': 1-log(leaves[n])/log(n), + 'source_types': len(source), 'exit_types': len(exit), + 'boundary_exit_types': len(recipe['boundary_exits'])} + return saved diff --git a/research/chronological-batch-width/vendor/p7-RESULT.json b/research/chronological-batch-width/vendor/p7-RESULT.json new file mode 100644 index 0000000000..ebb30a9b3b --- /dev/null +++ b/research/chronological-batch-width/vendor/p7-RESULT.json @@ -0,0 +1,296 @@ +{ + "endpoint": { + "compiler": { + "H0": 4307773805920, + "H1": 16201843136005340321, + "N_encoding": "2^16201843136005340321", + "delta": "1/1400000000", + "exit_coefficient_log2_upper": "26640", + "final_strict_power_gap": "1/1400000000", + "h": "1/26", + "materialized_tensor_rule_or_uniform_word": false, + "negative_log2_eta_upper": "147931769/1250000", + "paid_max_bound_encoding": "10^6240", + "rank_one_induction": "131723^n > 131115^n; target padding adds equal paid and target rank, and splitting preserves rank", + "t": "12466419/12500000", + "target_max_encoding": "121^6240", + "target_min_encoding": "11^6240", + "tensor_power": 6240, + "theta_upper": "25/26", + "z": "139623893/140000000", + "z0": "1396238929/1400000000" + }, + "gain_over_PR4359": "38647/100000000", + "gain_over_PR4405": "19069/50000000", + "gain_over_PR4414": "33/5000000", + "gain_over_allfresh_p3": "5223/25000000", + "kappa": "268647/100000000", + "ledger_source_sha256": "d097e55f06c3f244f2074ffd7c1a0a5f3c4b4b6a6accf9619d1dde5c0ae85e15", + "minimum_outer_margin": "524529867/122500000000000000", + "negative_controls": { + "closed_epsilon": { + "actual_logarithmic_gamma_guard": "0", + "epsilon_below_one": "0", + "gaussian_above_main": "-1410399/122500000000000000", + "global_gamma_power_slack": "-1/7000000000", + "new_semantic_guard_with_C1_one": "0", + "source_axis_superpolynomial": "0" + }, + "closed_uniform_gap": { + "new_complex_uniform_saving_above_b": "0" + }, + "insufficient_BIT": { + "actual_bit_above_effective": "-270533/700000000" + }, + "unfunded_outer_point": { + "boundary_algebraic_matrix_above_kappa": "-525470133/122500000000000000", + "fused_gaussian_above_kappa": "-526410399/122500000000000000", + "global_coordinate_router_above_kappa": "-3/700000000", + "group_bit_router_above_kappa": "-1405641599/490000000000000000", + "main_transform_above_kappa": "-700470133/122500000000000000" + } + }, + "outer": { + "functional_checks": { + "fixed_halo_explicit_metadata_branch": "13475000001/175000000", + "new_BIT_row_stock_sublinear_in_active_group": "697899997009/700000000000", + "new_semantic_group_guard": "3/700000000" + }, + "margins": { + "boundary_algebraic_matrix": "329093274529867/122500000000000000", + "fused_gaussian": "329093273589601/122500000000000000", + "global_coordinate_router": "1880533/700000000", + "group_bit_router": "1316373794358401/490000000000000000", + "group_scans": "349999999/350000000", + "main_transform": "329093099529867/122500000000000000", + "microbox_face_corrections": "13475000001/175000000", + "polynomial_products": "699999999/700000000", + "sparse_union_movement": "50094718274529867/122500000000000000" + }, + "parameters": { + "a": "1880533/700000000", + "b": "940267/350000000", + "beta": "699999997/700000000", + "bit_saving": "27/10000", + "cap_xi": "111344718099529867/122500000000000000", + "complex_uniform_saving": "376107/140000000", + "d": "1/700000000", + "epsilon": "699999999/700000000", + "kappa": "268647/100000000", + "lambda_": "39892541/40000000", + "lambda_prime": "174529867/175000000", + "layout": "1/700000000", + "q": "470133/175000000", + "r0": "1/7000000000", + "stop": "1/700000000", + "tested_saving": "33581/12500000" + }, + "strict_checks": { + "actual_bit_above_effective": "9467/700000000", + "actual_logarithmic_gamma_guard": "1/700000000", + "actual_logarithmic_group_guard": "11155282162970133/61250000000000000", + "alpha_logarithm_absorption": "1/7000000000", + "boundary_algebraic_matrix_above_kappa": "699529867/122500000000000000", + "cap_above_band": "50094718099529867/122500000000000000", + "cap_below_cell": "11155281725470133/122500000000000000", + "cap_below_phase_cell_power": "133655281900470133/122500000000000000", + "complex_above_effective": "1/700000000", + "complex_below_one_over_32": "9997233/350000000", + "complex_endpoint": "1/350000000", + "epsilon_below_one": "1/700000000", + "epsilon_positive": "699999999/700000000", + "fine_prime_halo_umbrella": "7/2", + "fused_gaussian_above_kappa": "698589601/122500000000000000", + "gaussian_above_main": "87029867/61250000000000000", + "global_coordinate_router_above_kappa": "1/175000000", + "global_gamma_power_slack": "9/7000000000", + "group_below_dimension": "1/350000000", + "group_bit_router_above_kappa": "3494358401/490000000000000000", + "group_gauge_power_slack": "11155282154220133/61250000000000000", + "group_key_fits_record": "1/350000000", + "group_positive": "699999997/700000000", + "group_scans_above_kappa": "698119469/700000000", + "halo_covers_generic_inverse_radius": "5", + "improvement_over_user_baseline": "477749790400418148631/500000000000000000000000", + "lambda_above_internal": "1/1400000000", + "lambda_above_sigma": "3/1400000000", + "lambda_above_tau": "1/1400000000", + "lambda_prime_above_lambda": "1/1400000000", + "lambda_prime_above_leaf": "699059733/245000000000000000", + "leaf_saving_above_effective": "349059733/245000000000000000", + "main_transform_above_kappa": "524529867/122500000000000000", + "membership_arithmetic_fits_record": "1/700000000", + "microbox_face_corrections_above_kappa": "2155924779/28000000", + "microbox_halo_volume": "55300000003/700000000", + "new_complex_uniform_saving_above_b": "1/700000000", + "new_semantic_guard_with_C1_one": "1/700000000", + "polynomial_products_above_kappa": "69811947/70000000", + "positive_layout_slack": "1/700000000", + "q_below_effective": "1/700000000", + "q_below_internal": "1/700000000", + "q_below_leaf": "699059733/245000000000000000", + "q_positive": "470133/175000000", + "short_record_fallback": "349059733/350000000", + "source_axis_superpolynomial": "1/700000000", + "sparse_union_movement_above_kappa": "49765625699529867/122500000000000000", + "stop_below_one": "699999999/700000000", + "stop_positive": "1/700000000", + "strassen_integer_power_gap": "1951441519231", + "support_router_span": "3/700000000", + "theta_positive_polynomial_power": "2", + "union_header_fits_record": "3/700000000", + "union_tag_work_per_visit_fits_record": "3/700000000" + } + }, + "schema": "native-p7-padding-strictification-outer-endpoint/1", + "scope": "Source-bound native p7 geometry, a finite tensor recipe with target padding, exact moment and outer inequalities, and a specified finite uniform rank. Native tensor closure and the PR4359 inherited precision, storage, analytic, fixed-tape and recovery hypotheses are written premises, not a full formal theorem certificate.", + "status": "PASS_CONDITIONAL_P7_OUTER_POINT", + "strictification_source_sha256": "1f3c2a38b34d9dad7266be212ca5d0225827d8e05bda4831e6c25c5713f624f0", + "tested_saving": "33581/12500000" + }, + "independent_interval_crosscheck": true, + "scope": "Conditional native construction and exact finite arithmetic. The finite word and inherited physical, precision, analytic and fixed-tape proofs are not formally verified or materialized by this checker.", + "source_files": 23, + "status": "PASS_SOURCE_BOUND_CONDITIONAL_P7_PAID_PADDING_IMPROVEMENT", + "strictification": { + "alpha_interval": { + "lower": "0.99999998440390797702869232902431332", + "upper": "0.99999998440390797702869232902431333" + }, + "alpha_upper": "99999999/100000000", + "completion_decay_block_length": 2, + "controls": { + "one_decay_block_rejected": true, + "undamped_completion_rejected": true, + "unpadded_rank_one_tail_rejected": true + }, + "cutoff_base": 10, + "cutoff_encoding": "10^6240", + "decay_block_count": 16, + "decay_block_length": 390, + "delta_interval": { + "lower": "0.64382470915163933966321257464784307", + "upper": "0.64382470915163933966321257464784308" + }, + "delta_upper": "2/3", + "exponent": 6240, + "gamma_interval": { + "lower": "0.99819171247300624373216957625759087", + "upper": "0.99819171247300624373216957625759088" + }, + "gamma_upper": "4991/5000", + "materialized_tensor_or_completed_word": false, + "native_inventory": { + "artifact_hash_encoding": "Uncompressed UTF-8 JSON, sort_keys=True, separators=(comma,colon)", + "artifact_sha256": "12784fff6a13e3752ea6e80018e0484c5766a8adf2e88a7e71c80cf2bb68f398", + "contacts": 6720, + "dimension": 121, + "factor_receipt_sha256": "6f96f6be5d8441f71cbe6ebb1657c69b543eb085b848b92b591b7ac01d6e6598", + "fresh_helper_fields": 6120, + "keep": 232127, + "limits": "Finite exact physical controller admission; inherited all-column local word, tensor strictification, new full-word precision/stock and outer transfer remain written proof obligations.", + "main_fields": 1568, + "native_scalar_allowance": 2490856, + "native_source_gate": "PASS_ACTUAL_ARBITRARY_HELPERS_AND_COMPLETE_PHASE_CORRECT_IDLE_JOBS", + "negative_controls": { + "omitted_endpoint_translation_rejected": 784, + "wrong_native_orientation_rejected": true + }, + "p": 7, + "paid": { + "1": 37305, + "16": 448, + "2": 10695, + "3": 3360, + "32": 448, + "4": 1530, + "48": 448, + "5": 300, + "8": 1464 + }, + "paid_calls": 55998, + "productive_fields": 7688, + "rank_margin": 608, + "scalar_allowance": 2490856, + "schema": "source-bound-p7-all-fresh-complete-native-controller/1", + "source_sha256": { + "research/kappa-0023-productive-jobs/dependencies/kappa-next-regime/bit-compression/carrier-reuse/reference/joint_pair_dag.py": "8a0de761642d21919e969475c3f13e5d01a4bae7343c1e1f37c586d94b676a85", + "research/kappa-0023-productive-jobs/dependencies/kappa-next-regime/direct-decoder/sources/DATA-PHASES.json": "c5916ff312678f12aba403847643fbbc29f643acec60bdf836fa56cd3e8251fa", + "research/kappa-rebuild/bit/complex_controller_factor.py": "1de9aaf918e6a4f2f5448754c1f3c3da3b85e6257849ebd097af09859c4e5497", + "research/kappa-rebuild/bit/mixed_productive_bit.py": "b32291b0db7fc0d332ec444c70746ab0fb03351d2e50546f8bcb64060e3ff95e", + "research/kappa-rebuild/complex/fresh-certificates/THREE-base-HELPER-BOUNDARIES.json.gz": "f90517e395bde58c72cacd5d3481c4ea31d459fe4535384ac16547ac40460555", + "research/kappa-rebuild/complex/full-identity-certificates/RESULT.json": "943d5fad2fc529f470df05a35446e07ecaef7344abfce450d2c2eb2c9b3798f6", + "research/kappa-rebuild/complex/full-identity-certificates/THREE-base-FULL-IDENTITY-CANONICAL.json.gz": "6418ec3da24d548a57f5c3fe5b9062c26c9478e638504a61c387f5cfb5f4ed61", + "research/kappa-rebuild/complex/full-identity-certificates/THREE-base-FULL-IDENTITY-NATIVE.json.gz": "c54b0a3e129d28e6dbf74fa731fc3bb70fe3c6705f07256750fbecddcc842d39", + "research/kappa-rebuild/complex/full_identity_rebuild.py": "9af2ffbb0038c92e2a7d281081b0daaeadce75b11b566e5427845dc1af91e33d", + "research/kappa-rebuild/controller/P3-NATIVE-COVER.json.gz": "facfc6d6ecde151afb7e6a167776f3fdaac1c816e785a21a39f7f0bfd9140f3f", + "research/kappa-rebuild/controller/p3_native_cover.py": "fae71fcbbd20b9ee73b049cf6f43ea1d048217fb15feb6055a007e47da3363fe", + "research/kappa-rebuild/transfer-audit/p3_cover_audit.py": "a0fe9a26f77556e83b31b0c91fea909d6f3d8209d0f9f7ad4e5bc1375d33615e", + "research/kappa-rebuild/transfer-audit/p3_native_audit.py": "5504a55a50546418d10c522984438cdeedb44993f7c1dab7bd4aa1ae0515d902" + }, + "status": "PASS_EXACT_LAURENT_ALL_MAIN_CONTACTS_ENDPOINTS_AND_FULL_IDLE_PHASES", + "targets": { + "121": 224, + "25": 448, + "41": 448, + "5": 420, + "57": 448, + "6": 270, + "7": 840, + "8": 1395, + "9": 3195 + }, + "whole_idle_profile": { + "16": 448, + "32": 448, + "48": 448, + "8": 1344 + } + }, + "new_max_target_encoding": "121^6240", + "new_min_target_encoding": "11^6240", + "normalized_moment_upper_rational": "10240625039/10240638976", + "paid": { + "1": 37305, + "16": 448, + "2": 10695, + "3": 3360, + "32": 448, + "4": 1530, + "48": 448, + "5": 300, + "8": 1464 + }, + "paid_rank_one_moment": 131115, + "productive_fields": 7688, + "rank_one_surplus_encoding": "131723^6240-131115^6240", + "schema": "p7-paid-target-completion-tensor-certificate/1", + "scope": "Exact moment bounds for the documented chronological native product, paid target completion and disjoint splitting. Native all-column, precision, storage, analytic and fixed-tape premises remain separate; no full multiplication theorem is formally verified.", + "source_sha256": { + "research/kappa-rebuild/architecture/mixed_target_probe.py": "011c3c9d0cf81103dc84d709a0e36793eb7c5ae3f23c85eac27650ef13afa04a" + }, + "status": "PASS_EXACT_P7_TARGET_COMPLETION_STRICTIFICATION", + "strict_moment_verified": true, + "strictification_gap": { + "lower": "0.00000136095023295546357907266586564", + "upper": "0.00000136095023295546357907266586565" + }, + "strictification_gap_rational": "13937/10240638976", + "target_floor_base": 11, + "target_floor_encoding": "11^6240", + "target_rank_one_moment": 131723, + "targets": { + "121": 224, + "25": 448, + "41": 448, + "5": 420, + "57": 448, + "6": 270, + "7": 840, + "8": 1395, + "9": 3195 + }, + "tested_saving": "33581/12500000", + "theta_upper": "25/26" + } +} diff --git a/research/chronological-batch-width/verify.py b/research/chronological-batch-width/verify.py new file mode 100644 index 0000000000..2e24e27e44 --- /dev/null +++ b/research/chronological-batch-width/verify.py @@ -0,0 +1,236 @@ +#!/usr/bin/env python3 +"""Source-bound exact checks for the chronological batch-width lemma. + +Mihir Srivastava, with substantial OpenAI Codex assistance. Apache-2.0. +The written argument, not these finite checks, supplies the all-rank lemma. +""" +import argparse +from collections import Counter +from fractions import Fraction +import hashlib +from itertools import product +import json +from math import prod +from pathlib import Path +import sys + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from batches import (check_batches, compile_widths, direct_flow, multiplier, + require, requirements) + +HERE = Path(__file__).resolve().parent + + +def digest(data): + return hashlib.sha256(data).hexdigest() + + +def integer_record(value): + return {'bits': value.bit_length(), 'unsigned_big_endian_sha256': + digest(value.to_bytes(max(1, (value.bit_length()+7)//8), 'big'))} + + +def canonical(data): + return json.dumps(data, sort_keys=True, separators=(',', ':')).encode() + + +def source_check(root=HERE): + rows = json.loads((root/'VENDOR.json').read_text(encoding='utf-8')) + for row in rows: + content = (root/row['path']).read_bytes() + require(digest(content) == row['sha256'], 'vendored source SHA256') + blob = hashlib.sha1(b'blob '+str(len(content)).encode()+b'\0'+content).hexdigest() + require(blob == row['git_blob'], 'vendored Git blob') + return {row['path']: row['sha256'] for row in rows} + + +def literal_flow(targets, paid_word, n): + """Enumerate ordered target words and each chronological paid position. + + This checker uses neither Pascal coefficients nor merged path counts. + It is bounded to small fixtures, and returns repeated cut batches literally. + """ + m, kmin = max(targets), min(targets) + cap, G, power = n//m, 0, 1 + while power*kmin <= cap: + G += 1 + power *= kmin + alphabet = [k for k, count in targets.items() for _ in range(count)] + source, exits, cuts = Counter(), Counter(), [] + unit_count = columns = 0 + + def visit(path, rho): + nonlocal unit_count, columns + level = G-len(path) + supplies = Counter(prod(word) for word in product(alphabet, repeat=level) + if prod(word)*rho <= cap) + unit_count += sum(supplies.values()) + columns += sum(rho*c*q for c, q in supplies.items()) + demands = Counter() + for c, q in supplies.items(): + for k in alphabet: + demands[c*k] += q + return supplies, demands + + def run(path, rho, incoming): + supplies, demands = visit(path, rho) + for c, q in demands.items(): + require(incoming[c] <= q, 'literal incoming slots') + source[rho*c] += q-incoming[c] + for position, r in enumerate(paid_word): + rr = rho*r + if len(path) == G: + waiting = Counter({rr*c: q for c, q in supplies.items()}) + else: + child_units = Counter(prod(word) for word in product(alphabet, repeat=G-len(path)-1) + if prod(word)*rr <= cap) + child_demands = Counter() + for c, q in child_units.items(): + for k in alphabet: + child_demands[c*k] += q + passed = Counter({c: min(q, child_demands[c]) for c, q in supplies.items()}) + waiting = Counter({rr*c: q-passed[c] for c, q in supplies.items()}) + for rank, count in waiting.items(): + if count: + exits[rank] += count + cuts.append((len(path), rho, r, rank, count)) + if len(path) < G and rr <= cap: + run(path+(position,), rr, passed) + run((), 1, Counter()) + return +source, +exits, Counter(cuts), unit_count, columns + + +def expect_failure(function, message): + try: + function() + except ValueError as exc: + require(message in str(exc), 'expected rejection reason: '+message) + return + raise ValueError('control was accepted: '+message) + + +def main_result(): + pins = source_check() + reference = json.loads((HERE/'vendor/direct-flow-RESULT.json').read_text(encoding='utf-8')) + native = json.loads((HERE/'vendor/p7-RESULT.json').read_text(encoding='utf-8'))['strictification']['native_inventory'] + parse = lambda h: {int(k): v for k, v in h.items()} + t7, p7 = parse(native['targets']), parse(native['paid']) + require(sum(t7.values()) == 7688 and sum(p7.values()) == 55998, 'p7 source census') + + # Match all nine frozen #4436 receipts, not a predecessor evaluator. + for row in reference['finite_flows']: + expected = row['flow'] + flow = direct_flow(parse(row['targets']), parse(row['paid']), expected['n']) + for key in ('sources', 'exits', 'boundary_exits'): + require(flow[key] == parse(expected[key]), 'frozen '+key) + for key in ('height', 'units', 'column_mass', 'matched_jobs'): + require(flow[key] == expected[key], 'frozen '+key) + + literal_count = 0 + for targets, word, ranks in [({2:1,5:1}, [1,4,1], range(5,46)), + ({2:2,3:1}, [2,1,2], range(3,29)), + ({2:1,4:1,8:1}, [1,3,1], range(8,41)), + ({2:4,3:1}, [1]*6+[2]*2, [12])]: + for n in ranks: + flow = direct_flow(targets, Counter(word), n) + ss, ee, cc, uu, qq = literal_flow(targets, word, n) + compressed = Counter() + for cut in flow['cuts']: + compressed[tuple(cut[k] for k in ('depth','rho','paid_rank','rank','count'))] += cut['copies'] + require((flow['sources'], flow['exits'], compressed, flow['units'], flow['column_mass']) + == (ss, ee, cc, uu, qq), 'literal chronological cuts') + literal_count += 1 + + # Independently brute-force the least positive integer for two constraints. + brute_count = 0 + for b1, b2, q1, q2 in product(range(1,9), range(1,9), range(1,7), range(1,7)): + brute = next(a for a in range(1,b1*b2+1) if a*q1 % b1 == 0 and a*q2 % b2 == 0) + require(multiplier([b1,b2], [(0,q1),(1,q2)]) == brute, 'exhaustive multiplier minimum') + brute_count += 1 + + outputs = [] + cases = [('strict-overlap', {2:1,5:1}, {1:2,4:1}, 100, reference['exact_toy_compilations'][0]), + ('source-open-equality', {2:4,3:1}, {1:6,2:2}, 100, reference['exact_toy_compilations'][1]), + ('raw-p7', t7, p7, 1000, reference['exact_p7_direct_compilation'])] + compiled = {} + for name, targets, paid, maximum, expected in cases: + result = compile_widths(targets, paid, maximum) + compiled[name] = result + require(integer_record(result['nested_widths'][-1]) == expected['productive_width'], + 'frozen nested width') + require(integer_record(result['nested_leaves'][-1]) == expected['paid_rank_one_leaves'], + 'frozen nested leaf count') + # Check the aggregate rational recurrence separately at every rank. + rational = [Fraction(n) for n in range(max(targets))] + for n in range(max(targets), maximum+1): + f = direct_flow(targets, paid, n) + cost = (sum(q*rational[n-s] for s,q in f['sources'].items()) + +sum(q*rational[e] for e,q in f['exits'].items())) / sum(f['sources'].values()) + require(cost == Fraction(result['leaves'][n],result['widths'][n]), 'rational leaf recurrence') + rational.append(cost) + outputs.append({'rule': name, 'maximum': maximum, **result['counters'], + 'width': integer_record(result['widths'][-1]), + 'nested_width': integer_record(result['nested_widths'][-1]), + 'leaves': integer_record(result['leaves'][-1]), + 'width_reduction_factor': integer_record(result['nested_widths'][-1]//result['widths'][-1]), + 'all_rank_receipt_sha256': digest(canonical(result['rows'])), + 'normalized_leaf_cost_unchanged': True, + 'new_width_divides_nested_at_every_rank': True, + 'first_pooled_failure': result['first_pooled_failure']}) + + fail = compiled['source-open-equality']['first_pooled_failure'] + require(fail['n'] == 12 and fail['pooled_multiplier'] == 175 + and fail['chronological_multiplier'] == fail['child_width'] == 700, + 'actual chronology counterexample') + toy_flow = direct_flow({2:4,3:1}, {1:6,2:2}, 12) + widths = compiled['source-open-equality']['widths'][:12] + pooled_rows = requirements(toy_flow,12,pooled_exits=True) + check_batches(widths, pooled_rows, 175) # positive: the tempting relaxation passes + controls = [] + def reject(name, function, message): + expect_failure(function,message); controls.append(name) + reject('pooled exit multiplier at actual cut', lambda: check_batches(widths,requirements(toy_flow,12),175), 'whole chronological batch') + reject('drop a factor from least multiplier', lambda: check_batches(widths,requirements(toy_flow,12),350), 'whole chronological batch') + reject('zero replication', lambda: check_batches(widths,requirements(toy_flow,12),0), 'positive replication') + reject('zero supplier width', lambda: multiplier([0],[(0,1)]), 'positive supplier width') + reject('zero job count', lambda: multiplier([1],[(0,0)]), 'positive batch count') + reject('negative job count', lambda: multiplier([1],[(0,-1)]), 'positive batch count') + reject('boolean job count', lambda: multiplier([1],[(0,True)]), 'positive batch count') + reject('future rank', lambda: multiplier([1],[(1,1)]), 'smaller rank') + reject('paid rank equal to ambient', lambda: direct_flow({2:1,5:1},{5:1},10), 'strict rank contract') + reject('noninteger target multiplicity', lambda: direct_flow({2:1.0,5:1},{1:1},10), 'positive integer histogram') + f = direct_flow({2:1,5:1},{1:2,4:1},20) + trimmed = f['exits']-f['boundary_exits'] + reject('delete premature exits', lambda: require(sum(s*q for s,q in f['sources'].items())-sum(e*q for e,q in trimmed.items()) == f['column_mass'], 'rank-one conservation'), 'rank-one conservation') + multiplied = [(c['rank'],c['count']*c['copies']) for c in toy_flow['cuts']] + bad_a = multiplier(widths,[(12-s,q) for s,q in toy_flow['sources'].items()]+multiplied) + reject('merge repeated parent paths and paid positions', lambda: check_batches(widths,requirements(toy_flow,12),bad_a), 'whole chronological batch') + return {'schema': 'chronological-batch-width/v1', 'claim_type': 'conditional batching lemma and exact finite accounting', + 'no_new_kappa': True, 'source_sha256': pins, + 'frozen_flows_matched': 9, 'independent_literal_cut_fixtures': literal_count, + 'brute_force_minimality_cases': brute_count, 'compilations': outputs, + 'chronology_counterexample': {**fail, 'widths_through_12': compiled['source-open-equality']['widths'][:13], + 'aggregate_exits': dict(toy_flow['exits']), + 'aggregate_sources': dict(toy_flow['sources']), + 'repeated_cut_multiplier': bad_a}, + 'rejected_controls': controls} + + +def main(): + ap=argparse.ArgumentParser(description=__doc__) + ap.add_argument('--write', action='store_true', help='authoring only: replace RESULT.json') + args=ap.parse_args() + # JSON object keys are strings after serialization (the small witness + # contains rank-indexed dictionaries). Compare the same representation. + result=json.loads(canonical(main_result())) + target=HERE/'RESULT.json' + if args.write: + target.write_text(json.dumps(result,indent=2,sort_keys=True)+'\n',encoding='utf-8',newline='\n') + else: + require(result == json.loads(target.read_text(encoding='utf-8')), 'committed result matches fresh replay') + print('PASS_CHRONOLOGICAL_BATCH_WIDTH cuts='+str(result['independent_literal_cut_fixtures']) + +' controls='+str(len(result['rejected_controls']))) + + +if __name__ == '__main__': + main()