1 · The question

Put as many points as you can on the n \times n grid of lattice points so that no straight line passes through three of them — any line, not just rows, columns and diagonals. Dudeney posed it in 1900 with sixteen pawns on a chessboard.

The ceiling is free. Three points in one row are collinear, so each row holds at most two, and there are n rows:

k \;\le\; 2n \qquad \text{for every } n.

That is a one-line argument, and it is a theorem: no configuration found by any method can exceed it. The floor is not free — whether 2n is actually attained at a given n is a hard question, and past the small cases the answers come from computer search.

So this study asks a question with two halves, and the second half is the one it exists for:

On an n \times n integer grid, how many points can a budgeted iterated local search place with no three collinear — judged only by a declared exact verifier that shares no code with the search — at an n where the proven maximum should be reachable and at an n where it should not?

Why an optimize study, and why this problem

A search that scores itself is a witness testifying about its own case. Klein's optimize contract breaks that mechanically: the track declares a verifier, the verifier lives outside the per-experiment mutable surface, the METHOD gate hashes it so it can never change again, and klein run-one runs it as a second process on the artifact the search wrote. Its number is the one that enters the ledger. The searcher's own claim is recorded beside it, and a disagreement is a crash.

No-three-in-line is the right problem to demonstrate that on, for one reason: the objective is an integer — how many points are in the set — so the checker needs no tolerance. Two integers either agree or they do not.

The two instances, and a frontier that was closed before it opened

TrackGridProven maximum 2nBest known valueHeadroom h
n_small11 × 1122220
n_large31 × 3162620

The best known value equals the pigeonhole bound at both sizes (ref:flammenkamp_records, ref:mathworld_no3), so the detection-limit arithmetic

h \;=\; \frac{\text{ideal} - \text{incumbent}}{\text{minimum delta}}

gives zero on both tracks. No run in this study could ever have been a keep — a keep would have had to beat a theorem — and the study computed that, acknowledged the closed door with klein headroom ack, and redefined success before spending anything:

This study is not looking for an improvement. It is looking for an object that attains the known maximum, and for a record of who certified it.

Ten runs later: zero keeps, exactly as registered.

2 · The method taught

Two pieces of code do all the work here, and the whole point of the study is that they must not be the same piece. Learn the checker first — in an optimize study the checker is the load-bearing part, and Klein's METHOD gate treats it that way: the Practice leg of the Theory + Papers + Practice triad is the from-scratch verifier, not the searcher.

§2.1 · The one equation

Three points p, q, r with integer coordinates are collinear exactly when the cross product of the two edge vectors vanishes:

(q-p) \times (r-p) \;=\; (q_x-p_x)(r_y-p_y) - (q_y-p_y)(r_x-p_x)

The quantity is twice the signed area of the triangle. It is an integer, so the test is exact: there is no division, no slope, no floating point and no rounding decision anywhere on the path. A configuration S is valid when that expression is non-zero for every triple it contains.

§2.2 · The checker: enumerate everything

The verifier is deliberately the dumbest correct implementation. It reads the artifact, checks it is well-formed — integer coordinates (a Python bool is an int, and is refused explicitly), on the grid, no repeats — and then walks every triple:

for a, b, c in combinations(points, 3):
    cross = (b[0]-a[0])*(c[1]-a[1]) - (b[1]-a[1])*(c[0]-a[0])
    if cross == 0:
        raise Rejected(f"points {a}, {b} and {c} are collinear")
return len(points)

No sampling, no early exit that could hide a triple, no clever geometry. On the largest object this study verified that is 26235 cross products, and the checker's own log records 0.002046 seconds for it — cheap, and the cost is charged to no guardrail.

§2.3 · The searcher: hash directions instead

The search may be as clever as it likes. Adding a point p to a valid set can only create triples that contain p, and \{p,q,r\} is collinear exactly when q-p is parallel to r-p. So look at the world from p: reduce each offset to its primitive direction and ask whether two of them collide.

d(p,q) \;=\; \frac{q-p}{\gcd\big(|q_x-p_x|,\; |q_y-p_y|\big)} \quad\text{(sign-normalized)}

That turns an O(k^2) question into an O(k) one — and it is not what the checker does. Two deliberately different algorithms agreeing is evidence; one algorithm agreeing with itself is a tautology.

§2.4 · The search loop

Iterated local search over configurations that are valid at every instant: complete greedily, keep improvements, perturb, repeat.

S = []                                  # always a VALID configuration
while evaluations < B:
    order = shuffle(all cells); order.sort(key=lambda c: rows[c.y] + cols[c.x])
    for p in order:                     # one pass = one greedy completion
        evaluations += 1                # ONE EVALUATION = one addability test
        if addable(p, S): S.append(p)
    if len(S) > len(best): best = S[:]  # accept improvements only
    elif stale >= 2n:     S = []        # restart from empty
    else:                 remove 1-3 random points from S

Two details matter. The budget unit is one call to addable — the atomic cost of the search — and it is what the registered guardrail caps. The ordering is most-constrained-first: a 2n configuration needs exactly two points in every row and every column, so the emptiest lines are the ones still to be filled; the shuffle comes before the sort, so ties break randomly and every pass is a fresh sample.

The whole thing is deterministic in (n, \text{seed}, B): one random stream drives every choice and the budget only says when to stop. A larger budget is therefore a strict extension of a smaller one, which is why the ladder below is one trajectory read at three points and its objective is monotone by construction rather than by luck.

§2.5 · The one construction we knew in advance

For prime p, the parabola P = \{(x,\; x^2 \bmod p)\} has p points and no three collinear. If three were, the integer determinant above would vanish, hence vanish mod p, where it factors as

