{"data":{"kind":"file","path":"README.md","version_id":"pdh1ld7xv1m5hnukvz0uewn4","entry":{"name":"README.md","path":"README.md","is_directory":false,"size":4078,"modified_at":"2026-08-20T02:30:16.850000","content_hash":"eaf07753fc9a2e66c874b25ccfc5f911cbcab49528000ad25396546a931705b9"},"entries":[],"content":"# exact-determinant\n\nA verifiable RL environment / eval for exact integer linear algebra: compute the\ndeterminant of a random n x n integer matrix (n = 5..9, entries in [-9, 9]) **exactly**.\n\n**Task.** Each instance is a matrix whose determinant is a single large integer. The\nmodel must return that integer exactly; floating-point evaluation is not accurate\nenough at these sizes, so the task genuinely requires exact (fraction-free or rational)\nelimination or a very careful cofactor expansion.\n\n**Why this environment is trustworthy.**\n- **Recomputed rewards, no answer key.** The reward function recomputes det(A) from the\n  matrix at verify time by fraction-free Bareiss elimination over Z (stdlib big\n  integers, no floats) and compares exactly. A stored label is never trusted, and the\n  grader never raises: malformed answers (floats, non-ASCII digits, >4300-digit\n  strings) and malformed matrices score 0.0.\n- **Cross-certified labels.** At mint time every determinant is computed by two\n  independent algorithms (Bareiss over Z, and Gaussian elimination over Q via\n  `fractions.Fraction`); minting fails loudly if they ever disagree. A property test\n  re-checks agreement on 300 random matrices plus forced-singular cases, and another\n  test asserts the shipped bundle is exactly reproducible from the default seed with\n  every instance satisfying the floor below.\n- **Guess-resistant by construction.** Minting rejects any matrix with\n  |det| < 10^(n-1). With n >= 5, **no integer with |g| <= 9999 is ever a correct\n  answer** - the small-integer attack is impossible by construction, not by luck. An\n  attacker sampling uniformly from a range that contains the answer has per-try hit\n  probability <= 1/(2 * 10^(n-1)) = 5e-5 at n=5, shrinking to 5e-9 at n=9.\n- **Deterministic, seed-honest minting.** Instances are minted deterministically from\n  a seed; per-instance seeds are derived as (seed << 64) + i, so distinct seeds can\n  never share an instance stream (tested). Passing a non-default seed, count > 40, or\n  fresh=True always mints fresh instances - the bundled 40 are served only for the\n  default seed. The instance space is ~19^25 (> 10^31) even at n=5, so fresh seeds\n  collide with previously published matrices only with vanishing probability.\n\n**Measured numbers** (default bundle: seed 20260819, 40 instances, 8 each of n = 5..9):\n\n| quantity | measured |\n|---|---|\n| |det| across bundle | min 10,625 / median 4,346,126 / max 4,344,498,058 |\n| random attack, uniform on [-1e13, 1e13] (superset of the Hadamard bound, so the true answer is always in range) | **0 / 200,000** |\n| exhaustive attack, every integer |g| <= 9999 | **0 / 799,960** (guaranteed 0 by the mint floor) |\n| always-answer-0 attack | 0 / 40 |\n| mint 40 instances | 0.005 s |\n| verify one answer (incl. det recompute) | ~0.01 ms |\n\nThe test suite (`tests/test_env.py`, 19 tests) includes the random attack, the\nexhaustive small-integer attack, off-by-one and sign-flip rejection, garbage/float/\nnon-ASCII-digit rejection, a >4300-digit-answer crash regression, non-integer matrix\nentry rejection, cross-algorithm agreement, the mint floor property, mint determinism,\nseed/count honesty, adjacent-seed disjointness, bundle reproducibility, a\nprompt-leak regression test, and an end-to-end scoring test through the real\nverifiers rubric pipeline.\n\n**Usage.**\n```python\nfrom exact_determinant import load_environment\nenv = load_environment()                      # bundled 40 instances, n = 5..9\nenv = load_environment(seed=7, count=100, fresh=True)   # mint fresh, never-served instances\n```\nThe answer format is a single integer; the parser takes the last integer token in the\ncompletion (ASCII digits; thousands separators tolerated), so models may reason freely\nbefore answering.\n\n**Graded signal.** Binary 1.0 / 0.0 by design: exact answers only. There is no partial\ncredit because nearly-right determinants (wrong sign, off by one) indicate a wrong\ncomputation, not partial understanding.\n\nBuilt by Half Ounce Research (halfounce.io) - certified computation, published record.\n","encoding":"utf-8","truncated":false,"total_bytes":4078},"status":null}