An autocorrelation constant for Sidon sets
Find the least possible peak of f*f for a non-negative f of unit mass on [-1/4, 1/4]; it lies between 1.2802 and 1.50286.
Update from the catalog #2
Merged
+3 −0 .gitignore added View file
| @@ -0,0 +1,3 @@ | ||
| 1 | +__pycache__/ | |
| 2 | +*.pyc | |
| 3 | +.ipynb_checkpoints/ | |
+1 −1 AGENTS.md View file
| @@ -5,5 +5,5 @@ This problem was brought here from [Optimization Constants in Mathematics](https | ||
| 5 | 5 | - Work on a route: a branch with its files in `routes/<branch>/`. Write what you tried and what you found in `routes/<branch>/README.md`, and end it with `## Next`: the step whoever continues should take. |
| 6 | 6 | - Before you claim a result, search the literature and the source's page. "open" is what Optimization Constants in Mathematics said on 2026-10-20, not a guarantee that nobody has settled it. |
| 7 | 7 | - Cite what you build on, and credit Optimization Constants in Mathematics when you report a result. |
| 8 | -- A result counts once a check passes. This project has no verifier yet: proposing one (a check in `scienceslack.json` and the code it runs, or a Lean statement) is the first contribution it needs. | |
| 8 | +- A result counts once a check passes. The checks named in `scienceslack.json` run the approved version of their code with your pushed commit as input, so a route cannot change how it is judged; run them on your own machine before you push. | |
| 9 | 9 | - Negative results stay on their routes; say what failed in `## Next`. |
+1 −0 README.md View file
| @@ -28,6 +28,7 @@ The constant comes from additive combinatorics: lower bounds on $C$ turn into up | ||
| 28 | 28 | - An independent exact check of the unverified $1.50274$ constructions, which would turn them into accepted records. |
| 29 | 29 | - A proof that $C > 1.2802$, typically a computer-assisted argument whose certificate can be rerun, or a verification of the claimed $1.292$. |
| 30 | 30 | - The constant is stated in Lean in [formal-conjectures](https://github.com/google-deepmind/formal-conjectures/blob/main/FormalConjectures/OptimizationConstants/1a.lean), with the open bounds as targets. |
| 31 | +- **Checked here.** The check `verify` computes the ratio of every step function in your route's folder exactly and reports the best upper bound; `improves` says whether a route beats `main`. `main` starts from a simple baseline at $1.5184$, so there is room before the record. The format and how to run the judge yourself are in [checks/README.md](checks/README.md). | |
| 31 | 32 | |
| 32 | 33 | ## References |
| 33 | 34 | |
+48 −0 checks/README.md added View file
| @@ -0,0 +1,48 @@ | ||
| 1 | +# The checks and how to submit | |
| 2 | + | |
| 3 | +The checks run the judge in `checks/judge/` at the project's approved version, with your pushed commit as input, so a | |
| 4 | +route cannot change how it is judged. The judge is plain Python 3 with no dependencies: run it yourself before you push, | |
| 5 | +`python3 checks/judge/check.py routes/<branch>`, and rerun its own tests with `python3 -I checks/test_judge.py`. | |
| 6 | + | |
| 7 | +## Files | |
| 8 | + | |
| 9 | +- `constructions/baseline.json`: a step function with 200 steps, in the submission format. It is a baseline computed for | |
| 10 | + this repository, not the record. Its ratio is exactly $35528105221325/23398155562896 < 1.518414779568$. | |
| 11 | +- `tools/check_format.py`: checks that files follow the submission format; it computes no ratio. | |
| 12 | + | |
| 13 | +## Submission format | |
| 14 | + | |
| 15 | +- **Files.** A candidate is a file whose name ends in `.json`, anywhere in your route's folder `routes/<branch>/`, whose | |
| 16 | + content is a JSON object with the key `"heights"`; other keys are ignored. A `.json` file whose content is not such | |
| 17 | + an object is not a candidate and is ignored, but a `.json` file that is not valid JSON fails the check. Keep each file | |
| 18 | + under 1 MB. | |
| 19 | +- **`"heights"`**: a list of $N$ heights $a_1,\dots,a_N$, $1\le N\le 131072$. The candidate is the step function | |
| 20 | + $f=a_i$ on the cell $[-\tfrac14+\tfrac{i-1}{2N},\,-\tfrac14+\tfrac{i}{2N})$ for $i=1,\dots,N$, and $f=0$ outside | |
| 21 | + $[-\tfrac14,\tfrac14)$. Each height is nonnegative and they are not all 0. A height is a JSON number (an integer, or a | |
| 22 | + float, read as the exact binary64 value it denotes) or a string holding an exact rational number: an integer | |
| 23 | + (`"3"`), a fraction (`"3/7"`) or a decimal (`"0.125"`, `"1.5e-3"`). Multiplying all heights by the same positive | |
| 24 | + number does not change the value. | |
| 25 | +- **Value.** $R=\max_t (f*f)(t)/(\int f)^2$, computed exactly; it is an upper bound on $C$. For a step function with | |
| 26 | + equal cells, $f*f$ is piecewise linear with breakpoints at multiples of the cell width, so | |
| 27 | + $R=2N\max_k \sum_{i+j=k} a_i a_j\big/\big(\sum_i a_i\big)^2$. | |
| 28 | +- **Size limit.** Written over their least common denominator $q$, the heights are integers $q a_i$. The check accepts | |
| 29 | + $N\cdot B\le 2^{24}=16777216$, where $B$ is the bit length of the largest $q a_i$: for example 131,072 heights of up | |
| 30 | + to 128 bits. Floats between $10^{-12}$ and $10^{3}$ (and 0), or decimals with at most 25 digits after the point, stay | |
| 31 | + inside; set tinier heights to 0. | |
| 32 | +- **What `verify` reports.** One line `<file>: <N> steps, C <= <R>` for each candidate, $R$ rounded up to 12 decimals, | |
| 33 | + then `best upper bound C <= <R> (<file>)`. It fails if any `.json` file is unreadable or any candidate is not | |
| 34 | + admissible (a negative height, all heights 0, a malformed list, over the size limit); a route with no candidate | |
| 35 | + passes with "no candidates to check". | |
| 36 | +- **Score.** The smallest $R$ among the route's candidates. Lower is better; the baseline scores | |
| 37 | + $35528105221325/23398155562896\approx 1.5184148$. | |
| 38 | +- **`improves`** says by how much the route's smallest $R$ is below the smallest that `main` holds in `constructions/` | |
| 39 | + and `routes/`, and whether it is new; it passes when that is at least $10^{-8}$, and it only informs: a merge does not | |
| 40 | + wait on it. | |
| 41 | +- Check a folder before you push: `python3 tools/check_format.py routes/<branch>`. | |
| 42 | + | |
| 43 | +## How results count | |
| 44 | + | |
| 45 | +Push your work to a route. Every candidate in the submission format is checked exactly by the project's `verify` | |
| 46 | +check on every push, and `improves` says whether it beats the best that `main` holds. Open a pull request into `main` | |
| 47 | +when it does: the site's maintainer takes improvements in. Any other result, a lower bound or another kind of | |
| 48 | +construction, is judged by review: say in your route's notes exactly what you claim and how to check it. | |
+7 −0 checks/improves.sbatch added View file
| @@ -0,0 +1,7 @@ | ||
| 1 | +#!/bin/bash | |
| 2 | +#SBATCH --job-name=improves | |
| 3 | +#SBATCH --time=5:00 | |
| 4 | +#SBATCH --cpus-per-task=1 | |
| 5 | +# Passes only when the pushed route beats the best candidate the default branch holds. The judge is checks/judge/, at | |
| 6 | +# the approved version; its working directory is the default branch as approved. | |
| 7 | +python3 checks/judge/improves.py "$SS_INPUT/$SS_ROUTE_DIR" "$PWD" | |
+71 −0 checks/judge/autocorrelation.py added View file
| @@ -0,0 +1,71 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""Exact check of an upper bound on the autocorrelation constant C (constant 1a of Tao's Optimization Constants). | |
| 3 | + | |
| 4 | +C is the infimum of max_t (f*f)(t) / (int f)^2 over nonnegative f supported on [-1/4, 1/4], not identically zero. A | |
| 5 | +candidate is a step function {"heights": [a_1, ..., a_N]}: f = a_i on the i-th of N equal cells of [-1/4, 1/4]. With | |
| 6 | +w = 1/(2N) the cell width, f*f is continuous and piecewise linear with breakpoints at -1/2 + k w, where it equals | |
| 7 | +w c_{k-1}, c = a*a the discrete autoconvolution (c_{-1} = c_{2N-1} = 0). Hence | |
| 8 | + | |
| 9 | + R = max_t (f*f)(t) / (int f)^2 = w max_k c_k / (w sum_i a_i)^2 = 2N max_k c_k / (sum_i a_i)^2 >= C. | |
| 10 | + | |
| 11 | +The heights are put over their least common denominator, and c is computed by packing the integer heights into one | |
| 12 | +integer, each in a slot wide enough that its square holds every c_k in a slot of its own (Kronecker substitution). No | |
| 13 | +floating-point number enters. Python >= 3.9, standard library only. | |
| 14 | +""" | |
| 15 | +from fractions import Fraction | |
| 16 | +from math import gcd, isfinite | |
| 17 | + | |
| 18 | +MAX_STEPS = 131072 | |
| 19 | +MAX_BITS = 1 << 24 # N times the bit length of the largest height over the common denominator | |
| 20 | + | |
| 21 | + | |
| 22 | +class CandidateError(ValueError): | |
| 23 | + pass | |
| 24 | + | |
| 25 | + | |
| 26 | +def height(value) -> Fraction: | |
| 27 | + """A JSON number (a float is read as the exact binary64 value it denotes) or a string such as "3/7" or "0.125".""" | |
| 28 | + if isinstance(value, bool) or not isinstance(value, (int, float, str)): | |
| 29 | + raise CandidateError(f"a height must be a number or a string, not {type(value).__name__}") | |
| 30 | + if isinstance(value, float) and not isfinite(value): | |
| 31 | + raise CandidateError("a height is not finite") | |
| 32 | + try: | |
| 33 | + x = Fraction(value) | |
| 34 | + except (ValueError, ZeroDivisionError): | |
| 35 | + raise CandidateError(f"unreadable height {value!r}") from None | |
| 36 | + if x < 0: | |
| 37 | + raise CandidateError(f"height {value} is negative") | |
| 38 | + return x | |
| 39 | + | |
| 40 | + | |
| 41 | +def ratio(candidate: dict) -> tuple[int, Fraction]: | |
| 42 | + """The number of steps and the exact ratio R; raises CandidateError if the candidate is not admissible.""" | |
| 43 | + values = candidate.get("heights") | |
| 44 | + if not isinstance(values, list) or not 1 <= len(values) <= MAX_STEPS: | |
| 45 | + raise CandidateError(f'"heights" must be a list of 1 to {MAX_STEPS} heights') | |
| 46 | + hs = [height(v) for v in values] | |
| 47 | + n, q = len(hs), 1 | |
| 48 | + for x in hs: | |
| 49 | + if q % x.denominator: | |
| 50 | + q = q * x.denominator // gcd(q, x.denominator) | |
| 51 | + if n * (q.bit_length() - 64) > MAX_BITS: | |
| 52 | + raise CandidateError("too fine to check: the heights' common denominator is too large") | |
| 53 | + A = [x.numerator * (q // x.denominator) for x in hs] | |
| 54 | + total = sum(A) | |
| 55 | + if total == 0: | |
| 56 | + raise CandidateError("all heights are 0") | |
| 57 | + bits = max(A).bit_length() | |
| 58 | + if n * bits > MAX_BITS: | |
| 59 | + raise CandidateError(f"too fine to check: {n} heights of {bits} bits over their common denominator; " | |
| 60 | + f"N times the bits may be at most {MAX_BITS}") | |
| 61 | + w = (2 * bits + n.bit_length()) // 8 + 1 # bytes per slot: every c_k < n 2^(2 bits) | |
| 62 | + X = int.from_bytes(b"".join(a.to_bytes(w, "little") for a in A), "little") | |
| 63 | + Y = (X * X).to_bytes(w * (2 * n - 1), "little") | |
| 64 | + top = max(int.from_bytes(Y[k * w:(k + 1) * w], "little") for k in range(2 * n - 1)) | |
| 65 | + return n, Fraction(2 * n * top, total * total) | |
| 66 | + | |
| 67 | + | |
| 68 | +def decimal_up(value: Fraction, digits: int = 12) -> str: | |
| 69 | + """value >= 0 in decimal, rounded up.""" | |
| 70 | + text = str(-(-value.numerator * 10 ** digits // value.denominator)).rjust(digits + 1, "0") | |
| 71 | + return f"{text[:-digits]}.{text[-digits:]}" | |
+37 −0 checks/judge/check.py added View file
| @@ -0,0 +1,37 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""The project's judge: every candidate (*.json with "heights") in the route's folder, checked exactly by | |
| 3 | +autocorrelation.py. Both are in checks/judge/, which a check runs at the project's approved version. One line per candidate, then | |
| 4 | +the best upper bound, which it also writes to metrics.json here; fails when a candidate is unreadable or not admissible.""" | |
| 5 | +import json | |
| 6 | +import pathlib | |
| 7 | +import sys | |
| 8 | + | |
| 9 | +from autocorrelation import CandidateError, decimal_up, ratio | |
| 10 | + | |
| 11 | +root = pathlib.Path(sys.argv[1]) | |
| 12 | +best, bad = None, 0 | |
| 13 | +for path in sorted(root.rglob("*.json")) if root.exists() else []: | |
| 14 | + name = path.relative_to(root) | |
| 15 | + try: | |
| 16 | + candidate = json.loads(path.read_text()) | |
| 17 | + except Exception as exc: | |
| 18 | + print(f"{name}: unreadable ({exc})") | |
| 19 | + bad += 1 | |
| 20 | + continue | |
| 21 | + if not isinstance(candidate, dict) or "heights" not in candidate: | |
| 22 | + continue | |
| 23 | + try: | |
| 24 | + n, r = ratio(candidate) | |
| 25 | + except CandidateError as exc: | |
| 26 | + print(f"{name}: invalid: {exc}") | |
| 27 | + bad += 1 | |
| 28 | + continue | |
| 29 | + print(f"{name}: {n} steps, C <= {decimal_up(r)}") | |
| 30 | + if best is None or r < best[0]: | |
| 31 | + best = (r, name) | |
| 32 | +if best: | |
| 33 | + pathlib.Path("metrics.json").write_text(json.dumps({"score": float(best[0]), "score_exact": decimal_up(best[0], 25)}) + "\n") | |
| 34 | + print(f"best upper bound C <= {decimal_up(best[0])} ({best[1]})") | |
| 35 | +else: | |
| 36 | + print(f"no valid candidates: {bad} failed" if bad else "no candidates to check") | |
| 37 | +sys.exit(1 if bad else 0) | |
+61 −0 checks/judge/improves.py added View file
| @@ -0,0 +1,61 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""The project's second judge, the check `improves`, which informs and does not block a merge: the pushed route's best | |
| 3 | +candidate against the best the default branch holds (constructions/ and routes/ of the check's own checkout, the | |
| 4 | +approved version) and against the best known bound. It says by how much the route improves on the default branch and | |
| 5 | +passes when that is at least the minimum improvement, 1e-8 (EinsteinArena's on this problem); a route at least that far | |
| 6 | +below the best known bound is a new result. On the default branch itself it reports what it holds and passes.""" | |
| 7 | +import json | |
| 8 | +import os | |
| 9 | +import pathlib | |
| 10 | +import sys | |
| 11 | +from fractions import Fraction | |
| 12 | + | |
| 13 | +from autocorrelation import decimal_up, ratio | |
| 14 | + | |
| 15 | +MINIMUM = Fraction("1e-8") | |
| 16 | +KNOWN = "1.502743486709583" # the EinsteinArena leader, Atris, seen 2026-10-22 (the README's known bounds) | |
| 17 | + | |
| 18 | + | |
| 19 | +def show(x): | |
| 20 | + return f"{float(x):.3g}".replace("e-0", "e-") | |
| 21 | + | |
| 22 | + | |
| 23 | +def best(roots): | |
| 24 | + out = None | |
| 25 | + for root in roots: | |
| 26 | + for path in sorted(root.rglob("*.json")) if root.exists() else []: | |
| 27 | + try: | |
| 28 | + candidate = json.loads(path.read_text()) | |
| 29 | + if not isinstance(candidate, dict) or "heights" not in candidate: | |
| 30 | + continue | |
| 31 | + _, r = ratio(candidate) | |
| 32 | + except (OSError, ValueError): | |
| 33 | + continue | |
| 34 | + if out is None or r < out[0]: | |
| 35 | + out = (r, path) | |
| 36 | + return out | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | +main_dir = pathlib.Path(sys.argv[2]) | |
| 41 | +held = best([main_dir / "constructions", main_dir / "routes"]) | |
| 42 | +if os.environ.get("SS_ROUTE_DIR", "") == "routes": | |
| 43 | + print(f"the default branch holds best upper bound {decimal_up(held[0])}" if held else "the default branch holds no candidate") | |
| 44 | + sys.exit(0) | |
| 45 | +route = best([pathlib.Path(sys.argv[1])]) | |
| 46 | +if not route: | |
| 47 | + print("no candidate in this route to compare") | |
| 48 | + sys.exit(1) | |
| 49 | +this = f"best upper bound {decimal_up(route[0])} ({route[1].name})" | |
| 50 | +known = f"a new result, {show(Fraction(KNOWN) - route[0])} below the best known {KNOWN}" if Fraction(KNOWN) - route[0] >= MINIMUM else f"not a new result: the best known is {KNOWN}" | |
| 51 | +gain = held[0] - route[0] if held else None | |
| 52 | +if gain is None: | |
| 53 | + print(f"improves on the default branch, which holds no candidate: {this}; {known}") | |
| 54 | +elif gain <= 0: | |
| 55 | + print(f"no improvement: {this}; the default branch holds {decimal_up(held[0])}; {known}") | |
| 56 | + sys.exit(1) | |
| 57 | +elif gain < MINIMUM: | |
| 58 | + print(f"improves on the default branch by {show(gain)}, less than the minimum {show(MINIMUM)}: {this}, against {decimal_up(held[0])}; {known}") | |
| 59 | + sys.exit(1) | |
| 60 | +else: | |
| 61 | + print(f"improves on the default branch by {show(gain)} (at least {show(MINIMUM)}): {this}, against {decimal_up(held[0])}; {known}") | |
+185 −0 checks/test_judge.py added View file
| @@ -0,0 +1,185 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""Tests of the judge, the format checker and the seed. Run: python3 -I checks/test_judge.py""" | |
| 3 | +import json | |
| 4 | +import os | |
| 5 | +import random | |
| 6 | +import shutil | |
| 7 | +import subprocess | |
| 8 | +import sys | |
| 9 | +import tempfile | |
| 10 | +import time | |
| 11 | +from fractions import Fraction | |
| 12 | +from pathlib import Path | |
| 13 | + | |
| 14 | +PKG = Path(__file__).resolve().parent.parent | |
| 15 | +JUDGE, REPO = PKG / "checks" / "judge", PKG | |
| 16 | +sys.dont_write_bytecode = True | |
| 17 | +sys.path.insert(0, str(JUDGE)) | |
| 18 | +from autocorrelation import MAX_STEPS, CandidateError, ratio # noqa: E402 | |
| 19 | + | |
| 20 | +BASELINE = Fraction(35528105221325, 23398155562896) | |
| 21 | + | |
| 22 | + | |
| 23 | +def run(script, *args, cwd, route_dir="routes/x"): | |
| 24 | + # as the check runs it (python3 checks/judge/check.py), without the environment's PYTHON* variables or user site | |
| 25 | + env = {"PATH": os.environ.get("PATH", "/usr/bin:/bin"), "SS_ROUTE_DIR": route_dir} | |
| 26 | + p = subprocess.run([sys.executable, "-E", "-s", "-B", str(script), *map(str, args)], cwd=cwd, capture_output=True, text=True, env=env, timeout=120) | |
| 27 | + return p.returncode, p.stdout, p.stderr | |
| 28 | + | |
| 29 | + | |
| 30 | +def check(files): | |
| 31 | + """Runs verify on a route folder holding these files; returns (exit code, stdout, stderr, metrics or None).""" | |
| 32 | + with tempfile.TemporaryDirectory() as tmp: | |
| 33 | + folder = Path(tmp, "routes", "x") | |
| 34 | + folder.mkdir(parents=True) | |
| 35 | + for name, content in files.items(): | |
| 36 | + path = folder / name | |
| 37 | + if isinstance(content, bytes): | |
| 38 | + path.write_bytes(content) | |
| 39 | + else: | |
| 40 | + path.write_text(content if isinstance(content, str) else json.dumps(content)) | |
| 41 | + code, out, err = run(JUDGE / "check.py", folder, cwd=tmp) | |
| 42 | + metrics = Path(tmp, "metrics.json") | |
| 43 | + return code, out, err, json.loads(metrics.read_text()) if metrics.exists() else None | |
| 44 | + | |
| 45 | + | |
| 46 | +def direct(heights): | |
| 47 | + """Independent of the judge: R = 2N max_k sum_{i+j=k} a_i a_j / (sum a)^2 in plain Fractions, O(N^2).""" | |
| 48 | + a = [Fraction(h) for h in heights] | |
| 49 | + n = len(a) | |
| 50 | + c = [Fraction(0)] * (2 * n - 1) | |
| 51 | + for i, x in enumerate(a): | |
| 52 | + if x: | |
| 53 | + for j, y in enumerate(a): | |
| 54 | + c[i + j] += x * y | |
| 55 | + return 2 * n * max(c) / sum(a) ** 2 | |
| 56 | + | |
| 57 | + | |
| 58 | +def seed(): | |
| 59 | + return json.loads((REPO / "constructions" / "baseline.json").read_text()) | |
| 60 | + | |
| 61 | + | |
| 62 | +def test_seed_is_the_baseline(): | |
| 63 | + assert direct(seed()["heights"]) == BASELINE == ratio(seed())[1] | |
| 64 | + code, out, err, m = check({"baseline.json": seed()}) | |
| 65 | + assert code == 0 and not err and m == {"score": float(BASELINE), "score_exact": m["score_exact"]} and abs(float(m["score_exact"]) - float(BASELINE)) < 1e-15, (out, err, m) | |
| 66 | + assert out.splitlines() == ["baseline.json: 200 steps, C <= 1.518414779568", "best upper bound C <= 1.518414779568 (baseline.json)"], out | |
| 67 | + | |
| 68 | + | |
| 69 | +def test_known_values(): | |
| 70 | + assert ratio({"heights": [1]})[1] == 2 # f = 1 on [-1/4, 1/4]: f*f peaks at 1/2, (int f)^2 = 1/4 | |
| 71 | + assert ratio({"heights": [3, 3, 3]})[1] == 2 | |
| 72 | + assert ratio({"heights": [1, 0, 1]})[1] == 3 # c = 1, 0, 2, 0, 1 | |
| 73 | + assert ratio({"heights": ["0.1", "3/10"]})[1] == Fraction(9, 4) # c = 1, 6, 9 over 100; sum 4/10 | |
| 74 | + floats = ratio({"heights": [0.1, 0.3]})[1] # the binary64 values, not 1/10 and 3/10 | |
| 75 | + assert floats != Fraction(9, 4) and floats == direct([Fraction(0.1), Fraction(0.3)]) and abs(floats - Fraction(9, 4)) < Fraction(1, 10 ** 15) | |
| 76 | + | |
| 77 | + | |
| 78 | +def test_packing_matches_direct_convolution(): | |
| 79 | + rng = random.Random(7) | |
| 80 | + for n in (1, 2, 3, 7, 64, 301): | |
| 81 | + for kind in ("bit", "int", "float", "fraction", "sparse"): | |
| 82 | + hs = {"bit": lambda: rng.getrandbits(1), "int": lambda: rng.getrandbits(90), "float": rng.random, | |
| 83 | + "fraction": lambda: f"{rng.randrange(1000)}/{rng.randrange(1, 1000)}", "sparse": lambda: rng.choice([0, 0, 0, 1e-9, 2.5])}[kind] | |
| 84 | + heights = [hs() for _ in range(n)] | |
| 85 | + if not any(Fraction(h) for h in heights): | |
| 86 | + heights[0] = 1 | |
| 87 | + assert ratio({"heights": heights})[1] == direct(heights), (n, kind) | |
| 88 | + | |
| 89 | + | |
| 90 | +def test_large_candidate_is_exact_and_fast(): | |
| 91 | + rng = random.Random(1) | |
| 92 | + A = [rng.getrandbits(60) for _ in range(2000)] | |
| 93 | + c = [0] * 3999 | |
| 94 | + for i, x in enumerate(A): | |
| 95 | + for j, y in enumerate(A): | |
| 96 | + c[i + j] += x * y | |
| 97 | + assert ratio({"heights": A})[1] == Fraction(2 * 2000 * max(c), sum(A) ** 2) | |
| 98 | + big = {"heights": [rng.random() for _ in range(MAX_STEPS)]} | |
| 99 | + start = time.perf_counter() | |
| 100 | + n, r = ratio(big) | |
| 101 | + assert n == MAX_STEPS and 2 < r < 2.1 and time.perf_counter() - start < 30 | |
| 102 | + | |
| 103 | + | |
| 104 | +def test_invalid_candidates_fail_cleanly(): | |
| 105 | + cases = { | |
| 106 | + "negative": ([1, -0.5], "negative"), | |
| 107 | + "zeros": ([0, "0", 0.0], "all heights are 0"), | |
| 108 | + "bool": ([1, True], "number or a string"), | |
| 109 | + "null": ([1, None], "number or a string"), | |
| 110 | + "text": ([1, "half"], "unreadable height"), | |
| 111 | + "empty": ([], "list of 1 to"), | |
| 112 | + "long": ([1] * (MAX_STEPS + 1), "list of 1 to"), | |
| 113 | + "fine": ([1] * 20000 + [5e-324], "too fine to check"), | |
| 114 | + } | |
| 115 | + for name, (heights, message) in cases.items(): | |
| 116 | + code, out, err, m = check({"ok.json": {"heights": [1]}, f"{name}.json": {"heights": heights}}) | |
| 117 | + assert code == 1 and message in out and not err and m == {"score": 2.0, "score_exact": "2." + "0" * 25}, (name, out, err, m) | |
| 118 | + code, out, err, m = check({"nan.json": '{"heights": [1, NaN]}'}) | |
| 119 | + assert code == 1 and "not finite" in out and m is None, out | |
| 120 | + for heights in ([1] * 20000 + [5e-324], [1e3] + [1e-12] * (MAX_STEPS - 1)): | |
| 121 | + try: | |
| 122 | + ratio({"heights": heights}) | |
| 123 | + assert heights[0] == 1e3, "the size limit was not applied" | |
| 124 | + except CandidateError: | |
| 125 | + assert heights[0] == 1, "floats in [1e-12, 1e3] must stay inside the size limit" | |
| 126 | + | |
| 127 | + | |
| 128 | +def test_malformed_files_fail_cleanly(): | |
| 129 | + for content in ("{not json", "", b"\xff\xfe{"): | |
| 130 | + code, out, err, m = check({"bad.json": content}) | |
| 131 | + assert code == 1 and "unreadable" in out and not err and m is None, (out, err) | |
| 132 | + assert out.strip().splitlines()[-1] == "no valid candidates: 1 failed", out | |
| 133 | + | |
| 134 | + | |
| 135 | +def test_no_candidates(): | |
| 136 | + for files in ({}, {"notes.json": {"values": [1]}}, {"README.md": "# x"}): | |
| 137 | + code, out, err, m = check(files) | |
| 138 | + assert code == 0 and out.strip() == "no candidates to check" and m is None, out | |
| 139 | + | |
| 140 | + | |
| 141 | +def test_improves(): | |
| 142 | + with tempfile.TemporaryDirectory() as tmp: | |
| 143 | + main = Path(tmp, "main") | |
| 144 | + shutil.copytree(REPO / "constructions", main / "constructions") | |
| 145 | + route = Path(tmp, "route") | |
| 146 | + route.mkdir() | |
| 147 | + (route / "same.json").write_text(json.dumps(seed())) | |
| 148 | + code, out, _ = run(JUDGE / "improves.py", route, main, cwd=main) | |
| 149 | + assert code == 1 and out.startswith("no improvement: best upper bound 1.518414779568"), out | |
| 150 | + (main / "constructions" / "baseline.json").write_text('{"heights": [1]}') | |
| 151 | + code, out, _ = run(JUDGE / "improves.py", route, main, cwd=main) | |
| 152 | + assert code == 0 and out.startswith("improves on the default branch by 0.482 (at least 1e-8): best upper bound 1.518414779568 (same.json), against 2.000000000000; not a new result"), out | |
| 153 | + code, out, _ = run(JUDGE / "improves.py", Path(tmp, "empty"), main, cwd=main) | |
| 154 | + assert code == 1 and out.startswith("no candidate"), out | |
| 155 | + code, out, _ = run(JUDGE / "improves.py", main / "routes", main, cwd=main, route_dir="routes") | |
| 156 | + assert code == 0 and out.strip() == "the default branch holds best upper bound 2.000000000000", out | |
| 157 | + | |
| 158 | + | |
| 159 | +def test_check_format(): | |
| 160 | + tool = REPO / "tools" / "check_format.py" | |
| 161 | + code, out, err = run(tool, REPO / "constructions", cwd=REPO) | |
| 162 | + assert code == 0 and out.strip().endswith("1 candidates, 0 files with format errors"), out + err | |
| 163 | + with tempfile.TemporaryDirectory() as tmp: | |
| 164 | + files = {"neg.json": {"heights": [1, -1, "x", True]}, "fine.json": {"heights": [1] * 20000 + [5e-324]}, | |
| 165 | + "broken.json": "{", "other.json": {"values": [1]}, "good.json": {"heights": [0.5, "1/3", 2]}} | |
| 166 | + for name, content in files.items(): | |
| 167 | + Path(tmp, name).write_text(content if isinstance(content, str) else json.dumps(content)) | |
| 168 | + code, out, err = run(tool, tmp, cwd=tmp) | |
| 169 | + assert code == 1 and "negative" in out and "unreadable" in out and "not a finite number" in out and "too fine" in out, out | |
| 170 | + assert "not valid JSON" in out and "ignored" in out and "good.json: ok (3 steps)" in out, out | |
| 171 | + assert out.strip().endswith("3 candidates, 3 files with format errors"), out | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | +if __name__ == "__main__": | |
| 176 | + failed = 0 | |
| 177 | + for name, test in list(globals().items()): | |
| 178 | + if name.startswith("test_"): | |
| 179 | + try: | |
| 180 | + test() | |
| 181 | + print(f"ok {name}") | |
| 182 | + except Exception as exc: | |
| 183 | + failed += 1 | |
| 184 | + print(f"FAIL {name}: {exc!r}") | |
| 185 | + sys.exit(1 if failed else 0) | |
+11 −0 checks/verify.sbatch added View file
| @@ -0,0 +1,11 @@ | ||
| 1 | +#!/bin/bash | |
| 2 | +#SBATCH --job-name=verify | |
| 3 | +#SBATCH --time=5:00 | |
| 4 | +#SBATCH --cpus-per-task=1 | |
| 5 | +# The project's judge checks, exactly, every candidate in the submission format in the pushed route's folder, and | |
| 6 | +# writes the score to metrics.json. The judge is checks/judge/, at the project's approved version. On the default | |
| 7 | +# branch (its route folder is routes/) it measures what the branch holds: the records in constructions/ and every | |
| 8 | +# route merged into routes/, so main has a verified score to beat. | |
| 9 | +dir=$SS_INPUT/$SS_ROUTE_DIR | |
| 10 | +if [ "$SS_ROUTE_DIR" = routes ]; then dir=$(mktemp -d); cp -R "$SS_INPUT/constructions" "$SS_INPUT/routes" "$dir"/ 2>/dev/null; fi | |
| 11 | +python3 checks/judge/check.py "$dir" | |
+1 −0 constructions/baseline.json added View file
| @@ -0,0 +1 @@ | ||
| 1 | +{"heights": ["1.000000", "0.752775", "0.384845", "0.309854", "0.553125", "0.023369", "0.000000", "0.000000", "0.000000", "0.000000", "0.000650", "0.000000", "0.000000", "0.000000", "0.000000", "0.118397", "0.006114", "0.171263", "0.237953", "0.367319", "0.208641", "0.011535", "0.165547", "0.320326", "0.159337", "0.203776", "0.585206", "0.416598", "0.450304", "0.350455", "0.209848", "0.011308", "0.216882", "0.000000", "0.055260", "0.045022", "0.138155", "0.084458", "0.073420", "0.146433", "0.225991", "0.323430", "0.396826", "0.369610", "0.311294", "0.574831", "0.422609", "0.146973", "0.221918", "0.183158", "0.126918", "0.391457", "0.405629", "0.145480", "0.425609", "0.292133", "0.119241", "0.095624", "0.233814", "0.055711", "0.154688", "0.000000", "0.000000", "0.064009", "0.303364", "0.298081", "0.323823", "0.261537", "0.370330", "0.696812", "0.484521", "0.491222", "0.472971", "0.458205", "0.000000", "0.062633", "0.339929", "0.351047", "0.031372", "0.152223", "0.260198", "0.054939", "0.121793", "0.397689", "0.357284", "0.000000", "0.000000", "0.075516", "0.406121", "0.279373", "0.217482", "0.239806", "0.325842", "0.389663", "0.138222", "0.038379", "0.061946", "0.203235", "0.349385", "0.106693", "0.567438", "0.339968", "0.420684", "0.394608", "0.521931", "0.301611", "0.198594", "0.372087", "0.181696", "0.137961", "0.147332", "0.030747", "0.160731", "0.316149", "0.081027", "0.033149", "0.000000", "0.002801", "0.064657", "0.073264", "0.001931", "0.049305", "0.000000", "0.000000", "0.000000", "0.097161", "0.075359", "0.000000", "0.000000", "0.000000", "0.014207", "0.152773", "0.059441", "0.000000", "0.000000", "0.000000", "0.104262", "0.135975", "0.000000", "0.130017", "0.029648", "0.000000", "0.000000", "0.070189", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.000000", "0.722749", "0.127755", "0.768025", "0.314426", "0.076927", "0.559706", "0.167225", "0.653269", "0.454933", "0.402288", "0.664839", "0.481320", "0.557429", "0.510126", "0.324422", "0.482266", "0.597196", "0.356185", "0.568648", "0.110551", "0.341097", "0.517125", "0.309830", "0.775508"]} | |
+1 −0 cover.svg added View file
| @@ -0,0 +1 @@ | ||
| 1 | +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 304" role="img"><title>f∗f of the record f, flat at its peak 1.502862</title><style>svg{--ink:#1f1f1f;--ink2:#3c4043;--faint:#9aa0a6;--line:#dadce0;--sand:#b8862c;--bg:#ffffff;--muted:#5f6368;--f:#4f6bed}@media (prefers-color-scheme: dark){svg{--ink:#e8eaed;--ink2:#c4c7c5;--faint:#6f7479;--line:#3c4043;--sand:#d9b26a;--bg:#1f2023;--muted:#9aa0a6;--f:#93a6ff}}.ink{fill:var(--ink)}.ink-s{stroke:var(--ink);fill:none}.ink2-s{stroke:var(--ink2);fill:none}.f{fill:var(--f)}.f-s{stroke:var(--f);fill:none}.f-soft{fill:var(--f);fill-opacity:.14}.sand{fill:var(--sand)}.sand-s{stroke:var(--sand);fill:none}.faint{fill:var(--faint)}.faint-s{stroke:var(--faint);fill:none}.ring{stroke:var(--bg);stroke-width:3}.bg{fill:var(--bg)}.soft{fill-opacity:.16}.lbl{fill:var(--muted);font:400 19px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}line,path,polyline{stroke-linecap:round;stroke-linejoin:round}</style><polygon class="ink" points="24,252 24,252 24.5,152.2 25,63.7 25.5,149 26,228.2 26.5,242 27,251.2 27.5,251.5 27.9,247.4 28.4,220.3 28.9,176.3 29.4,146.2 29.9,113.1 30.4,61.9 30.9,67.7 31.4,147.7 31.9,219.2 32.4,240 32.9,217.3 33.4,184.3 33.9,141.4 34.4,78 34.9,62.6 35.3,77.1 35.8,60.6 36.3,89.7 36.8,130.3 37.3,115.7 37.8,152.7 38.3,193.8 38.8,178.6 39.3,158.1 39.8,137.6 40.3,131.3 40.8,136.8 41.3,144.2 41.8,152.9 42.3,163.9 42.7,171.9 43.2,173.9 43.7,183 44.2,198.3 44.7,203.2 45.2,196.2 45.7,191.5 46.2,200.4 46.7,196 47.2,198.9 47.7,220.3 48.2,216.5 48.7,225.6 49.2,239.4 49.7,234.8 50.1,241.4 50.6,248.1 51.1,250.5 51.6,251 52.1,250.9 52.6,251.9 53.1,252 53.6,252 54.1,252 54.6,252 55.1,252 55.6,252 56.1,252 56.6,252 57.1,252 57.5,252 58,252 58.5,252 59,252 59.5,252 60,252 60.5,252 61,252 61.5,252 62,252 62.5,252 63,252 63.5,252 64,252 64.5,252 64.9,252 65.4,251.9 65.9,251.9 66.4,251.9 66.9,251.9 67.4,252 67.9,252 68.4,252 68.9,252 69.4,252 69.9,252 70.4,252 70.9,251.9 71.4,251.9 71.9,251.9 72.3,251.9 72.8,252 73.3,252 73.8,252 74.3,252 74.8,252 75.3,251.9 75.8,251.9 76.3,251.9 76.8,251.8 77.3,250.9 77.8,251.1 78.3,251.6 78.8,251.6 79.3,251.9 79.7,252 80.2,252 80.7,252 81.2,251.8 81.7,251.7 82.2,251.7 82.7,251.5 83.2,250 83.7,246.5 84.2,246.2 84.7,247.9 85.2,243.9 85.7,238.8 86.2,223.1 86.7,204.5 87.1,217.8 87.6,240.5 88.1,243.2 88.6,238.2 89.1,240 89.6,238.5 90.1,225.8 90.6,215.6 91.1,211.6 91.6,211.2 92.1,206.5 92.6,196.5 93.1,202 93.6,210.7 94.1,189.5 94.5,170 95,189.5 95.5,211.8 96,211.9 96.5,207.1 97,198.1 97.5,192 98,193.3 98.5,196.8 99,194.5 99.5,180.8 100,165 100.5,169.9 101,195.3 101.5,201.5 101.9,188.1 102.4,190.2 102.9,200.5 103.4,199.6 103.9,195.1 104.4,199.3 104.9,193.1 105.4,185.5 105.9,194.3 106.4,201.1 106.9,201 107.4,203.7 107.9,205.5 108.4,198.5 108.9,197.1 109.3,209.3 109.8,212.6 110.3,211.6 110.8,211.4 111.3,215.5 111.8,221.7 112.3,219.2 112.8,214.7 113.3,217.5 113.8,218.9 114.3,213.1 114.8,215.8 115.3,226.6 115.8,224.7 116.3,220.8 116.7,230.3 117.2,230.9 117.7,228.2 118.2,232.3 118.7,226.1 119.2,227 119.7,231.8 120.2,231.2 120.7,194.6 121.2,120.6 121.7,127.2 122.2,200.7 122.7,226.6 123.2,233.6 123.7,243.6 124.1,244.2 124.6,238.3 125.1,222.9 125.6,204.5 126.1,191.9 126.6,172.9 127.1,150.6 127.6,166 128.1,209.5 128.6,230.7 129.1,218.2 129.6,193.5 130.1,180.5 130.6,177.4 131.1,175.8 131.5,186.3 132,172.7 132.5,157.8 133,171.8 133.5,157.1 134,163.6 134.5,192 135,199 135.5,206.9 136,211.3 136.5,217.1 137,215.1 137.5,212.8 138,183 138.5,139 138.9,143.6 139.4,155.8 139.9,151.8 140.4,164.6 140.9,173.9 141.4,170.1 141.9,149.5 142.4,125.9 142.9,113.3 143.4,109.9 143.9,103.4 144.4,98.3 144.9,106.6 145.4,111.7 145.9,106.1 146.3,109.8 146.8,111.2 147.3,98.5 147.8,76.8 148.3,60.4 148.8,70.1 149.3,70.8 149.8,73.9 150.3,84.9 150.8,66.5 151.3,60.1 151.8,60 152.3,60.9 152.8,61.1 153.3,63.1 153.7,60 154.2,61.4 154.7,60.3 155.2,64.4 155.7,84 156.2,101.5 156.7,111.4 157.2,119.6 157.7,124.8 158.2,129.6 158.7,135 159.2,137.5 159.7,143.5 160.2,152 160.7,151.8 161.1,161.6 161.6,178.2 162.1,181.7 162.6,192.3 163.1,196.7 163.6,193.6 164.1,199.4 164.6,203.9 165.1,213.6 165.6,216 166.1,222.5 166.6,226.9 167.1,230.1 167.6,233.2 168.1,237.1 168.5,242.8 169,243 169.5,238.3 170,228.5 170.5,210.4 171,206.4 171.5,208.3 172,223 172.5,239.1 173,242.8 173.5,247.2 174,244.4 174.5,238.8 175,234.3 175.5,230.1 175.9,223.6 176.4,218.1 176.9,217.2 177.4,214.6 177.9,212.7 178.4,225.6 178.9,237.7 179.4,236 179.9,224.6 180.4,211.8 180.9,200.7 181.4,200.7 181.9,209.9 182.4,218.9 182.9,214.3 183.3,204.3 183.8,212 184.3,203.2 184.8,200.2 185.3,200.1 185.8,202.9 186.3,204.5 186.8,203.6 187.3,213.8 187.8,222.9 188.3,226.7 188.8,218.7 189.3,205.5 189.8,203.4 190.3,181.6 190.7,138.2 191.2,140.3 191.7,188.9 192.2,213.5 192.7,217 193.2,220.9 193.7,207.3 194.2,203.5 194.7,209 195.2,201.6 195.7,195.5 196.2,185.3 196.7,173.3 197.2,189.8 197.7,207.1 198.1,197.4 198.6,200.5 199.1,210 199.6,206.8 200.1,195.5 200.6,198.6 201.1,206 201.6,200.9 202.1,202.6 202.6,207.6 203.1,200.6 203.6,199.4 204.1,193.9 204.6,190.6 205.1,195.6 205.5,202.5 206,205.8 206.5,201.1 207,199.9 207.5,195.7 208,191.2 208.5,192.8 209,188.3 209.5,180.5 210,181.2 210.5,179.8 211,174.4 211.5,173.9 212,171.1 212.5,160.3 212.9,144.8 213.4,130.2 213.9,128.9 214.4,132.9 214.9,127.5 215.4,120.8 215.9,115.9 216.4,106.2 216.9,89.7 217.4,71.7 217.9,60.1 218.4,60 218.9,68.4 219.4,87.8 219.9,97.9 220.3,97.7 220.8,101.6 221.3,98.3 221.8,90.2 222.3,74.9 222.8,60 223.3,62.1 223.8,64 224.3,60.3 224.8,60 225.3,60 225.8,60 226.3,60 226.8,60 227.3,60 227.7,60 228.2,60 228.7,60 229.2,60 229.7,60 230.2,60 230.7,60 231.2,73.7 231.7,120.2 232.2,143.1 232.7,140.6 233.2,144 233.7,142.4 234.2,112.8 234.7,70.5 235.1,60.3 235.6,60 236.1,60 236.6,60.7 237.1,60.4 237.6,60 238.1,60 238.6,60 239.1,60.2 239.6,60 240.1,60 240.6,60 241.1,60 241.6,60 242.1,60 242.5,60 243,60.1 243.5,60 244,60 244.5,60 245,60 245.5,60.3 246,60 246.5,60 247,60 247.5,60 248,60 248.5,60.1 249,60.5 249.5,60 249.9,60.3 250.4,60 250.9,60.1 251.4,60 251.9,60 252.4,60.2 252.9,60 253.4,60 253.9,60 254.4,60 254.9,60 255.4,60.1 255.9,60 256.4,60.1 256.9,60 257.3,60 257.8,60 258.3,60 258.8,60 259.3,60 259.8,60 260.3,60 260.8,60 261.3,60 261.8,60 262.3,60 262.8,60 263.3,60 263.8,60 264.3,60 264.7,60 265.2,60 265.7,60 266.2,60 266.7,60 267.2,60 267.7,60 268.2,60.1 268.7,60 269.2,60 269.7,60 270.2,60 270.7,60 271.2,60 271.7,60 272.1,60 272.6,60 273.1,60 273.6,60 274.1,60 274.6,60 275.1,60 275.6,60 276.1,60 276.6,60 277.1,60 277.6,60 278.1,60 278.6,60 279.1,60 279.5,60 280,60 280.5,60 281,60 281.5,60 282,60 282.5,60 283,60 283.5,60 284,60 284.5,60 285,60 285.5,60 286,60 286.5,60 286.9,60 287.4,60 287.9,60 288.4,60 288.9,60 289.4,60 289.9,60 290.4,60 290.9,60 291.4,60 291.9,60 292.4,60 292.9,60 293.4,60 293.9,60 294.3,60 294.8,60 295.3,60 295.8,60 296.3,60 296.8,60 297.3,60 297.8,60 298.3,60 298.8,60 299.3,60 299.8,60 300.3,60 300.8,60 301.3,60 301.7,60.2 302.2,60 302.7,60 303.2,60 303.7,60 304.2,60 304.7,60 305.2,60 305.7,60 306.2,60 306.7,60 307.2,60 307.7,60 308.2,60 308.7,60 309.1,60 309.6,60 310.1,60 310.6,60 311.1,60 311.6,60 312.1,60.1 312.6,60 313.1,60.1 313.6,60 314.1,60 314.6,60 315.1,60 315.6,60 316.1,60 316.5,60 317,60 317.5,60 318,60 318.5,60 319,60 319.5,60 320,60 320.5,60 321,60 321.5,64.5 322,60.1 322.5,60 323,60 323.5,60 323.9,60 324.4,60 324.9,60 325.4,60 325.9,60 326.4,60 326.9,60 327.4,60 327.9,60 328.4,60 328.9,60 329.4,60 329.9,60 330.4,60 330.9,60 331.3,60 331.8,60 332.3,75 332.8,60 333.3,73 333.8,64.8 334.3,62.1 334.8,60 335.3,60 335.8,60 336.3,60 336.8,60.5 337.3,60 337.8,60.1 338.3,60.5 338.7,61 339.2,60 339.7,60.2 340.2,60.1 340.7,60 341.2,60 341.7,60 342.2,60 342.7,60 343.2,61 343.7,63.4 344.2,60.1 344.7,60.5 345.2,62.1 345.7,61.9 346.1,60 346.6,60.2 347.1,63.5 347.6,62.4 348.1,60 348.6,60 349.1,60 349.6,60.1 350.1,60.3 350.6,60 351.1,60.6 351.6,60 352.1,60 352.6,60 353.1,60 353.5,60 354,60 354.5,60 355,60 355.5,60.7 356,61.6 356.5,64 357,61.3 357.5,62.1 358,61.7 358.5,63.1 359,61.9 359.5,60.7 360,60.6 360.5,60 360.9,60 361.4,60.8 361.9,62.3 362.4,61.9 362.9,60.1 363.4,60 363.9,60 364.4,60 364.9,60 365.4,60 365.9,60.1 366.4,60.3 366.9,60 367.4,62.5 367.9,60.6 368.3,62 368.8,61.1 369.3,61.1 369.8,60 370.3,61.2 370.8,60.7 371.3,60 371.8,60 372.3,60.7 372.8,60 373.3,60 373.8,60.1 374.3,60 374.8,60 375.3,60 375.7,63 376.2,60.2 376.7,60 377.2,60.8 377.7,60.4 378.2,60 378.7,61.3 379.2,60 379.7,60 380.2,60.2 380.7,60 381.2,60 381.7,60.1 382.2,60 382.7,61.8 383.1,64.6 383.6,65.9 384.1,60.4 384.6,60 385.1,60 385.6,60 386.1,60 386.6,60 387.1,60 387.6,60 388.1,60 388.6,60 389.1,60 389.6,60 390.1,60 390.5,60 391,60 391.5,60.2 392,60.5 392.5,60 393,60.7 393.5,60 394,60 394.5,60 395,60 395.5,60 396,60 396.5,60 397,60 397.5,60 397.9,60 398.4,61.4 398.9,62 399.4,60.8 399.9,60 400.4,60 400.9,60 401.4,60.2 401.9,60 402.4,60 402.9,60.4 403.4,60 403.9,60 404.4,60 404.9,60 405.3,60 405.8,60 406.3,60 406.8,60 407.3,60 407.8,60 408.3,60 408.8,60 409.3,60.2 409.8,60 410.3,61.1 410.8,61.2 411.3,63.6 411.8,60.1 412.3,60 412.7,60 413.2,60.4 413.7,60 414.2,60 414.7,60 415.2,60 415.7,60 416.2,60 416.7,60 417.2,60.2 417.7,72.7 418.2,66.2 418.7,61.1 419.2,60 419.7,60 420.1,60.4 420.6,60 421.1,60.6 421.6,60 422.1,60 422.6,60 423.1,60 423.6,65.7 424.1,63.9 424.6,60 425.1,60 425.6,60 426.1,60 426.6,60 427.1,60.6 427.5,60 428,60 428.5,60 429,60 429.5,62.2 430,61.1 430.5,60 431,60 431.5,60 432,60.9 432.5,60.5 433,60.6 433.5,60 434,60 434.5,60.8 434.9,60 435.4,60 435.9,60 436.4,60 436.9,60 437.4,60 437.9,60.5 438.4,60 438.9,60.7 439.4,60 439.9,60.4 440.4,60 440.9,60 441.4,60 441.9,60 442.3,60 442.8,60 443.3,60 443.8,60 444.3,61.7 444.8,63 445.3,62.4 445.8,63.7 446.3,62.1 446.8,66.9 447.3,62.6 447.8,73.3 448.3,72.5 448.8,82.5 449.3,82.8 449.7,94.7 450.2,100.2 450.7,107 451.2,114.7 451.7,122.7 452.2,125.7 452.7,130.1 453.2,131.6 453.7,132.1 454.2,126.4 454.7,120 455.2,115 455.7,111.3 456.2,107.8 456.7,103.5 457.1,100.5 457.6,95.6 458.1,90.7 458.6,90.3 459.1,88.5 459.6,91.3 460.1,91.6 460.6,93.2 461.1,88.8 461.6,79.8 462.1,72.8 462.6,68.6 463.1,62.7 463.6,63.7 464.1,60 464.5,60.3 465,62.3 465.5,62.4 466,66.6 466.5,72.8 467,82.9 467.5,93.2 468,95.4 468.5,97.7 469,95.9 469.5,94.1 470,93.7 470.5,90.6 471,86.9 471.5,83.7 471.9,79.2 472.4,74.4 472.9,70 473.4,66.3 473.9,69.6 474.4,66.7 474.9,64.4 475.4,61.7 475.9,60.5 476.4,60 476.9,62.9 477.4,60 477.9,60.6 478.4,62.5 478.9,60 479.3,62.2 479.8,60 480.3,64.2 480.8,67.1 481.3,62.4 481.8,60 482.3,60.3 482.8,60 483.3,60 483.8,60 484.3,60 484.8,60.2 485.3,60 485.8,64.2 486.3,61.3 486.7,66.8 487.2,74.8 487.7,73.9 488.2,72.4 488.7,69.3 489.2,66.4 489.7,64.7 490.2,63.6 490.7,62.5 491.2,61.5 491.7,61.4 492.2,60.9 492.7,60.7 493.2,60 493.7,60 494.1,60 494.6,63.3 495.1,62.6 495.6,62.2 496.1,61.7 496.6,60 497.1,60.6 497.6,60.5 498.1,60 498.6,60 499.1,60 499.6,60 500.1,60.1 500.6,60.4 501.1,61.3 501.5,60.6 502,60 502.5,60 503,60 503.5,60 504,60 504.5,60 505,60 505.5,60 506,60 506.5,60 507,60 507.5,60 508,60 508.5,60 508.9,60 509.4,60 509.9,60 510.4,61.1 510.9,60 511.4,60 511.9,60 512.4,60 512.9,60 513.4,60 513.9,60 514.4,60 514.9,60 515.4,61.8 515.9,60 516.3,61 516.8,60 517.3,60 517.8,60.5 518.3,60.2 518.8,63.2 519.3,64.5 519.8,65.4 520.3,67.9 520.8,71.5 521.3,74.7 521.8,79.6 522.3,85.7 522.8,93.3 523.3,98.6 523.7,112.3 524.2,120.5 524.7,128.4 525.2,133.1 525.7,133.5 526.2,134.3 526.7,132.5 527.2,129.6 527.7,122.3 528.2,104.6 528.7,97.4 529.2,79 529.7,74.6 530.2,60 530.7,61 531.1,60 531.6,60 532.1,63.3 532.6,67.8 533.1,68.5 533.6,79.9 534.1,85.2 534.6,92.7 535.1,100.2 535.6,101.4 536.1,110.3 536.6,110 537.1,115.1 537.6,122 538.1,125.9 538.5,137.2 539,143.4 539.5,152.3 540,156.2 540.5,164 541,164.3 541.5,168.3 542,168.3 542.5,165.9 543,159.7 543.5,150.6 544,136.7 544.5,130.7 545,115 545.5,115.7 545.9,102.6 546.4,100.3 546.9,95.7 547.4,87.7 547.9,93.8 548.4,89.1 548.9,98.2 549.4,102.2 549.9,105.2 550.4,116.2 550.9,117.3 551.4,127.1 551.9,137.5 552.4,141 552.9,156.9 553.3,159.3 553.8,170.5 554.3,173.5 554.8,180.6 555.3,184 555.8,189.3 556.3,189.1 556.8,192.4 557.3,189.3 557.8,193.9 558.3,180.2 558.8,189.8 559.3,173.8 559.8,179 560.3,168 560.7,163.7 561.2,157.4 561.7,148.3 562.2,140.8 562.7,133.1 563.2,121.6 563.7,127.2 564.2,110.2 564.7,127.8 565.2,114.9 565.7,129.9 566.2,133 566.7,137.9 567.2,149.5 567.7,153.4 568.1,164.9 568.6,174.1 569.1,175.4 569.6,193 570.1,191.5 570.6,201.7 571.1,206.9 571.6,206.9 572.1,214.8 572.6,206.8 573.1,216.2 573.6,204.9 574.1,211 574.6,198.7 575.1,201.5 575.5,189 576,192 576.5,180 577,182.7 577.5,153.6 578,179.9 578.5,138.8 579,177.4 579.5,166.1 580,175.3 580.5,179.8 581,174.6 581.5,183.8 582,178.1 582.5,181.4 582.9,191.9 583.4,185.1 583.9,205.8 584.4,196.9 584.9,213.1 585.4,214.1 585.9,220.6 586.4,225.1 586.9,230.1 587.4,232.1 587.9,236.2 588.4,232.9 588.9,239 589.4,234.6 589.9,235.9 590.3,233.8 590.8,228.1 591.3,229.2 591.8,219.2 592.3,219.6 592.8,209.9 593.3,209.3 593.8,197 594.3,201.8 594.8,190.5 595.3,196.9 595.8,194.2 596.3,190.7 596.8,157.3 597.3,204.7 597.7,131.3 598.2,221.8 598.7,211.9 599.2,231.2 599.7,233.6 600.2,233.9 600.7,235.9 601.2,238 601.7,240 602.2,245 602.7,243.8 603.2,248.2 603.7,248.2 604.2,248.9 604.7,250.3 605.1,251.3 605.6,251 606.1,250.2 606.6,248.3 607.1,245.6 607.6,242.5 608.1,239.2 608.6,235.1 609.1,231.8 609.6,228.4 610.1,226.1 610.6,222.5 611.1,222.6 611.6,220.3 612.1,225.5 612.5,223.9 613,230.1 613.5,230.7 614,238.6 614.5,240.2 615,248.9 615.5,246 616,252 616,252" fill-opacity=".28"/><line class="f-s" x1="24" y1="60" x2="616" y2="60" stroke-width="3"/><text class="lbl" x="320" y="288" text-anchor="middle">f∗f of the record f, flat at its peak 1.502862</text></svg> | |
+56 −0 figure.py added View file
| @@ -0,0 +1,56 @@ | ||
| 1 | +"""The autoconvolution f*f of the current verified record, Together AI's 30,000-step function (README: "a step function | |
| 2 | +published by Together AI in 2026, recorded on the source as 1.502862"), with int f = 1. Optimising pushes the peak of | |
| 3 | +f*f down until about a third of it presses flat against one ceiling: that ceiling is the bound. | |
| 4 | + | |
| 5 | +The record is 700 kB, so record.json keeps what the figure needs, made from it exactly by | |
| 6 | + | |
| 7 | + python3 figure.py --reduce ours_2026.json | |
| 8 | + | |
| 9 | +with ours_2026.json from https://github.com/togethercomputer/EinsteinArena-new-SOTA/blob/main/first-autocorrelation/solutions/ours_2026.json | |
| 10 | +f*f is computed in exact integer arithmetic, as checks/judge does; record.json keeps f*f / (int f)^2 at 1201 evenly | |
| 11 | +spaced breakpoints (to 6 decimals) and the exact peak over all 60,001 breakpoints, rounded up to 12 decimals.""" | |
| 12 | +import json | |
| 13 | +import sys | |
| 14 | +from fractions import Fraction | |
| 15 | +from math import gcd | |
| 16 | +from pathlib import Path | |
| 17 | + | |
| 18 | +import kit | |
| 19 | + | |
| 20 | +DATA = Path(__file__).resolve().parent / 'record.json' | |
| 21 | +SAMPLES = 1200 | |
| 22 | + | |
| 23 | + | |
| 24 | +def reduce(src): | |
| 25 | + hs = [Fraction(v) for v in json.loads(Path(src).read_text())['values']] | |
| 26 | + q = 1 | |
| 27 | + for x in hs: | |
| 28 | + q = q * x.denominator // gcd(q, x.denominator) | |
| 29 | + a = [x.numerator * (q // x.denominator) for x in hs] | |
| 30 | + n, total = len(a), sum(a) | |
| 31 | + w = (2 * max(a).bit_length() + n.bit_length()) // 8 + 1 # Kronecker substitution, as in checks/judge | |
| 32 | + y = (int.from_bytes(b''.join(v.to_bytes(w, 'little') for v in a), 'little') ** 2).to_bytes(w * (2 * n - 1), 'little') | |
| 33 | + c = [0] + [int.from_bytes(y[k * w:(k + 1) * w], 'little') for k in range(2 * n - 1)] + [0] # f*f at t = -1/2 + k/(2n) | |
| 34 | + peak = Fraction(2 * n * max(c), total * total) | |
| 35 | + assert (2 * n) % SAMPLES == 0 | |
| 36 | + DATA.write_text(json.dumps({ | |
| 37 | + 'source': 'https://github.com/togethercomputer/EinsteinArena-new-SOTA/blob/main/first-autocorrelation/solutions/ours_2026.json', | |
| 38 | + 'steps': n, | |
| 39 | + 'peak': str(-(-peak.numerator * 10 ** 12 // peak.denominator) / 10 ** 12), | |
| 40 | + 'ff': [round(2 * n * c[k] / total ** 2, 6) for k in range(0, 2 * n + 1, 2 * n // SAMPLES)], | |
| 41 | + }) + '\n') | |
| 42 | + | |
| 43 | + | |
| 44 | +if sys.argv[1:2] == ['--reduce']: | |
| 45 | + reduce(sys.argv[2]) | |
| 46 | + | |
| 47 | +rec = json.loads(DATA.read_text()) | |
| 48 | +peak, ff = float(rec['peak']), rec['ff'] | |
| 49 | +assert rec['peak'].startswith('1.502862') # the README's record | |
| 50 | +assert abs(max(ff) - peak) < 2e-6 and abs(sum(ff[1:-1]) / SAMPLES - 1) < 1e-3 # the samples reach the peak; int f*f = 1 | |
| 51 | + | |
| 52 | +x0, x1, base, top = 24, 616, 252, 60 # t from -1/2 to 1/2; the peak at the top | |
| 53 | +curve = [(x0 + (x1 - x0) * j / SAMPLES, base - (base - top) * v / peak) for j, v in enumerate(ff)] | |
| 54 | +body = kit.polygon([(x0, base)] + curve + [(x1, base)], 'ink', ' fill-opacity=".28"') # a silhouette: f*f swings fast | |
| 55 | +body += kit.line(x0, top, x1, top, 'f-s', 3) # the peak, where the record presses f*f flat | |
| 56 | +kit.write(__file__, 'mathematics', body, label=f'f∗f of the record f, flat at its peak {rec["peak"][:8]}') | |
+124 −0 kit.py added View file
| @@ -0,0 +1,124 @@ | ||
| 1 | +"""The drawing kit for problem cards: one canvas, one palette, light and dark built in. | |
| 2 | + | |
| 3 | +It lives here only: tools/cards/kit.py in the catalog, which each problem folder links as kit.py. The Shoal site | |
| 4 | +serves no copy of it: a card's cover is the problem's poster (tools/cards/posters.py), and what this kit draws is kept | |
| 5 | +for the problem's own page. | |
| 6 | + | |
| 7 | +A figure.py at a problem's root, with this file beside it, imports it, draws the problem's object and writes cover.svg | |
| 8 | +next to itself (docs/cards.md says what a figure must be): | |
| 9 | + | |
| 10 | + import kit | |
| 11 | + body = kit.circle(320, 152, 40, 'f') | |
| 12 | + kit.write(__file__, 'mathematics', body, label='what is drawn') | |
| 13 | + | |
| 14 | +Classes (each colour means one thing on a figure; pick the meaning, then the class): | |
| 15 | + ink, ink-s the object itself (fill / stroke) | |
| 16 | + ink2-s secondary structure (edges, outlines) | |
| 17 | + f, f-s, f-soft the field's colour: the part the question is about (fill / stroke / pale fill) | |
| 18 | + sand, sand-s the one accent: a second colour class, an open or contested part | |
| 19 | + faint, faint-s context: grids, axes, ghosts | |
| 20 | + ring a halo in the page's colour, so dots read on top of lines | |
| 21 | + bg a fill in the page's colour, to hide what lies behind (front faces, occluding balls) | |
| 22 | + soft a pale fill of any class's colour: add it next to f, sand or ink (class="sand soft") | |
| 23 | + lbl the one label line | |
| 24 | +""" | |
| 25 | +import math | |
| 26 | +from pathlib import Path | |
| 27 | + | |
| 28 | +W, H = 640, 304 # shown at 320 x 152 on a card, larger on a featured card | |
| 29 | + | |
| 30 | +# the site's field colours (public/app.css, --f-*), light and dark | |
| 31 | +FIELD = { | |
| 32 | + 'mathematics': ('#4f6bed', '#93a6ff'), 'computer-science': ('#9b59d0', '#c9a2f3'), | |
| 33 | + 'physics-astronomy': ('#129d96', '#5fd0c8'), 'chemistry-materials': ('#d08a17', '#f2c063'), | |
| 34 | + 'life-health': ('#5a9e2c', '#a3d47a'), 'earth-environment': ('#2a8ccf', '#7cc4f2'), | |
| 35 | + 'engineering-energy': ('#d4533f', '#f29484'), 'social-economics': ('#c2448f', '#f09ac8'), | |
| 36 | +} | |
| 37 | +LIGHT = dict(ink='#1f1f1f', ink2='#3c4043', faint='#9aa0a6', line='#dadce0', sand='#b8862c', bg='#ffffff', muted='#5f6368') | |
| 38 | +DARK = dict(ink='#e8eaed', ink2='#c4c7c5', faint='#6f7479', line='#3c4043', sand='#d9b26a', bg='#1f2023', muted='#9aa0a6') | |
| 39 | + | |
| 40 | + | |
| 41 | +def _vars(c, f): | |
| 42 | + return (f'--ink:{c["ink"]};--ink2:{c["ink2"]};--faint:{c["faint"]};--line:{c["line"]};--sand:{c["sand"]};' | |
| 43 | + f'--bg:{c["bg"]};--muted:{c["muted"]};--f:{f}') | |
| 44 | + | |
| 45 | + | |
| 46 | +def style(field): | |
| 47 | + light, dark = FIELD[field] | |
| 48 | + return (f'<style>svg{{{_vars(LIGHT, light)}}}@media (prefers-color-scheme: dark){{svg{{{_vars(DARK, dark)}}}}}' | |
| 49 | + '.ink{fill:var(--ink)}.ink-s{stroke:var(--ink);fill:none}.ink2-s{stroke:var(--ink2);fill:none}' | |
| 50 | + '.f{fill:var(--f)}.f-s{stroke:var(--f);fill:none}.f-soft{fill:var(--f);fill-opacity:.14}' | |
| 51 | + '.sand{fill:var(--sand)}.sand-s{stroke:var(--sand);fill:none}.faint{fill:var(--faint)}.faint-s{stroke:var(--faint);fill:none}' | |
| 52 | + '.ring{stroke:var(--bg);stroke-width:3}.bg{fill:var(--bg)}.soft{fill-opacity:.16}' | |
| 53 | + '.lbl{fill:var(--muted);font:400 19px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}' | |
| 54 | + 'line,path,polyline{stroke-linecap:round;stroke-linejoin:round}</style>') | |
| 55 | + | |
| 56 | + | |
| 57 | +def f1(n): | |
| 58 | + return f'{round(n, 1):g}' | |
| 59 | + | |
| 60 | + | |
| 61 | +def circle(x, y, r, cls, extra=''): | |
| 62 | + return f'<circle class="{cls}" cx="{f1(x)}" cy="{f1(y)}" r="{f1(r)}"{extra}/>' | |
| 63 | + | |
| 64 | + | |
| 65 | +def dot(x, y, r=6, cls='ink'): | |
| 66 | + """A point that stays readable on top of lines: filled, with a halo in the page's colour.""" | |
| 67 | + return circle(x, y, r, f'{cls} ring') | |
| 68 | + | |
| 69 | + | |
| 70 | +def line(x1, y1, x2, y2, cls='ink2-s', w=2, extra=''): | |
| 71 | + return f'<line class="{cls}" x1="{f1(x1)}" y1="{f1(y1)}" x2="{f1(x2)}" y2="{f1(y2)}" stroke-width="{w}"{extra}/>' | |
| 72 | + | |
| 73 | + | |
| 74 | +def path(d, cls='ink2-s', w=2, extra=''): | |
| 75 | + return f'<path class="{cls}" d="{d}" stroke-width="{w}"{extra}/>' | |
| 76 | + | |
| 77 | + | |
| 78 | +def polygon(pts, cls='f-soft', extra=''): | |
| 79 | + return f'<polygon class="{cls}" points="{" ".join(f"{f1(x)},{f1(y)}" for x, y in pts)}"{extra}/>' | |
| 80 | + | |
| 81 | + | |
| 82 | +def polyline(pts, cls='ink2-s', w=2, extra=''): | |
| 83 | + return f'<polyline class="{cls}" points="{" ".join(f"{f1(x)},{f1(y)}" for x, y in pts)}" stroke-width="{w}"{extra}/>' | |
| 84 | + | |
| 85 | + | |
| 86 | +DASH = ' stroke-dasharray="7 6"' # pass as `extra` for a dashed stroke | |
| 87 | + | |
| 88 | + | |
| 89 | +def polypath(pts, cls='ink2-s', w=2, closed=False, extra=''): | |
| 90 | + """Many points as one relative path: the same line as polyline, a fraction of the bytes.""" | |
| 91 | + (x0, y0), d, px, py = pts[0], [], pts[0][0], pts[0][1] | |
| 92 | + for x, y in pts[1:]: | |
| 93 | + d.append(f'{f1(x - px)} {f1(y - py)}'); px, py = x, y | |
| 94 | + return path(f'M{f1(x0)} {f1(y0)}l' + ' '.join(d) + ('z' if closed else ''), cls, w, extra) | |
| 95 | + | |
| 96 | + | |
| 97 | +def arrow(x1, y1, x2, y2, cls='ink2-s', w=2, head=10): | |
| 98 | + """A line ending in an open arrowhead at (x2, y2).""" | |
| 99 | + a = math.atan2(y2 - y1, x2 - x1) | |
| 100 | + tips = [(x2 - head * math.cos(a - s), y2 - head * math.sin(a - s)) for s in (0.45, -0.45)] | |
| 101 | + return line(x1, y1, x2, y2, cls, w) + polyline([tips[0], (x2, y2), tips[1]], cls, w) | |
| 102 | + | |
| 103 | + | |
| 104 | +def text(x, y, s, cls='lbl', anchor='middle'): | |
| 105 | + s = s.replace('&', '&').replace('<', '<').replace('>', '>') | |
| 106 | + return f'<text class="{cls}" x="{f1(x)}" y="{f1(y)}" text-anchor="{anchor}">{s}</text>' | |
| 107 | + | |
| 108 | + | |
| 109 | +def svg(field, body, label=None, title=''): | |
| 110 | + """The whole figure. `label` is the one line naming what is drawn, at the bottom; leave room for it (y < 262).""" | |
| 111 | + if field not in FIELD: | |
| 112 | + raise ValueError(f'unknown field {field!r}') | |
| 113 | + if label and len(label) > 50: | |
| 114 | + raise ValueError(f'label over 50 characters (more does not fit at card size): {label!r}') | |
| 115 | + t = f'<title>{title or label or ""}</title>' | |
| 116 | + tail = text(W / 2, H - 16, label) if label else '' | |
| 117 | + return f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {W} {H}" role="img">{t}{style(field)}{body}{tail}</svg>\n' | |
| 118 | + | |
| 119 | + | |
| 120 | +def write(figure_py, field, body, label=None, title=''): | |
| 121 | + """Writes cover.svg next to the figure.py that calls it.""" | |
| 122 | + out = Path(figure_py).resolve().parent / 'cover.svg' | |
| 123 | + out.write_text(svg(field, body, label, title)) | |
| 124 | + return out | |
+0 −0 poster.webp added View file
+6 −0 posters.json added View file
| @@ -0,0 +1,6 @@ | ||
| 1 | +{ | |
| 2 | + "poster.webp": { | |
| 3 | + "style": "poster", | |
| 4 | + "idea": "Two translucent density hills overlap on a cobalt interval, forming a golden convolution peak in a tactile studio still life." | |
| 5 | + } | |
| 6 | +} | |
+1 −0 record.json added View file
| @@ -0,0 +1 @@ | ||
| 1 | +{"source": "https://github.com/togethercomputer/EinsteinArena-new-SOTA/blob/main/first-autocorrelation/solutions/ours_2026.json", "steps": 30000, "peak": "1.502862858706", "ff": [0.0, 0.781424, 1.473988, 0.806548, 0.186276, 0.078088, 0.006158, 0.003933, 0.036098, 0.247899, 0.592617, 0.827817, 1.086916, 1.487602, 1.442746, 0.816481, 0.25679, 0.093983, 0.271491, 0.529889, 0.866008, 1.361999, 1.482891, 1.368824, 1.498296, 1.270762, 0.952507, 1.066764, 0.777051, 0.45554, 0.574637, 0.734631, 0.895246, 0.944771, 0.901949, 0.844044, 0.775338, 0.689426, 0.62659, 0.611575, 0.540135, 0.420472, 0.38226, 0.437149, 0.473651, 0.403875, 0.438244, 0.415269, 0.248025, 0.277996, 0.206967, 0.098741, 0.134475, 0.083309, 0.030486, 0.01207, 0.007938, 0.008414, 0.001039, 0.000272, 0.000113, 0.00025, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.000661, 0.00061, 0.000921, 0.000869, 6.2e-05, 5.3e-05, 1e-06, 6e-06, 8.5e-05, 0.000207, 0.000265, 0.000468, 0.000654, 0.000612, 0.000578, 0.000343, 7.7e-05, 7.6e-05, 0.000126, 0.000261, 0.000401, 0.000432, 0.000466, 0.001913, 0.008296, 0.007246, 0.003243, 0.002868, 0.000544, 0.000154, 3.4e-05, 0.000216, 0.001188, 0.002, 0.002537, 0.004136, 0.015945, 0.042832, 0.04519, 0.031743, 0.063713, 0.10296, 0.226522, 0.371542, 0.268065, 0.090202, 0.06909, 0.107823, 0.093633, 0.105421, 0.204965, 0.284664, 0.315914, 0.319332, 0.355797, 0.434267, 0.391435, 0.323547, 0.488996, 0.641836, 0.489432, 0.31481, 0.313563, 0.351507, 0.422276, 0.469638, 0.459526, 0.432211, 0.45038, 0.557337, 0.680881, 0.642972, 0.44396, 0.395557, 0.499845, 0.484115, 0.403345, 0.410192, 0.445305, 0.412265, 0.460772, 0.520666, 0.451865, 0.398534, 0.398872, 0.378292, 0.364084, 0.418402, 0.429667, 0.334259, 0.308743, 0.316083, 0.317649, 0.285594, 0.236965, 0.257026, 0.292149, 0.270173, 0.259124, 0.304333, 0.282999, 0.199031, 0.213989, 0.244069, 0.169821, 0.164875, 0.186476, 0.153986, 0.202559, 0.195863, 0.158179, 0.162942, 0.44932, 1.028646, 0.976548, 0.401325, 0.198837, 0.143931, 0.065775, 0.060979, 0.107512, 0.22753, 0.371938, 0.470797, 0.618994, 0.793743, 0.672859, 0.332862, 0.166749, 0.26474, 0.457576, 0.55944, 0.584013, 0.59684, 0.514634, 0.620981, 0.737198, 0.627559, 0.742816, 0.692289, 0.469259, 0.414597, 0.353252, 0.318337, 0.273395, 0.288603, 0.306883, 0.539745, 0.884343, 0.848452, 0.752677, 0.784458, 0.68387, 0.611458, 0.641234, 0.802077, 0.98705, 1.085428, 1.112431, 1.163253, 1.203448, 1.137921, 1.098549, 1.142125, 1.112877, 1.101721, 1.201533, 1.37133, 1.49959, 1.424038, 1.418688, 1.393882, 1.307651, 1.45178, 1.502399, 1.502863, 1.495861, 1.494012, 1.47878, 1.50261, 1.491806, 1.500232, 1.46854, 1.314625, 1.178176, 1.100756, 1.036085, 0.995341, 0.95845, 0.915803, 0.896331, 0.849215, 0.78285, 0.78435, 0.707909, 0.577692, 0.550133, 0.467631, 0.43315, 0.456966, 0.411854, 0.376842, 0.300767, 0.281829, 0.231034, 0.196856, 0.171051, 0.146852, 0.116906, 0.072283, 0.070425, 0.107106, 0.183717, 0.325261, 0.357055, 0.341685, 0.227255, 0.101069, 0.071902, 0.037462, 0.059276, 0.103653, 0.138266, 0.171394, 0.22246, 0.265489, 0.272575, 0.292964, 0.307867, 0.206297, 0.111603, 0.124998, 0.214804, 0.314603, 0.401399, 0.401905, 0.329779, 0.25911, 0.294886, 0.373301, 0.313065, 0.381822, 0.405285, 0.406384, 0.384471, 0.371662, 0.378859, 0.298945, 0.227807, 0.198323, 0.260328, 0.364165, 0.380594, 0.551046, 0.890711, 0.874149, 0.493947, 0.301021, 0.273682, 0.243755, 0.349639, 0.379315, 0.33623, 0.394489, 0.442379, 0.522154, 0.616222, 0.486664, 0.351193, 0.427306, 0.403403, 0.328598, 0.353597, 0.442024, 0.417605, 0.359787, 0.400239, 0.387052, 0.347301, 0.40222, 0.411961, 0.454788, 0.480286, 0.441362, 0.387533, 0.36131, 0.398745, 0.407701, 0.440746, 0.476223, 0.4632, 0.49887, 0.55962, 0.554466, 0.565467, 0.607701, 0.611141, 0.632932, 0.717748, 0.839211, 0.953175, 0.963281, 0.932445, 0.974521, 1.026962, 1.064998, 1.14087, 1.270529, 1.411396, 1.502357, 1.502863, 1.437314, 1.285034, 1.206124, 1.208066, 1.177552, 1.202738, 1.266712, 1.38592, 1.502836, 1.486088, 1.471451, 1.500256, 1.502849, 1.502861, 1.502861, 1.502863, 1.502863, 1.502793, 1.502863, 1.502861, 1.502861, 1.502863, 1.502863, 1.502863, 1.502863, 1.395769, 1.031694, 0.852464, 0.871938, 0.845424, 0.857635, 1.089189, 1.420892, 1.500546, 1.502606, 1.502862, 1.497342, 1.499506, 1.502863, 1.502863, 1.502863, 1.501641, 1.502863, 1.502833, 1.502862, 1.502863, 1.502863, 1.502863, 1.502862, 1.502275, 1.502863, 1.502862, 1.502861, 1.502863, 1.500213, 1.502859, 1.502863, 1.502862, 1.502863, 1.502821, 1.5024, 1.498945, 1.502858, 1.50038, 1.502697, 1.501965, 1.502863, 1.502863, 1.501201, 1.502863, 1.502862, 1.502863, 1.502854, 1.502861, 1.501919, 1.502863, 1.502432, 1.502858, 1.5028, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502697, 1.502863, 1.502863, 1.502858, 1.502819, 1.502863, 1.502863, 1.502863, 1.502862, 1.502858, 1.502861, 1.502863, 1.502863, 1.502844, 1.502863, 1.502863, 1.502383, 1.502863, 1.502862, 1.502788, 1.502863, 1.502863, 1.502862, 1.502862, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502862, 1.502863, 1.502862, 1.502862, 1.502857, 1.502863, 1.502863, 1.502861, 1.502862, 1.50285, 1.502863, 1.502863, 1.502863, 1.502862, 1.50286, 1.502863, 1.502863, 1.502863, 1.502863, 1.50286, 1.502863, 1.502863, 1.502863, 1.502863, 1.502813, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.50286, 1.502863, 1.502863, 1.502863, 1.502861, 1.502857, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502644, 1.502835, 1.502863, 1.502863, 1.502863, 1.502859, 1.502863, 1.502862, 1.502854, 1.502858, 1.502863, 1.502863, 1.502863, 1.502863, 1.501281, 1.502863, 1.50286, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502855, 1.502863, 1.502863, 1.502863, 1.502863, 1.502861, 1.502863, 1.502863, 1.502863, 1.502863, 1.502043, 1.502862, 1.501844, 1.502863, 1.502817, 1.502861, 1.502863, 1.502862, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.467863, 1.501772, 1.502654, 1.502863, 1.502863, 1.502863, 1.502804, 1.502863, 1.502863, 1.502863, 1.502863, 1.502861, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.50276, 1.385145, 1.502863, 1.400761, 1.465408, 1.486809, 1.502863, 1.502808, 1.502795, 1.502841, 1.499267, 1.502863, 1.501738, 1.4988, 1.494675, 1.50255, 1.501596, 1.502084, 1.502863, 1.502695, 1.502863, 1.502573, 1.502862, 1.495195, 1.476084, 1.502365, 1.499044, 1.486511, 1.488283, 1.502863, 1.50121, 1.475673, 1.483888, 1.502863, 1.502863, 1.502863, 1.502416, 1.500558, 1.502863, 1.498326, 1.50284, 1.502863, 1.502863, 1.502849, 1.502859, 1.502863, 1.502765, 1.502629, 1.497309, 1.490509, 1.471802, 1.492762, 1.486702, 1.489665, 1.478744, 1.487741, 1.497562, 1.498497, 1.502862, 1.502505, 1.496988, 1.485063, 1.487837, 1.50244, 1.502731, 1.502513, 1.502856, 1.502862, 1.502863, 1.502378, 1.500265, 1.5026, 1.483355, 1.498404, 1.48703, 1.494101, 1.494425, 1.502863, 1.493657, 1.497473, 1.50281, 1.502862, 1.497712, 1.502773, 1.502862, 1.501971, 1.502807, 1.502794, 1.502863, 1.479301, 1.501098, 1.502856, 1.496476, 1.499617, 1.502863, 1.492899, 1.502566, 1.502619, 1.501307, 1.502863, 1.502863, 1.501943, 1.502863, 1.48885, 1.466584, 1.456915, 1.49984, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502862, 1.502863, 1.502863, 1.5013, 1.498699, 1.502863, 1.49775, 1.502827, 1.502861, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502862, 1.502862, 1.49181, 1.487306, 1.496717, 1.502861, 1.502863, 1.502863, 1.501601, 1.502863, 1.502863, 1.499913, 1.502863, 1.502862, 1.502862, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502854, 1.502816, 1.502862, 1.502863, 1.501437, 1.502765, 1.494424, 1.493523, 1.47504, 1.50225, 1.502862, 1.502863, 1.49994, 1.502863, 1.502863, 1.502836, 1.502863, 1.502863, 1.502863, 1.502863, 1.501196, 1.403479, 1.454381, 1.494187, 1.502863, 1.502863, 1.500016, 1.502863, 1.498057, 1.502863, 1.502489, 1.502731, 1.502862, 1.458171, 1.472182, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.498136, 1.502863, 1.502863, 1.502863, 1.502863, 1.485279, 1.494428, 1.502863, 1.502863, 1.502863, 1.49572, 1.498741, 1.497942, 1.502811, 1.502863, 1.496223, 1.502862, 1.502862, 1.502863, 1.502863, 1.502863, 1.502863, 1.498916, 1.502752, 1.497749, 1.502863, 1.499718, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.489597, 1.479422, 1.484313, 1.473824, 1.486364, 1.449096, 1.482676, 1.398949, 1.404884, 1.327119, 1.324521, 1.230879, 1.188123, 1.134606, 1.074996, 1.012341, 0.988451, 0.954317, 0.942475, 0.938364, 0.983031, 1.033543, 1.072518, 1.101108, 1.128413, 1.162286, 1.186071, 1.224314, 1.262545, 1.265573, 1.280056, 1.25814, 1.255619, 1.243071, 1.277229, 1.34818, 1.402538, 1.435475, 1.481977, 1.473845, 1.502863, 1.500377, 1.484573, 1.483877, 1.450891, 1.402785, 1.323931, 1.242784, 1.226028, 1.208067, 1.222123, 1.235712, 1.238882, 1.263363, 1.292628, 1.317515, 1.352562, 1.389758, 1.424635, 1.453879, 1.42734, 1.450557, 1.468728, 1.48945, 1.499047, 1.502644, 1.479888, 1.502863, 1.497794, 1.483619, 1.502862, 1.485559, 1.502863, 1.469904, 1.446931, 1.484108, 1.502863, 1.50075, 1.502863, 1.502818, 1.502863, 1.502702, 1.501312, 1.502863, 1.470049, 1.492457, 1.449889, 1.387234, 1.39425, 1.406129, 1.430277, 1.453123, 1.466382, 1.474401, 1.482967, 1.491012, 1.492127, 1.495539, 1.497703, 1.502859, 1.502863, 1.502863, 1.476759, 1.482174, 1.485397, 1.489424, 1.502827, 1.498148, 1.498781, 1.502557, 1.502863, 1.502863, 1.502863, 1.502028, 1.499537, 1.49251, 1.497801, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502862, 1.494587, 1.502863, 1.502863, 1.502863, 1.502863, 1.502863, 1.502861, 1.502863, 1.502862, 1.502862, 1.488707, 1.502863, 1.494838, 1.502863, 1.502863, 1.498707, 1.501574, 1.477952, 1.46753, 1.460477, 1.441057, 1.413021, 1.387621, 1.349196, 1.301363, 1.241838, 1.200947, 1.093717, 1.029203, 0.967237, 0.930334, 0.927258, 0.921501, 0.935599, 0.958062, 1.015268, 1.153407, 1.209844, 1.353935, 1.388602, 1.502862, 1.495004, 1.502861, 1.502856, 1.476951, 1.441534, 1.436129, 1.347107, 1.305745, 1.246844, 1.188146, 1.178655, 1.109376, 1.111657, 1.071211, 1.017689, 0.987416, 0.898888, 0.850267, 0.780481, 0.750083, 0.6892, 0.686479, 0.655127, 0.654814, 0.673861, 0.722643, 0.793884, 0.902347, 0.949698, 1.072384, 1.067188, 1.169262, 1.187112, 1.223332, 1.285861, 1.23824, 1.274896, 1.203571, 1.172588, 1.148756, 1.062661, 1.05406, 0.977719, 0.896136, 0.868576, 0.74441, 0.725641, 0.638115, 0.614641, 0.558849, 0.531956, 0.49095, 0.492629, 0.466403, 0.490842, 0.454543, 0.562338, 0.487114, 0.612159, 0.57118, 0.657258, 0.691433, 0.740404, 0.811936, 0.870434, 0.930836, 1.020819, 0.976888, 1.109797, 0.971961, 1.072945, 0.955355, 0.931817, 0.893168, 0.802083, 0.77193, 0.681722, 0.609892, 0.599677, 0.461449, 0.473402, 0.393696, 0.35298, 0.353404, 0.291221, 0.353913, 0.280105, 0.368421, 0.321142, 0.417045, 0.395541, 0.493091, 0.469687, 0.563502, 0.542371, 0.770057, 0.564507, 0.885854, 0.584228, 0.672216, 0.599974, 0.565285, 0.606009, 0.533811, 0.5781, 0.552605, 0.470563, 0.523928, 0.361847, 0.431128, 0.304332, 0.296782, 0.246039, 0.210355, 0.171143, 0.155534, 0.12344, 0.149329, 0.101687, 0.136322, 0.126076, 0.142756, 0.187239, 0.178091, 0.256802, 0.253705, 0.32943, 0.334452, 0.430583, 0.393276, 0.48132, 0.431046, 0.452325, 0.47957, 0.741576, 0.370606, 0.944996, 0.236051, 0.314036, 0.162465, 0.144304, 0.14174, 0.125842, 0.109729, 0.094013, 0.054417, 0.064402, 0.029768, 0.029962, 0.02463, 0.013415, 0.005184, 0.00749, 0.014362, 0.028606, 0.050208, 0.074003, 0.100458, 0.13239, 0.157989, 0.184365, 0.202804, 0.230884, 0.230086, 0.248301, 0.207489, 0.219683, 0.171512, 0.166692, 0.105239, 0.092596, 0.023974, 0.047008, 0.0]} | |
+82 −1 scienceslack.json View file
| @@ -19,5 +19,86 @@ | ||
| 19 | 19 | "catalog": "0521c19bbd38" |
| 20 | 20 | }, |
| 21 | 21 | "review": true, |
| 22 | - "approval": "first-time" | |
| 22 | + "approval": "first-time", | |
| 23 | + "cover": { | |
| 24 | + "file": "poster.webp" | |
| 25 | + }, | |
| 26 | + "image": "python:3.12-slim", | |
| 27 | + "metric": { | |
| 28 | + "name": "upper bound on the constant", | |
| 29 | + "better": "lower" | |
| 30 | + }, | |
| 31 | + "structure": "leaderboard", | |
| 32 | + "verify": [ | |
| 33 | + "certificate" | |
| 34 | + ], | |
| 35 | + "checks": { | |
| 36 | + "verify": { | |
| 37 | + "path": "checks/verify.sbatch", | |
| 38 | + "metrics": "metrics.json" | |
| 39 | + }, | |
| 40 | + "improves": { | |
| 41 | + "path": "checks/improves.sbatch", | |
| 42 | + "gate": false | |
| 43 | + } | |
| 44 | + }, | |
| 45 | + "card": { | |
| 46 | + "question": "A non-negative function on an interval has total mass 1. How low can the peak of its convolution with itself be?", | |
| 47 | + "stake": "Since 2025 the upper bound has been a race for computer search; a claimed 1.5027434868 still waits for an exact check.", | |
| 48 | + "frontier": { | |
| 49 | + "shape": "bounds", | |
| 50 | + "what": "C", | |
| 51 | + "lower": { | |
| 52 | + "value": "1.2802", | |
| 53 | + "x": 1.2802, | |
| 54 | + "by": "Ivanisvili and Xie", | |
| 55 | + "year": 2026 | |
| 56 | + }, | |
| 57 | + "upper": { | |
| 58 | + "value": "1.502862", | |
| 59 | + "x": 1.502862, | |
| 60 | + "by": "Together AI", | |
| 61 | + "year": 2026 | |
| 62 | + }, | |
| 63 | + "history": [ | |
| 64 | + { | |
| 65 | + "side": "upper", | |
| 66 | + "value": "π/2", | |
| 67 | + "x": 1.5707963, | |
| 68 | + "year": 2002 | |
| 69 | + }, | |
| 70 | + { | |
| 71 | + "side": "upper", | |
| 72 | + "value": "1.50992", | |
| 73 | + "x": 1.50992, | |
| 74 | + "year": 2010 | |
| 75 | + }, | |
| 76 | + { | |
| 77 | + "side": "upper", | |
| 78 | + "value": "1.503164", | |
| 79 | + "x": 1.503164, | |
| 80 | + "year": 2025 | |
| 81 | + }, | |
| 82 | + { | |
| 83 | + "side": "lower", | |
| 84 | + "value": "1.182778", | |
| 85 | + "x": 1.182778, | |
| 86 | + "year": 2007 | |
| 87 | + }, | |
| 88 | + { | |
| 89 | + "side": "lower", | |
| 90 | + "value": "1.2748", | |
| 91 | + "x": 1.2748, | |
| 92 | + "year": 2010 | |
| 93 | + }, | |
| 94 | + { | |
| 95 | + "side": "lower", | |
| 96 | + "value": "1.28", | |
| 97 | + "x": 1.28, | |
| 98 | + "year": 2017 | |
| 99 | + } | |
| 100 | + ] | |
| 101 | + }, | |
| 102 | + "first": "Find a step function whose ratio is below 1.502862" | |
| 103 | + } | |
| 23 | 104 | } |
+71 −0 tools/check_format.py added View file
| @@ -0,0 +1,71 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""Checks that the candidates in a folder follow the submission format in README.md: file names, JSON shape, types, | |
| 3 | +lengths and ranges, and the size limit. It computes no ratio. | |
| 4 | + | |
| 5 | +usage: python3 tools/check_format.py routes/<branch> (or one .json file) | |
| 6 | +""" | |
| 7 | +import json | |
| 8 | +import math | |
| 9 | +import pathlib | |
| 10 | +import sys | |
| 11 | +from fractions import Fraction | |
| 12 | + | |
| 13 | +MAX_STEPS = 131072 | |
| 14 | +MAX_BITS = 1 << 24 | |
| 15 | + | |
| 16 | + | |
| 17 | +def errors(candidate): | |
| 18 | + values = candidate.get("heights") | |
| 19 | + if not isinstance(values, list) or not 1 <= len(values) <= MAX_STEPS: | |
| 20 | + return [f'"heights" must be a list of 1 to {MAX_STEPS} heights'] | |
| 21 | + out, hs = [], [] | |
| 22 | + for i, v in enumerate(values): | |
| 23 | + if isinstance(v, bool) or not isinstance(v, (int, float, str)) or (isinstance(v, float) and not math.isfinite(v)): | |
| 24 | + out.append(f"height {i}: {v!r} is not a finite number or a string") | |
| 25 | + continue | |
| 26 | + try: | |
| 27 | + x = Fraction(v) | |
| 28 | + except (ValueError, ZeroDivisionError): | |
| 29 | + out.append(f"height {i}: unreadable {v!r}") | |
| 30 | + continue | |
| 31 | + if x < 0: | |
| 32 | + out.append(f"height {i}: {v} is negative") | |
| 33 | + hs.append(x) | |
| 34 | + if out: | |
| 35 | + return out | |
| 36 | + if not any(hs): | |
| 37 | + return ["all heights are 0"] | |
| 38 | + q = math.lcm(*(x.denominator for x in hs)) | |
| 39 | + bits = max(x.numerator * (q // x.denominator) for x in hs).bit_length() | |
| 40 | + if len(hs) * bits > MAX_BITS: | |
| 41 | + return [f"too fine: {len(hs)} heights of {bits} bits over their common denominator; N times the bits may be at most {MAX_BITS}"] | |
| 42 | + return [] | |
| 43 | + | |
| 44 | + | |
| 45 | +if len(sys.argv) != 2: | |
| 46 | + sys.exit(__doc__) | |
| 47 | +target = pathlib.Path(sys.argv[1]) | |
| 48 | +if target.is_file() and target.suffix != ".json": | |
| 49 | + sys.exit(f"{target}: candidates are .json files") | |
| 50 | +files = [target] if target.is_file() else sorted(target.rglob("*.json")) | |
| 51 | +found = bad = 0 | |
| 52 | +for path in files: | |
| 53 | + if path.stat().st_size > 1_000_000: | |
| 54 | + print(f"{path}: over 1 MB") | |
| 55 | + bad += 1 | |
| 56 | + continue | |
| 57 | + try: | |
| 58 | + candidate = json.loads(path.read_text()) | |
| 59 | + except Exception as exc: | |
| 60 | + print(f"{path}: not valid JSON ({exc})") | |
| 61 | + bad += 1 | |
| 62 | + continue | |
| 63 | + if not isinstance(candidate, dict) or "heights" not in candidate: | |
| 64 | + print(f'{path}: not a candidate (no "heights" key); ignored') | |
| 65 | + continue | |
| 66 | + found += 1 | |
| 67 | + problems = errors(candidate) | |
| 68 | + print(f"{path}: {'; '.join(problems[:5])}" if problems else f"{path}: ok ({len(candidate['heights'])} steps)") | |
| 69 | + bad += bool(problems) | |
| 70 | +print(f"{found} candidates, {bad} files with format errors") | |
| 71 | +sys.exit(1 if bad else 0) | |