(b-a)(c-a)(c-b) \pmod p

— a product of units for distinct a,b,c \in [0,p). Contradiction. That is why this object can serve as a control whose score is known before any code runs: exactly p.

3 · The data story

This study has no dataset. Its data.modality is none, and Klein's DATA gate is typed by modality: where a tabular study gets a profile and a four-row leakage audit, a verifier-only study gets a verifier card. The audit is of the oracle, because the oracle is the evidence source.

§3.1 · What the gate actually froze

prepare.py writes a problem statement, not data, and the DATA gate hashes it. Inside data/prepared/instances.json:

The seed blocks are how a study with no rows gets a sealed partition. data.split.kind is none, so there is nothing to partition; klein run-one --final-test sets KLEIN_EVALUATION_KIND=final_test and search.py reads the sealed block by name out of the hashed file. No literal seed appears in search.py, verify.py or lib/ — war story 8's failure mode (an evaluator carrying a retired split seed) cannot occur when there is no split to carry.

§3.2 · The controls, and why freezing them first is the whole trick

The naming follows the protocol's detector convention: the positive control is the one on which the detector must fire; the negative control is the one on which it must stay silent.

Positive — twelve planted invalid objects the checker must reject. Seven geometric defects spanning the slopes 0, undefined, +1, -1, +2, +1/2 and a +2 line with unequal lattice gaps; three well-formedness defects (a coordinate equal to n, a negative coordinate, a non-integer coordinate); a repeated lattice point; and one almost valid object — the parabola set plus a single cell that creates exactly one collinear triple among its twelve points, which a checker that sampled triples would probably pass.

Negative — one known-valid object the checker must accept, at a value known in advance. The Erdős parabola set on the 11 × 11 grid: valid by the proof in §2.5, so its score is 11 before any code runs.

A positive control that can be softened after it fails is not a control. These twelve objects were hashed into the DATA gate record before the checker ever met them, and the gate's sha256 is on events.jsonl.

§3.3 · The go/no-go call

The card ruled GO, with the checker exercised in both directions before any search existed: it fired on all twelve planted objects and accepted the known-valid one at exactly its predicted 11. That exercise was the audit, not the evidence — it ran outside a transaction, so E0001 re-ran the same battery under the notary and that is where the prediction was adjudicated.

The card's ranked issues were four NOTEs and one WARN, and the WARN is the honest one: the search and the checker share an idea — both decide collinearity — even though they share no code, so a common conceptual error would survive their agreement. The seven planted geometric controls exist to span exactly that failure class, and the checker uses the general cross product, which has no special cases at all.

§3.4 · One correction, filed after the fact

The card also wrote, at the gate and before any run existed, that the checker's cost would be "sub-millisecond at every size this study uses". That was a fair pre-run estimate and it is wrong: the verifier logs record 0.002046 seconds on the largest object, and four of the ten exceed a millisecond. The card is a gate-hashed artifact and is not edited — editing it after the runs would silently invalidate the record it is part of — so the correction lives in findings.md, in program.md, and in erratum E1 against claim C6. §5 tells that story properly; it is the study's own best example of why a number needs a home.

4 · The experiment journey

Ten runs, in two phases, on two tracks. Every one of them is a discard or a crash — that was arithmetic, registered in advance (§1) — so the interesting structure is not a frontier climbing but a reach being measured, and one refusal being tested.

§4.1 · The ledger, as the engine draws it

Run order rather than budget, one panel per track. The discards are evidence dots; the crash has no metric and therefore no place on a metric axis, so it sits on the rug where it can still be seen; the sealed cell is a star, outside the adaptive frontier by construction.

Decision trajectory for track n_small: four development discards, the E0008 crash on the rug, and the sealed star at 22.
Track n_small (the 11 × 11 grid), every notarized run in ledger order against the objective the declared verifier scored: the development cells as discard dots, the E0008 crash on the rug because a run with no metric has no place on a metric axis, and the sealed cell as a star off the frontier. Headroom was zero before the first run, so every development cell was a discard by design — and the sealed cell reached 22, the proven maximum. Close
Decision trajectory for track n_large: three development discards and the sealed star at 55.
The same drawing for track n_large (the 31 × 31 grid): its development cells, all discards by the same arithmetic, and its one sealed cell as a star apart from them. The star reads 55, above the development lane's 54 and far below the 62 that is known to be attainable here — so what this panel measures is a reach, not a climb. Close

Tracks: n_small — points (higher is better) · n_large — points (higher is better)

