# Qyxo-Zhaenivoth v1 architecture search and fixed-total theorem This is an independent second-pass design record. The target is a **major practical improvement on an explicitly delimited workload**, not an assertion that every algorithm is a mathematical breakthrough. Nothing in this record is measured performance. The name is a semantic reset; truth and the prior-art boundary do not depend on it. ## Problem and scope Maintain a large, static bank of signed interval values `l[i,j] <= v[i,j] <= h[i,j]` while a small number of nonnegative mass intervals `L[i] <= w[i] <= U[i]` change between policy queries. Compute **exact inclusive robust threshold decisions** and, optionally, exact sharp mean bounds. The denominator is shared with the numerator. Queries and patches should not rescan every unchanged row. Values are finite binary64 inputs converted exactly; exact arithmetic concerns those converted inputs. For one coordinate with selected value endpoint `x_i`, put `delta_i=U_i-L_i`, `A=N0+sum(L_i*x_i)` and `B=D0+sum(L_i)>0`. Then \[ F_+(t)=A-Bt+\sum_i\delta_i(x_i-t)_+, \qquad F_-(t)=A-Bt-\sum_i\delta_i(t-x_i)_+. \] The upper mean endpoint is the unique zero of `F_+`; the lower endpoint is the unique zero of `F_-`. A threshold decision is a sign check of the corresponding support. Hinge algebra and this fractional reduction are inherited mathematics. ## Nine structurally different mechanisms Let `n` be rows, `p` coordinates, `k` patched rows, `q` thresholds in a batch, `r` changed rows retained since an epoch, `b` blocks, and `d` threshold rank movement. Arithmetic-operation bounds below omit arbitrary-precision bit costs; multiplication and addition must be charged at actual operand widths in performance measurements. ### 1. Exact sorted hinge index — selected core 1. Primitive: dynamic prefix/suffix moments of a piecewise-affine support function. 2. State: sorted static lower/upper endpoints, original-row rank maps, exact baseline numerator/denominator, Fenwick arrays of `delta` and `delta*x`, current mass intervals. 3. Update: for a mass patch, update the baseline by `change(L)*(x,1)` and update two moment trees by `change(delta)*(x,1)` at that row's rank. 4. Objective: sharp exact predicates under changing mass boxes without a full rescan. 5. Time: build `O(p*n*log n)` including sorting, linear tree construction after sorting; sparse patch `O(k*p*log n)`, arbitrary threshold `O(p*log n)`, sharp endpoints `O(p*log n)` by direct tree lifting. 6. Memory: `O(p*n)` exact cells and rank maps; operand widths matter. 7. Advantage: online sparse updates and arbitrarily changing thresholds, including cancellation and exact ties; no training or numerical-filter assumptions. 8. Failure: dense patches, mutable values, large `p`, large exact operand widths, short lifetimes, and materialized witnesses. A witness still costs `Omega(n)` to write. 9. Nearest techniques: Fenwick trees, dynamic prefix sums/order-statistic trees, Karnik–Mendel switching-point type reduction, linear-fractional box optimization, hinge-loss moments. 10. Non-equivalence: unlike a full support scan or cached stale endpoints, the retained state exposes exact sparse updates and arbitrary threshold/root queries with logarithmic arithmetic work. That is a real capability difference from QZ v0.2.1. The combination is a specialization of known machinery; no original data-structure theorem is established. ### 2. Fixed-policy exact watch counters — strongest restricted baseline 1. Primitive: incrementally maintain a finite set of already chosen support evaluations. 2. State: exact `F_+(t_a)`/`F_-(t_a)` for `a=1..q`, old masses, static values. 3. Update: subtract each patched row's old support and add its new support for every watched threshold. 4. Objective: constant-time decisions for a small fixed collection of policy thresholds. 5. Time: build `O(n*p*q)`, patch `O(k*p*q)`, decision `O(p)`. 6. Memory: `O(n*p+p*q)`; no sorted trees required. 7. Advantage: for one fixed threshold, `O(k*p)` updates beat the selected index's logarithmic factor. 8. Failure: newly requested thresholds require an initial full scan; many thresholds make every patch expensive; no cheap arbitrary sharp-bound query. 9. Nearest: materialized views, incremental aggregation, delta maintenance. 10. Non-equivalence: state is policy-specific rather than a representation of the complete support curve. **Retain as mandatory baseline, not a weak comparator to suppress.** ### 3. Epoch baseline plus sparse compensator 1. Primitive: exact decomposition into a static baseline plus explicit changed-row support differences. 2. State: static sorted prefix arrays for an epoch and a dictionary of rows differing from that epoch. 3. Update: add/replace a dictionary entry; periodically rebuild the epoch. 4. Objective: avoid both full rescans and tree update overhead when only a few distinct rows ever change. 5. Time: build `O(p*n*log n)`, patch `O(k*p)`, threshold `O(p*(log n+r))`; rebuilding costs `O(p*n)` after the value order is available. 6. Memory: `O(n*p+r*p)`. 7. Advantage: one or two recurring changed rows; cheap writes and compact exact deltas. 8. Failure: changing-row set grows; endpoint finding can multiply residual work; rebuild scheduling is workload-dependent. 9. Nearest: log-structured merge designs, static/dynamic decomposition, incremental materialized views. 10. Non-equivalence: queries evaluate explicit sparse corrections to static arrays rather than updating a complete dynamic index. **Serious adversarial peer; may be superior for tiny persistent delta sets.** ### 4. Common latent-coordinate quotient 1. Primitive: prove that all coordinates share an exact one-dimensional ordered latent value. 2. State: `x_ij=a_j*z_i+b_j`, one ordered scalar mass index, and coordinate coefficients. 3. Update: update the scalar index once for each mass patch; map extrema by the sign of `a_j`. 4. Objective: eliminate the multiplicative coordinate factor when exact affine dependence exists. 5. Time: verify a supplied factorization `O(n*p)`, scalar preprocessing `O(n*log n)`, patch `O(k*log n)`, query `O(log n+p)`. 6. Memory: `O(n+p)` after exact verification, or `O(n*p)` if originals are retained. 7. Advantage: correlated engineering signals, affine-derived metrics, very large coordinate counts. 8. Failure: approximate low rank does not commute with hinges and cannot preserve exact guarantees without a separately derived residual envelope. Generic value intervals need compatible endpoint factorizations. 9. Nearest: sufficient statistics, exact matrix rank/factorization, affine dimension reduction. 10. Non-equivalence: a proved quotient removes redundant coordinates instead of merely indexing each separately. **Eliminate from the default release: useful special case, insufficiently general.** ### 5. Unsorted hierarchical sign partition 1. Primitive: recursively aggregate a block if all its values lie on one side of the query threshold. 2. State: a row tree with value min/max, exact mass/value moments, and per-node uncertainty capacity. 3. Update: change moments and extrema along a path; mutable values are permitted if leaf identity stays fixed. 4. Objective: query only blocks whose value hull crosses the threshold. 5. Time: build `O(n*p)`, patch `O(k*p*log n)`, query `O(p*b)` visited nodes, worst `O(n*p)`. 6. Memory: `O(n*p)`. 7. Advantage: clustered local values, row locality, mutable value banks, and large pure-sign blocks. 8. Failure: alternating/random values make every block straddle thresholds; tree traversal loses to scans; exact endpoint finding can visit many blocks repeatedly. 9. Nearest: segment trees, branch and bound, interval trees, hierarchical aggregation. 10. Non-equivalence: geometry/locality permits value changes without preserving a global sort, at the cost of losing logarithmic worst-case queries. **Eliminate as default because sorted static banks are the chosen workload.** ### 6. Coarse capacity envelopes with exact challenger 1. Primitive: replace a block's `delta_i` distribution by total capacity and its value hull, then refine only an ambiguous sign. 2. State: `b` fixed buckets with baseline exact moments, uncertainty capacities, lower/upper value extrema; original rows for refinement. 3. Update: adjust a bucket's aggregate and update its extrema if needed. 4. Objective: cheap one-sided certified decisions with exact fallback near boundaries. 5. Time: build `O(n*p)`, typical patch `O(k*p)` for fixed values, approximate certificate `O(b*p)`, worst fallback `O(n*p)`. 6. Memory: `O(n*p+b*p)`. 7. Advantage: separated policy signs and narrow within-block value variation, small summaries, streaming portability. 8. Failure: bounding capacity and values independently creates artificial states; adversarial cancellation and wide value buckets force fallback; batch sizes may conceal extra work. 9. Nearest: histogram bounds, hierarchical uncertainty envelopes, adaptive exact predicates. 10. Non-equivalence: deliberately coarsens the support curve and certifies only separated decisions rather than maintaining it sharply. **Eliminate: v0.2.1 already owns a competitive separated-sign niche, while the selected exact index removes the boundary collapse.** ### 7. Offline/monotone threshold event sweep 1. Primitive: cross sorted breakpoints once and update the support's slope/intercept by events. 2. State: current threshold rank, current exact support segment, sorted event list, mass changes, possibly a queue of known future queries. 3. Update: apply sparse mass corrections in the current partition; move to each threshold by crossing only intervening events. 4. Objective: near-linear total cost for monotone or sorted threshold batches. 5. Time: static batch `O(n*p+q*p)` after sorting thresholds; an online step `O(p*(k+d))`; random jumps can cost `O(n*p)` unless a prefix index is added. 6. Memory: `O(n*p+q*p)` offline, `O(n*p)` streaming. 7. Advantage: sweeping an entire risk curve; huge sorted batches; no logarithmic factor per nearby query. 8. Failure: arbitrary threshold order, mass updates spanning many coordinates, unpredictable threshold streams. 9. Nearest: sweep-line algorithms, kinetic data structures, sorted multipoint evaluation. 10. Non-equivalence: exploits query order rather than dynamic range queries. **Retain for batched future APIs and as a favorable-control baseline.** ### 8. Reused local affine certificate with breakpoint continuation 1. Primitive: retain one exact active support segment and certify that the next root/query remains inside it. 2. State: a previous switching rank, local affine coefficients, neighboring values, and an index or explicit move list when continuation fails. 3. Update: sparse changes adjust the local coefficients according to the retained partition. If the new root ratio stays within neighboring breakpoints, accept immediately; otherwise move the partition or invoke a global index. 4. Objective: remove search work for temporally stable mass/threshold streams. 5. Time: stable patch/query `O(k*p+p)`, unstable local repair `O(p*d)` plus a fallback `O(p*log n)`. 6. Memory: `O(n*p)` with a complete fallback index, `O(p)` extra continuation state. 7. Advantage: a stable switching rank can persist over many updates even when exact support signs are tiny. 8. Failure: adversarial root motion and equality ties; a stale rank without a rigorous segment check is unsound; adds mutable cache invariants. 9. Nearest: active-set warm starts, Newton/Karnik–Mendel switching-point iterations, kinetic certificates. 10. Non-equivalence: an exact affine-segment membership test skips global search on successful continuation; it does not replace the index. **Eliminate from first v1 unless profiling proves contribution; correctness complexity is unnecessary before the core wins.** ### 9. Fixed-total capacity selection — selected narrow extension 1. Primitive: exact capacity allocation under the coupling constraint `sum(w_i)=W`. 2. State: the same sorted `delta` and `delta*x` moment trees as architecture 1 plus baseline moments and total lower/upper mass. 3. Update: identical sparse mass patch. A query verifies feasibility, selects a prefix capacity by Fenwick lifting, and allocates one partial boundary amount. 4. Objective: sharp guarantees for a known total mass, avoiding the independent box's fictitious population/reweighting states. 5. Time: build and patch as architecture 1; bounds and policies `O(p*log n)`. 6. Memory: no extra asymptotic storage beyond the selected index. 7. Advantage: known population totals, fixed retained-record counts, fixed-budget resource weights, calibrated rebalancing. If converted capacities and total are integers, the extremal allocation is integral. 8. Failure: arbitrary further correlations, per-group total constraints not separately indexed, nonlinear weight restrictions, and overinterpreting coordinate-specific witnesses as simultaneous vector extremes. 9. Nearest: fractional knapsack, continuous bounded resource allocation, dynamic weighted quantile selection, box-plus-hyperplane linear programming. 10. Non-equivalence: the feasible set differs substantively from v0.2.1's independent boxes, and exact total-mass selection shares the existing dynamic state. **This is an added application capability, not invention of greedy LP or weighted order statistics.** ## Direct endpoint search: remove a logarithmic factor The naive composition “binary search sorted breakpoints, making a Fenwick support query at every midpoint” costs `O(log² n)`. That unnecessary composition can be removed. For sorted `x_1 <= ... <= x_n`, let `C_j=sum_{i<=j} delta_i*x_i`, `E_j=sum_{i<=j} delta_i`, and let `C_n,E_n` be totals. At a breakpoint, \[ F_+(x_j)=A+C_n-C_j-(B+E_n-E_j)x_j, \qquad F_-(x_j)=A+C_j-(B+E_j)x_j. \] Both support functions are strictly decreasing since `B>0`. Therefore the predicate `F(x_j)>=0` is monotone in rank. Fenwick binary lifting builds the candidate prefix moments from one tree node per bit and evaluates that predicate in constant arithmetic work per bit. It locates the largest admissible `j` in `O(log n)` arithmetic operations, even though the moment `C_j` itself need not be monotone because values can be signed. The monotonic object is **the support evaluated at its ordered breakpoints**, not the signed moment sum. The exact roots then are \[ y_+=\frac{A+C_n-C_j}{B+E_n-E_j}, \qquad y_-=\frac{A+C_j}{B+E_j}. \] Use `j=0` when every breakpoint predicate is false and `j=n` when all are true. Roots outside the value hull are valid when a nonzero base numerator/denominator contributes an external value. Duplicate keys and equality are harmless: zero hinge terms allow either side of a tied breakpoint; selecting the last true rank is deterministic. This is a derived specialization of standard tree descent/binary lifting. It is not a claimed new general lower bound or a new search data structure. ## Standalone fixed-total theorem **Theorem (sharp box-plus-total normalized bounds, exact real arithmetic).** Let all selected value endpoints `x_i` be finite reals, `0<=L_i<=U_i`, `D0>=0`, and `N0` finite. Define `delta_i=U_i-L_i`, `Ltot=sum L_i`, `E=sum delta_i`. Suppose \[ L_{tot}\le W\le L_{tot}+E,\qquad D_0+W>0. \] Put `R=W-Ltot`. Sort `x_i` increasingly, retaining the matching capacities. Let \[ P_j=\sum_{i\le j}\delta_i,\quad M_j=\sum_{i\le j}\delta_i x_i, \quad j(R)=\max\{j\in\{0,\ldots,n\}:P_j\le R\}. \] Define \[ H_x(R)= \begin{cases} M_n,&j(R)=n,\\ M_{j(R)}+[R-P_{j(R)}]x_{j(R)+1},&j(R)=t` predicate is `y_min(W)>=t`. **Proof.** Write `w_i=L_i+z_i`. All feasible denominators are the same positive number `D0+W`, so extremizing the quotient is equivalent to extremizing its numerator. Positive masses let each coordinate choose its corresponding value endpoint. For minimization, if `x_a0`, moving `epsilon=min(delta_a-z_a,z_b)` from `b` to `a` preserves capacity bounds and total mass while decreasing the moment by `epsilon*(x_b-x_a)`. Repeating this exchange yields a prefix filled to capacity, at most one partially filled boundary, then zeros. This is exactly `H_x(R)`; tied values do not change the objective. For maximization, apply the same minimum formula to omitted capacity `delta_i-z_i`, whose total is `E-R`. The omitted moment is least when its capacity is assigned to low values, so the retained residual moment is `M_n-H_x(E-R)`. Feasibility follows from `0<=R<=E`. This proves attainment, sharpness, and both predicates. **Integrality corollary.** If the converted `L_i,U_i,W` are integers, all prefix sums and the partial amount are integers, so the greedy extremal masses are integers. The theorem therefore remains sharp with integer mass restrictions. The word “converted” matters: converting an arbitrary integer above binary64's exact integer range can alter the intended model before the algorithm begins. **Complexity corollary.** A Fenwick array of nonnegative capacities supports selection of the largest prefix `P_j<=R` by ordinary binary lifting, and a parallel signed moment array produces `M_j` during the same traversal. This requires `O(log n)` arithmetic operations and `O(n)` cells. A zero-capacity run is skipped by the non-strict comparison. A patch changes `O(log n)` cells. Independent mass totals and exact bit widths must be maintained rather than silently rescaling every stored node. **Implementation domain note.** The coupled theorem permits `D0+sum L_i=0` provided `D0+W>0`. If a public constructor retains the stricter independent-box requirement, the implementation covers a proper subset of this theorem. Either allow coupled-only construction and reject undefined independent queries, or state the narrower constructor domain explicitly. ## Smallest decisive demonstration and hostile controls ### Derived future extension: a total-mass interval This extension is **not implemented or empirically tested in v1**. If the additional coupling is `W_a<=sum w_i<=W_b`, restrict it to the feasible mass range first. Put `R_a=W_a-sum L`, `R_b=W_b-sum L`. For an upper policy support at `t`, let `R_pos=sum_{h_i>t}delta_i`. The optimal residual total is `R_star=clamp(R_pos,R_a,R_b)`, and its contribution is obtained by selecting the highest `R_star` capacity and subtracting `t*R_star`. For lower support, let `R_neg=sum_{l_i