| 1 | """Check a known-cases map: every case sourced, status consistent with peer review, two reviews.""" |
| 2 | import json, sys |
| 3 | from pathlib import Path |
| 4 | |
| 5 | STATUS = {"proved", "claimed", "retracted"} |
| 6 | |
| 7 | def fail(msg): |
| 8 | print(f"rejected: {msg}") |
| 9 | sys.exit(1) |
| 10 | |
| 11 | def main(): |
| 12 | if len(sys.argv) != 2: |
| 13 | fail("usage: python3 verify.py <route folder>") |
| 14 | f = Path(sys.argv[1]) / "cases.json" |
| 15 | if not f.exists(): |
| 16 | fail("cases.json missing") |
| 17 | try: |
| 18 | d = json.loads(f.read_text(encoding="utf-8")) |
| 19 | except ValueError as e: |
| 20 | fail(f"cases.json is not JSON: {e}") |
| 21 | if d.get("example"): |
| 22 | print("EXAMPLE ONLY: reviewers are fictional; sources still to be checked") |
| 23 | cases = d.get("cases") |
| 24 | if not isinstance(cases, list) or not cases: |
| 25 | fail("cases must be a nonempty list") |
| 26 | for i, c in enumerate(cases, 1): |
| 27 | for k in ("variety", "statement", "status", "source", "coefficients"): |
| 28 | if not isinstance(c.get(k), str) or not c[k].strip(): |
| 29 | fail(f"case {i}: {k} missing") |
| 30 | dim = c.get("dimension") |
| 31 | if not (dim == "any" or (isinstance(dim, int) and dim >= 1)): |
| 32 | fail(f"case {i}: dimension must be a positive integer or 'any'") |
| 33 | if c["coefficients"] not in ("rational", "integral"): |
| 34 | fail(f"case {i}: coefficients must be rational or integral") |
| 35 | if c["status"] not in STATUS: |
| 36 | fail(f"case {i}: status must be proved, claimed or retracted") |
| 37 | if not isinstance(c.get("peer_reviewed"), bool): |
| 38 | fail(f"case {i}: peer_reviewed must be true or false") |
| 39 | if c["status"] == "proved" and not c["peer_reviewed"]: |
| 40 | fail(f"case {i}: {c['variety']} marked proved without a peer-reviewed source; use claimed") |
| 41 | author = str(d.get("author", "")).strip() |
| 42 | if not author: |
| 43 | fail("author missing") |
| 44 | reviews = {r.strip() for r in d.get("reviews", []) if isinstance(r, str) and r.strip()} |
| 45 | reviews.discard(author) |
| 46 | if len(reviews) < 2: |
| 47 | fail(f"need 2 reviews other than the author, found {len(reviews)}") |
| 48 | counts = {s: sum(c["status"] == s for c in cases) for s in sorted(STATUS)} |
| 49 | print("status: " + ", ".join(f"{k} {v}" for k, v in counts.items())) |
| 50 | print(f"map: {len(cases)} cases, every case sourced") |
| 51 | |
| 52 | main() |