ExpTrackKindMetricStatusDescription
E0001n_smalldevelopment11discardcontrols: the declared verifier against the twelve frozen invalid objects, and the known-valid Erdos parabola set handed to the notary as this cell's own artifact; did not improve track frontier 22 by minimum_delta=1 (external incumbent 22)
E0002n_smalldevelopment20discardn_small at the smallest registered budget: 20 000 addability tests on the 11 x 11 grid, development seed block; did not improve track frontier 22 by minimum_delta=1 (external incumbent 22)
E0003n_smalldevelopment21discardn_small at the middle rung: 200 000 addability tests on the 11 x 11 grid, same development seed block, so this trajectory extends E0002's; did not improve track frontier 22 by minimum_delta=1 (external incumbent 22)
E0004n_smalldevelopment21discardn_small at the largest registered budget: 2 000 000 addability tests on the 11 x 11 grid; decides P1; did not improve track frontier 22 by minimum_delta=1 (external incumbent 22)
E0005n_largedevelopment50discardn_large at the smallest registered budget: 20 000 addability tests on the 31 x 31 grid, development seed block; did not improve track frontier 62 by minimum_delta=1 (external incumbent 62)
E0006n_largedevelopment53discardn_large at the middle rung: 200 000 addability tests on the 31 x 31 grid, same development seed block; did not improve track frontier 62 by minimum_delta=1 (external incumbent 62)
E0007n_largedevelopment54discardn_large at the largest registered budget: 2 000 000 addability tests on the 31 x 31 grid; decides P2; did not improve track frontier 62 by minimum_delta=1 (external incumbent 62)
E0008n_smalldevelopmentNAcrashthe deliberate disagreement: the searcher reports ONE more point than the object it wrote, nothing else changes; the expected outcome is a crash naming verifier_disagreement; verifier_disagreement: the run reported 21 but the verifier measured 20 (tolerance 0) — one of them is wrong, and the search is not the one to ask
E0009n_smallfinal_test22discardsealed confirmation on n_small: the same search at the largest budget from the sealed seed block, which no development run has used; decides P6; sealed final-test evidence; excluded from the adaptive frontier (external incumbent 22)
E0010n_largefinal_test55discardsealed confirmation on n_large: the same search at the largest budget from the sealed seed block; decides P7; sealed final-test evidence; excluded from the adaptive frontier (external incumbent 62)

§4.2 · E0001 — audit the judge before believing anything

The first cell runs the declared verifier, unchanged, on each of the twelve frozen invalid objects and counts the rejections, then hands the notary the known-valid parabola set as its own artifact — so the acceptance half is performed by the notary's own verifier invocation rather than by the search. Printed: planted: 12, rejected: 12, and a ledger metric of 11, exactly the value the theorem predicts. P3 supported. Nothing after this line would be worth reading if this line had failed.

Left: all twelve planted invalid objects rejected with exit 2. Right: E0008's searcher reported 21 where the checker measured 20.
What the checker did to the ledger, from E0001 and E0008, both development cells on track n_small. Left: each frozen invalid object against the verdict it received — all 12 rejected, so the detector fires when it should. Right: the deliberate overclaim cell, the search's own report beside the checker's measurement, 21 against 20, recorded as a crash whose ledger row is NA. A guard that has never fired is a guard nobody has tested. Close

§4.3 · E0002–E0007 — the same search, two instances, one budget ladder

Three rungs per track — 20000, 200000, 2000000 addability tests — from the development seed block. Because the budget is a strict prefix of one random stream, the three rungs are one trajectory read at three points, so the curve is monotone by construction.

Verified objective against evaluation budget for both tracks, with the proven maximum drawn as a dashed reference line.
The verified objective against the evaluation budget, one panel per track on a log budget axis: the development seed block's three rungs joined into a line, the sealed cell as a hollow star at the same largest budget, and the proven maximum 2n as a dashed reference no point can rise above. On n_small the star sits on that line at 22 where the development lane stopped at 21; on n_large both lanes stay well short of 62, and the same budget bought 19014 greedy completions at n = 11 against 2190 at n = 31. Close

On the 11 × 11 grid: 20, then 21, then 21. On the 31 × 31 grid: 50, then 53, then 54. P2 supported at n = 31 (54 < 62). And at n = 11 —

P1 refuted. The prediction said the search would reach 22 within 2000000 addability tests. It reached 21. The sharper detail is inside the run: the best object was found at evaluation 152572, and the remaining budget — 19014 greedy completions in all — produced nothing better. This was not a budget shortfall.

One number is worth carrying into §5: the same budget bought 19014 completions at n = 11 and 2190 at n = 31, because one completion costs about n^2 addability tests. "The same budget" and "the same search effort" are not the same sentence.

§4.4 · E0008 — make the searcher lie, on purpose

One run of the ten was spent making search.py report exactly one point more than the object it wrote. Nothing else changed. The notary refused it:

E0008: crash metric=None
decision_reason: verifier_disagreement: the run reported 21 but the verifier
measured 20 (tolerance 0) — one of them is wrong, and the search is not the
one to ask

The manifest keeps both numbers side by side (reported 21.0, verified 20.0) and results.tsv carries NA: the inflated number reaches no table anywhere in the study. A guard that has never fired is a guard nobody has tested, and the cost of testing it was one phase slot.

§4.5 · E0009, E0010 — the sealed cells, and the surprise

Each track gets one sealed access, rehearsed first with klein run-one --final-test --dry-run (which hands back the development block and prints sealed_dryrun: 1, so the seal survives the rehearsal). The sealed cells then run the same search at the same largest budget from the sealed seed block — one integer different, nothing else.

At n = 31, 55 — a little better than the development lane's 54, still far short. P7 supported.

At n = 11, 22 — the proven maximum, found at evaluation 1612132. P6 supported, and P1's refutation stands beside it, unrewritten.

Same instance, same algorithm, same budget, same commit; the two lanes land on opposite sides of a theorem's ceiling. That pair is the finding, and §5 says what may and may not be concluded from it.

§4.6 · Re-verification

Every development run was re-checked with klein replicate --verify-only: the declared verifier re-run in a fresh process on the pinned artifact, no search, no worktree. Seven records, reproduced: true in every one, tolerance 0.0 taken from verifier.tolerance, difference 0.0 on the primary metric. P4 supported.

5 · Findings & insights

§5.1 · The object

The study's one construction: a 22-point configuration on the 11 × 11 grid with no three collinear, found by E0009 from the sealed seed block, accepted by the declared verifier, committed as bytes at models/E0009/solution.json. Twenty-two is 2n at n = 11, so the object attains the proven maximum and matches the best known value for this instance. Beside it, the negative control it was checked against.

