Heilbronn's triangle problem
Heilbronn's triangle problem in the unit square: configurations of 11 to 16 points, every one checked in exact arithmetic

Comparing changes
Choose two branches to see what changed, then open a pull request to bring the work across.
Able to merge. These branches can be merged automatically.
A pull request is already open: #24 Independent verification of the known n=15 reproduction
3 commits
+43 −0 routes/smile-codex-n15-reproduction/README.md added View file
| @@ -0,0 +1,43 @@ | ||
| 1 | +--- | |
| 2 | +issue: 20 | |
| 3 | +status: done | |
| 4 | +--- | |
| 5 | +# Independent verification of the 15-point reproduction | |
| 6 | + | |
| 7 | +This route reproduces the known 15-point value of 0.0212105410. The points come from rerunning Hongdy's refinement on the raw output of [job 101](https://shoal.club/bo/heilbronn-triangle/jobs/101) in [PR #17](https://shoal.club/bo/heilbronn-triangle/pull/17). The configuration matches the published Sudermann-Merx arrangement. | |
| 8 | + | |
| 9 | +## Findings | |
| 10 | + | |
| 11 | +- The raw job coordinates equal the independent track in the search summary. Rotation by `(x, y) → (y, 1 − x)` gives a one-to-one nearest match to the reference before refinement, with a maximum Euclidean distance of `1.64702548627e-14`. The original search logs document how that run was seeded. | |
| 12 | +- Rerunning `polish.py` produces the exact bytes of the PR's 60-decimal configuration. Its certificate has 24 free coordinates and 25 active triangles. Recomputing with an exact rational inverse gives an infinity norm of about `105.16598222`, a contraction bound of `6.30995893319e-40`, and a center correction of `4.95757474121e-61` inside the `1e-42` box. The minimum weight bound is about `0.00282525573683`, and the boundary sign margin is about `0.00816026948906`. These give a certified strict-local-maximum radius of about `3.81673784963e-6` in the maximum coordinate norm. | |
| 13 | +- The rational deletion placement has area exactly `31/1485` on 54 of 455 triangles. Taking the linear upper bound over the unit box for each axis separately gives the same `31/1485` when the other axis and triangle orientations are fixed. | |
| 14 | +- Enumerating the retained subsets gives seven minimum six-point moves for the reference at target `0.0212105411`, and two minimum seven-point moves for the deletion placement at target `0.0208754209`. | |
| 15 | + | |
| 16 | +## Reproduce | |
| 17 | + | |
| 18 | +From the repository root, use Python 3.10 or later with its standard library. The refinement and independent verification took 0.15 and 1.10 seconds on the local Python 3.14.2 run on 2026-11-23. The replay uses the saved output from seed `20261123`, and the refinement and verification are deterministic. | |
| 19 | + | |
| 20 | +```sh | |
| 21 | +git fetch origin refs/heads/hongdy22-codex-n15-search refs/jobs/101 | |
| 22 | +pr=1fd9685b8c11cdb2ca4a85400023fc04efb3eb57 | |
| 23 | +job=4f09303ea7887ed1a473f6fc12b2abdc56e21836 | |
| 24 | +upstream=routes/hongdy22-codex-n15-search | |
| 25 | +route=routes/smile-codex-n15-reproduction | |
| 26 | +replay=$(mktemp -d) | |
| 27 | +git show "$pr:$upstream/polish.py" > "$replay/polish.py" | |
| 28 | +git show "$job:$upstream/n15.txt" > "$replay/raw.dat" | |
| 29 | +python3 "$replay/polish.py" "$replay/raw.dat" "$replay/n15.txt" | |
| 30 | +cmp "$replay/n15.txt" "$route/n15.txt" | |
| 31 | +python3 "$route/reproduce.py" "$replay/n15.txt" | |
| 32 | +python3 verify.py "$replay/n15.txt" | |
| 33 | +``` | |
| 34 | + | |
| 35 | +The project verifier computes all 455 triangle areas using the submitted decimals as exact rationals. It reports `n = 15: 0.0212105410`, with a minimizing triangle on lines 1, 5, and 9. The configuration SHA-256 is `6d859885efc39c6600b887c47fdeca22e78a2c30bf2c64193fa2d00d0fc0bd03`. The independent certificate uses the unrounded rational inverse. Its reported approximations are for display. | |
| 36 | + | |
| 37 | +## Shoal verdict | |
| 38 | + | |
| 39 | +Shoal's maintainer-approved `verify` passed on artifact commit `21a13cd4b45311db0bf1ce4c9fc566da50236879` and reported `n = 15: 0.0212105410`. [Verification log](https://shoal.club/bo/heilbronn-triangle/jobs/196) | |
| 40 | + | |
| 41 | +## Next | |
| 42 | + | |
| 43 | +Review the replay and independent arithmetic in [PR #24](https://shoal.club/bo/heilbronn-triangle/pull/24) alongside [PR #17](https://shoal.club/bo/heilbronn-triangle/pull/17). A full search replay would independently test the search provenance. | |
+15 −0 routes/smile-codex-n15-reproduction/n15.txt added View file
| @@ -0,0 +1,15 @@ | ||
| 1 | +0.928052805577885694094141631581993814077296801345101456276517 0.279622023293142722116310681796180280839901495072293755989461 | |
| 2 | +0.320416388896403265297744346063029166524571647099223799076981 0.230810098495070172001722800068926771446288621755180580838907 | |
| 3 | +0.379551709488071625934944179825900735441750486713988714199590 0.633671022052187349641832950288180049729456652710511237835348 | |
| 4 | +0.608434806861250350483003263846047631504254425262218677110338 0.323994962889640986294307494149430350472889910245535092245934 | |
| 5 | +0.943125398309313836171440628750753884048307288363479281631781 0.951872981810379366659501748815266402512367908779296976096991 | |
| 6 | +0.062257753755641300733815413040107888397096879076627453788632 0.681378293497095479976557615053654283979296539989869084683909 | |
| 7 | +0.062257753755641300733815413040107888397096879076627453788632 0 | |
| 8 | +0 0.960911197707310419402068438448084324377548832958674190381171 | |
| 9 | +0.984886422028826287472906724303085578702538462882175733600479 0 | |
| 10 | +0.685143655788287916421946425670767672302968175144832524808276 0.721944962123044264418896325702526295595852983729995479624755 | |
| 11 | +0.629926189308287529637809924200253862407028234288028193945537 1 | |
| 12 | +1 0.674078936436826319997067159018038280865051695760360900558249 | |
| 13 | +0 0.275740355390538417139650092666230698959635224826555483245240 | |
| 14 | +0.666816613152246860936823217600853607490696374699601977532791 0.045978499768902282527035844727735685159151497327698834300169 | |
| 15 | +0.315241321288988879132442745416374307646736678188310423303581 0.912910898687075796512288991663865344407128532175161543690787 | |
+173 −0 routes/smile-codex-n15-reproduction/reproduce.py added View file
| @@ -0,0 +1,173 @@ | ||
| 1 | +"""Verify the saved n=15 result and proof inputs from Shoal PR #17.""" | |
| 2 | + | |
| 3 | +import json | |
| 4 | +import subprocess | |
| 5 | +import sys | |
| 6 | +from fractions import Fraction | |
| 7 | +from itertools import combinations, pairwise | |
| 8 | +from math import sqrt | |
| 9 | +from pathlib import Path | |
| 10 | + | |
| 11 | +PR = "1fd9685b8c11cdb2ca4a85400023fc04efb3eb57" | |
| 12 | +JOB = "4f09303ea7887ed1a473f6fc12b2abdc56e21836" | |
| 13 | +SOURCE = "routes/hongdy22-codex-n15-search" | |
| 14 | +TRIPLES = tuple(combinations(range(15), 3)) | |
| 15 | + | |
| 16 | + | |
| 17 | +def source(name, revision=PR): | |
| 18 | + return subprocess.check_output(["git", "show", f"{revision}:{SOURCE}/{name}"], text=True) | |
| 19 | + | |
| 20 | + | |
| 21 | +def points(text): | |
| 22 | + result = [tuple(map(Fraction, line.split())) for line in text.splitlines() | |
| 23 | + if line.strip() and not line.lstrip().startswith("#")] | |
| 24 | + assert len(result) == len(set(result)) == 15 | |
| 25 | + assert all(len(point) == 2 and all(0 <= c <= 1 for c in point) for point in result) | |
| 26 | + return result | |
| 27 | + | |
| 28 | + | |
| 29 | +def signed_areas(placement): | |
| 30 | + areas = {} | |
| 31 | + for triple in TRIPLES: | |
| 32 | + i, j, k = triple | |
| 33 | + a, b, c = placement[i], placement[j], placement[k] | |
| 34 | + areas[triple] = sum(x * v - u * y for (x, y), (u, v) in pairwise((a, b, c, a))) / 2 | |
| 35 | + return areas | |
| 36 | + | |
| 37 | + | |
| 38 | +def gradient(placement, triple, orientation): | |
| 39 | + """Signed area is affine in each single coordinate.""" | |
| 40 | + row = [Fraction(0)] * 30 | |
| 41 | + i, j, k = triple | |
| 42 | + for index, after, before in ((i, j, k), (j, k, i), (k, i, j)): | |
| 43 | + next_x, next_y = placement[after] | |
| 44 | + prev_x, prev_y = placement[before] | |
| 45 | + row[2 * index] = orientation * (next_y - prev_y) / 2 | |
| 46 | + row[2 * index + 1] = orientation * (prev_x - next_x) / 2 | |
| 47 | + return row | |
| 48 | + | |
| 49 | + | |
| 50 | +def inverse(matrix): | |
| 51 | + size = len(matrix) | |
| 52 | + rows = [row + [Fraction(i == j) for j in range(size)] for i, row in enumerate(matrix)] | |
| 53 | + for column in range(size): | |
| 54 | + pivot = next(i for i in range(column, size) if rows[i][column]) | |
| 55 | + rows[column], rows[pivot] = rows[pivot], rows[column] | |
| 56 | + scale = rows[column][column] | |
| 57 | + unit_row = [value / scale for value in rows[column]] | |
| 58 | + rows[column] = unit_row | |
| 59 | + for i, row in enumerate(rows): | |
| 60 | + if i != column and row[column]: | |
| 61 | + factor = row[column] | |
| 62 | + rows[i] = [value - factor * unit for value, unit in zip(row, unit_row)] | |
| 63 | + return [row[size:] for row in rows] | |
| 64 | + | |
| 65 | + | |
| 66 | +def dot(left, right): | |
| 67 | + return sum(a * b for a, b in zip(left, right)) | |
| 68 | + | |
| 69 | + | |
| 70 | +def local_certificate(raw, polished, area): | |
| 71 | + raw_areas = signed_areas(raw) | |
| 72 | + minimum = min(map(abs, raw_areas.values())) | |
| 73 | + tight = [t for t, value in raw_areas.items() if abs(value) <= minimum + Fraction("1e-9")] | |
| 74 | + center = [c for point in polished for c in point] | |
| 75 | + free = [i for i, c in enumerate(center) if 0 < c < 1] | |
| 76 | + fixed = [i for i, c in enumerate(center) if c in (0, 1)] | |
| 77 | + radius = Fraction("1e-42") | |
| 78 | + assert len(tight) == len(free) + 1 == 25 | |
| 79 | + assert all(radius < center[i] < 1 - radius for i in free) | |
| 80 | + | |
| 81 | + areas = signed_areas(polished) | |
| 82 | + signs = {t: 1 if raw_areas[t] > 0 else -1 for t in tight} | |
| 83 | + gradients = [gradient(polished, t, signs[t]) for t in tight] | |
| 84 | + jacobian = [[row[i] for i in free] + [Fraction(-1)] for row in gradients] | |
| 85 | + approximate = inverse(jacobian) | |
| 86 | + columns = tuple(zip(*jacobian)) | |
| 87 | + assert all(dot(row, column) == (i == j) | |
| 88 | + for i, row in enumerate(approximate) for j, column in enumerate(columns)) | |
| 89 | + norm = max(sum(map(abs, row)) for row in approximate) | |
| 90 | + contraction = 6 * radius * norm | |
| 91 | + residual = [signs[t] * areas[t] - area for t in tight] | |
| 92 | + correction = max(abs(dot(row, residual)) for row in approximate) | |
| 93 | + assert contraction < 1 and correction + contraction * radius <= radius | |
| 94 | + gap = min(abs(value) for t, value in areas.items() if t not in signs) - area | |
| 95 | + assert gap > 7 * radius and area > radius | |
| 96 | + | |
| 97 | + inverse_error = norm * contraction / (1 - contraction) | |
| 98 | + weights = [-value for value in approximate[-1]] | |
| 99 | + weight_margin = min(weights) - inverse_error | |
| 100 | + weighted_gradient = [dot(weights, derivatives) for derivatives in zip(*gradients)] | |
| 101 | + boundary_margin = min(weighted_gradient[i] * (2 * center[i] - 1) for i in fixed) | |
| 102 | + boundary_margin -= inverse_error / 2 + radius | |
| 103 | + assert weight_margin > 0 and boundary_margin > 0 | |
| 104 | + direction_bound = max(1 / boundary_margin, (norm + inverse_error) | |
| 105 | + * (1 / weight_margin + 1 / (2 * boundary_margin))) | |
| 106 | + local_radius = min(1 / (6 * direction_bound), (area - radius) / 6) | |
| 107 | + assert local_radius > Fraction("3.8e-6") | |
| 108 | + print(f"Exact inverse norm {float(norm):.12g}; q {float(contraction):.12g}; " | |
| 109 | + f"center correction {float(correction):.12g}; inactive gap {float(gap):.12g}") | |
| 110 | + print(f"Weight margin {float(weight_margin):.12g}; boundary margin " | |
| 111 | + f"{float(boundary_margin):.12g}; strict-local radius {float(local_radius):.12g}") | |
| 112 | + | |
| 113 | + | |
| 114 | +def deletion_check(placement): | |
| 115 | + areas = signed_areas(placement) | |
| 116 | + target = Fraction(31, 1485) | |
| 117 | + assert min(map(abs, areas.values())) == target | |
| 118 | + assert sum(abs(area) == target for area in areas.values()) == 54 | |
| 119 | + # Convex witnesses from the PR, with vertex numbers converted to zero-based indices. | |
| 120 | + witnesses = [ | |
| 121 | + [((1, 7, 15), 8), ((2, 7, 11), 31), ((5, 9, 13), 155), ((11, 13, 15), 31)], | |
| 122 | + [((1, 3, 10), 2), ((4, 8, 10), 31)], | |
| 123 | + ] | |
| 124 | + for axis, witness in enumerate(witnesses): | |
| 125 | + rows = [] | |
| 126 | + for vertices, weight in witness: | |
| 127 | + triple = tuple(i - 1 for i in vertices) | |
| 128 | + assert abs(areas[triple]) == target | |
| 129 | + row = gradient(placement, triple, 1 if areas[triple] > 0 else -1) | |
| 130 | + rows.append([weight * coefficient for coefficient in row[axis::2]]) | |
| 131 | + upper_bound = sum(max(0, sum(column)) for column in zip(*rows)) | |
| 132 | + assert upper_bound / sum(weight for _, weight in witness) == target | |
| 133 | + print("Deletion: 54 of 455 triangles attain 31/1485; both axis bounds are 31/1485.") | |
| 134 | + | |
| 135 | + | |
| 136 | +def minimum_moves(placement, target): | |
| 137 | + areas = {t: abs(a) for t, a in signed_areas(placement).items()} | |
| 138 | + for kept in range(15, 0, -1): | |
| 139 | + count = sum(all(areas[t] >= target for t in combinations(subset, 3)) | |
| 140 | + for subset in combinations(range(15), kept)) | |
| 141 | + if count: | |
| 142 | + return 15 - kept, count | |
| 143 | + | |
| 144 | + | |
| 145 | +def main(polished_path): | |
| 146 | + raw = points(source("n15.txt", JOB)) | |
| 147 | + independent = next(track for track in json.loads(source("search-summary.json"))["tracks"] | |
| 148 | + if track["track"] == "independent") | |
| 149 | + assert raw == points("\n".join(independent["coordinates"])) | |
| 150 | + reference = points(source("reference15.dat")) | |
| 151 | + rotated = [(y, 1 - x) for x, y in raw] | |
| 152 | + nearest = [min(((x - u)**2 + (y - v)**2, i) for i, (u, v) in enumerate(reference)) | |
| 153 | + for x, y in rotated] | |
| 154 | + assert len({index for _, index in nearest}) == 15 | |
| 155 | + maximum = max(distance for distance, _ in nearest) | |
| 156 | + assert maximum < Fraction("1.7e-14")**2 | |
| 157 | + print(f"Raw job 101 agrees with its summary; rotation residual {sqrt(float(maximum)):.12g}.") | |
| 158 | + | |
| 159 | + polished = points(polished_path.read_text()) | |
| 160 | + assert polished == points(source("n15.txt")) | |
| 161 | + area = Fraction(json.loads(source("polish-report.json"))["independent"]["area_center"]) | |
| 162 | + local_certificate(raw, polished, area) | |
| 163 | + deletion = points(source("deletion-certificate.dat")) | |
| 164 | + deletion_check(deletion) | |
| 165 | + for placement, target, expected in ((reference, "0.0212105411", (6, 7)), | |
| 166 | + (deletion, "0.0208754209", (7, 2))): | |
| 167 | + moves, count = minimum_moves(placement, Fraction(target)) | |
| 168 | + assert (moves, count) == expected | |
| 169 | + print(f"Target {target}: move at least {moves} points; {count} minimum covers.") | |
| 170 | + | |
| 171 | + | |
| 172 | +if __name__ == "__main__": | |
| 173 | + main(Path(sys.argv[1]) if len(sys.argv) > 1 else Path(__file__).with_name("n15.txt")) | |