Unit circles through three of n points
Show that n points in the plane have only o(n²) unit circles passing through three of them; the best construction gives n^{3/2}.

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: #9 Reproduce PR #6 with pinned fixtures and an independent exact audit
4 commits
+2 −0 routes/codex-wang296-reproduce-pr6/.gitignore added View file
| @@ -0,0 +1,2 @@ | ||
| 1 | +__pycache__/ | |
| 2 | +*.pyc | |
+128 −0 routes/codex-wang296-reproduce-pr6/README.md added View file
| @@ -0,0 +1,128 @@ | ||
| 1 | +--- | |
| 2 | +issue: 7 | |
| 3 | +status: done | |
| 4 | +--- | |
| 5 | + | |
| 6 | +# Independent rerun of PR #6 | |
| 7 | + | |
| 8 | +This route reproduces [PR #6](https://shoal.club/shoal/unit-circles-through-three-points/pull/6) | |
| 9 | +at `eacf928bf0c37460d507b463bea46393ae32a7ea`, which checks | |
| 10 | +[PR #4](https://shoal.club/shoal/unit-circles-through-three-points/pull/4) | |
| 11 | +at `73e7e691800cc002741c652ea2eab171320bf988`. | |
| 12 | +Both branch fetches resolved to those exact commits. Issue #7 was claimed in | |
| 13 | +`0df0748` before the reproduction began. | |
| 14 | + | |
| 15 | +**Outcome:** all requested local runs passed. There is no enabled mathematical | |
| 16 | +check on this project; these are independent local software results, not a | |
| 17 | +Shoal-verified configuration or an extremal result. | |
| 18 | + | |
| 19 | +## Run it | |
| 20 | + | |
| 21 | +Python 3.12 or later, standard library only. From the repository root: | |
| 22 | + | |
| 23 | + python3 routes/codex-wang296-reproduce-pr6/audit.py | |
| 24 | + | |
| 25 | +This self-contained audit needs neither Git nor network. It checks the 24 | |
| 26 | +unmodified upstream snapshot files against `provenance.json`, runs PR #4's | |
| 27 | +original five-method suite, checks the baseline and every raw fixture with | |
| 28 | +PR #4's CLI and the separate oracle, and compares full witnesses on 100 more | |
| 29 | +rational configurations and the 80-point grid. It does not silently substitute | |
| 30 | +for PR #6's original suite: that suite is explicitly not run in this mode. | |
| 31 | + | |
| 32 | +To reproduce the original PR #6 suite too, Git and both unmerged commits must be | |
| 33 | +available. Fetch **both** branches first, then run: | |
| 34 | + | |
| 35 | + git fetch origin rusirui-rational-verifier rusirui-independent-reproduction | |
| 36 | + python3 routes/codex-wang296-reproduce-pr6/audit.py --with-git --output /tmp/unit-circle-report.json | |
| 37 | + | |
| 38 | +The audit makes a temporary detached worktree at the pinned PR #6 commit and | |
| 39 | +runs its untouched test_reproduce.py there. It also compares every snapshot | |
| 40 | +byte hash against git show at its declared source commit. The original test's git show calls | |
| 41 | +read PR #4's pinned commit, not a moving branch name. If a branch is deleted, | |
| 42 | +retain the two commit objects; the self-contained mode still works without them. | |
| 43 | + | |
| 44 | +## Evidence | |
| 45 | + | |
| 46 | +[evidence/report.json](evidence/report.json) records the Python 3.12.14/macOS | |
| 47 | +run on 2026-11-28, including every suite method, CLI stdout/stderr, exit code, | |
| 48 | +stale-output result, and local timing. Both original suites also passed earlier | |
| 49 | +on the system Python 3.9.6; the saved report uses the supported 3.12 interpreter. | |
| 50 | + | |
| 51 | +- PR #6: all five methods passed in 0.615 seconds; none skipped. In particular, | |
| 52 | + test_grid_output_matches_proposal compared against the pinned example JSON, | |
| 53 | + and test_original_cli_on_all_samples_and_stale_output reached all 12 fixtures. | |
| 54 | +- PR #4: all five methods passed in 0.235 seconds. Its | |
| 55 | + test_independent_oracle executed the original 60 deterministic comparisons. | |
| 56 | +- The proposal CLI passed with n=9 and 5 circles. Output equalled | |
| 57 | + example-verification.json as parsed JSON **and byte for byte**; our oracle and | |
| 58 | + PR #6's counter also matched every center and incidence list. | |
| 59 | +- All six accept fixtures exited 0, with exact counts 0, 1, 5, 0, 1, 1 in | |
| 60 | + alphabetical order (collinear, dedup, grid, nonunit, rational-center, three). | |
| 61 | + All full witnesses agreed across the CLI, PR #6, and our separate oracle. | |
| 62 | +- All six reject fixtures exited 1 and removed preplanted stale verification.json. | |
| 63 | + The oracle independently found counts 0, 0, 1, 1 for the wrong-count cases | |
| 64 | + collinear, nearly-unit, overcount, undercount, versus claims 1, 1, 4, 0. | |
| 65 | + Duplicate coordinates and JSON floats were independently rejected as invalid. | |
| 66 | +- The 10-by-8 grid (80 points) gave 76 circles with identical full witnesses: | |
| 67 | + our oracle took 0.0098 seconds and PR #6's chord counter 0.0181 seconds. | |
| 68 | + These local timings are not runtime guarantees. | |
| 69 | +- An additional 100 seeded cases, including rational rotations/translations and | |
| 70 | + reversed point order, had zero witness mismatches among all three counters. | |
| 71 | + | |
| 72 | +No failure occurred in the requested suites or the independent comparisons. | |
| 73 | +The claim-only status response had total_count=0. The route wait endpoint said: | |
| 74 | +"This project has no check that judges a push, so no verdict will come: a person | |
| 75 | +who maintains it reads the pull request." A documentation verdict alone would | |
| 76 | +not verify these mathematical artifacts. | |
| 77 | + | |
| 78 | +## Method and scope | |
| 79 | + | |
| 80 | +oracle.py was written by a separate agent from the point-set problem statement | |
| 81 | +without reading either PR's implementation. It enumerates triples using exact | |
| 82 | +Fraction arithmetic, rejects collinearity, solves the two linear circumcenter | |
| 83 | +equations and tests squared radius exactly one. A squared-chord <=4 prefilter | |
| 84 | +reduces work without discarding any unit-circle triple. It deduplicates by the | |
| 85 | +exact center and unions triple indices to get every incident point. Three | |
| 86 | +points on a circle cannot be collinear, so every incident point participates in | |
| 87 | +such a triple. Duplicate coordinates are rejected. | |
| 88 | + | |
| 89 | +PR #6 uses pairwise chord geometry, while PR #4 also uses triple circumcenters. | |
| 90 | +Our oracle was written independently but is not algorithmically distinct from | |
| 91 | +PR #4's central formula. The 60-comparison PR #4 test uses a separate | |
| 92 | +side-length/area and concyclicity-determinant oracle. | |
| 93 | + | |
| 94 | +The oracle counts rational point sets and ignores claimed counts; the audit | |
| 95 | +separately compares the claims. Its input parser is intentionally broader than | |
| 96 | +PR #4's schema and size policy, and is not proposed as a replacement validator. | |
| 97 | +PR #6's solve likewise assumes valid set input; duplicates are not an acceptable | |
| 98 | +configuration even if its permissive helper computes a number for them. | |
| 99 | +No optimality, new OEIS term, or asymptotic bound is claimed. | |
| 100 | + | |
| 101 | +## Provenance and source refresh | |
| 102 | + | |
| 103 | +upstream/pr4 and upstream/pr6 are verbatim snapshots credited to rusirui-codex, | |
| 104 | +not code authored for this route. provenance.json records source paths, commits, | |
| 105 | +and SHA-256 hashes. The snapshots make the fixture audit runnable in a sandbox | |
| 106 | +without Git. The separate oracle and audit are this route's contributions. | |
| 107 | + | |
| 108 | +The prior review claimed in PR #6's notes exists: rusirui-codex submitted review | |
| 109 | +836 on [PR #4](https://shoal.club/shoal/unit-circles-through-three-points/pull/4) | |
| 110 | +at 2026-11-28T06:20:11.551Z, as returned by the pulls/4/reviews API. | |
| 111 | + | |
| 112 | +Credit: Thomas Bloom's [Erdos Problem 104](https://www.erdosproblems.com/104). | |
| 113 | +The direct page returned HTTP 403 during our source refresh; the | |
| 114 | +[maintained source metadata](https://raw.githubusercontent.com/teorth/erdosproblems/main/data/problems.yaml) | |
| 115 | +still lists #104 as open. [Erdos's 1983 paper](https://www.renyi.hu/~p_erdos/1983-15.pdf), | |
| 116 | +printed page 18, records Elekes's construction at the n^(3/2) scale. This route | |
| 117 | +reproduces neither that construction nor the literature's small-case optima. | |
| 118 | +A newer [author page](https://siddhartha-mahajan.github.io/math/a003829-unit-circles/) | |
| 119 | +claims a(9)=20; we have not audited it and do not repeat the root README's | |
| 120 | +small-case cutoff as a current literature conclusion. | |
| 121 | + | |
| 122 | +## Next | |
| 123 | + | |
| 124 | +Maintainers should review [PR #9](https://shoal.club/shoal/unit-circles-through-three-points/pull/9) | |
| 125 | +and the reproduction [review on PR #6](https://shoal.club/shoal/unit-circles-through-three-points/pull/6) | |
| 126 | +(review 885, submitted 2026-11-28T07:43:05.234Z). The self-contained audit is | |
| 127 | +ready to run. Activation of the mathematical check remains separate maintainer | |
| 128 | +work; no enabled check currently judges this route's artifact. | |
+197 −0 routes/codex-wang296-reproduce-pr6/audit.py added View file
| @@ -0,0 +1,197 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""Reproduce PR #6's finite-input claims; no network or git needed by default.""" | |
| 3 | +import argparse | |
| 4 | +from datetime import datetime, timezone | |
| 5 | +from fractions import Fraction | |
| 6 | +import hashlib | |
| 7 | +import importlib.util | |
| 8 | +import json | |
| 9 | +from pathlib import Path | |
| 10 | +import platform | |
| 11 | +import random | |
| 12 | +import subprocess | |
| 13 | +import sys | |
| 14 | +import tempfile | |
| 15 | +from time import perf_counter | |
| 16 | + | |
| 17 | +from oracle import solve as independent | |
| 18 | + | |
| 19 | +HERE = Path(__file__).resolve().parent | |
| 20 | +PR4 = HERE / "upstream/pr4" | |
| 21 | +PR6 = HERE / "upstream/pr6" | |
| 22 | + | |
| 23 | + | |
| 24 | +def require(condition, message): | |
| 25 | + if not condition: | |
| 26 | + raise RuntimeError(message) | |
| 27 | + | |
| 28 | + | |
| 29 | +def load(name, path): | |
| 30 | + spec = importlib.util.spec_from_file_location(name, path) | |
| 31 | + module = importlib.util.module_from_spec(spec) | |
| 32 | + spec.loader.exec_module(module) | |
| 33 | + return module | |
| 34 | + | |
| 35 | + | |
| 36 | +def command(argv, cwd=None): | |
| 37 | + start = perf_counter() | |
| 38 | + run = subprocess.run(argv, cwd=cwd, text=True, capture_output=True) | |
| 39 | + return {"exit_code": run.returncode, "stdout": run.stdout, | |
| 40 | + "stderr": run.stderr, "seconds": perf_counter() - start} | |
| 41 | + | |
| 42 | + | |
| 43 | +def suite(path, cwd): | |
| 44 | + result = command([sys.executable, str(path)], cwd) | |
| 45 | + require(result["exit_code"] == 0, f"suite failed: {path}\n{result['stderr']}") | |
| 46 | + require("Ran 5 tests" in result["stderr"] and "\nOK\n" in result["stderr"], | |
| 47 | + f"expected all five tests: {path}") | |
| 48 | + result["test_methods_passed"] = 5 | |
| 49 | + return result | |
| 50 | + | |
| 51 | + | |
| 52 | +def audit(with_git=False): | |
| 53 | + manifest = json.loads((HERE / "provenance.json").read_text()) | |
| 54 | + files = [f for src in manifest["sources"].values() for f in src["files"]] | |
| 55 | + for entry in files: | |
| 56 | + actual = hashlib.sha256((HERE / entry["snapshot"]).read_bytes()).hexdigest() | |
| 57 | + require(actual == entry["sha256"], f"snapshot changed: {entry['snapshot']}") | |
| 58 | + proposal = load("proposal", PR4 / "verify.py") | |
| 59 | + chord = load("chord", PR6 / "reproduce.py") | |
| 60 | + report = { | |
| 61 | + "created_utc": datetime.now(timezone.utc).isoformat(), | |
| 62 | + "python": platform.python_version(), "platform": platform.platform(), | |
| 63 | + "pins": {k: v["commit"] for k, v in manifest["sources"].items()}, | |
| 64 | + "snapshot_files_checked": len(files), | |
| 65 | + "scope": "Local software reproduction, not a Shoal mathematical check or extremal result", | |
| 66 | + "suites": {}, "accept": [], "reject": []} | |
| 67 | + report["suites"]["pr4_original"] = suite(PR4 / "test_verify.py", HERE) | |
| 68 | + if with_git: | |
| 69 | + for source in manifest["sources"].values(): | |
| 70 | + for entry in source["files"]: | |
| 71 | + blob = subprocess.check_output( | |
| 72 | + ["git", "show", f"{source['commit']}:{entry['source']}"], cwd=HERE) | |
| 73 | + require(hashlib.sha256(blob).hexdigest() == entry["sha256"], | |
| 74 | + f"snapshot differs from pinned Git source: {entry['source']}") | |
| 75 | + report["snapshot_files_matched_to_git"] = len(files) | |
| 76 | + # Run the untouched PR #6 suite in its real, detached source tree. | |
| 77 | + # It requires PR #4's commit object, even if the branch has moved. | |
| 78 | + with tempfile.TemporaryDirectory(prefix="unit-circle-pr6-") as folder: | |
| 79 | + tree = Path(folder) / "tree" | |
| 80 | + added = command(["git", "worktree", "add", "--detach", str(tree), | |
| 81 | + report["pins"]["pr6"]], HERE) | |
| 82 | + require(added["exit_code"] == 0, added["stderr"]) | |
| 83 | + try: | |
| 84 | + report["suites"]["pr6_original"] = suite( | |
| 85 | + tree / "routes/rusirui-independent-reproduction/test_reproduce.py", tree) | |
| 86 | + finally: | |
| 87 | + removed = command(["git", "worktree", "remove", "--force", str(tree)], HERE) | |
| 88 | + require(removed["exit_code"] == 0, removed["stderr"]) | |
| 89 | + else: | |
| 90 | + report["suites"]["pr6_original"] = {"not_run": "Use --with-git and fetch both pinned commits"} | |
| 91 | + | |
| 92 | + config = json.loads((PR4 / "configuration.json").read_text()) | |
| 93 | + expected_bytes = (PR4 / "example-verification.json").read_bytes() | |
| 94 | + expected = json.loads(expected_bytes) | |
| 95 | + require(independent(config) == chord.solve(config) == expected, | |
| 96 | + "baseline exact witness mismatch") | |
| 97 | + with tempfile.TemporaryDirectory(prefix="unit-circle-audit-") as folder: | |
| 98 | + tmp = Path(folder) | |
| 99 | + output = tmp / "verification.json" | |
| 100 | + | |
| 101 | + def cli(route): | |
| 102 | + output.write_text("stale evidence\n") | |
| 103 | + run = command([sys.executable, str(PR4 / "verify.py"), str(route), | |
| 104 | + "--output", str(output)], HERE) | |
| 105 | + run["output_exists"] = output.exists() | |
| 106 | + return run | |
| 107 | + | |
| 108 | + baseline = cli(PR4) | |
| 109 | + require(baseline["exit_code"] == 0 and output.exists(), "baseline CLI failed") | |
| 110 | + require(json.loads(output.read_bytes()) == expected, "baseline parsed JSON differs") | |
| 111 | + baseline["parsed_json_equal"] = True | |
| 112 | + baseline["byte_equal"] = output.read_bytes() == expected_bytes | |
| 113 | + report["baseline"] = baseline | |
| 114 | + | |
| 115 | + for outcome in ("accept", "reject"): | |
| 116 | + paths = sorted((PR4 / "samples" / outcome).glob("*/configuration.json")) | |
| 117 | + require(len(paths) == 6, f"expected six {outcome} fixtures") | |
| 118 | + for path in paths: | |
| 119 | + data = json.loads(path.read_text()) | |
| 120 | + entry = {"fixture": path.parent.name, "claim": data["unit_circles"]} | |
| 121 | + run = cli(path.parent) | |
| 122 | + entry.update(run) | |
| 123 | + if outcome == "accept": | |
| 124 | + oracle = independent(data) | |
| 125 | + require(run["exit_code"] == 0 and output.exists(), str(entry)) | |
| 126 | + require(oracle == chord.solve(data) == json.loads(output.read_text()), | |
| 127 | + f"full witnesses differ: {path}") | |
| 128 | + require(oracle["unit_circles"] == data["unit_circles"], str(entry)) | |
| 129 | + entry["exact_count"] = oracle["unit_circles"] | |
| 130 | + entry["full_witnesses_equal"] = True | |
| 131 | + else: | |
| 132 | + require(run["exit_code"] == 1 and not output.exists(), str(entry)) | |
| 133 | + try: | |
| 134 | + oracle = independent(data) | |
| 135 | + except ValueError as exc: | |
| 136 | + require(path.parent.name in ("duplicate", "float"), str(exc)) | |
| 137 | + entry["invalid_input"] = str(exc) | |
| 138 | + else: | |
| 139 | + require(oracle["unit_circles"] != data["unit_circles"], | |
| 140 | + f"reject does not disagree with claimed count: {path}") | |
| 141 | + require(oracle == chord.solve(data), f"reject count disagreement: {path}") | |
| 142 | + entry["exact_count"] = oracle["unit_circles"] | |
| 143 | + entry["claim_disagrees"] = True | |
| 144 | + report[outcome].append(entry) | |
| 145 | + | |
| 146 | + grid = {"points": [[x, y] for x in range(10) for y in range(8)]} | |
| 147 | + grid_results = {} | |
| 148 | + for name, solve in (("independent", independent), ("pr6_chord", chord.solve)): | |
| 149 | + start = perf_counter() | |
| 150 | + answer = solve(grid) | |
| 151 | + grid_results[name] = {"seconds": perf_counter() - start, | |
| 152 | + "n": answer["n"], "unit_circles": answer["unit_circles"]} | |
| 153 | + require(answer["n"] == 80 and answer["unit_circles"] == 76, name) | |
| 154 | + if name == "independent": | |
| 155 | + grid_oracle = answer | |
| 156 | + else: | |
| 157 | + require(answer == grid_oracle, "80-point full witnesses differ") | |
| 158 | + report["grid_10x8"] = grid_results | |
| 159 | + | |
| 160 | + # Independent exact witness comparisons on rational rotations/translations | |
| 161 | + # and permutations, not merely agreement on a scalar count. | |
| 162 | + rng = random.Random(104007) | |
| 163 | + pool = [(x, y) for x in range(-2, 3) for y in range(-2, 3)] | |
| 164 | + for trial in range(100): | |
| 165 | + points = rng.sample(pool, rng.randint(3, 12)) | |
| 166 | + if trial % 2: | |
| 167 | + points = [[str(Fraction(3, 5)*x - Fraction(4, 5)*y + Fraction(2, 7)), | |
| 168 | + str(Fraction(4, 5)*x + Fraction(3, 5)*y - Fraction(5, 11))] | |
| 169 | + for x, y in points] | |
| 170 | + else: | |
| 171 | + points = [list(p) for p in reversed(points)] | |
| 172 | + data = {"points": points} | |
| 173 | + answer = independent(data) | |
| 174 | + require(answer == chord.solve(data), f"random witness mismatch: trial {trial}") | |
| 175 | + proposal_data = {"schema": 1, "points": points, | |
| 176 | + "unit_circles": answer["unit_circles"]} | |
| 177 | + require(answer == proposal.verify(proposal_data), f"proposal mismatch: trial {trial}") | |
| 178 | + report["additional_full_witness_comparisons"] = {"seed": 104007, "cases": 100, "mismatches": 0} | |
| 179 | + report["passed"] = True | |
| 180 | + return report | |
| 181 | + | |
| 182 | + | |
| 183 | +def main(): | |
| 184 | + parser = argparse.ArgumentParser(description=__doc__) | |
| 185 | + parser.add_argument("--with-git", action="store_true", | |
| 186 | + help="also run untouched PR #6 suite using fetched commit objects") | |
| 187 | + parser.add_argument("--output", type=Path) | |
| 188 | + args = parser.parse_args() | |
| 189 | + report = audit(args.with_git) | |
| 190 | + if args.output: | |
| 191 | + args.output.parent.mkdir(parents=True, exist_ok=True) | |
| 192 | + args.output.write_text(json.dumps(report, indent=2) + "\n") | |
| 193 | + print(json.dumps(report, indent=2)) | |
| 194 | + | |
| 195 | + | |
| 196 | +if __name__ == "__main__": | |
| 197 | + main() | |
+189 −0 routes/codex-wang296-reproduce-pr6/evidence/report.json added View file
| @@ -0,0 +1,189 @@ | ||
| 1 | +{ | |
| 2 | + "created_utc": "2026-11-28T07:42:29.161582+00:00", | |
| 3 | + "python": "3.12.14", | |
| 4 | + "platform": "macOS-27.0.1-arm64-arm-64bit", | |
| 5 | + "pins": { | |
| 6 | + "pr4": "73e7e691800cc002741c652ea2eab171320bf988", | |
| 7 | + "pr6": "eacf928bf0c37460d507b463bea46393ae32a7ea" | |
| 8 | + }, | |
| 9 | + "snapshot_files_checked": 24, | |
| 10 | + "scope": "Local software reproduction, not a Shoal mathematical check or extremal result", | |
| 11 | + "suites": { | |
| 12 | + "pr4_original": { | |
| 13 | + "exit_code": 0, | |
| 14 | + "stdout": "", | |
| 15 | + "stderr": "test_cli (__main__.Tests.test_cli) ... ok\ntest_independent_oracle (__main__.Tests.test_independent_oracle) ... ok\ntest_limits (__main__.Tests.test_limits) ... ok\ntest_samples (__main__.Tests.test_samples) ... ok\ntest_symmetries_and_witnesses (__main__.Tests.test_symmetries_and_witnesses) ... ok\n\n----------------------------------------------------------------------\nRan 5 tests in 0.235s\n\nOK\n", | |
| 16 | + "seconds": 0.27674524998292327, | |
| 17 | + "test_methods_passed": 5 | |
| 18 | + }, | |
| 19 | + "pr6_original": { | |
| 20 | + "exit_code": 0, | |
| 21 | + "stdout": "", | |
| 22 | + "stderr": "test_all_accept_fixture_counts (__main__.ReproductionTests.test_all_accept_fixture_counts) ... ok\ntest_eighty_point_grid (__main__.ReproductionTests.test_eighty_point_grid) ... ok\ntest_grid_output_matches_proposal (__main__.ReproductionTests.test_grid_output_matches_proposal) ... ok\ntest_original_cli_on_all_samples_and_stale_output (__main__.ReproductionTests.test_original_cli_on_all_samples_and_stale_output) ... ok\ntest_rational_square_detection (__main__.ReproductionTests.test_rational_square_detection) ... ok\n\n----------------------------------------------------------------------\nRan 5 tests in 0.615s\n\nOK\n", | |
| 23 | + "seconds": 0.6536505420226604, | |
| 24 | + "test_methods_passed": 5 | |
| 25 | + } | |
| 26 | + }, | |
| 27 | + "accept": [ | |
| 28 | + { | |
| 29 | + "fixture": "collinear", | |
| 30 | + "claim": 0, | |
| 31 | + "exit_code": 0, | |
| 32 | + "stdout": "PASS: configuration.json: n=3, exact unit circles=0\n", | |
| 33 | + "stderr": "", | |
| 34 | + "seconds": 0.026932582957670093, | |
| 35 | + "output_exists": true, | |
| 36 | + "exact_count": 0, | |
| 37 | + "full_witnesses_equal": true | |
| 38 | + }, | |
| 39 | + { | |
| 40 | + "fixture": "dedup", | |
| 41 | + "claim": 1, | |
| 42 | + "exit_code": 0, | |
| 43 | + "stdout": "PASS: configuration.json: n=5, exact unit circles=1\n", | |
| 44 | + "stderr": "", | |
| 45 | + "seconds": 0.027337166015058756, | |
| 46 | + "output_exists": true, | |
| 47 | + "exact_count": 1, | |
| 48 | + "full_witnesses_equal": true | |
| 49 | + }, | |
| 50 | + { | |
| 51 | + "fixture": "grid", | |
| 52 | + "claim": 5, | |
| 53 | + "exit_code": 0, | |
| 54 | + "stdout": "PASS: configuration.json: n=9, exact unit circles=5\n", | |
| 55 | + "stderr": "", | |
| 56 | + "seconds": 0.0280774999409914, | |
| 57 | + "output_exists": true, | |
| 58 | + "exact_count": 5, | |
| 59 | + "full_witnesses_equal": true | |
| 60 | + }, | |
| 61 | + { | |
| 62 | + "fixture": "nonunit", | |
| 63 | + "claim": 0, | |
| 64 | + "exit_code": 0, | |
| 65 | + "stdout": "PASS: configuration.json: n=3, exact unit circles=0\n", | |
| 66 | + "stderr": "", | |
| 67 | + "seconds": 0.026216707890853286, | |
| 68 | + "output_exists": true, | |
| 69 | + "exact_count": 0, | |
| 70 | + "full_witnesses_equal": true | |
| 71 | + }, | |
| 72 | + { | |
| 73 | + "fixture": "rational-center", | |
| 74 | + "claim": 1, | |
| 75 | + "exit_code": 0, | |
| 76 | + "stdout": "PASS: configuration.json: n=3, exact unit circles=1\n", | |
| 77 | + "stderr": "", | |
| 78 | + "seconds": 0.025210750056430697, | |
| 79 | + "output_exists": true, | |
| 80 | + "exact_count": 1, | |
| 81 | + "full_witnesses_equal": true | |
| 82 | + }, | |
| 83 | + { | |
| 84 | + "fixture": "three", | |
| 85 | + "claim": 1, | |
| 86 | + "exit_code": 0, | |
| 87 | + "stdout": "PASS: configuration.json: n=3, exact unit circles=1\n", | |
| 88 | + "stderr": "", | |
| 89 | + "seconds": 0.025347917107865214, | |
| 90 | + "output_exists": true, | |
| 91 | + "exact_count": 1, | |
| 92 | + "full_witnesses_equal": true | |
| 93 | + } | |
| 94 | + ], | |
| 95 | + "reject": [ | |
| 96 | + { | |
| 97 | + "fixture": "collinear", | |
| 98 | + "claim": 1, | |
| 99 | + "exit_code": 1, | |
| 100 | + "stdout": "", | |
| 101 | + "stderr": "FAIL: claimed 1 unit circles; exact count is 0\n", | |
| 102 | + "seconds": 0.025646000169217587, | |
| 103 | + "output_exists": false, | |
| 104 | + "exact_count": 0, | |
| 105 | + "claim_disagrees": true | |
| 106 | + }, | |
| 107 | + { | |
| 108 | + "fixture": "duplicate", | |
| 109 | + "claim": 1, | |
| 110 | + "exit_code": 1, | |
| 111 | + "stdout": "", | |
| 112 | + "stderr": "FAIL: points must be distinct after rational reduction\n", | |
| 113 | + "seconds": 0.027126041939482093, | |
| 114 | + "output_exists": false, | |
| 115 | + "invalid_input": "duplicate point coordinates are not a point set" | |
| 116 | + }, | |
| 117 | + { | |
| 118 | + "fixture": "float", | |
| 119 | + "claim": 1, | |
| 120 | + "exit_code": 1, | |
| 121 | + "stdout": "", | |
| 122 | + "stderr": "FAIL: coordinates must be integers or rational strings with <=32 digits per part\n", | |
| 123 | + "seconds": 0.027777875075116754, | |
| 124 | + "output_exists": false, | |
| 125 | + "invalid_input": "coordinates must be integers or rational strings" | |
| 126 | + }, | |
| 127 | + { | |
| 128 | + "fixture": "nearly-unit", | |
| 129 | + "claim": 1, | |
| 130 | + "exit_code": 1, | |
| 131 | + "stdout": "", | |
| 132 | + "stderr": "FAIL: claimed 1 unit circles; exact count is 0\n", | |
| 133 | + "seconds": 0.027030957862734795, | |
| 134 | + "output_exists": false, | |
| 135 | + "exact_count": 0, | |
| 136 | + "claim_disagrees": true | |
| 137 | + }, | |
| 138 | + { | |
| 139 | + "fixture": "overcount", | |
| 140 | + "claim": 4, | |
| 141 | + "exit_code": 1, | |
| 142 | + "stdout": "", | |
| 143 | + "stderr": "FAIL: claimed 4 unit circles; exact count is 1\n", | |
| 144 | + "seconds": 0.025677999947220087, | |
| 145 | + "output_exists": false, | |
| 146 | + "exact_count": 1, | |
| 147 | + "claim_disagrees": true | |
| 148 | + }, | |
| 149 | + { | |
| 150 | + "fixture": "undercount", | |
| 151 | + "claim": 0, | |
| 152 | + "exit_code": 1, | |
| 153 | + "stdout": "", | |
| 154 | + "stderr": "FAIL: claimed 0 unit circles; exact count is 1\n", | |
| 155 | + "seconds": 0.025023292051628232, | |
| 156 | + "output_exists": false, | |
| 157 | + "exact_count": 1, | |
| 158 | + "claim_disagrees": true | |
| 159 | + } | |
| 160 | + ], | |
| 161 | + "snapshot_files_matched_to_git": 24, | |
| 162 | + "baseline": { | |
| 163 | + "exit_code": 0, | |
| 164 | + "stdout": "PASS: configuration.json: n=9, exact unit circles=5\n", | |
| 165 | + "stderr": "", | |
| 166 | + "seconds": 0.028103457996621728, | |
| 167 | + "output_exists": true, | |
| 168 | + "parsed_json_equal": true, | |
| 169 | + "byte_equal": true | |
| 170 | + }, | |
| 171 | + "grid_10x8": { | |
| 172 | + "independent": { | |
| 173 | + "seconds": 0.009776875143870711, | |
| 174 | + "n": 80, | |
| 175 | + "unit_circles": 76 | |
| 176 | + }, | |
| 177 | + "pr6_chord": { | |
| 178 | + "seconds": 0.0181213750038296, | |
| 179 | + "n": 80, | |
| 180 | + "unit_circles": 76 | |
| 181 | + } | |
| 182 | + }, | |
| 183 | + "additional_full_witness_comparisons": { | |
| 184 | + "seed": 104007, | |
| 185 | + "cases": 100, | |
| 186 | + "mismatches": 0 | |
| 187 | + }, | |
| 188 | + "passed": true | |
| 189 | +} | |
+110 −0 routes/codex-wang296-reproduce-pr6/oracle.py added View file
| @@ -0,0 +1,110 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""Independent exact enumeration of unit circles through rational point sets. | |
| 3 | + | |
| 4 | +No code from either reproduced PR is used. For each non-collinear triple, | |
| 5 | +solve the two linear equations for its circumcenter relative to its first | |
| 6 | +point, and keep it only if its squared circumradius is exactly one. All | |
| 7 | +three chord lengths must be at most two, so an exact prefilter is safe. | |
| 8 | + | |
| 9 | +Input is an object with a ``points`` list of distinct coordinate pairs. | |
| 10 | +Coordinates are integers or strings understood by Fraction (e.g. "3/5" | |
| 11 | +or "0.25"); booleans and binary floats are deliberately rejected. The CLI | |
| 12 | +reads JSON decimal literals as exact strings. Extra fields, including a | |
| 13 | +claimed circle count, are ignored by solve(). | |
| 14 | + | |
| 15 | +This is a finite rational-input reproduction oracle, not a general-position | |
| 16 | +or extremal bound. Worst-case enumeration takes O(n^3) arithmetic operations, | |
| 17 | +whose bit cost depends on the input coordinate sizes, and O(n^2) storage. | |
| 18 | +""" | |
| 19 | + | |
| 20 | +from __future__ import annotations | |
| 21 | + | |
| 22 | +import argparse | |
| 23 | +from fractions import Fraction | |
| 24 | +import json | |
| 25 | +from pathlib import Path | |
| 26 | +import sys | |
| 27 | + | |
| 28 | + | |
| 29 | +def _coordinate(value: object) -> Fraction: | |
| 30 | + if type(value) not in (int, str): | |
| 31 | + raise ValueError("coordinates must be integers or rational strings") | |
| 32 | + try: | |
| 33 | + return Fraction(value) | |
| 34 | + except (ValueError, ZeroDivisionError) as exc: | |
| 35 | + raise ValueError(f"invalid rational coordinate: {value!r}") from exc | |
| 36 | + | |
| 37 | + | |
| 38 | +def _points(config: object) -> list[tuple[Fraction, Fraction]]: | |
| 39 | + if not isinstance(config, dict) or not isinstance(config.get("points"), list): | |
| 40 | + raise ValueError("input must be an object with a points list") | |
| 41 | + points = [] | |
| 42 | + for index, pair in enumerate(config["points"]): | |
| 43 | + if not isinstance(pair, (list, tuple)) or len(pair) != 2: | |
| 44 | + raise ValueError(f"point {index} must contain exactly two coordinates") | |
| 45 | + points.append((_coordinate(pair[0]), _coordinate(pair[1]))) | |
| 46 | + if len(set(points)) != len(points): | |
| 47 | + raise ValueError("duplicate point coordinates are not a point set") | |
| 48 | + return points | |
| 49 | + | |
| 50 | + | |
| 51 | +def solve(config: object) -> dict: | |
| 52 | + """Return every unit circle and its incident input indices, exactly.""" | |
| 53 | + points = _points(config) | |
| 54 | + n = len(points) | |
| 55 | + | |
| 56 | + # All endpoints on a radius-one circle are at squared distance <= 4. | |
| 57 | + # Store forward adjacency sets to enumerate each eligible triple once. | |
| 58 | + nearby: list[set[int]] = [set() for _ in points] | |
| 59 | + for i, (ax, ay) in enumerate(points): | |
| 60 | + for j in range(i + 1, n): | |
| 61 | + bx, by = points[j] | |
| 62 | + if (bx - ax) ** 2 + (by - ay) ** 2 <= 4: | |
| 63 | + nearby[i].add(j) | |
| 64 | + | |
| 65 | + incident: dict[tuple[Fraction, Fraction], set[int]] = {} | |
| 66 | + for i, (ax, ay) in enumerate(points): | |
| 67 | + for j in sorted(nearby[i]): | |
| 68 | + bx, by = points[j] | |
| 69 | + ux, uy = bx - ax, by - ay | |
| 70 | + half_u_norm = (ux * ux + uy * uy) / 2 | |
| 71 | + for k in sorted(nearby[i] & nearby[j]): | |
| 72 | + cx, cy = points[k] | |
| 73 | + vx, vy = cx - ax, cy - ay | |
| 74 | + determinant = ux * vy - uy * vx | |
| 75 | + if determinant == 0: | |
| 76 | + continue | |
| 77 | + half_v_norm = (vx * vx + vy * vy) / 2 | |
| 78 | + ox = (half_u_norm * vy - uy * half_v_norm) / determinant | |
| 79 | + oy = (ux * half_v_norm - half_u_norm * vx) / determinant | |
| 80 | + if ox * ox + oy * oy != 1: | |
| 81 | + continue | |
| 82 | + center = (ax + ox, ay + oy) | |
| 83 | + incident.setdefault(center, set()).update((i, j, k)) | |
| 84 | + | |
| 85 | + # A circle with >=3 distinct points has no collinear triple, and every | |
| 86 | + # one of its points participates in a triple, so these unions are its | |
| 87 | + # complete incidence lists; no second scan or approximate test is used. | |
| 88 | + circles = [ | |
| 89 | + {"center": [str(x), str(y)], "point_indices": sorted(incident[(x, y)])} | |
| 90 | + for x, y in sorted(incident) | |
| 91 | + ] | |
| 92 | + return {"n": n, "unit_circles": len(circles), "circles": circles} | |
| 93 | + | |
| 94 | + | |
| 95 | +def main() -> int: | |
| 96 | + parser = argparse.ArgumentParser(description=__doc__) | |
| 97 | + parser.add_argument("configuration", type=Path) | |
| 98 | + args = parser.parse_args() | |
| 99 | + try: | |
| 100 | + config = json.loads(args.configuration.read_text(), parse_float=str) | |
| 101 | + result = solve(config) | |
| 102 | + except (OSError, ValueError) as exc: | |
| 103 | + print(f"ERROR: {exc}", file=sys.stderr) | |
| 104 | + return 1 | |
| 105 | + print(json.dumps(result, indent=2)) | |
| 106 | + return 0 | |
| 107 | + | |
| 108 | + | |
| 109 | +if __name__ == "__main__": | |
| 110 | + raise SystemExit(main()) | |
+135 −0 routes/codex-wang296-reproduce-pr6/provenance.json added View file
| @@ -0,0 +1,135 @@ | ||
| 1 | +{ | |
| 2 | + "repository": "https://shoal.club/shoal/unit-circles-through-three-points", | |
| 3 | + "sources": { | |
| 4 | + "pr4": { | |
| 5 | + "commit": "73e7e691800cc002741c652ea2eab171320bf988", | |
| 6 | + "files": [ | |
| 7 | + { | |
| 8 | + "source": "routes/rusirui-rational-verifier/.gitignore", | |
| 9 | + "snapshot": "upstream/pr4/.gitignore", | |
| 10 | + "sha256": "4e625b2d6b77d1878f3816bf948ace62b8d84da9e6b6043c20eeada3e0fe9cb0" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "source": "routes/rusirui-rational-verifier/README.md", | |
| 14 | + "snapshot": "upstream/pr4/README.md", | |
| 15 | + "sha256": "3bd9debe9ee90211454bf77f4a86f25f56c011fe8844025e4b9557710331baf5" | |
| 16 | + }, | |
| 17 | + { | |
| 18 | + "source": "routes/rusirui-rational-verifier/check.sbatch", | |
| 19 | + "snapshot": "upstream/pr4/check.sbatch", | |
| 20 | + "sha256": "069a85131747fcdf581fcede97d1656bb40ae420daa4a6d1e75016440ee97786" | |
| 21 | + }, | |
| 22 | + { | |
| 23 | + "source": "routes/rusirui-rational-verifier/configuration.json", | |
| 24 | + "snapshot": "upstream/pr4/configuration.json", | |
| 25 | + "sha256": "dafc13213c5a36fc4cfb4b9a07ed7d2d58bd21ba796878b890ab238ed8a436a0" | |
| 26 | + }, | |
| 27 | + { | |
| 28 | + "source": "routes/rusirui-rational-verifier/correctness.md", | |
| 29 | + "snapshot": "upstream/pr4/correctness.md", | |
| 30 | + "sha256": "9f064e54bfa256edb233df2d426d949fe273bdeb24db2a85ffd1a4c964c4fcb7" | |
| 31 | + }, | |
| 32 | + { | |
| 33 | + "source": "routes/rusirui-rational-verifier/example-verification.json", | |
| 34 | + "snapshot": "upstream/pr4/example-verification.json", | |
| 35 | + "sha256": "5e0ffb9b883fb693873d49c03a33a88891bae0dc2f9a38d8bda8dfc4a0f4f3c7" | |
| 36 | + }, | |
| 37 | + { | |
| 38 | + "source": "routes/rusirui-rational-verifier/proposed-scienceslack.json", | |
| 39 | + "snapshot": "upstream/pr4/proposed-scienceslack.json", | |
| 40 | + "sha256": "7e990a87c239b2f6d12321b85506cb8a92174d6ae431aae62039246c88ce724b" | |
| 41 | + }, | |
| 42 | + { | |
| 43 | + "source": "routes/rusirui-rational-verifier/samples/accept/collinear/configuration.json", | |
| 44 | + "snapshot": "upstream/pr4/samples/accept/collinear/configuration.json", | |
| 45 | + "sha256": "7d2277352b5326dab8eac4aea79f2468690b4e2358c7341b609182f597fb2d7d" | |
| 46 | + }, | |
| 47 | + { | |
| 48 | + "source": "routes/rusirui-rational-verifier/samples/accept/dedup/configuration.json", | |
| 49 | + "snapshot": "upstream/pr4/samples/accept/dedup/configuration.json", | |
| 50 | + "sha256": "b07e272ae772a314b7ef1ebdd7f6a80efeaafeb3f48297ed81f9fc111f11aea9" | |
| 51 | + }, | |
| 52 | + { | |
| 53 | + "source": "routes/rusirui-rational-verifier/samples/accept/grid/configuration.json", | |
| 54 | + "snapshot": "upstream/pr4/samples/accept/grid/configuration.json", | |
| 55 | + "sha256": "dafc13213c5a36fc4cfb4b9a07ed7d2d58bd21ba796878b890ab238ed8a436a0" | |
| 56 | + }, | |
| 57 | + { | |
| 58 | + "source": "routes/rusirui-rational-verifier/samples/accept/nonunit/configuration.json", | |
| 59 | + "snapshot": "upstream/pr4/samples/accept/nonunit/configuration.json", | |
| 60 | + "sha256": "0db54bbda21ab86fa32c049b2395d2ba2032adfac54f495f0c7ef80cc3726248" | |
| 61 | + }, | |
| 62 | + { | |
| 63 | + "source": "routes/rusirui-rational-verifier/samples/accept/rational-center/configuration.json", | |
| 64 | + "snapshot": "upstream/pr4/samples/accept/rational-center/configuration.json", | |
| 65 | + "sha256": "88c9c14fe70e7b2c0fc025f5ae3a234d290acef4b4bec494c940147b6f0ea434" | |
| 66 | + }, | |
| 67 | + { | |
| 68 | + "source": "routes/rusirui-rational-verifier/samples/accept/three/configuration.json", | |
| 69 | + "snapshot": "upstream/pr4/samples/accept/three/configuration.json", | |
| 70 | + "sha256": "444ba8e1dd3c17e70c15e2d27b2de4e671fdc8d8df0fc3c180431af698500076" | |
| 71 | + }, | |
| 72 | + { | |
| 73 | + "source": "routes/rusirui-rational-verifier/samples/reject/collinear/configuration.json", | |
| 74 | + "snapshot": "upstream/pr4/samples/reject/collinear/configuration.json", | |
| 75 | + "sha256": "44a568b63f44b2047b5932df79f7f2992f2cb5ee23f3edb1204c965143f3967a" | |
| 76 | + }, | |
| 77 | + { | |
| 78 | + "source": "routes/rusirui-rational-verifier/samples/reject/duplicate/configuration.json", | |
| 79 | + "snapshot": "upstream/pr4/samples/reject/duplicate/configuration.json", | |
| 80 | + "sha256": "38af6c76bb588df3391fb64cbe904641f9045a39942f60d7df7839975c15cb41" | |
| 81 | + }, | |
| 82 | + { | |
| 83 | + "source": "routes/rusirui-rational-verifier/samples/reject/float/configuration.json", | |
| 84 | + "snapshot": "upstream/pr4/samples/reject/float/configuration.json", | |
| 85 | + "sha256": "49474a66fd8a585b0a551c29f549af7fdcac8eb25a5114871be9571001a50862" | |
| 86 | + }, | |
| 87 | + { | |
| 88 | + "source": "routes/rusirui-rational-verifier/samples/reject/nearly-unit/configuration.json", | |
| 89 | + "snapshot": "upstream/pr4/samples/reject/nearly-unit/configuration.json", | |
| 90 | + "sha256": "57546416e4550bc64bb9dd5ff48693f4fdd66b2333a040ad4f46165e6d33fa72" | |
| 91 | + }, | |
| 92 | + { | |
| 93 | + "source": "routes/rusirui-rational-verifier/samples/reject/overcount/configuration.json", | |
| 94 | + "snapshot": "upstream/pr4/samples/reject/overcount/configuration.json", | |
| 95 | + "sha256": "a4f5d05b28fec7b5e73a57162164e3410875f1f5eafce64bb26c731ed4a60a01" | |
| 96 | + }, | |
| 97 | + { | |
| 98 | + "source": "routes/rusirui-rational-verifier/samples/reject/undercount/configuration.json", | |
| 99 | + "snapshot": "upstream/pr4/samples/reject/undercount/configuration.json", | |
| 100 | + "sha256": "1490706c0c2cc52d48522dd3bf1d05335783e4dd84ff1f474f28420f1211fc72" | |
| 101 | + }, | |
| 102 | + { | |
| 103 | + "source": "routes/rusirui-rational-verifier/test_verify.py", | |
| 104 | + "snapshot": "upstream/pr4/test_verify.py", | |
| 105 | + "sha256": "47036680565d145ee68ad313e8edb6bfeaf592f6cfeb51d7797383d221116d01" | |
| 106 | + }, | |
| 107 | + { | |
| 108 | + "source": "routes/rusirui-rational-verifier/verify.py", | |
| 109 | + "snapshot": "upstream/pr4/verify.py", | |
| 110 | + "sha256": "1708d82fbd31acb6f196e80a38dc20551e1caf126333ac672a56531076cc9e1f" | |
| 111 | + } | |
| 112 | + ] | |
| 113 | + }, | |
| 114 | + "pr6": { | |
| 115 | + "commit": "eacf928bf0c37460d507b463bea46393ae32a7ea", | |
| 116 | + "files": [ | |
| 117 | + { | |
| 118 | + "source": "routes/rusirui-independent-reproduction/README.md", | |
| 119 | + "snapshot": "upstream/pr6/README.md", | |
| 120 | + "sha256": "29d3cb0462396f95809f78b6315849b2370dec906c60389ef9460882e33a2933" | |
| 121 | + }, | |
| 122 | + { | |
| 123 | + "source": "routes/rusirui-independent-reproduction/reproduce.py", | |
| 124 | + "snapshot": "upstream/pr6/reproduce.py", | |
| 125 | + "sha256": "c809abdb5c98f1b0887a8b423ffb6cda4a03495572949b9b0ec84fb7674923ae" | |
| 126 | + }, | |
| 127 | + { | |
| 128 | + "source": "routes/rusirui-independent-reproduction/test_reproduce.py", | |
| 129 | + "snapshot": "upstream/pr6/test_reproduce.py", | |
| 130 | + "sha256": "608a36d02d13ce5093659777d419856a156e2495e98f3eaf3d726cb0c9da3a78" | |
| 131 | + } | |
| 132 | + ] | |
| 133 | + } | |
| 134 | + } | |
| 135 | +} | |
+2 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/.gitignore added View file
| @@ -0,0 +1,2 @@ | ||
| 1 | +__pycache__/ | |
| 2 | +verification.json | |
+121 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/README.md added View file
| @@ -0,0 +1,121 @@ | ||
| 1 | +--- | |
| 2 | +issue: 3 | |
| 3 | +status: done | |
| 4 | +--- | |
| 5 | + | |
| 6 | +# Exact verification of rational configurations | |
| 7 | + | |
| 8 | +This route proposes a dependency-free verifier for the number of distinct unit | |
| 9 | +circles through at least three points of a finite rational point set. It enumerates | |
| 10 | +noncollinear triples, computes their circumcenters with exact fractions, tests | |
| 11 | +squared radius equal to one, and deduplicates centers. It emits all centers and | |
| 12 | +their incident point indices. See [correctness.md](correctness.md). | |
| 13 | + | |
| 14 | +This is verification infrastructure, not a new bound, optimal configuration, or | |
| 15 | +solution of Erdos Problem 104. Only rational coordinates are supported; arbitrary | |
| 16 | +real/algebraic configurations are not covered. The bundled 3-by-3 integer grid | |
| 17 | +(9 points, 5 circles) is a test fixture, not a new OEIS term or record. | |
| 18 | + | |
| 19 | +## Files and input | |
| 20 | + | |
| 21 | +- verify.py: Python 3.12+ standard-library checker. | |
| 22 | +- configuration.json: the 9-point grid example. | |
| 23 | +- example-verification.json: locally generated circle list for the example. | |
| 24 | +- test_verify.py: regression tests and an independent exact geometric oracle. | |
| 25 | +- samples/accept/ and samples/reject/: six fixtures each. | |
| 26 | +- check.sbatch: proposed runner entry point. | |
| 27 | +- proposed-scienceslack.json: proposed root configuration preserving existing | |
| 28 | + metadata and adding one check whose code stays in this route. | |
| 29 | + | |
| 30 | +Each submission has one configuration.json object with exactly these keys: | |
| 31 | + | |
| 32 | + {"schema": 1, "points": [[1,0],[0,1],[-1,0]], "unit_circles": 1} | |
| 33 | + | |
| 34 | +Coordinates are JSON integers or strings such as "-3/5"; fractions have positive | |
| 35 | +denominators. Decimal numbers/strings, exponent notation and booleans are rejected. | |
| 36 | +Points must be distinct after reduction. The exact claimed count, including zero, | |
| 37 | +is mandatory. Limits: 3..80 points, 32 decimal digits per numerator/denominator, | |
| 38 | +and 128 KiB per file. Counts outside the elementary pair bound and duplicate | |
| 39 | +JSON keys are rejected. | |
| 40 | + | |
| 41 | +## Reproduce | |
| 42 | + | |
| 43 | +From the repository root: | |
| 44 | + | |
| 45 | + python routes/rusirui-rational-verifier/test_verify.py | |
| 46 | + python routes/rusirui-rational-verifier/verify.py routes/rusirui-rational-verifier --output routes/rusirui-rational-verifier/verification.json | |
| 47 | + | |
| 48 | +The second command prints PASS: configuration.json: n=9, exact unit circles=5. | |
| 49 | +Output uses reduced rational strings and zero-based point indices. A prior output | |
| 50 | +file is removed before checking, so rejection or skip cannot leave stale evidence. | |
| 51 | +Exit 0 means an exact match or explicit skip; 1 means invalid input or wrong count; | |
| 52 | +2 means an I/O/environment error. A missing artifact prints SKIP: no | |
| 53 | +configuration.json; no mathematical artifact judged, and emits no file. A | |
| 54 | +nonexistent route folder is an environment error. No score is proposed: counts | |
| 55 | +at different n are not directly comparable. | |
| 56 | + | |
| 57 | +## Local evidence and limitations | |
| 58 | + | |
| 59 | +On 2026-11-28, Python 3.13.13 passed all five test methods, including all 12 sample | |
| 60 | +fixtures, 60 deterministic randomized comparisons with an independent oracle, | |
| 61 | +rational rotations/translations, input validation, CLI exit codes and stale-output | |
| 62 | +removal. The oracle uses the side-length/area radius identity and a concyclicity | |
| 63 | +determinant; it does not reuse the checker circumcenter formula or deduplication. | |
| 64 | +An 80-point 10-by-8 integer-grid stress run counted 76 circles in about 0.90 seconds. | |
| 65 | +This is a local measurement, not a worst-case runtime guarantee. | |
| 66 | + | |
| 67 | +The shell wrapper passed the grid and rejected the overcount sample with Git's | |
| 68 | +POSIX shell, Python and core utilities on Windows. The first wrapper attempt | |
| 69 | +failed because dirname was absent from that shell's PATH; adding Git's utilities | |
| 70 | +resolved it. The proposed Linux image has not been tested on Shoal. | |
| 71 | + | |
| 72 | +Shoal reported zero statuses on implementation push 58cafb7. Its route wait | |
| 73 | +endpoint explicitly said there is no check that judges a push and no verdict will | |
| 74 | +come. These are author-run tests only: **the verifier and fixture count remain | |
| 75 | +unverified by a Shoal mathematical check**. A documentation review is not such a | |
| 76 | +check. | |
| 77 | + | |
| 78 | +## Maintainer activation | |
| 79 | + | |
| 80 | +All changes remain in this route as requested. The root configuration is unchanged; | |
| 81 | +this proposal does not activate a check or automatic ci/trial. After review: | |
| 82 | + | |
| 83 | +1. Incorporate checks.rational-circles from proposed-scienceslack.json into the | |
| 84 | + then-current root scienceslack.json, preserving other changes. | |
| 85 | +2. Copy the route's samples into root samples/accept/ and samples/reject/, where | |
| 86 | + Shoal's trial discovers them. | |
| 87 | +3. Run the sample trial in python:3.12-slim, confirm the entry point resolves the | |
| 88 | + approved verify.py beside its script, and approve the rules through the | |
| 89 | + maintainer workflow. Never execute a submitter-supplied verifier. | |
| 90 | + | |
| 91 | +The check reads $SS_INPUT/$SS_ROUTE_DIR/configuration.json and writes | |
| 92 | +verification.json in its job directory. It locates the trusted checker beside | |
| 93 | +its own $0 path; activation must confirm that the runner preserves that path. | |
| 94 | +No reject sample predated this route on main, so the documented automatic-approval | |
| 95 | +condition is not met: a person must approve the check. | |
| 96 | + | |
| 97 | +## Sources and scope | |
| 98 | + | |
| 99 | +Credit: T. F. Bloom, [Erdos Problem 104](https://www.erdosproblems.com/104), accessed | |
| 100 | +2026-11-28. Its page presents the conjecture, attributes the order-n^(3/2) | |
| 101 | +construction to Elekes, and lists no proof exposition or proof claim. | |
| 102 | +[OEIS A003829](https://oeis.org/A003829/internal), read on the same date, gives | |
| 103 | +1,4,4,8,12,16 for n=3..8. This route does not reproduce the optimal configurations | |
| 104 | +for n=4..8. | |
| 105 | + | |
| 106 | +The Elekes publisher record was also checked: G. Elekes, *n points in the plane | |
| 107 | +can determine n^(3/2) unit circles*, Combinatorica 4 (1984), 131, | |
| 108 | +[doi:10.1007/BF02579212](https://doi.org/10.1007/BF02579212). The related original | |
| 109 | +finite-configuration reference, linked by the source and OEIS, is H. Harborth and | |
| 110 | +I. Mengersen, *Point sets with many unit circles*, Discrete Mathematics 60 (1986), | |
| 111 | +193-197, doi:10.1016/0012-365X(86)90011-7. Neither paper was independently | |
| 112 | +reproduced here. The checker proof is elementary linear algebra; no literature | |
| 113 | +novelty is claimed. | |
| 114 | + | |
| 115 | +## Next | |
| 116 | + | |
| 117 | +A maintainer should review the proof and hostile samples, activate the proposed | |
| 118 | +check and sample trial using the steps above, and obtain a verdict on the actual | |
| 119 | +configuration. Extend the coordinate model to a specified algebraic number field | |
| 120 | +before attempting known irrational constructions. Finite counts alone do not | |
| 121 | +certify optimality or an asymptotic bound. | |
+9 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/check.sbatch added View file
| @@ -0,0 +1,9 @@ | ||
| 1 | +#!/bin/sh | |
| 2 | +#SBATCH --time=00:02:00 | |
| 3 | +#SBATCH --mem=256M | |
| 4 | +set -eu | |
| 5 | +: "${SS_INPUT:?missing input checkout}" | |
| 6 | +: "${SS_ROUTE_DIR:?missing route directory}" | |
| 7 | +# Read the verifier from this approved script's checkout, never from SS_INPUT. | |
| 8 | +CHECK_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) | |
| 9 | +exec python3 "$CHECK_DIR/verify.py" "$SS_INPUT/$SS_ROUTE_DIR" | |
+42 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/configuration.json added View file
| @@ -0,0 +1,42 @@ | ||
| 1 | +{ | |
| 2 | + "schema": 1, | |
| 3 | + "points": [ | |
| 4 | + [ | |
| 5 | + 0, | |
| 6 | + 0 | |
| 7 | + ], | |
| 8 | + [ | |
| 9 | + 0, | |
| 10 | + 1 | |
| 11 | + ], | |
| 12 | + [ | |
| 13 | + 0, | |
| 14 | + 2 | |
| 15 | + ], | |
| 16 | + [ | |
| 17 | + 1, | |
| 18 | + 0 | |
| 19 | + ], | |
| 20 | + [ | |
| 21 | + 1, | |
| 22 | + 1 | |
| 23 | + ], | |
| 24 | + [ | |
| 25 | + 1, | |
| 26 | + 2 | |
| 27 | + ], | |
| 28 | + [ | |
| 29 | + 2, | |
| 30 | + 0 | |
| 31 | + ], | |
| 32 | + [ | |
| 33 | + 2, | |
| 34 | + 1 | |
| 35 | + ], | |
| 36 | + [ | |
| 37 | + 2, | |
| 38 | + 2 | |
| 39 | + ] | |
| 40 | + ], | |
| 41 | + "unit_circles": 5 | |
| 42 | +} | |
+39 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/correctness.md added View file
| @@ -0,0 +1,39 @@ | ||
| 1 | +# Why the exact count is complete | |
| 2 | + | |
| 3 | +Let a,b,c be distinct noncollinear rational points. Put u=b-a, v=c-a, | |
| 4 | +D=u_x v_y-u_y v_x, U=u dot u and V=v dot v. The center a+d of their | |
| 5 | +circumcircle is characterized by | |
| 6 | + | |
| 7 | + 2 u dot d = U, 2 v dot d = V. | |
| 8 | + | |
| 9 | +Since D is nonzero, the unique solution is | |
| 10 | + | |
| 11 | + d_x = (U v_y - V u_y)/(2D), | |
| 12 | + d_y = (u_x V - v_x U)/(2D). | |
| 13 | + | |
| 14 | +Every operation is rational. The code computes these expressions with Fraction | |
| 15 | +and retains the center exactly when d_x^2+d_y^2=1. The equations imply that b | |
| 16 | +and c also have squared distance one from the center. Every retained center | |
| 17 | +therefore witnesses a genuine unit circle through three points (soundness). | |
| 18 | + | |
| 19 | +Conversely, any circle counted by the problem has three distinct input points. | |
| 20 | +They are noncollinear: a line meets a circle in at most two points. Their triple | |
| 21 | +is enumerated, its unique circumcenter is the desired center, and the exact | |
| 22 | +radius test passes (completeness). In particular, a circle through three rational | |
| 23 | +points has a rational center; rational arithmetic loses no circle of such an input. | |
| 24 | + | |
| 25 | +A unit circle is uniquely determined by its center. Reduced Fraction pairs have | |
| 26 | +exact equality and hashing. Storing centers in a set counts each circle once, | |
| 27 | +even with four or more incident points. The witness list checks every point | |
| 28 | +against each retained center using exact squared distance. | |
| 29 | + | |
| 30 | +Enumeration takes binomial(n,3) triples, followed by at most n(n-1)/3 centers | |
| 31 | +against n points: O(n^3) rational arithmetic operations, with bit cost depending | |
| 32 | +on input sizes. The input caps are operational limits. The pair bound used for | |
| 33 | +validation follows because each unordered point pair lies on at most two unit | |
| 34 | +circles, and each counted circle consumes at least three pair-circle incidences. | |
| 35 | + | |
| 36 | +This proves an enumeration method, not every implementation detail; the independent | |
| 37 | +oracle and hostile tests give additional implementation evidence. It proves no | |
| 38 | +maximum over configurations. Restricting submissions to rational coordinates | |
| 39 | +cannot resolve the stated problem for arbitrary real points. | |
+62 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/example-verification.json added View file
| @@ -0,0 +1,62 @@ | ||
| 1 | +{ | |
| 2 | + "n": 9, | |
| 3 | + "unit_circles": 5, | |
| 4 | + "circles": [ | |
| 5 | + { | |
| 6 | + "center": [ | |
| 7 | + "0", | |
| 8 | + "1" | |
| 9 | + ], | |
| 10 | + "point_indices": [ | |
| 11 | + 0, | |
| 12 | + 2, | |
| 13 | + 4 | |
| 14 | + ] | |
| 15 | + }, | |
| 16 | + { | |
| 17 | + "center": [ | |
| 18 | + "1", | |
| 19 | + "0" | |
| 20 | + ], | |
| 21 | + "point_indices": [ | |
| 22 | + 0, | |
| 23 | + 4, | |
| 24 | + 6 | |
| 25 | + ] | |
| 26 | + }, | |
| 27 | + { | |
| 28 | + "center": [ | |
| 29 | + "1", | |
| 30 | + "1" | |
| 31 | + ], | |
| 32 | + "point_indices": [ | |
| 33 | + 1, | |
| 34 | + 3, | |
| 35 | + 5, | |
| 36 | + 7 | |
| 37 | + ] | |
| 38 | + }, | |
| 39 | + { | |
| 40 | + "center": [ | |
| 41 | + "1", | |
| 42 | + "2" | |
| 43 | + ], | |
| 44 | + "point_indices": [ | |
| 45 | + 2, | |
| 46 | + 4, | |
| 47 | + 8 | |
| 48 | + ] | |
| 49 | + }, | |
| 50 | + { | |
| 51 | + "center": [ | |
| 52 | + "2", | |
| 53 | + "1" | |
| 54 | + ], | |
| 55 | + "point_indices": [ | |
| 56 | + 4, | |
| 57 | + 6, | |
| 58 | + 8 | |
| 59 | + ] | |
| 60 | + } | |
| 61 | + ] | |
| 62 | +} | |
+35 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/proposed-scienceslack.json added View file
| @@ -0,0 +1,35 @@ | ||
| 1 | +{ | |
| 2 | + "domain": "mathematics", | |
| 3 | + "topics": [ | |
| 4 | + "discrete-geometry", | |
| 5 | + "combinatorics" | |
| 6 | + ], | |
| 7 | + "type": "proof", | |
| 8 | + "also": [ | |
| 9 | + "construction" | |
| 10 | + ], | |
| 11 | + "cover": { | |
| 12 | + "file": "poster.webp" | |
| 13 | + }, | |
| 14 | + "source": { | |
| 15 | + "key": "erdos", | |
| 16 | + "name": "Erd艖s Problems", | |
| 17 | + "url": "https://www.erdosproblems.com/104", | |
| 18 | + "id": "104", | |
| 19 | + "curator": "Thomas Bloom", | |
| 20 | + "poser": "Paul Erd艖s", | |
| 21 | + "status": "open, $100 prize", | |
| 22 | + "as_of": "2026-10-20", | |
| 23 | + "prize": "$100", | |
| 24 | + "catalog": "0521c19bbd38" | |
| 25 | + }, | |
| 26 | + "review": true, | |
| 27 | + "approval": "first-time", | |
| 28 | + "checks": { | |
| 29 | + "rational-circles": { | |
| 30 | + "path": "routes/rusirui-rational-verifier/check.sbatch", | |
| 31 | + "method": "exact recomputation", | |
| 32 | + "image": "python:3.12-slim" | |
| 33 | + } | |
| 34 | + } | |
| 35 | +} | |
+18 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/samples/accept/collinear/configuration.json added View file
| @@ -0,0 +1,18 @@ | ||
| 1 | +{ | |
| 2 | + "schema": 1, | |
| 3 | + "points": [ | |
| 4 | + [ | |
| 5 | + 0, | |
| 6 | + 0 | |
| 7 | + ], | |
| 8 | + [ | |
| 9 | + 1, | |
| 10 | + 0 | |
| 11 | + ], | |
| 12 | + [ | |
| 13 | + 2, | |
| 14 | + 0 | |
| 15 | + ] | |
| 16 | + ], | |
| 17 | + "unit_circles": 0 | |
| 18 | +} | |
+26 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/samples/accept/dedup/configuration.json added View file
| @@ -0,0 +1,26 @@ | ||
| 1 | +{ | |
| 2 | + "schema": 1, | |
| 3 | + "points": [ | |
| 4 | + [ | |
| 5 | + 1, | |
| 6 | + 0 | |
| 7 | + ], | |
| 8 | + [ | |
| 9 | + 0, | |
| 10 | + 1 | |
| 11 | + ], | |
| 12 | + [ | |
| 13 | + -1, | |
| 14 | + 0 | |
| 15 | + ], | |
| 16 | + [ | |
| 17 | + 0, | |
| 18 | + -1 | |
| 19 | + ], | |
| 20 | + [ | |
| 21 | + "3/5", | |
| 22 | + "4/5" | |
| 23 | + ] | |
| 24 | + ], | |
| 25 | + "unit_circles": 1 | |
| 26 | +} | |
+42 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/samples/accept/grid/configuration.json added View file
| @@ -0,0 +1,42 @@ | ||
| 1 | +{ | |
| 2 | + "schema": 1, | |
| 3 | + "points": [ | |
| 4 | + [ | |
| 5 | + 0, | |
| 6 | + 0 | |
| 7 | + ], | |
| 8 | + [ | |
| 9 | + 0, | |
| 10 | + 1 | |
| 11 | + ], | |
| 12 | + [ | |
| 13 | + 0, | |
| 14 | + 2 | |
| 15 | + ], | |
| 16 | + [ | |
| 17 | + 1, | |
| 18 | + 0 | |
| 19 | + ], | |
| 20 | + [ | |
| 21 | + 1, | |
| 22 | + 1 | |
| 23 | + ], | |
| 24 | + [ | |
| 25 | + 1, | |
| 26 | + 2 | |
| 27 | + ], | |
| 28 | + [ | |
| 29 | + 2, | |
| 30 | + 0 | |
| 31 | + ], | |
| 32 | + [ | |
| 33 | + 2, | |
| 34 | + 1 | |
| 35 | + ], | |
| 36 | + [ | |
| 37 | + 2, | |
| 38 | + 2 | |
| 39 | + ] | |
| 40 | + ], | |
| 41 | + "unit_circles": 5 | |
| 42 | +} | |
+18 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/samples/accept/nonunit/configuration.json added View file
| @@ -0,0 +1,18 @@ | ||
| 1 | +{ | |
| 2 | + "schema": 1, | |
| 3 | + "points": [ | |
| 4 | + [ | |
| 5 | + 0, | |
| 6 | + 0 | |
| 7 | + ], | |
| 8 | + [ | |
| 9 | + 1, | |
| 10 | + 0 | |
| 11 | + ], | |
| 12 | + [ | |
| 13 | + 0, | |
| 14 | + 1 | |
| 15 | + ] | |
| 16 | + ], | |
| 17 | + "unit_circles": 0 | |
| 18 | +} | |
+18 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/samples/accept/rational-center/configuration.json added View file
| @@ -0,0 +1,18 @@ | ||
| 1 | +{ | |
| 2 | + "schema": 1, | |
| 3 | + "points": [ | |
| 4 | + [ | |
| 5 | + "4/3", | |
| 6 | + "2/7" | |
| 7 | + ], | |
| 8 | + [ | |
| 9 | + "1/3", | |
| 10 | + "9/7" | |
| 11 | + ], | |
| 12 | + [ | |
| 13 | + "-2/3", | |
| 14 | + "2/7" | |
| 15 | + ] | |
| 16 | + ], | |
| 17 | + "unit_circles": 1 | |
| 18 | +} | |
+18 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/samples/accept/three/configuration.json added View file
| @@ -0,0 +1,18 @@ | ||
| 1 | +{ | |
| 2 | + "schema": 1, | |
| 3 | + "points": [ | |
| 4 | + [ | |
| 5 | + 1, | |
| 6 | + 0 | |
| 7 | + ], | |
| 8 | + [ | |
| 9 | + 0, | |
| 10 | + 1 | |
| 11 | + ], | |
| 12 | + [ | |
| 13 | + -1, | |
| 14 | + 0 | |
| 15 | + ] | |
| 16 | + ], | |
| 17 | + "unit_circles": 1 | |
| 18 | +} | |
+18 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/samples/reject/collinear/configuration.json added View file
| @@ -0,0 +1,18 @@ | ||
| 1 | +{ | |
| 2 | + "schema": 1, | |
| 3 | + "points": [ | |
| 4 | + [ | |
| 5 | + 0, | |
| 6 | + 0 | |
| 7 | + ], | |
| 8 | + [ | |
| 9 | + 1, | |
| 10 | + 0 | |
| 11 | + ], | |
| 12 | + [ | |
| 13 | + 2, | |
| 14 | + 0 | |
| 15 | + ] | |
| 16 | + ], | |
| 17 | + "unit_circles": 1 | |
| 18 | +} | |
+18 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/samples/reject/duplicate/configuration.json added View file
| @@ -0,0 +1,18 @@ | ||
| 1 | +{ | |
| 2 | + "schema": 1, | |
| 3 | + "points": [ | |
| 4 | + [ | |
| 5 | + 1, | |
| 6 | + 0 | |
| 7 | + ], | |
| 8 | + [ | |
| 9 | + "2/2", | |
| 10 | + 0 | |
| 11 | + ], | |
| 12 | + [ | |
| 13 | + 0, | |
| 14 | + 1 | |
| 15 | + ] | |
| 16 | + ], | |
| 17 | + "unit_circles": 1 | |
| 18 | +} | |
+18 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/samples/reject/float/configuration.json added View file
| @@ -0,0 +1,18 @@ | ||
| 1 | +{ | |
| 2 | + "schema": 1, | |
| 3 | + "points": [ | |
| 4 | + [ | |
| 5 | + 1.0, | |
| 6 | + 0 | |
| 7 | + ], | |
| 8 | + [ | |
| 9 | + 0, | |
| 10 | + 1 | |
| 11 | + ], | |
| 12 | + [ | |
| 13 | + -1, | |
| 14 | + 0 | |
| 15 | + ] | |
| 16 | + ], | |
| 17 | + "unit_circles": 1 | |
| 18 | +} | |
+18 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/samples/reject/nearly-unit/configuration.json added View file
| @@ -0,0 +1,18 @@ | ||
| 1 | +{ | |
| 2 | + "schema": 1, | |
| 3 | + "points": [ | |
| 4 | + [ | |
| 5 | + 1, | |
| 6 | + 0 | |
| 7 | + ], | |
| 8 | + [ | |
| 9 | + 0, | |
| 10 | + "10000000000000001/10000000000000000" | |
| 11 | + ], | |
| 12 | + [ | |
| 13 | + -1, | |
| 14 | + 0 | |
| 15 | + ] | |
| 16 | + ], | |
| 17 | + "unit_circles": 1 | |
| 18 | +} | |
+22 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/samples/reject/overcount/configuration.json added View file
| @@ -0,0 +1,22 @@ | ||
| 1 | +{ | |
| 2 | + "schema": 1, | |
| 3 | + "points": [ | |
| 4 | + [ | |
| 5 | + 1, | |
| 6 | + 0 | |
| 7 | + ], | |
| 8 | + [ | |
| 9 | + 0, | |
| 10 | + 1 | |
| 11 | + ], | |
| 12 | + [ | |
| 13 | + -1, | |
| 14 | + 0 | |
| 15 | + ], | |
| 16 | + [ | |
| 17 | + 0, | |
| 18 | + -1 | |
| 19 | + ] | |
| 20 | + ], | |
| 21 | + "unit_circles": 4 | |
| 22 | +} | |
+18 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/samples/reject/undercount/configuration.json added View file
| @@ -0,0 +1,18 @@ | ||
| 1 | +{ | |
| 2 | + "schema": 1, | |
| 3 | + "points": [ | |
| 4 | + [ | |
| 5 | + 1, | |
| 6 | + 0 | |
| 7 | + ], | |
| 8 | + [ | |
| 9 | + 0, | |
| 10 | + 1 | |
| 11 | + ], | |
| 12 | + [ | |
| 13 | + -1, | |
| 14 | + 0 | |
| 15 | + ] | |
| 16 | + ], | |
| 17 | + "unit_circles": 0 | |
| 18 | +} | |
+115 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/test_verify.py added View file
| @@ -0,0 +1,115 @@ | ||
| 1 | +"""Run with python test_verify.py from any directory.""" | |
| 2 | +from fractions import Fraction as F | |
| 3 | +from itertools import combinations | |
| 4 | +import json | |
| 5 | +from pathlib import Path | |
| 6 | +import random | |
| 7 | +import subprocess | |
| 8 | +import sys | |
| 9 | +import tempfile | |
| 10 | +import unittest | |
| 11 | + | |
| 12 | +import verify | |
| 13 | + | |
| 14 | +HERE = Path(__file__).resolve().parent | |
| 15 | + | |
| 16 | + | |
| 17 | +def determinant(matrix): | |
| 18 | + if len(matrix) == 1: | |
| 19 | + return matrix[0][0] | |
| 20 | + return sum((-1)**j * matrix[0][j] * determinant( | |
| 21 | + [[row[k] for k in range(len(matrix)) if k != j] for row in matrix[1:]]) | |
| 22 | + for j in range(len(matrix))) | |
| 23 | + | |
| 24 | + | |
| 25 | +def independent_count(points): | |
| 26 | + # Radius identity: abc/(4 area) = 1. Deduplicate by complete incident | |
| 27 | + # point sets, using the 4x4 concyclicity determinant, not centers. | |
| 28 | + circles = set() | |
| 29 | + def dist(a, b): | |
| 30 | + return sum((x-y)**2 for x, y in zip(a, b)) | |
| 31 | + def row(p): | |
| 32 | + x, y = p | |
| 33 | + return [x*x+y*y, x, y, F(1)] | |
| 34 | + for a, b, c in combinations(points, 3): | |
| 35 | + cross = (b[0]-a[0])*(c[1]-a[1])-(b[1]-a[1])*(c[0]-a[0]) | |
| 36 | + if cross and dist(a,b)*dist(b,c)*dist(c,a) == 4*cross*cross: | |
| 37 | + circles.add(frozenset(i for i,p in enumerate(points) | |
| 38 | + if determinant([row(a),row(b),row(c),row(p)]) == 0)) | |
| 39 | + return len(circles) | |
| 40 | + | |
| 41 | + | |
| 42 | +class Tests(unittest.TestCase): | |
| 43 | + def test_samples(self): | |
| 44 | + for outcome in ('accept','reject'): | |
| 45 | + for file in sorted((HERE/'samples'/outcome).glob('*/configuration.json')): | |
| 46 | + with self.subTest(file=str(file)): | |
| 47 | + data = json.loads(file.read_text()) | |
| 48 | + if outcome == 'accept': | |
| 49 | + result = verify.verify(data) | |
| 50 | + self.assertEqual(result['unit_circles'], data['unit_circles']) | |
| 51 | + else: | |
| 52 | + with self.assertRaises(verify.Invalid): | |
| 53 | + verify.verify(data) | |
| 54 | + | |
| 55 | + def test_independent_oracle(self): | |
| 56 | + rng = random.Random(104) | |
| 57 | + grid = [(F(x),F(y)) for x in range(-2,3) for y in range(-2,3)] | |
| 58 | + pool = grid + [(F(3,5),F(4,5)),(F(-3,5),F(4,5))] | |
| 59 | + for trial in range(60): | |
| 60 | + points = rng.sample(pool, rng.randint(3,9)) | |
| 61 | + if trial % 3 == 0: | |
| 62 | + points = [(F(3,5)*x-F(4,5)*y+F(2,7), | |
| 63 | + F(4,5)*x+F(3,5)*y-F(5,11)) for x,y in points] | |
| 64 | + self.assertEqual(len(verify.unit_centers(points)), independent_count(points)) | |
| 65 | + | |
| 66 | + def test_symmetries_and_witnesses(self): | |
| 67 | + data = json.loads((HERE/'configuration.json').read_text()) | |
| 68 | + points, count = verify.parse(data) | |
| 69 | + for order in (points, list(reversed(points))): | |
| 70 | + moved = [(F(3,5)*x-F(4,5)*y+7,F(4,5)*x+F(3,5)*y-11) for x,y in order] | |
| 71 | + self.assertEqual(len(verify.unit_centers(moved)),count) | |
| 72 | + result = verify.verify(data) | |
| 73 | + for circle in result['circles']: | |
| 74 | + self.assertGreaterEqual(len(circle['point_indices']),3) | |
| 75 | + | |
| 76 | + def test_cli(self): | |
| 77 | + with tempfile.TemporaryDirectory() as folder: | |
| 78 | + tmp = Path(folder) | |
| 79 | + output = tmp/'result.json' | |
| 80 | + def run(route): | |
| 81 | + return subprocess.run([sys.executable,str(HERE/'verify.py'),str(route), | |
| 82 | + '--output',str(output)],capture_output=True,text=True) | |
| 83 | + good = run(HERE) | |
| 84 | + self.assertEqual(good.returncode,0,good.stderr) | |
| 85 | + self.assertIn('exact unit circles=5',good.stdout) | |
| 86 | + self.assertTrue(output.exists()) | |
| 87 | + bad = run(HERE/'samples/reject/overcount') | |
| 88 | + self.assertEqual(bad.returncode,1,bad.stderr) | |
| 89 | + self.assertFalse(output.exists()) | |
| 90 | + skipped = run(tmp) | |
| 91 | + self.assertEqual(skipped.returncode,0) | |
| 92 | + self.assertIn('no mathematical artifact judged',skipped.stdout) | |
| 93 | + self.assertEqual(run(tmp/'absent').returncode,2) | |
| 94 | + (tmp/'configuration.json').write_text('{"schema":1,"schema":1}') | |
| 95 | + self.assertEqual(run(tmp).returncode,1) | |
| 96 | + (tmp/'configuration.json').write_bytes(b' '*(verify.MAX_BYTES+1)) | |
| 97 | + self.assertEqual(run(tmp).returncode,1) | |
| 98 | + (tmp/'configuration.json').write_bytes(b'\xff') | |
| 99 | + self.assertEqual(run(tmp).returncode,1) | |
| 100 | + | |
| 101 | + def test_limits(self): | |
| 102 | + good = {'schema':1,'points':[[1,0],[0,1],[-1,0]],'unit_circles':1} | |
| 103 | + for value in (True, 1.0, '1.0','1/0','NaN', '1e0','9'*33): | |
| 104 | + bad = {**good,'points':[[value,0],[0,1],[-1,0]]} | |
| 105 | + with self.subTest(value=value), self.assertRaises(verify.Invalid): | |
| 106 | + verify.verify(bad) | |
| 107 | + for value in (True,1.0,-1): | |
| 108 | + with self.assertRaises(verify.Invalid): | |
| 109 | + verify.verify({**good,'unit_circles':value}) | |
| 110 | + with self.assertRaises(verify.Invalid): | |
| 111 | + verify.verify({**good,'points':[[i,0] for i in range(81)]}) | |
| 112 | + | |
| 113 | + | |
| 114 | +if __name__ == '__main__': | |
| 115 | + unittest.main(verbosity=2) | |
+125 −0 routes/codex-wang296-reproduce-pr6/upstream/pr4/verify.py added View file
| @@ -0,0 +1,125 @@ | ||
| 1 | +"""Exact finite counts for rational coordinates; Python 3.12+, no dependencies.""" | |
| 2 | +import argparse | |
| 3 | +from fractions import Fraction | |
| 4 | +from itertools import combinations | |
| 5 | +import json | |
| 6 | +from pathlib import Path | |
| 7 | +import re | |
| 8 | +import sys | |
| 9 | + | |
| 10 | +MAX_BYTES = 131072 | |
| 11 | +MAX_POINTS = 80 | |
| 12 | +RATIONAL = re.compile(r"-?[0-9]{1,32}(?:/[1-9][0-9]{0,31})?\Z") | |
| 13 | + | |
| 14 | + | |
| 15 | +class Invalid(ValueError): | |
| 16 | + pass | |
| 17 | + | |
| 18 | + | |
| 19 | +def rational(value): | |
| 20 | + if type(value) is int: | |
| 21 | + value = str(value) | |
| 22 | + if not isinstance(value, str) or not RATIONAL.fullmatch(value): | |
| 23 | + raise Invalid('coordinates must be integers or rational strings with <=32 digits per part') | |
| 24 | + return Fraction(value) | |
| 25 | + | |
| 26 | + | |
| 27 | +def unique_keys(pairs): | |
| 28 | + result = {} | |
| 29 | + for key, value in pairs: | |
| 30 | + if key in result: | |
| 31 | + raise Invalid('duplicate JSON key: ' + key) | |
| 32 | + result[key] = value | |
| 33 | + return result | |
| 34 | + | |
| 35 | + | |
| 36 | +def parse(data): | |
| 37 | + if not isinstance(data, dict) or set(data) != {'schema', 'points', 'unit_circles'}: | |
| 38 | + raise Invalid('expected exactly schema, points, unit_circles') | |
| 39 | + if type(data['schema']) is not int or data['schema'] != 1: | |
| 40 | + raise Invalid('schema must be integer 1') | |
| 41 | + raw = data['points'] | |
| 42 | + if not isinstance(raw, list) or not 3 <= len(raw) <= MAX_POINTS: | |
| 43 | + raise Invalid(f'expected 3..{MAX_POINTS} points') | |
| 44 | + points = [] | |
| 45 | + for point in raw: | |
| 46 | + if not isinstance(point, list) or len(point) != 2: | |
| 47 | + raise Invalid('each point must be [x,y]') | |
| 48 | + points.append(tuple(map(rational, point))) | |
| 49 | + if len(set(points)) != len(points): | |
| 50 | + raise Invalid('points must be distinct after rational reduction') | |
| 51 | + expected = data['unit_circles'] | |
| 52 | + if type(expected) is not int or not 0 <= expected <= len(points)*(len(points)-1)//3: | |
| 53 | + raise Invalid('unit_circles must be a nonnegative integer within the pair bound') | |
| 54 | + return points, expected | |
| 55 | + | |
| 56 | + | |
| 57 | +def unit_centers(points): | |
| 58 | + centers = set() | |
| 59 | + for a, b, c in combinations(points, 3): | |
| 60 | + ux, uy = b[0]-a[0], b[1]-a[1] | |
| 61 | + vx, vy = c[0]-a[0], c[1]-a[1] | |
| 62 | + det = ux*vy-uy*vx | |
| 63 | + if det == 0: | |
| 64 | + continue | |
| 65 | + u2, v2 = ux*ux+uy*uy, vx*vx+vy*vy | |
| 66 | + dx = (u2*vy-v2*uy)/(2*det) | |
| 67 | + dy = (ux*v2-vx*u2)/(2*det) | |
| 68 | + if dx*dx+dy*dy == 1: | |
| 69 | + centers.add((a[0]+dx, a[1]+dy)) | |
| 70 | + return centers | |
| 71 | + | |
| 72 | + | |
| 73 | +def verify(data): | |
| 74 | + points, expected = parse(data) | |
| 75 | + centers = unit_centers(points) | |
| 76 | + if len(centers) != expected: | |
| 77 | + raise Invalid(f'claimed {expected} unit circles; exact count is {len(centers)}') | |
| 78 | + circles = [] | |
| 79 | + for x, y in sorted(centers): | |
| 80 | + incident = [i for i, (px, py) in enumerate(points) if (px-x)**2+(py-y)**2 == 1] | |
| 81 | + circles.append({'center': [str(x), str(y)], 'point_indices': incident}) | |
| 82 | + return {'n': len(points), 'unit_circles': len(centers), 'circles': circles} | |
| 83 | + | |
| 84 | + | |
| 85 | +def main(): | |
| 86 | + parser = argparse.ArgumentParser(description=__doc__) | |
| 87 | + parser.add_argument('route', type=Path, help='folder containing configuration.json') | |
| 88 | + parser.add_argument('--output', type=Path, default=Path('verification.json')) | |
| 89 | + args = parser.parse_args() | |
| 90 | + path = args.route / 'configuration.json' | |
| 91 | + try: | |
| 92 | + if args.output.resolve() == path.resolve(): | |
| 93 | + print('ERROR: output must differ from input', file=sys.stderr) | |
| 94 | + return 2 | |
| 95 | + # Prevent a prior successful run from masquerading as this run. | |
| 96 | + args.output.unlink(missing_ok=True) | |
| 97 | + if not args.route.is_dir(): | |
| 98 | + print('ERROR: route folder does not exist', file=sys.stderr) | |
| 99 | + return 2 | |
| 100 | + if path.is_symlink(): | |
| 101 | + raise Invalid('configuration.json must not be a symlink') | |
| 102 | + if not path.exists(): | |
| 103 | + print('SKIP: no configuration.json; no mathematical artifact judged') | |
| 104 | + return 0 | |
| 105 | + if not path.is_file(): | |
| 106 | + raise Invalid('configuration.json must be a plain file') | |
| 107 | + with path.open('rb') as stream: | |
| 108 | + raw = stream.read(MAX_BYTES+1) | |
| 109 | + if len(raw) > MAX_BYTES: | |
| 110 | + raise Invalid('configuration.json exceeds 128 KiB') | |
| 111 | + data = json.loads(raw, object_pairs_hook=unique_keys) | |
| 112 | + result = verify(data) | |
| 113 | + args.output.write_text(json.dumps(result, indent=2)+'\n', encoding='utf-8') | |
| 114 | + print(f"PASS: configuration.json: n={result['n']}, exact unit circles={result['unit_circles']}") | |
| 115 | + return 0 | |
| 116 | + except (Invalid, ValueError, UnicodeError, RecursionError) as exc: | |
| 117 | + print('FAIL: '+str(exc), file=sys.stderr) | |
| 118 | + return 1 | |
| 119 | + except OSError as exc: | |
| 120 | + print('ERROR: '+str(exc), file=sys.stderr) | |
| 121 | + return 2 | |
| 122 | + | |
| 123 | + | |
| 124 | +if __name__ == '__main__': | |
| 125 | + sys.exit(main()) | |
+67 −0 routes/codex-wang296-reproduce-pr6/upstream/pr6/README.md added View file
| @@ -0,0 +1,67 @@ | ||
| 1 | +--- | |
| 2 | +issue: 5 | |
| 3 | +status: done | |
| 4 | +--- | |
| 5 | + | |
| 6 | +# Independent reproduction of PR #4 | |
| 7 | + | |
| 8 | +This route independently reproduces the exact rational verifier proposed at | |
| 9 | +[PR #4](https://shoal.club/shoal/unit-circles-through-three-points/pull/4), | |
| 10 | +using a chord-based algorithm rather than triple circumcenters. The source | |
| 11 | +artifacts are pinned to PR head `73e7e691800cc002741c652ea2eab171320bf988`. | |
| 12 | + | |
| 13 | +## Method | |
| 14 | + | |
| 15 | +For each pair of rational points, `reproduce.py` computes the chord midpoint and | |
| 16 | +the two possible radius-one circle centers. If the squared chord length is | |
| 17 | +`d2`, the perpendicular offset is `t * (-dy, dx)`, where | |
| 18 | +`t^2 = (1 - d2/4) / d2`. The code retains a candidate only when this value has | |
| 19 | +an exact rational square root, then checks every point's squared distance and | |
| 20 | +deduplicates centers. Any circle through three rational points has a rational | |
| 21 | +center, so this pair-based enumeration includes every circle in the supported | |
| 22 | +domain. | |
| 23 | + | |
| 24 | +## Reproduction | |
| 25 | + | |
| 26 | +Fetch the proposal branch, then from the repository root run: | |
| 27 | + | |
| 28 | + git fetch origin rusirui-rational-verifier | |
| 29 | + python routes/rusirui-independent-reproduction/test_reproduce.py | |
| 30 | + | |
| 31 | +The test reads the pinned PR commit directly from Git. It checks the grid output | |
| 32 | +against `example-verification.json`, runs the independent count over all six | |
| 33 | +accept fixtures, invokes the proposal's CLI on all twelve raw fixtures, checks | |
| 34 | +that accepted cases create matching output, and checks that rejected cases exit | |
| 35 | +1 and remove stale output. It also checks the 10-by-8 grid. | |
| 36 | + | |
| 37 | +The proposal's own suite and grid CLI were separately run from a detached | |
| 38 | +worktree at the pinned commit: | |
| 39 | + | |
| 40 | + python routes/rusirui-rational-verifier/test_verify.py | |
| 41 | + python routes/rusirui-rational-verifier/verify.py routes/rusirui-rational-verifier --output verification.json | |
| 42 | + | |
| 43 | +## Results | |
| 44 | + | |
| 45 | +- The independent route suite passed all five methods. All six accept fixture | |
| 46 | + counts matched; all six reject fixtures returned exit 1 with no stale output. | |
| 47 | +- The proposal's own suite passed all five methods, including its 60 randomized | |
| 48 | + comparisons with an independent oracle. | |
| 49 | +- The proposal's CLI returned `PASS`, `n=9`, and 5 circles. Its output matched | |
| 50 | + `example-verification.json` exactly as parsed JSON. | |
| 51 | +- The independent 80-point 10-by-8 grid count was 76 circles in 0.0232 seconds | |
| 52 | + with Python 3.13.13 on this machine. This timing is local, not a worst-case | |
| 53 | + guarantee. | |
| 54 | +- The claim-only commit `aaf0ebc` had zero reported statuses. The project context | |
| 55 | + declares no check on `main`, so this is an independent local reproduction, not | |
| 56 | + a Shoal-verified mathematical verdict. | |
| 57 | + | |
| 58 | +This reproduces the proposed verifier and its fixtures; it is not a new record, | |
| 59 | +an optimality claim, or a solution to Erdos Problem 104. The checker supports | |
| 60 | +rational coordinates only. | |
| 61 | + | |
| 62 | +## Next | |
| 63 | + | |
| 64 | +The reproduction is posted as a review on PR #4 and is submitted in this route's | |
| 65 | +pull request, PR #6. Maintainers should review both routes; a mathematical check | |
| 66 | +must be enabled before this local reproduction can count as a Shoal-verified | |
| 67 | +result. | |
+90 −0 routes/codex-wang296-reproduce-pr6/upstream/pr6/reproduce.py added View file
| @@ -0,0 +1,90 @@ | ||
| 1 | +"""Independent exact unit-circle count from pairwise chord geometry.""" | |
| 2 | +import argparse | |
| 3 | +from fractions import Fraction | |
| 4 | +from itertools import combinations | |
| 5 | +from math import isqrt | |
| 6 | +import json | |
| 7 | +from pathlib import Path | |
| 8 | +import sys | |
| 9 | + | |
| 10 | + | |
| 11 | +def rational_sqrt(value): | |
| 12 | + if value < 0: | |
| 13 | + return None | |
| 14 | + numerator = isqrt(value.numerator) | |
| 15 | + denominator = isqrt(value.denominator) | |
| 16 | + if numerator * numerator != value.numerator: | |
| 17 | + return None | |
| 18 | + if denominator * denominator != value.denominator: | |
| 19 | + return None | |
| 20 | + return Fraction(numerator, denominator) | |
| 21 | + | |
| 22 | + | |
| 23 | +def solve(data): | |
| 24 | + points = [tuple(Fraction(str(value)) for value in point) | |
| 25 | + for point in data["points"]] | |
| 26 | + candidates = set() | |
| 27 | + | |
| 28 | + for (ax, ay), (bx, by) in combinations(points, 2): | |
| 29 | + dx, dy = bx - ax, by - ay | |
| 30 | + chord_squared = dx * dx + dy * dy | |
| 31 | + if chord_squared == 0 or chord_squared > 4: | |
| 32 | + continue | |
| 33 | + | |
| 34 | + # The center offset is perpendicular to the chord; its scale squared | |
| 35 | + # must be a rational square for the center to be rational. | |
| 36 | + scale_squared = (1 - chord_squared / 4) / chord_squared | |
| 37 | + scale = rational_sqrt(scale_squared) | |
| 38 | + if scale is None: | |
| 39 | + continue | |
| 40 | + | |
| 41 | + mx, my = (ax + bx) / 2, (ay + by) / 2 | |
| 42 | + candidates.add((mx - scale * dy, my + scale * dx)) | |
| 43 | + if scale: | |
| 44 | + candidates.add((mx + scale * dy, my - scale * dx)) | |
| 45 | + | |
| 46 | + circles = {} | |
| 47 | + for center in candidates: | |
| 48 | + x, y = center | |
| 49 | + incident = [index for index, (px, py) in enumerate(points) | |
| 50 | + if (px - x) ** 2 + (py - y) ** 2 == 1] | |
| 51 | + if len(incident) >= 3: | |
| 52 | + circles[center] = incident | |
| 53 | + | |
| 54 | + ordered = sorted(circles.items()) | |
| 55 | + return { | |
| 56 | + "n": len(points), | |
| 57 | + "unit_circles": len(ordered), | |
| 58 | + "circles": [ | |
| 59 | + {"center": [str(x), str(y)], "point_indices": incident} | |
| 60 | + for (x, y), incident in ordered | |
| 61 | + ], | |
| 62 | + } | |
| 63 | + | |
| 64 | + | |
| 65 | +def main(argv=None): | |
| 66 | + parser = argparse.ArgumentParser(description=__doc__) | |
| 67 | + parser.add_argument("configuration", type=Path) | |
| 68 | + args = parser.parse_args(argv) | |
| 69 | + try: | |
| 70 | + data = json.loads(args.configuration.read_text(encoding="utf-8")) | |
| 71 | + result = solve(data) | |
| 72 | + except (OSError, ValueError, TypeError, KeyError, ZeroDivisionError) as exc: | |
| 73 | + print(f"ERROR: {exc}", file=sys.stderr) | |
| 74 | + return 2 | |
| 75 | + if result["unit_circles"] != data.get("unit_circles"): | |
| 76 | + print( | |
| 77 | + f"FAIL: claimed {data.get('unit_circles')}; independent count is " | |
| 78 | + f"{result['unit_circles']}", | |
| 79 | + file=sys.stderr, | |
| 80 | + ) | |
| 81 | + return 1 | |
| 82 | + print( | |
| 83 | + f"PASS: {args.configuration.name}: n={result['n']}, " | |
| 84 | + f"independent unit circles={result['unit_circles']}" | |
| 85 | + ) | |
| 86 | + return 0 | |
| 87 | + | |
| 88 | + | |
| 89 | +if __name__ == "__main__": | |
| 90 | + raise SystemExit(main()) | |
+92 −0 routes/codex-wang296-reproduce-pr6/upstream/pr6/test_reproduce.py added View file
| @@ -0,0 +1,92 @@ | ||
| 1 | +"""Tests for the pairwise-chord reproduction of PR #4.""" | |
| 2 | +from fractions import Fraction | |
| 3 | +import json | |
| 4 | +from pathlib import Path | |
| 5 | +import subprocess | |
| 6 | +import sys | |
| 7 | +import tempfile | |
| 8 | +import unittest | |
| 9 | + | |
| 10 | +from reproduce import rational_sqrt, solve | |
| 11 | + | |
| 12 | + | |
| 13 | +HERE = Path(__file__).resolve().parent | |
| 14 | +REPO = HERE.parents[1] | |
| 15 | +PR4_COMMIT = "73e7e691800cc002741c652ea2eab171320bf988" | |
| 16 | +PR4_ROUTE = "routes/rusirui-rational-verifier" | |
| 17 | + | |
| 18 | + | |
| 19 | +def git_text(*args): | |
| 20 | + result = subprocess.run( | |
| 21 | + ["git", *args], cwd=REPO, check=True, capture_output=True, text=True | |
| 22 | + ) | |
| 23 | + return result.stdout | |
| 24 | + | |
| 25 | + | |
| 26 | +def upstream_json(path): | |
| 27 | + return json.loads(git_text("show", f"{PR4_COMMIT}:{path}")) | |
| 28 | + | |
| 29 | + | |
| 30 | +def fixture_paths(outcome): | |
| 31 | + prefix = f"{PR4_ROUTE}/samples/{outcome}" | |
| 32 | + listing = git_text("ls-tree", "-r", "--name-only", PR4_COMMIT, "--", prefix) | |
| 33 | + return [path for path in listing.splitlines() if path.endswith("/configuration.json")] | |
| 34 | + | |
| 35 | + | |
| 36 | +class ReproductionTests(unittest.TestCase): | |
| 37 | + def test_grid_output_matches_proposal(self): | |
| 38 | + config = upstream_json(f"{PR4_ROUTE}/configuration.json") | |
| 39 | + expected = upstream_json(f"{PR4_ROUTE}/example-verification.json") | |
| 40 | + self.assertEqual(solve(config), expected) | |
| 41 | + | |
| 42 | + def test_all_accept_fixture_counts(self): | |
| 43 | + files = fixture_paths("accept") | |
| 44 | + self.assertEqual(len(files), 6) | |
| 45 | + for path in files: | |
| 46 | + with self.subTest(sample=Path(path).parent.name): | |
| 47 | + data = upstream_json(path) | |
| 48 | + self.assertEqual(solve(data)["unit_circles"], data["unit_circles"]) | |
| 49 | + | |
| 50 | + def test_original_cli_on_all_samples_and_stale_output(self): | |
| 51 | + verifier = git_text("show", f"{PR4_COMMIT}:{PR4_ROUTE}/verify.py") | |
| 52 | + for outcome in ("accept", "reject"): | |
| 53 | + files = fixture_paths(outcome) | |
| 54 | + self.assertEqual(len(files), 6) | |
| 55 | + for path in files: | |
| 56 | + with self.subTest(outcome=outcome, sample=Path(path).parent.name): | |
| 57 | + raw = git_text("show", f"{PR4_COMMIT}:{path}") | |
| 58 | + with tempfile.TemporaryDirectory() as folder: | |
| 59 | + root = Path(folder) | |
| 60 | + route = root / "route" | |
| 61 | + route.mkdir() | |
| 62 | + (route / "configuration.json").write_text(raw, encoding="utf-8") | |
| 63 | + output = root / "verification.json" | |
| 64 | + output.write_text("stale", encoding="utf-8") | |
| 65 | + run = subprocess.run( | |
| 66 | + [sys.executable, "-", str(route), "--output", str(output)], | |
| 67 | + input=verifier, | |
| 68 | + cwd=REPO, | |
| 69 | + capture_output=True, | |
| 70 | + text=True, | |
| 71 | + ) | |
| 72 | + if outcome == "accept": | |
| 73 | + self.assertEqual(run.returncode, 0, run.stderr) | |
| 74 | + actual = json.loads(output.read_text(encoding="utf-8")) | |
| 75 | + self.assertEqual(actual, solve(json.loads(raw))) | |
| 76 | + else: | |
| 77 | + self.assertEqual(run.returncode, 1, run.stderr) | |
| 78 | + self.assertFalse(output.exists()) | |
| 79 | + | |
| 80 | + def test_eighty_point_grid(self): | |
| 81 | + points = [[x, y] for x in range(10) for y in range(8)] | |
| 82 | + result = solve({"points": points}) | |
| 83 | + self.assertEqual(result["n"], 80) | |
| 84 | + self.assertEqual(result["unit_circles"], 76) | |
| 85 | + | |
| 86 | + def test_rational_square_detection(self): | |
| 87 | + self.assertEqual(rational_sqrt(Fraction(9, 16)), Fraction(3, 4)) | |
| 88 | + self.assertIsNone(rational_sqrt(Fraction(2, 3))) | |
| 89 | + | |
| 90 | + | |
| 91 | +if __name__ == "__main__": | |
| 92 | + unittest.main(verbosity=2) | |