Left: the sealed run's 22-point object on the 11 by 11 grid, exactly two points per row and per column. Right: the eleven-point Erdos parabola control.
The two objects the checker accepted, drawn from the same bytes it scored. Left: E0009's sealed 22-point configuration on the 11 × 11 grid from track n_small, with two points in every row and every column. Right: the negative control it was checked against — Erdős's 11-point parabola set, valid by theorem before any code ran. Attaining 2n looks like the left panel, and make_figures.py re-runs the collinearity test over every triple before it will draw either one. Close

Count the rows and columns in the left panel: exactly two points in each. That is what attaining 2n looks like, and it is what the checker verified over every triple — twice, since figures/make_figures.py re-runs the collinearity test on the same bytes before it will draw them.

§5.2 · The verdicts

ClaimClassStrengthWhat it says
C1empirical-descriptionexploratoryon 11 × 11: 20 points at 20000 tests, 21 at 200000, 21 at 2000000 from the development block — and 22 from the sealed block at that same budget
C2empirical-descriptionexploratoryon 31 × 31: 50, 53, 54, and 55 sealed — it did not reach 62 at either seed; the same budget bought 19014 completions at the smaller instance and 2190 at this one
C3procedural-verdictconfirmed12 of 12 planted objects rejected, the known-valid object accepted at its predicted 11, and the one overclaiming run refused: reported 21.0 against verified 20.0, crash, ledger row NA
C4procedural-verdictconfirmedthe two lanes differ only in the seed and disagree about the maximum: 21 at evaluation 152572, against 22 at evaluation 1612132, at the same budget of 2000000
C5mechanism-interpretationexploratorya single run of a randomized heuristic reports a draw, not a property
C6–C9research-disciplineexploratorythe four lessons in §6

All seven registered predictions closed: six supported, one refuted, none inconclusive, none open.

§5.3 · The surprise, and what it does not license

P1 was written expecting the maximum at n = 11 and got 21. P6 was written expecting the same thing from a block nobody had touched, and got 22. The development trajectory found its best at evaluation 152572 and then spent the rest of 2000000 without improving, so "more budget" was demonstrably not the missing ingredient — the honest reading of the development lane alone ("this search plateaus at 21 here") was a statement about one draw wearing the costume of a statement about the search.

A difference, not a rate. Two seeds, one success. This study cannot say how often the search reaches 22, and does not. A registered seed sweep is the first item in §7 for exactly that reason.

P1 stays refuted and is not re-scoped by P6. Two predictions, two lanes, two verdicts — rewriting the first in the light of the second would delete the most informative thing the study measured.

§5.4 · Consequences for the bound

What the objects establish: a lower bound. The 22-point object attains 2n at n=11; the 55-point object is a lower bound on what this search reaches at n=31 and nothing more.

What they do not establish: nothing about the problem. The 21-point plateau and the 54/55-point results are search limits — facts about one algorithm under one budget from two named seeds — and the correct reading of every one of them is "did not reach", never "cannot". The study can say that with unusual confidence because the counterexample is inside it: the same search missed 22 from one seed and reached it from another. No upper bound is established or improved; the only one in play, 2n, was a theorem before the study began, which is precisely what headroom zero means.

§5.5 · The erratum, and why it is in the tutorial

The referee found that C6's locked sentence ends "and stayed sub-millisecond", and that C6's own pinned artifact refutes it: runs/E0010/verify.log, the file that supplies C6's 26235, records 0.002046 seconds beside it. Four of the ten verifier logs exceed a millisecond; sub-millisecond holds only for the 11 × 11 objects, where E0009 reads 0.000169.

The phrase came from the data card, which wrote it at Gate 1 as a pre-run cost estimate — before any run existed — and it was never re-checked once the logs existed. So: erratum E1 is filed against C6, the two measured seconds are now pinned numbers attached to it, and the findings and the knowledge entry quote them. C6's sentence itself is untouched, because claims.lock is append-only and an erratum re-scopes rather than rewrites — a reader sees both what was claimed and what was later learned.

Why it survived every mechanical check: "sub-millisecond" is a word, not a numeral, so klein verify --numbers was never looking at it. A numeral scan catches invented numbers; it does not catch an adjective that has quietly become a claim.

The lock and the gate keep their own tally of all of that — what is claimed, at what strength, with which errata attached, and what the referee made of it:

claims
9 locked in claims.lock
by strength
confirmed 2 · exploratory 7
by class
empirical-description 2 · mechanism-interpretation 1 · procedural-verdict 2 · research-discipline 4
errata
1 of 9 claims tagged · 1 erratum record(s) in the lock
locked at
7d55da17c43a · klein 2.0.0
label
exploratory
referee
PASS-WITH-NOTES — klein-referee (Claude Code subagent, model: claude-opus-5[1m]) · independent of the experimenter: no
confirmation gap · n_large
verify: track 'n_large' has no development run to reproduce (confirmation.require names verify)
confirmation gap · n_small
verify: track 'n_small' has no development run to reproduce (confirmation.require names verify)

§5.6 · Why the label above is not a shortfall

Arithmetic, not a shortfall. confirmation.require is [verify], which on a frontier track resolves to a re-verification record for the track's final keep. There are no keeps and there could not have been, so there is no incumbent to confirm, and the engine files the label it does. That label does not mean the objects are unverified: every development run carries a re-verification at tolerance 0, and the referee re-ran the declared verifier itself, in a fresh process, on the pinned object — and got 22.

6 · Search and verifier coding advice

Four lessons, each with the run that paid for it. They are the study's research-discipline claims, and they are what transfers.

§6.1 · Write the checker as the dumbest correct thing — C6

