diff --git a/research/randomized-query-power-frontier/PROOF.md b/research/randomized-query-power-frontier/PROOF.md
new file mode 100644
index 0000000000..b56a8c47d6
--- /dev/null
+++ b/research/randomized-query-power-frontier/PROOF.md
@@ -0,0 +1,161 @@
+# The exact stochastic rank-power frontier
+
+This contribution was produced by Nick Petalas. Apache-2.0.
+
+Claim type: scoped algebraic proof with finite corroboration. No physical
+supplier or new kappa is claimed.
+
+## Contract
+
+Fix integers `1 <= R <= k`, a real exponent `0 < t < 1`, and a budget
+`0 < B <= R^t`. A random complex `k` by `k` matrix `A` is chosen independently
+of the input. Require `E A = I_k`, `rank A <= R` almost surely and a finite
+second moment. Its declared query bill is `E (rank A)^t <= B`, with `0^t=0`.
+Define the worst-input relative mean-square error by
+
+```
+omega(A) = sup_{||x||_2=1} E ||(A-I)x||_2^2.
+```
+
+This is a linear response contract. It permits arbitrary complex encoders
+and decoders. It does not permit selecting the matrix as a function of the
+input, bias, nonlinear decoding or an exact correction supplied for free.
+Write `b=B/R^t` for the normalized expected bill.
+
+For interpretation as a shared-query interface, the target is `k` independent
+copies of a common unitary job `Q`. A fixed outcome with scalar lane response
+`A` has target part `A tensor Q`, so the relative error equals the expression
+above. A rank-`r` response factors through `r` linear channels. The price
+`r^t` is an **assumption of this optimistic relaxation**. Lane rank is not
+automatically a selected supplier's frame rank or recursive-child tariff.
+Any application must prove that bridge. Granting conversion, acquisition,
+randomness, workspace and restoration free does not supply that bridge.
+
+The inequality also applies if an implementation has a larger complete bill
+which dominates `E (rank A)^t`. For a single additive query layer, subadditivity
+gives `sum_j r_j^t >= (sum_j r_j)^t >= (rank A)^t`, provided each query really
+has response rank at most `r_j` and is charged at least `r_j^t` in the same
+normalization. Products, feedback and reused observations need a fresh rank
+argument. An arbitrary dirty auxiliary state cannot defeat the stated lower
+bound: restrict it to zero. No constructive dirty restoration is asserted.
+
+## Sharp theorem
+
+The exact infimum is attained and is
+
+```
+inf omega(A) = k R^(t-1)/B - 1 = k/(b R) - 1. (1)
+```
+
+In particular, without a proper rank cap, `R=k`,
+
+```
+B >= k^t/(1+omega).
+```
+
+For `0 < t < 1`, equality at any budget in this interval has only the two
+response matrices
+
+```
+A = 0 with probability 1-B/k^t,
+A = (k^t/B) I_k with probability B/k^t. (2)
+```
+
+Thus the exact optimizer in this price model either omits the whole job or
+performs a rescaled whole job. Intermediate response ranks cannot attain it.
+This is a statement about expected work and mean-square error, not an
+exact-on-each-run implementation or a bound on successful recovery probability.
+
+### Lower bound
+
+Put `r=rank A`. For any fixed matrix let `P` be the orthogonal projection onto
+its image. Since `P A=A`, Frobenius Cauchy-Schwarz gives the classical inequality
+
+```
+|tr A| = |
_F| <= sqrt(r) ||A||_F.
+```
+
+It is valid for nonnormal and nonsymmetric matrices. Set both sides to zero
+when `r=0`. Applying Cauchy-Schwarz also over the probability space gives
+
+```
+k^2 = |E tr A|^2 <= (E r) E ||A||_F^2. (3)
+```
+
+For every integer `0 <= r <= R`,
+
+```
+r <= R^(1-t) r^t,
+```
+
+strictly for `0= k/(R^(1-t)B)-1`, which is (1).
+
+### Attainment and equality
+
+With probability `b` choose a uniformly random `R`-subset `S` of the `k`
+coordinates, let `P_S` be its coordinate projection, and set
+`A=k P_S/(bR)`. With probability `1-b` set `A=0`. Directly,
+
+```
+E A = I, E (rank A)^t = b R^t = B,
+E (A-I)* (A-I) = (k/(bR)-1) I.
+```
+
+This finite law attains the worst-input bound, not only an average over
+inputs. More generally one may use any distribution of rank-`R` orthogonal
+projections satisfying `E P=(R/k)I` on the nonzero branch. Uniform coordinate
+sparsification and its usual `k/R-1` variance at `b=1` are classical; see
+Safaryan, Shulgin and Richtarik's [compression uncertainty paper](https://arxiv.org/abs/2002.08958).
+No priority is claimed for that construction or the trace inequality. The
+new interface calculation includes the concave rank-power bill, random zero
+branch, exact worst-input optimum and its equality restriction.
+
+To prove (2), equality in (1) forces equality in every intervening bound.
+In particular `E r=R^(1-t) E r^t=R^(1-t)B`. Strictness at intermediate ranks
+forces `r` to be either zero or `R`. When `R=k`, a nonzero `A` has image the
+whole space, so equality in the fixed-matrix trace inequality forces
+`A=alpha I`. Equality in probabilistic Cauchy-Schwarz forces the same scalar
+`alpha` on every nonzero branch, with common nonnegative trace phase.
+The cost fixes its probability to `b=B/k^t`; unbiasedness then gives
+`alpha=1/b`. Conversely (2) attains every bound. This includes `b=1`.
+
+## Consequences and boundary of the obstruction
+
+For a normalized tolerance `omega <= epsilon^2`, the unrestricted-cap
+interface cannot save more than the fraction `epsilon^2/(1+epsilon^2)` of
+the deterministic rank-power bill. At `epsilon=2^-g`, this is exactly
+`1/(4^g+1)`. This is a normalized relative MSE tolerance; `g` has not been
+identified with any selected word's precision guard. For example `g=6`
+allows at most `1/4097` expected fractional saving. Zero variance permits
+no saving. The explicit optimum still has a nonzero probability of returning
+zero when the budget is below the full bill.
+
+With a hard proper cap `R= 0 for p, _ in law), "probability")
+ require(sum(p for p, _ in law) == 1, "probability sum")
+ mean = [[F(0) for _ in range(k)] for _ in range(k)]
+ error = [[F(0) for _ in range(k)] for _ in range(k)]
+ mean_rank = F(0)
+ for probability, matrix in law:
+ r = rank(matrix)
+ require(r <= cap, "rank cap")
+ mean_rank += probability * r
+ for i in range(k):
+ for j in range(k):
+ mean[i][j] += probability * matrix[i][j]
+ error[i][j] += probability * sum(
+ (matrix[h][i] - (h == i)) * (matrix[h][j] - (h == j))
+ for h in range(k))
+ require(tuple(map(tuple, mean)) == identity(k), "unbiased operator")
+ return tuple(map(tuple, error)), mean_rank
+
+
+def projection_law(k, cap, beta, walsh=False):
+ """Uniform coordinate projectors, optionally in a rational Walsh basis."""
+ require(1 <= cap <= k <= 8 and 0 < beta <= 1, "projection parameters")
+ require(not walsh or k & (k - 1) == 0, "Walsh width")
+ law = [(1 - beta, zero(k))]
+ weight = beta / comb(k, cap)
+ scale = F(k, cap) / beta
+ for subset in combinations(range(k), cap):
+ if walsh:
+ matrix = tuple(tuple(scale * sum(
+ (-1) ** ((i & h).bit_count() + (j & h).bit_count())
+ for h in subset) / k for j in range(k)) for i in range(k))
+ else:
+ matrix = tuple(tuple(scale * (i == j and i in subset)
+ for j in range(k)) for i in range(k))
+ law.append((weight, matrix))
+ return law
+
+
+def check_attainers():
+ cases = outcomes = 0
+ examples = []
+ for k in range(1, 9):
+ for cap in range(1, k + 1):
+ for beta in (F(1), F(1, 2), F(2, 3), F(1, 4)):
+ for walsh in ((False, True) if k & (k - 1) == 0 else (False,)):
+ law = projection_law(k, cap, beta, walsh)
+ covariance, mean_rank = inspect_law(k, cap, law)
+ variance = F(k, cap) / beta - 1
+ expected = tuple(tuple(variance * (i == j) for j in range(k))
+ for i in range(k))
+ require(covariance == expected, "sharp worst-input covariance")
+ require(mean_rank == beta * cap, "rank charge")
+ require(all(p == 0 or rank(a) in (0, cap) for p, a in law),
+ "only endpoint ranks attain the power relaxation")
+ cases += 1
+ outcomes += len(law)
+ if (k, cap, beta, walsh) in ((8, 4, F(1, 2), False),
+ (8, 8, F(2, 3), True)):
+ examples.append({"k": k, "cap": cap, "beta": str(beta),
+ "variance": str(variance)})
+ return {"laws": cases, "outcomes": outcomes, "examples": examples}
+
+
+def check_trace_rank():
+ matrices = equalities = 0
+ for k in range(1, 4):
+ for entries in product((-1, 0, 1), repeat=k * k):
+ a = tuple(tuple(F(entries[i * k + j]) for j in range(k))
+ for i in range(k))
+ r = rank(a)
+ trace = sum(a[i][i] for i in range(k))
+ norm2 = sum(x * x for row in a for x in row)
+ require(trace * trace <= r * norm2, "trace-rank inequality")
+ if r and trace * trace == r * norm2:
+ scale = trace / r
+ square = multiply(a, a)
+ require(all(a[i][j] == a[j][i] and square[i][j] == scale * a[i][j]
+ for i in range(k) for j in range(k)),
+ "equality is a scalar orthogonal projector")
+ equalities += 1
+ matrices += 1
+ return {"matrices": matrices, "nonzero_equalities": equalities}
+
+
+def check_power_and_precision():
+ inequalities = strict = 0
+ for cap in range(1, 65):
+ for r in range(1, cap + 1):
+ for numerator, denominator in ((1, 2), (2, 3), (9, 10), (499, 500)):
+ # ((r/cap)^t >= r/cap)^denominator, exactly over integers.
+ left = r ** numerator * cap ** denominator
+ right = r ** denominator * cap ** numerator
+ require(left >= right and (left == right) == (r == cap),
+ "strict concave rank-price comparison")
+ inequalities += 1
+ strict += left > right
+ rows = []
+ for guard in range(17):
+ epsilon2 = F(1, 4 ** guard)
+ beta = 1 / (1 + epsilon2)
+ require(1 / beta - 1 == epsilon2, "variance-budget inverse")
+ require(1 - beta == F(1, 4 ** guard + 1), "precision saving fraction")
+ rows.append({"g": guard, "maximum_fractional_saving": str(1 - beta)})
+ return {"power_comparisons": inequalities, "strict": strict,
+ "normalized_tolerances": rows}
+
+
+def expect_rejection(k, cap, law, message):
+ try:
+ inspect_law(k, cap, law)
+ except ValueError as error:
+ require(str(error) == message, "wrong failure reason")
+ return 1
+ raise ValueError("invalid law was accepted: " + message)
+
+
+def check_controls():
+ controls = 0
+ controls += expect_rejection(2, 0, [(F(1), identity(2))], "law dimensions")
+ controls += expect_rejection(9, 1, [(F(1), identity(9))], "law dimensions")
+ controls += expect_rejection(2, 2, [(F(-1), zero(2)), (F(2), identity(2))],
+ "probability")
+ controls += expect_rejection(2, 2, [(F(1, 2), identity(2))], "probability sum")
+ controls += expect_rejection(2, 1, [(F(1), identity(2))], "rank cap")
+ controls += expect_rejection(2, 2, [(F(1), zero(2))], "unbiased operator")
+ law = projection_law(2, 1, F(1, 2))
+ damaged = [(p, tuple(tuple(x / 2 for x in row) for row in a)) for p, a in law]
+ controls += expect_rejection(2, 1, damaged, "unbiased operator")
+ biased = [(F(1), ((F(1), F(0)), (F(0), F(0))))]
+ controls += expect_rejection(2, 1, biased, "unbiased operator")
+ covariance, _ = inspect_law(2, 1, law)
+ require(covariance != ((F(1), F(0)), (F(0), F(1))), "omitted thinning noise")
+ controls += 1
+ coordinate = projection_law(2, 1, F(1))
+ lottery = projection_law(2, 2, F(1, 2))
+ covariance1, rank1 = inspect_law(2, 1, coordinate)
+ covariance2, rank2 = inspect_law(2, 2, lottery)
+ require(covariance1 == covariance2 and rank1 == rank2 == 1,
+ "equal mean rank and noise do not fix the power price")
+ # At t=1/2 the normalized prices are sqrt(1/2) and 1/2.
+ require(F(1, 2) ** 2 < F(1, 2), "strict price advantage for the full-rank lottery")
+ controls += 1
+ for copies in range(1, 9):
+ repeated = [(F(comb(copies, j), 2 ** copies),
+ tuple(tuple(F(2 * j, copies) * (a == b) for b in range(2))
+ for a in range(2))) for j in range(copies + 1)]
+ covariance, _ = inspect_law(2, 2, repeated)
+ require(covariance == ((F(1, copies), F(0)), (F(0), F(1, copies))),
+ "independent averaging covariance")
+ require(F(copies, 2) >= 1 / (1 + covariance[0][0]), "repeats pay")
+ controls += 1
+ return controls
+
+
+def package_hashes(root):
+ names = ("README.md", "PROOF.md", "TASK.json", "SOURCES.json", "VERIFY.json", "verify.py")
+ hashes = {}
+ for name in names:
+ with (root / name).open("rb") as stream:
+ data = stream.read(262145)
+ require(len(data) <= 262144, "package file capacity")
+ hashes[name] = sha256(data).hexdigest()
+ return hashes
+
+
+def main():
+ require(len(sys.argv) == 1, "no command-line arguments")
+ root = Path(__file__).resolve().parent
+ result = {"status": "PASS_RANDOMIZED_QUERY_POWER_FRONTIER",
+ "attainers": check_attainers(), "trace_rank": check_trace_rank(),
+ "power_and_precision": check_power_and_precision(),
+ "controls": check_controls(), "python": sys.version.split()[0]}
+ result["sha256"] = package_hashes(root)
+ print(json.dumps(result, sort_keys=True, indent=2))
+
+
+if __name__ == "__main__":
+ main()