| |
| """Synchronize the Terminal-Bench finite-problem contribution. |
| |
| The UnsolvedMath export is denormalized across problems.json, dataset.json, |
| statistics.json, sets.json, and README.md. This script keeps those copies |
| consistent and makes the proposed contribution straightforward to review. |
| """ |
|
|
| from __future__ import annotations |
|
|
| import json |
| import re |
| from collections import Counter |
| from pathlib import Path |
|
|
|
|
| ROOT = Path(__file__).resolve().parents[2] |
| STAMP = "2026-07-31T00:00:00Z" |
| SET_ID = 14 |
| SET_RECORD = { |
| "id": SET_ID, |
| "name": "terminal_bench_verifiable_problems", |
| "display_name": "Terminal-Bench Verifiable Open Problems", |
| "description": ( |
| "Finite open mathematical and cryptanalytic problems selected and " |
| "formalized for Terminal-Bench, with exact witness checkers or Lean " |
| "statements supplied as optional verification artifacts." |
| ), |
| "slug": "terminal-bench-verifiable-problems", |
| "order_index": SET_ID, |
| "created_at": STAMP, |
| } |
|
|
|
|
| PROBLEMS = [ |
| { |
| "number": "TBV-001", |
| "title": "AES S-Box Multiplicative Complexity", |
| "statement": ( |
| "Determine whether the AES field-inversion map $F:\\mathbb F_{2^8}" |
| "\\to\\mathbb F_{2^8}$, $F(0)=0$ and $F(x)=x^{254}$ for $x\\ne0$, " |
| "has multiplicative complexity below 29. Equivalently, construct an " |
| "XOR/AND/NOT circuit with at most 28 AND gates, or prove that every " |
| "such circuit requires at least 29 AND gates. The field is " |
| "$\\mathbb F_2[X]/(X^8+X^4+X^3+X+1)$; XOR and NOT are free." |
| ), |
| "background": ( |
| "Multiplicative complexity counts nonlinear gates in a Boolean " |
| "circuit. In July 2026 an explicit 29-AND construction improved the " |
| "previous public 32-AND NIST circuit and was exhaustively checked on " |
| "all 256 inputs. The construction establishes only the upper bound; " |
| "no 28-AND circuit or matching 29-gate lower bound was located in the " |
| "status audit. Sources: https://umizame.github.io/S-box_29-AND/ ; " |
| "https://csrc.nist.gov/projects/circuit-complexity ; FIPS 197, " |
| "https://doi.org/10.6028/NIST.FIPS.197-upd1 . Status audited 31 July " |
| "2026. Formal statement and exhaustive checker: " |
| "verification/terminal-bench/TBV-001/." |
| ), |
| "category": 15, |
| "difficulty": 4, |
| }, |
| { |
| "number": "TBV-002", |
| "title": "Existence of a Costas Array of Order 32", |
| "statement": ( |
| "Does there exist a permutation $p$ of $\\{0,\\ldots,31\\}$ for " |
| "which all 496 displacement vectors $(j-i,p(j)-p(i))$, " |
| "$0\\le i<j<32$, are distinct?" |
| ), |
| "background": ( |
| "Costas arrays arose in sonar and radar design. Order 32 is the " |
| "smallest order whose existence remains unresolved publicly: neither " |
| "a permutation nor a nonexistence proof was found. Enumeration at " |
| "orders 28 and 29 required about 70 and 366.55 single-CPU years. " |
| "Sources: Dinitz, Henning, Montejano and Warnke, The Density of " |
| "Costas Arrays Decays Exponentially, " |
| "https://mathweb.ucsd.edu/~lwarnke/CostasArrayExponentialDecay.pdf ; " |
| "Afacan and Golomb, https://doi.org/10.1007/s10013-020-00392-5 ; " |
| "OEIS A008404, https://oeis.org/A008404 . Status audited 31 July " |
| "2026. Lean statement and exact displacement checker: " |
| "verification/terminal-bench/TBV-002/." |
| ), |
| "category": 2, |
| "difficulty": 4, |
| }, |
| { |
| "number": "TBV-003", |
| "title": "Existence of an Eight-Bit APN Permutation", |
| "statement": ( |
| "Does there exist a permutation $F:\\mathbb F_2^8\\to\\mathbb " |
| "F_2^8$ such that, for every nonzero $a$ and every $b$, the equation " |
| "$F(x+a)+F(x)=b$ has at most two solutions $x$? Equivalently, does an " |
| "almost-perfect-nonlinear permutation on eight bits exist?" |
| ), |
| "background": ( |
| "APN functions have optimal differential uniformity and are central " |
| "objects in vectorial Boolean-function theory. Even-dimensional APN " |
| "permutations are exceptionally constrained. The audit found many " |
| "dimension-eight APN functions but no dimension-eight APN permutation " |
| "and no universal nonexistence proof. Sources: Claude Carlet, " |
| "Vectorial Boolean Functions for Cryptography, " |
| "https://www.math.univ-paris13.fr/~carlet/chap-vectorial-fcts-corr.pdf ; " |
| "https://arxiv.org/abs/2508.04644 ; " |
| "https://arxiv.org/abs/2606.11967 . Status audited 31 July 2026. " |
| "Lean statement and complete difference-table checker: " |
| "verification/terminal-bench/TBV-003/." |
| ), |
| "category": 15, |
| "difficulty": 4, |
| }, |
| { |
| "number": "TBV-004", |
| "title": "Balanced Nine-Variable Boolean Nonlinearity Above 240", |
| "statement": ( |
| "Does there exist a balanced Boolean function " |
| "$f:\\mathbb F_2^9\\to\\mathbb F_2$ with nonlinearity at least 242? " |
| "Equivalently, can a balanced function have all Walsh coefficients of " |
| "absolute value at most 28, or is 240 a universal upper bound for the " |
| "balanced nine-variable case?" |
| ), |
| "background": ( |
| "Unbalanced nine-variable functions of nonlinearity 242 are known, " |
| "whereas the best balanced value located in the audit is 240. The " |
| "balance requirement is therefore essential. Sources: Kavut, Maitra " |
| "and Yucel, https://arxiv.org/abs/0808.0684 ; Claude Carlet, Boolean " |
| "Functions for Cryptography and Coding Theory, " |
| "https://www.math.univ-paris13.fr/~carlet/chap-fcts-Bool-corr.pdf ; " |
| "https://doi.org/10.1145/3512290.3528871 . Status audited 31 July " |
| "2026. Lean statement and exact Walsh-spectrum checker: " |
| "verification/terminal-bench/TBV-004/." |
| ), |
| "category": 15, |
| "difficulty": 4, |
| }, |
| { |
| "number": "TBV-005", |
| "title": "Binary Radius-Two Covering Code at Redundancy 18", |
| "statement": ( |
| "Is $\\ell_2(18,2)\\le830$? That is, does there exist a full-row-rank " |
| "binary parity-check matrix with 18 rows and at most 830 columns for " |
| "which every syndrome is the sum of at most two distinct columns? " |
| "Alternatively, prove that every such matrix has at least 831 columns." |
| ), |
| "background": ( |
| "A 2025 construction establishes $\\ell_2(18,2)\\le831$. Its explicit " |
| "831-column parity-check matrix has been independently reconstructed " |
| "and checked, but no 830-column construction or matching lower bound " |
| "was found. Source: Davydov, Marcugini and Pambianco, New upper bounds " |
| "for binary linear covering codes, " |
| "https://arxiv.org/abs/2511.02542 . Status audited 31 July 2026. Lean " |
| "statement and exhaustive syndrome checker: " |
| "verification/terminal-bench/TBV-005/." |
| ), |
| "category": 15, |
| "difficulty": 4, |
| }, |
| { |
| "number": "TBV-006", |
| "title": "A Ten-Multiplication Curve25519 Inversion Chain", |
| "statement": ( |
| "Starting from exponent 1, can the exact natural-number exponent " |
| "$2^{255}-21$ be reached using at most 254 doublings and at most ten " |
| "additions of two unequal previously reached exponents? Equivalently, " |
| "can Curve25519 field inversion be expressed by an addition chain with " |
| "254 squarings and ten nonsquare multiplications in this model?" |
| ), |
| "background": ( |
| "The familiar Curve25519 inversion chain reaches the exponent with " |
| "254 squarings and 11 nonsquare multiplications. The question freezes " |
| "exact exponent equality, rather than congruence modulo the " |
| "multiplicative-group order. No ten-multiplication chain or " |
| "impossibility proof was located. Sources: Daniel J. Bernstein, " |
| "Curve25519: new Diffie-Hellman speed records, " |
| "https://cr.yp.to/ecdh/curve25519-20060209.pdf ; verified addition-chain " |
| "software, https://github.com/mmcloughlin/addchain . Status audited 31 " |
| "July 2026. Lean statement and exact exponent checker: " |
| "verification/terminal-bench/TBV-006/." |
| ), |
| "category": 15, |
| "difficulty": 4, |
| }, |
| { |
| "number": "TBV-007", |
| "title": "Fukuoka MQ Challenge Type VI, 25 Equations", |
| "statement": ( |
| "Solve the official Fukuoka MQ Challenge Type VI seed-0 instance with " |
| "37 variables and 25 quadratic equations over $\\mathbb F_{31}$; that " |
| "is, exhibit a vector in $\\mathbb F_{31}^{37}$ at which all 25 frozen " |
| "polynomials vanish." |
| ), |
| "background": ( |
| "The official hall of fame records the corresponding seed-0 " |
| "24-equation instance as solved on 16 October 2025, while the " |
| "25-equation instance remained open at audit time. Official challenge " |
| "and instance: https://www.mqchallenge.org/ and " |
| "https://www.mqchallenge.org/challenges/VI/challenge-6-25-0.bz2 . " |
| "The frozen instance has SHA-256 " |
| "52b44066277c3b89a896967379789abb06bde8c6f269c5d33aeeb97915efa9e4. " |
| "Status audited 31 July 2026. Exact finite-field checker: " |
| "verification/terminal-bench/TBV-007/." |
| ), |
| "category": 15, |
| "difficulty": 3, |
| }, |
| { |
| "number": "TBV-008", |
| "title": "Provider0 Length-1473 Syndrome Decoding Challenge", |
| "statement": ( |
| "For the official Provider0 Goppa-McEliece challenge of length 1473 " |
| "and codimension 294, find a binary error vector of Hamming weight at " |
| "most 27 having the published syndrome." |
| ), |
| "background": ( |
| "The public syndrome-decoding hall of fame listed length 1409 and " |
| "weight 26 as the solved frontier; the Provider0 length-1473, weight-27 " |
| "instance remained open. Provider0 exposes a random binary matrix with " |
| "Goppa/Classic-McEliece-like parameters, not a hidden structured code. " |
| "Sources: https://decodingchallenge.org/goppa and official instance " |
| "https://decodingchallenge.org/Challenges/Goppa/Provider0/Goppa_1473 . " |
| "The frozen file SHA-256 is " |
| "8757e3f21842aab42943264daa88df3a472a9d464810cf31ca444f75cdbe12f5. " |
| "Status audited 31 July 2026. Exact syndrome checker: " |
| "verification/terminal-bench/TBV-008/." |
| ), |
| "category": 15, |
| "difficulty": 4, |
| }, |
| { |
| "number": "TBV-009", |
| "title": "Width-200 Three-Round Keccak Preimage Challenge", |
| "statement": ( |
| "Find a raw-Keccak preimage of the 80-bit target " |
| "$\\mathtt{d8ed85692afbee4c99ce}$ for width 200, rate 40, capacity " |
| "160, using any three consecutive rounds of Keccak-f[200], under the " |
| "Keccak Crunchy Contest padding and bit-order conventions." |
| ), |
| "background": ( |
| "The Keccak Crunchy Crypto Collision and Pre-image Contest continued " |
| "to mark this width-200 three-round cell as open. The target and " |
| "freedom to select a consecutive three-round window come from the " |
| "official contest. Source: https://keccak.team/crunchy_contest.html . " |
| "The verification semantics were checked against KeccakTools commit " |
| "3473478bf9c10bf95879cd8960c7409fee313162. Status audited 31 July " |
| "2026. Bit-exact sponge checker: " |
| "verification/terminal-bench/TBV-009/." |
| ), |
| "category": 15, |
| "difficulty": 3, |
| }, |
| { |
| "number": "TBV-010", |
| "title": "Minimum Three-Dimensional Kochen-Specker System", |
| "statement": ( |
| "Does there exist an uncolorable Kochen-Specker system of at most 30 " |
| "real projective rays in $\\mathbb R^3$? Here a coloring assigns 0 or " |
| "1 to every ray, no orthogonal pair may both receive 1, and no " |
| "orthogonal triple may receive three 0s. Alternatively, prove that " |
| "every system of at most 30 rays is colorable." |
| ), |
| "background": ( |
| "The smallest known real three-dimensional Kochen-Specker system has " |
| "31 rays, while the published global lower bound is 24. The question " |
| "is unrestricted over real coordinates; integer coordinates are only " |
| "one certificate class. Sources: Li, Bright and Ganesh, " |
| "https://doi.org/10.24963/ijcai.2024/210 ; Arends, Ouaknine and Wampler, " |
| "https://arxiv.org/abs/1111.3301 ; https://kochen-specker.info/ . " |
| "Status audited 31 July 2026. Lean real-coordinate statements and an " |
| "exact integer-ray checker: verification/terminal-bench/TBV-010/." |
| ), |
| "category": 16, |
| "difficulty": 4, |
| }, |
| { |
| "number": "TBV-011", |
| "title": "A 55-Addition Rank-23 Scheme for 3-by-3 Matrix Multiplication", |
| "statement": ( |
| "Does general $3\\times3$ matrix multiplication admit a bilinear " |
| "straight-line program using at most 23 scalar products and at most 55 " |
| "binary additions or subtractions? Signed copies and fanout are free; " |
| "all other integer linear combinations must be built from counted " |
| "binary gates. Alternatively, prove that every such rank-at-most-23 " |
| "program requires at least 56 additions." |
| ), |
| "background": ( |
| "Sun published an exact rank-23 scheme using 56 additions in April " |
| "2026. The printed program has been transcribed and all 729 integer " |
| "bilinear coefficients independently verified. No 55-addition scheme " |
| "or universal 56-addition lower bound in this precise signed-SLP model " |
| "was found. Sources: Yinqi Sun, https://arxiv.org/abs/2604.27645 and " |
| "https://github.com/sunyinqi0508/3by3r23-56a . Status audited 31 July " |
| "2026. Lean statement and exact symbolic checker: " |
| "verification/terminal-bench/TBV-011/." |
| ), |
| "category": 4, |
| "difficulty": 4, |
| }, |
| { |
| "number": "TBV-012", |
| "title": "The Order-23 Maximal Determinant Problem", |
| "statement": ( |
| "Determine $D(23)$, the largest absolute determinant of a " |
| "$23\\times23$ matrix with entries in $\\{-1,1\\}$. In particular, " |
| "either construct a matrix with determinant exceeding " |
| "$662671875\\cdot2^{22}=2779447296000000$, or prove that this " |
| "incumbent value is the exact maximum." |
| ), |
| "background": ( |
| "Order 23 remains one of the smallest unresolved Hadamard maximal " |
| "determinant cases. The incumbent follows from the corresponding " |
| "order-22 zero-one determinant by standard bordering. Sources: Orrick, " |
| "Solomon, Dowdeswell and Smith, https://arxiv.org/abs/math/0304410 ; " |
| "Browne et al., https://doi.org/10.37236/10367 ; OEIS A003432, " |
| "https://oeis.org/A003432 . Status audited 31 July 2026. Lean optimality " |
| "statement and exact Bareiss determinant checker: " |
| "verification/terminal-bench/TBV-012/." |
| ), |
| "category": 4, |
| "difficulty": 4, |
| }, |
| { |
| "number": "TBV-013", |
| "title": "A 66-XOR 32-Bit MDS Linear Layer", |
| "statement": ( |
| "Does there exist a linear map on four 8-bit input words with word " |
| "branch number 5 that can be implemented with at most 66 causal " |
| "two-input bit-XOR gates? Fanout, wire selection and copying are free, " |
| "but arbitrary linear forms and word-level XORs are not primitives. " |
| "Alternatively, prove that 67 XOR gates are necessary in this model." |
| ), |
| "background": ( |
| "Duval and Leurent publish a 67-XOR implementation of a four-word MDS " |
| "linear layer. Its word operations expand to exactly 67 two-input bit " |
| "XORs under the stated circuit model. No 66-gate construction or " |
| "lower-bound proof was located. Sources: Duval and Leurent, MDS " |
| "Matrices with Lightweight Circuits, " |
| "https://doi.org/10.46586/tosc.v2018.i2.48-78 and implementation " |
| "https://github.com/seduval/findmds . Status audited 31 July 2026. Lean " |
| "statement and exact linear-circuit checker: " |
| "verification/terminal-bench/TBV-013/." |
| ), |
| "category": 15, |
| "difficulty": 4, |
| }, |
| { |
| "number": "TBV-014", |
| "title": "Three Mutually Orthogonal Latin Squares of Order 10", |
| "statement": ( |
| "Do there exist three pairwise mutually orthogonal Latin squares of " |
| "order 10? Equivalently, is the maximum number $N(10)$ of MOLS of " |
| "order 10 at least three?" |
| ), |
| "background": ( |
| "Two MOLS of order 10 are known, but neither a triple nor an " |
| "unrestricted nonexistence proof was found; the published interval is " |
| "$2\\le N(10)\\le6$. Recent SAT results exclude substantial restricted " |
| "families without settling the general case. Sources: Bright, Keita " |
| "and Stevens, https://arxiv.org/abs/2503.10504 and " |
| "https://arxiv.org/abs/2509.09633 ; Rubin et al., " |
| "https://arxiv.org/abs/2103.11018 . Status audited 31 July 2026. Lean " |
| "statement and exact Latin/orthogonality checker: " |
| "verification/terminal-bench/TBV-014/." |
| ), |
| "category": 2, |
| "difficulty": 4, |
| }, |
| { |
| "number": "TBV-015", |
| "title": "Determine the Ramsey Number R(3,10)", |
| "statement": ( |
| "Is $R(3,10)=40$ or $R(3,10)=41$? Equivalently, does there exist a " |
| "triangle-free graph on 40 vertices with independence number at most " |
| "9?" |
| ), |
| "background": ( |
| "The current published bounds are $40\\le R(3,10)\\le41$. A qualifying " |
| "40-vertex graph proves the upper endpoint exact; a proof that no such " |
| "graph exists proves the lower endpoint exact. Sources: Vigleik " |
| "Angeltveit, R(3,10) <= 41, " |
| "https://www.combinatorics.org/ojs/index.php/eljc/article/view/v32i4p30 " |
| "and https://arxiv.org/abs/2401.00392 ; Small Ramsey Numbers survey, " |
| "https://www.cs.rit.edu/~spr/ElJC/sur.pdf . Status audited 31 July " |
| "2026. Lean statement and exact graph checker: " |
| "verification/terminal-bench/TBV-015/." |
| ), |
| "category": 3, |
| "difficulty": 4, |
| }, |
| { |
| "number": "TBV-016", |
| "title": "Eight-Bit Permutation Nonlinearity Above 112", |
| "statement": ( |
| "Does there exist a permutation $F:\\mathbb F_2^8\\to\\mathbb F_2^8$ " |
| "with standard vectorial nonlinearity at least 114? Equivalently, can " |
| "all Walsh coefficients $W_F(u,v)$ with $v\\ne0$ have absolute value " |
| "at most 28, or is 112 a universal upper bound for eight-bit " |
| "permutations?" |
| ), |
| "background": ( |
| "The best standard vectorial nonlinearity located for an eight-bit " |
| "permutation is 112, achieved by AES inversion; the applicable general " |
| "upper bound is 116. The definition ranges over all nonzero output " |
| "masks, not only coordinate functions. Sources: Claude Carlet, " |
| "Vectorial Boolean Functions for Cryptography, " |
| "https://www.math.univ-paris13.fr/~carlet/chap-vectorial-fcts-corr.pdf ; " |
| "Picek et al., https://doi.org/10.1016/j.asoc.2015.10.066 . Status " |
| "audited 31 July 2026. Lean statement and exact vectorial Walsh checker: " |
| "verification/terminal-bench/TBV-016/." |
| ), |
| "category": 15, |
| "difficulty": 4, |
| }, |
| { |
| "number": "TBV-017", |
| "title": "An Explicit Two-Block Collision for 32-Step SHA-256", |
| "statement": ( |
| "Find two distinct 128-byte messages that collide when processed as " |
| "two raw 64-byte blocks from the standard SHA-256 IV, with each " |
| "compression executing rounds 0 through 31 and applying the ordinary " |
| "feed-forward. No SHA-256 padding block is appended." |
| ), |
| "background": ( |
| "An explicit standard-IV two-block collision is published for 31-step " |
| "SHA-256 and separates after the 32nd step. Later papers give attack " |
| "algorithms on more steps, but the audit located no public 32-step pair " |
| "under this exact serialization. Sources: FIPS 180-4, " |
| "https://doi.org/10.6028/NIST.FIPS.180-4 ; The First Practical Collision " |
| "for 31-Step SHA-256, ASIACRYPT 2024 slides, " |
| "https://iacr.org/submit/files/slides/2024/asiacrypt/asiacrypt2024/64/64_slides.pdf ; " |
| "https://eprint.iacr.org/2026/232 and " |
| "https://eprint.iacr.org/2026/1120 . Status audited 31 July 2026. " |
| "Bit-exact reduced-compression checker: " |
| "verification/terminal-bench/TBV-017/." |
| ), |
| "category": 15, |
| "difficulty": 3, |
| }, |
| { |
| "number": "TBV-018", |
| "title": "Improve the Dimension-210 SVP Challenge Record", |
| "statement": ( |
| "For the official SVP Challenge lattice of dimension 210 and seed 0, " |
| "find a nonzero lattice vector of exact squared Euclidean norm less " |
| "than 14,497,861." |
| ), |
| "background": ( |
| "The SVP Challenge Hall listed a record vector by Jintai Ding and Ziyu " |
| "Zhao with displayed norm 3808 and exact squared norm 14,497,861. This " |
| "question asks for a strict improvement on the same frozen basis. " |
| "Sources: https://www.latticechallenge.org/svp-challenge/ ; official " |
| "basis https://www.latticechallenge.org/svp-challenge/download/challenges/svpchallengedim210seed0.txt ; " |
| "record vector https://www.latticechallenge.org/svp-challenge/solution.php?id=1 . " |
| "The basis SHA-256 is " |
| "020cd84a3ae1514c3d3a25a2c7350dacde955d8b7977253c71f9396e01e46e51. " |
| "Status audited 31 July 2026. Exact integer lattice checker: " |
| "verification/terminal-bench/TBV-018/." |
| ), |
| "category": 15, |
| "difficulty": 3, |
| }, |
| ] |
|
|
|
|
| EXISTING_UPDATES = { |
| "GRAPH-024": { |
| "background": ( |
| "Norman Biggs first suggested the feasible strongly regular graph " |
| "parameters $(99,14,1,2)$ in 1969; John Horton Conway later gave the " |
| "well-known reformulation from which the problem's common name derives. " |
| "Such a graph would have 99 vertices, degree 14, exactly one common " |
| "neighbor for adjacent pairs, and exactly two for nonadjacent pairs. " |
| "No construction or nonexistence proof was located in the 31 July 2026 " |
| "audit, and recent computational work still treats the question as open. " |
| "Sources: Keramatipour and Dawar, https://doi.org/10.5802/alco.418 ; " |
| "Brouwer and Van Maldeghem's parameter tables, " |
| "https://www.win.tue.nl/~aeb/graphs/srg/srgtab.html ; computational " |
| "search data, https://github.com/GrayTaylor/conway99 . A Lean " |
| "nonexistence statement and exact graph checker are supplied at " |
| "verification/terminal-bench/GRAPH-024/." |
| ), |
| }, |
| "GRAPH-025": { |
| "background": ( |
| "The degree-diameter problem asks for the maximum order of a graph with " |
| "maximum degree $d$ and diameter $k$. The Moore bound gives a general " |
| "upper bound, usually not attained. A concrete unresolved frontier is " |
| "$(d,k)=(5,5)$: the maintained record table listed Marston Conder's " |
| "648-vertex Cayley graph, communicated 18 January 2026, and no graph on " |
| "at least 649 vertices or proof of the upper bound 648 was located in " |
| "the 31 July 2026 audit. Sources: record table " |
| "https://web.mat.upc.edu/francesc.comellas/delta-d/table_degree_diameter.html " |
| "and published adjacency data " |
| "https://web.mat.upc.edu/francesc.comellas/delta-d/desc_g/desc_g5.html#55 . " |
| "A Lean upper-bound statement and exact degree/diameter checker for this " |
| "finite case are supplied at verification/terminal-bench/GRAPH-025/." |
| ), |
| }, |
| } |
|
|
|
|
| def dump(path: Path, value: object) -> None: |
| path.write_text(json.dumps(value, indent=2, ensure_ascii=False) + "\n") |
|
|
|
|
| def replace_readme_statistics(readme: str, stats: dict) -> str: |
| readme = readme.replace("**5,426 open mathematics problems**", "**5,444 open mathematics problems**") |
| readme = readme.replace("**Total Problems**: 5426", "**Total Problems**: 5444") |
| readme = readme.replace("**Problem Sets**: 13 curated collections", "**Problem Sets**: 14 curated collections") |
| if "- Terminal-Bench Verifiable Open Problems" not in readme: |
| readme = readme.replace( |
| "- AMR Open Problem Lists\n", |
| "- AMR Open Problem Lists\n- Terminal-Bench Verifiable Open Problems\n", |
| ) |
|
|
| difficulty_lines = "\n".join( |
| f"- {name}: {count}" for name, count in stats["problems_by_difficulty"].items() |
| ) |
| category_lines = "\n".join( |
| f"- {name}: {count}" for name, count in stats["problems_by_category"].items() |
| ) |
| status_lines = "\n".join( |
| f"- {name.replace('_', ' ').title()}: {count}" |
| for name, count in stats["problems_by_status"].items() |
| ) |
| readme = re.sub( |
| r"(### Problems by Difficulty\n\n).*?(\n\n### Problems by Category)", |
| rf"\g<1>{difficulty_lines}\g<2>", |
| readme, |
| flags=re.S, |
| ) |
| readme = re.sub( |
| r"(### Problems by Category\n\n).*?(\n\n### Problems by Status)", |
| rf"\g<1>{category_lines}\g<2>", |
| readme, |
| flags=re.S, |
| ) |
| readme = re.sub( |
| r"(### Problems by Status\n\n).*?(\n\n## Usage)", |
| rf"\g<1>{status_lines}\g<2>", |
| readme, |
| flags=re.S, |
| ) |
| return readme |
|
|
|
|
| def main() -> None: |
| categories = json.loads((ROOT / "categories.json").read_text()) |
| difficulties = json.loads((ROOT / "difficulty_levels.json").read_text()) |
| sets = json.loads((ROOT / "sets.json").read_text()) |
| problems = json.loads((ROOT / "problems.json").read_text()) |
|
|
| category_by_id = {x["id"]: x for x in categories} |
| difficulty_by_id = {x["id"]: x for x in difficulties} |
| sets = [x for x in sets if x["id"] != SET_ID] + [SET_RECORD] |
|
|
| existing_numbers = {x["problem_number"] for x in problems} |
| for number, update in EXISTING_UPDATES.items(): |
| if number not in existing_numbers: |
| raise RuntimeError(f"missing existing problem {number}") |
| record = next(x for x in problems if x["problem_number"] == number) |
| record.update(update) |
| record["updated_at"] = STAMP |
|
|
| new_numbers = {x["number"] for x in PROBLEMS} |
| problems = [x for x in problems if x["problem_number"] not in new_numbers] |
| for offset, source in enumerate(PROBLEMS, start=1): |
| category = category_by_id[source["category"]] |
| difficulty = difficulty_by_id[source["difficulty"]] |
| problems.append( |
| { |
| "id": 12_000_000 + offset, |
| "problem_number": source["number"], |
| "title": source["title"], |
| "statement": source["statement"], |
| "background": source["background"], |
| "difficulty_level_id": difficulty["id"], |
| "status": "open", |
| "proposed_by": None, |
| "proposed_year": None, |
| "category_id": category["id"], |
| "set_id": SET_ID, |
| "view_count": 0, |
| "favorite_count": 0, |
| "created_at": STAMP, |
| "updated_at": STAMP, |
| "published": True, |
| "category": category, |
| "difficulty": difficulty, |
| "set": SET_RECORD, |
| } |
| ) |
|
|
| if len({x["id"] for x in problems}) != len(problems): |
| raise RuntimeError("duplicate numeric problem ID") |
| for number in new_numbers: |
| if sum(x["problem_number"] == number for x in problems) != 1: |
| raise RuntimeError(f"new problem number is not unique: {number}") |
|
|
| by_difficulty = Counter(x["difficulty"]["name"] for x in problems) |
| by_category = Counter(x["category"]["display_name"] for x in problems) |
| by_status = Counter(x["status"] for x in problems) |
| by_set = Counter(x["set"]["name"] for x in problems if x.get("set")) |
| stats = { |
| "total_problems": len(problems), |
| "problems_by_difficulty": dict(by_difficulty), |
| "problems_by_category": dict(by_category), |
| "problems_by_status": dict(by_status), |
| "problems_by_set": dict(by_set), |
| } |
|
|
| dataset = json.loads((ROOT / "dataset.json").read_text()) |
| dataset["metadata"]["exported_at"] = STAMP |
| dataset["metadata"]["total_problems"] = len(problems) |
| dataset["metadata"]["total_sets"] = len(sets) |
| dataset["sets"] = sets |
| dataset["problems"] = problems |
|
|
| dump(ROOT / "sets.json", sets) |
| dump(ROOT / "problems.json", problems) |
| dump(ROOT / "dataset.json", dataset) |
| dump(ROOT / "statistics.json", stats) |
|
|
| readme_path = ROOT / "README.md" |
| readme_path.write_text(replace_readme_statistics(readme_path.read_text(), stats)) |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|