Here is the declared verifier, in full, as the bytes the METHOD gate hashed and the notary ran ten times. Read the check function: it is a sequence of refusals, then a loop over every triple.

verify.py · current file at build (outside the mutable surface) · sha256 959ba15bac56…
"""The declared verifier — the checker, never the searcher.

`klein run-one` runs this as a second bounded subprocess after the entrypoint
exits, with KLEIN_ARTIFACT pointing at the artifact the search produced, and
decides the run on the number THIS script prints. It is outside
study.yaml:entrypoint.mutable and is hashed at the METHOD gate: once E0001 has
run, a change here is refused.

Two design rules, and they are the whole point of the study:

1. **It shares no code with the search.** `lib/nothree.py` is never imported
   here and nothing here is importable from there. The search decides whether a
   candidate point is addable in O(k) by hashing normalized directions; this
   file re-derives the objective by enumerating every one of the C(k,3) triples
   and applying the integer cross-product test to each. The clever algorithm
   and the obvious one agreeing is evidence; one algorithm agreeing with itself
   would be a tautology.

2. **It is the dumbest correct thing.** No sampling, no early exit that could
   hide a triple, no floating point anywhere: `(b-a) x (c-a)` is an integer and
   the test is whether that integer is zero. C(62,3) = 37820 triples at the
   largest grid this study uses — a checker has no reason to be clever.

What it rejects, with exit code 2: a malformed artifact, a coordinate that is
not an integer, a point off the n x n grid, a repeated point, and any three
points on a common line. What it reports rather than rejects: `claim_excess`,
the searcher's own claimed objective minus the objective computed here. A
non-zero `claim_excess` is not the checker's business to punish — it is the
notary's, and it becomes a `verifier_disagreement` crash.
"""

from __future__ import annotations

import json
import os
import sys
import time
from itertools import combinations

from kleinlib.eval import evaluate_scalar


class Rejected(Exception):
    """The artifact is not a valid no-three-in-line configuration."""


def _load(artifact_path: str) -> dict:
    try:
        with open(artifact_path, encoding="utf-8") as handle:
            payload = json.load(handle)
    except (OSError, ValueError) as exc:
        raise Rejected(f"artifact is not readable JSON: {exc}") from exc
    if not isinstance(payload, dict):
        raise Rejected("artifact must be a JSON object")
    return payload


def _points(payload: dict, n: int) -> list[tuple[int, int]]:
    raw = payload.get("points")
    if not isinstance(raw, list):
        raise Rejected("artifact has no `points` list")
    points: list[tuple[int, int]] = []
    for index, item in enumerate(raw):
        if not isinstance(item, list) or len(item) != 2:
            raise Rejected(f"point {index} is not a [x, y] pair: {item!r}")
        x, y = item
        # bool is an int in Python; a lattice point is not True.
        for name, value in (("x", x), ("y", y)):
            if isinstance(value, bool) or not isinstance(value, int):
                raise Rejected(
                    f"point {index} has a non-integer {name} coordinate {value!r} — "
                    "a lattice point that is not one"
                )
        if not (0 <= x < n and 0 <= y < n):
            raise Rejected(f"point {index} = ({x}, {y}) is off the {n} x {n} grid")
        points.append((int(x), int(y)))
    if len(set(points)) != len(points):
        raise Rejected("the point list repeats a lattice point; a configuration is a set")
    return points


def check(artifact_path: str) -> tuple[float, dict[str, float]]:
    """Independently score the artifact; raise :class:`Rejected` on an invalid one.

    The controls live in `data/prepared/instances.json`, frozen at the DATA gate:
    a negative control (the Erdos parabola set, which this checker must ACCEPT
    and score at exactly 11) and twelve positive controls (planted invalid
    objects, on which this checker must FIRE). E0001 runs both batteries.
    """
    payload = _load(artifact_path)
    if payload.get("problem") != "no-three-in-line":
        raise Rejected(f"artifact declares problem {payload.get('problem')!r}")
    n = payload.get("n")
    if isinstance(n, bool) or not isinstance(n, int) or n < 1:
        raise Rejected(f"artifact declares a non-positive-integer grid size n={n!r}")
    points = _points(payload, n)

    triples = 0
    for a, b, c in combinations(points, 3):
        triples += 1
        cross = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0])
        if cross == 0:
            raise Rejected(f"points {a}, {b} and {c} are collinear")

    claimed = payload.get("claimed_objective")
    if isinstance(claimed, bool) or not isinstance(claimed, int):
        raise Rejected(
            "artifact does not state an integer `claimed_objective`; a searcher that "
            "will not say what it thinks it found cannot be audited"
        )
    objective = len(points)
    return float(objective), {
        "grid_n": float(n),
        "triples_checked": float(triples),
        "claim_excess": float(claimed - objective),
    }


def main() -> None:
    t0 = time.time()
    artifact_path = os.environ.get("KLEIN_ARTIFACT")
    if not artifact_path:
        raise RuntimeError(
            "verify.py is run by `klein run-one`, which sets KLEIN_ARTIFACT to the "
            "artifact the entrypoint declared."
        )
    try:
        value, extra = check(artifact_path)
    except Rejected as exc:
        print(f"REJECTED: {exc}")
        sys.exit(2)
    evaluate_scalar(
        value,
        exp_id=os.environ.get("KLEIN_EXPERIMENT_ID", "VERIFY"),
        # study_dir is deliberately NOT passed: aux_metrics.tsv is idempotent per
        # experiment id, so a verifier writing under the run's id would erase the
        # search telemetry the run just recorded. The verifier's own cost is on
        # the manifest as `verifier.wall_seconds`, where it belongs.
        study_dir=None,
        t0=t0,
        metric_name="points",
        metric_goal="higher",
        extra=extra,
    )


if __name__ == "__main__":
    main()

Things worth copying:

The cost of being dumb: 26235 cross products on the largest object, 0.002046 seconds. The benefit of being dumb is the planted control named parabola_plus_one — twelve points containing exactly one bad triple — which a checker that sampled triples would very likely have passed.

§6.2 · Freeze the controls before the checker meets them — C7

The twelve planted objects and the one known-valid object are written by prepare.py into the artifact the DATA gate hashes. The gate record carries its sha256; the file is regenerable from committed code and from nothing else.

payload = {
    "instances": {"n_small": {...}, "n_large": {...}},
    "seed_blocks": {"development": DEVELOPMENT_SEED, "sealed": SEALED_SEED},
    "budgets": BUDGETS,
    "controls": {
        "negative": {...},          # the Erdos parabola set, expected_objective = p
        "positive": {"count": 12, "objects": planted_invalid(N_SMALL)},
    },
}

It costs nothing to arrange and it removes a whole class of self-deception: a positive control that can be softened after it fails is not a control. The same file carries the seed blocks, which is how a study with no rows still gets a sealed access — and why no literal seed appears in any script this study owns.

§6.3 · Give the guard a test it can fail — C8

The per-experiment mutable surface is search.py, and a candidate is a cell: which mode, which rung of the frozen ladder. E0008's diff was three constants.

-CELL = "unassigned"        # the cell this candidate measures
-MODE = "search"            # controls | search | overclaim
-OVERCLAIM_BY = 0           # points to add to the SEARCH's self-report, not to the object
+CELL = "overclaim-by-one"  # the cell this candidate measures
+MODE = "overclaim"         # controls | search | overclaim
+OVERCLAIM_BY = 1           # points to add to the SEARCH's self-report, not to the object

One point of inflation — the smallest lie available — and the notary refused the run at tolerance: 0. If you ship a disagreement guard, spend one run proving it fires; documentation that a mechanism exists is not evidence that it works.

Here is the entrypoint the notary actually executed for the sealed n_small cell, E0009, in full — the honest surface, not E0008's inflated one. Note that it computes no objective that enters the ledger: it writes an object, states what it thinks that object is worth, and prints the artifact path the verifier will be pointed at.

search.py · executed by E0009 (final_test, track n_small) at commit f1edd1d9fa38 · sha256 15aef02dcadc…
"""Search for the object the verifier will grade.

This is the per-experiment mutable surface declared in study.yaml:entrypoint.
ONE falsifiable idea per candidate; `klein run-one` commits it before it runs.

A candidate here is a CELL: which mode, and which rung of the frozen budget
ladder. Everything else — the grid size, the seed blocks, the budget values, the
control objects — comes from `data/prepared/instances.json`, which the DATA gate
hashed, and the fixed machinery lives in `lib/nothree.py`. Nothing in this file
computes the objective that enters the ledger: it writes an object, states what
it thinks that object is worth, and the declared verifier decides.

  MODE = "controls"  -> run the frozen control battery against verify.py and
                        hand the notary the known-valid object (E0001)
  MODE = "search"    -> run the iterated local search at BUDGET (E0002-E0007,
                        E0009-E0010)
  MODE = "overclaim" -> search, then report OVERCLAIM_BY more points than the
                        object actually has (E0008, on purpose)
"""

from __future__ import annotations

import hashlib
import json
import os
import sys
import time
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parent))

from kleinlib.eval import evaluate_scalar  # noqa: E402
from lib.nothree import (  # noqa: E402
    Search,
    load_instances,
    run_verifier,
    write_planted,
    write_solution,
)

# --- the cell -------------------------------------------------------------
# Every candidate names its cell here and sets the three knobs below. The base
# state committed between runs is `unassigned`, so that the surface a discard
# restores is never itself a cell: on this study EVERY run is a discard (the
# frontier is seeded at the proven maximum), so without a cell label the surface
# would return to the previous candidate's exact configuration and `run-one`
# would rightly refuse the next one as an unchanged re-execution.
CELL = "n_small@2M-sealed"        # the cell this candidate measures
MODE = "search"            # controls | search | overclaim
BUDGET = "large"           # small | medium | large — a rung of the frozen ladder
OVERCLAIM_BY = 0           # points to add to the SEARCH's self-report, not to the object
# --------------------------------------------------------------------------

SMOKE = os.environ.get("KLEIN_SMOKE") == "1"
SEALED_DRYRUN = os.environ.get("KLEIN_SEALED_DRYRUN") == "1"
EXPERIMENT_ID = os.environ.get("KLEIN_EXPERIMENT_ID") or ("SMOKE" if SMOKE else None)
TRACK = os.environ.get("KLEIN_TRACK") or ("n_small" if SMOKE else None)


def seed_block(evaluation_kind: str) -> str:
    """Which frozen seed block this run may use — the analogue of a partition.

    `development` is the only block adaptive work may touch. `final_test`
    selects `sealed`, the block no development run has used, and that is the
    track's one sealed access. The sealed REHEARSAL
    (`klein run-one --final-test --dry-run`) must not touch it: like
    `kleinlib.data.load_partition`, it hands back the development block and
    prints `sealed_dryrun: 1` so a silent success cannot be mistaken for a pass.
    """
    if evaluation_kind not in {"development", "final_test"}:
        raise RuntimeError(f"invalid KLEIN_EVALUATION_KIND={evaluation_kind!r}")
    if evaluation_kind == "final_test" and SEALED_DRYRUN:
        print("sealed_dryrun: 1")
        return "development"
    return "sealed" if evaluation_kind == "final_test" else "development"


def block_fingerprint(track: str, n: int, block: str, seed: int) -> str:
    """What this study prints where a tabular study prints its partition hash.

    `data.split.kind` is `none`, so the DATA gate could realize no partition and
    the notary has nothing to compare against — it says so and proceeds. The
    fingerprint is printed anyway, because it is what makes each manifest carry
    a machine-readable record of WHICH seed block the run drew from: the sealed
    runs' manifests carry a different one from every development run's.
    """
    payload = json.dumps(
        {"track": track, "n": n, "block": block, "seed": seed},
        sort_keys=True,
        separators=(",", ":"),
    )
    return hashlib.sha256(payload.encode("utf-8")).hexdigest()


def controls(instances: dict, out_dir: Path) -> tuple[list[tuple[int, int]], int, dict]:
    """Run the frozen control battery against the DECLARED verifier.

    Positive control: every planted invalid object must be REJECTED (the
    detector must fire). Negative control: the known-valid Erdos parabola set is
    handed to the notary as this cell's own artifact, so the acceptance half is
    performed by the notary's own verifier invocation rather than by this file.
    """
    positive = instances["controls"]["positive"]["objects"]
    rejected = 0
    verdicts = []
    for obj in positive:
        path = write_planted(out_dir, obj)
        proc = run_verifier(path, study_dir=".", experiment_id=EXPERIMENT_ID or "CONTROL")
        fired = proc.returncode != 0
        rejected += fired
        verdicts.append((obj["name"], proc.returncode))
        print(f"control {obj['name']}: exit={proc.returncode} {'REJECTED' if fired else 'ACCEPTED'}")
    negative = instances["controls"]["negative"]
    points = [(int(x), int(y)) for x, y in negative["points"]]
    print(f"control {negative['name']}: handed to the notary as this cell's artifact")
    return points, negative["expected_objective"], {
        "planted": float(len(positive)),
        "rejected": float(rejected),
        "verdicts": verdicts,
    }


def main() -> None:
    t0 = time.time()
    evaluation_kind = os.environ.get("KLEIN_EVALUATION_KIND")
    if SMOKE:
        evaluation_kind = evaluation_kind or "development"
    missing = [
        name
        for name, value in (
            ("KLEIN_EVALUATION_KIND", evaluation_kind),
            ("KLEIN_EXPERIMENT_ID", EXPERIMENT_ID),
            ("KLEIN_TRACK", TRACK),
        )
        if value is None
    ]
    if missing:
        raise RuntimeError(
            "search.py must be invoked through `klein run-one`. For a pre-run "
            "syntax/shape check use `KLEIN_SMOKE=1 python search.py` — it prints "
            "the canonical block, writes no sidecars or snapshots, and is not "
            "evidence. Missing: " + ", ".join(missing)
        )

    instances = load_instances(".")
    n = int(instances["instances"][TRACK]["n"])
    block = seed_block(evaluation_kind)
    seed = int(instances["seed_blocks"][block])
    budget = int(instances["budgets"][BUDGET])
    if SMOKE:
        budget = 200

    out_dir = Path("models") / ("_smoke" if SMOKE else EXPERIMENT_ID)
    out_dir.mkdir(parents=True, exist_ok=True)

    extra: dict[str, float] = {}
    search_t0 = time.perf_counter()
    if MODE == "controls":
        points, claimed, control_extra = controls(instances, out_dir)
        extra["planted"] = control_extra["planted"]
        extra["rejected"] = control_extra["rejected"]
        extra["evaluations"] = 0.0
        extra["passes"] = 0.0
        extra["best_at_evaluation"] = 0.0
    else:
        result = Search(n=n, seed=seed, budget=budget).run()
        points = result.points
        claimed = result.objective + (OVERCLAIM_BY if MODE == "overclaim" else 0)
        extra["evaluations"] = float(result.evaluations)
        extra["passes"] = float(result.passes)
        extra["best_at_evaluation"] = float(result.best_at_evaluation)
    extra["search_seconds"] = time.perf_counter() - search_t0
    extra["grid_n"] = float(n)
    extra["budget"] = float(budget)
    extra["search_seed"] = float(seed)
    extra["sealed_block"] = 1.0 if block == "sealed" else 0.0
    extra["overclaim_by"] = float(OVERCLAIM_BY if MODE == "overclaim" else 0)
    extra["claimed_objective"] = float(claimed)
    extra["object_size"] = float(len(points))

    artifact = write_solution(
        out_dir / "solution.json",
        n=n,
        points=points,
        claimed_objective=claimed,
        meta={
            "mode": MODE,
            "track": TRACK,
            "seed_block": block,
            "budget_rung": BUDGET,
            "experiment": EXPERIMENT_ID,
        },
    )
    print(f"solution: {artifact.as_posix()}")

    evaluate_scalar(
        float(claimed),
        exp_id=EXPERIMENT_ID,
        study_dir=None if SMOKE else ".",
        t0=t0,
        metric_name="points",
        metric_goal="higher",
        split_fingerprint=block_fingerprint(TRACK, n, block, seed),
        extra=extra,
    )


if __name__ == "__main__":
    main()

§6.4 · Do the headroom arithmetic before the first run — C9

When the best known value equals a proven bound, the frontier is closed before it opens, and two divisions tell you so:

h_{\text{small}} = \frac{22 - 22}{1} = 0, \qquad h_{\text{large}} = \frac{62 - 62}{1} = 0

Klein discloses that at preflight and refuses development runs until the closed door is on the record. The acknowledgement is where a study says what it is for instead:

klein headroom ack --track n_small --acknowledged-by lead-agent \
  --note "run-anyway: the door is closed by a theorem, not by a losing phase. ...
          This study is not looking for an improvement; it is looking for an object
          that ATTAINS the known maximum, and for a record of who certified it."

§6.5 · Three pitfalls this study actually hit

  1. Every run restores the surface, so the base state must not be a cell. With zero keeps by construction, run-one restores search.py after every run — to the previous candidate's exact configuration, which it would then refuse as an unchanged re-execution. The fix is a CELL label whose base value ("unassigned") is never a cell any run uses.
  2. An adjective is not a numeral. "Sub-millisecond" travelled from a pre-run estimate on the data card into a locked claim, past every mechanical check, because no scan looks at words. Re-read your qualitative claims against the logs before you lock them. (§5.5; erratum E1.)
  3. The budget unit can hide the thing you are comparing. Counting addability tests is honest about cost and silent about effort: the same 2000000 tests bought 19014 greedy completions at n = 11 and 2190 at n = 31. If two instances are to be compared, register the unit that makes them comparable.

7 · Next steps & references

§7.1 · What to try next

  1. Register a seed sweep at n = 11 and the largest budget. The cheapest and the most important. E0004 and E0009 differ only in the seed and land on opposite sides of the proven maximum, so the quantity this study could not measure is the success rate — and a rate is exactly what a registered measurement sweep is for (klein sweep register, every trial to a sidecar). Thirty seeds at about a second each would turn C5 from an observation into a number.
  2. Locate where the reach breaks. The two instances are far apart: the maximum is reachable at one, out of reach at the other, and everything between is unmeasured. A third instance around n = 19 — the size at which integer programming is still provably optimal (ref:ramanathan2025) — would say whether the fall-off is a cliff or a slope. It needs a third track declared at CONSULT, which is exactly why this study did not add one after seeing its results.
  3. Budget in passes, not evaluations. Register the ladder in greedy completions so the two instances are compared at equal search effort rather than equal cost, and the pair of ladders side by side separates "the instance is harder" from "the budget bought less".
  4. Change the perturbation. The current move removes one to three random points; a move that removes a whole row's pair respects the structure a 2n configuration must have. That is a change to lib/, which this study may not make mid-loop, so it belongs to a follow-up whose predictions cite 11-exact-verifier-construction#C1 and #C5.

§7.2 · What was promoted to knowledge/

Four typed citations now seed knowledge/domains/math/, this repository's first entries for the math profile: the checker-independence rule (#C6), freezing controls and testing the guard (#C7, #C8), reading a heuristic's miss as a draw rather than a property (#C5, #C4), and doing the headroom arithmetic first (#C9). Each carries the erratum where one applies.

§7.3 · References

Ten, every one checked on 2026-09-03 — but not all the same way, and references.yaml records which is which in each entry's verified_by. Four were read at the source; six were checked against a bibliography (the Wikipedia article's reference list, or MathWorld's) rather than against the work itself. Both entries the contract leans on are in the first group.

KeyWorkChecked againstRelied on for
flammenkamp_recordsFlammenkamp, the maintained no-three-in-line record pagethe page itselfthe external incumbent on both tracks: solutions attaining the maximum are known for every grid size up to 70
mathworld_no3Weisstein, "No-Three-in-a-Line Problem", MathWorldthe page itselfthe independent second source for the same values, and a citation for the upper bound
ramanathan2025Ramanathan et al., "Three methods, one problem: classical and AI approaches to no-three-in-line", arXiv:2512.11469the arXiv abstract pagethe closest modern comparison: integer programming provably optimal to 19 × 19, a transformer matching it to 14 × 14, a PPO agent solving 10 × 10 and failing at 11 × 11
lourenco2019Lourenço, Martin & Stützle, "Iterated local search: framework and applications", Handbook of Metaheuristics 3rd ed.the Springer chapter pagethe search skeleton §2.4 implements
roth1951Roth, "On a problem of Heilbronn", J. London Math. Soc.Wikipedia's bibliographywhere Erdős's parabola construction is published — the negative control, and its proof
guy1968Guy & Kelly, "The no-three-in-line problem", Canad. Math. Bull.MathWorld's bibliographythe conjecture that the maximum is eventually unattainable — why a search failure is never evidence about the problem
hall1975Hall, Jackson, Sudbery & Wild, "Some advances in the no-three-in-line problem", JCTAWikipedia's bibliographythe hyperbola construction: the constructive yardstick a heuristic should be read against
flammenkamp1992, flammenkamp1998Flammenkamp, "Progress in the no-three-in-line problem" I and II, JCTAWikipedia's bibliographythe computational record papers
dudeney1900Dudeney, the original puzzle, The Weekly DispatchWikipedia, cross-checked against MathWorldprovenance of the problem

§7.4 · How to check this study yourself

Nothing here needs a model in the loop. From the repository root:

uv run --locked python studies/11-exact-verifier-construction/prepare.py
uv run --locked klein verify --study studies/11-exact-verifier-construction --numbers --evidence-use
uv run --locked klein claims verify --study studies/11-exact-verifier-construction --numbers
uv run --locked python studies/11-exact-verifier-construction/figures/make_figures.py

# and the check this study exists to make checkable — score the object yourself:
cd studies/11-exact-verifier-construction
KLEIN_ARTIFACT=models/E0009/solution.json uv run --locked python -u verify.py

The last command runs the same verify.py the METHOD gate hashed, in a fresh process, on the committed bytes of the object. It should print the same integer the ledger holds. The referee did exactly that, and it did.