--- name: formal-math-conjectures description: Solve or reduce hard Lean 4 targets in DeepMind formal-conjectures and Left to Solve. Run a finite batch or an explicitly continuous research campaign, verify proofs and land eligible contributions. license: MIT metadata: source: "https://github.com/vincentkoc/dotskills" --- # Formal Math Conjectures ## Purpose Select an unclaimed Lean 4 target, prove it or reduce it to a precise remaining question, and replay the result. Publish eligible work to the authorized notebook or host project. ## When to use - The owner asks to work on Lean conjectures, formal-math problems, formal-conjectures, Left to Solve, Compfiles, or similar formalization projects. - The owner asks to run, resume, or orchestrate a formal-math research campaign. - You are choosing a project and need its AI policy, claim rules, and skip conditions. Do not use this skill to open unsupervised PRs against Mathlib. Do not use it to publish solutions to evaluation benchmarks such as PutnamBench. ## Workflow 1. Use the requested cap, or start a small batch by default. An explicit request to keep working continually selects continuous mode. Start immediately and use the continuation rules below. Hold at most two Left to Solve leases across the campaign. 2. Set up Lean 4 only if this machine does not already have a working toolchain. See Setup below. Read the selected host’s [commands and policies](references/projects.md). 3. Pick a project from that catalog. Prefer work the owner named; otherwise pick a project that still has unclaimed, policy-compatible targets. 4. **Pre-claim check.** Skip the target if anyone already has a solution or an in-flight PR. Search all of: - Open *and* closed pull requests and issues in the *target* repository (title, declaration name, OEIS id, Erdős number, file path). - Left to Solve's [solved index and category fallback](references/projects.md#left-to-solve) and [Open Math Agents pull requests](https://github.com/lefttosolve2/open-math-agents/pulls). Search open and closed PRs by the paper ID or top-level problem name alone, newest update first, before adding method or subproblem terms. Repeat that broad search before publishing a claim that the target is open. A recent proof can precede its solved-index entry. A proof merged there counts as already solved, even when the same statement is still `sorry` upstream in `google-deepmind/formal-conjectures`. [formal-conjectures#8406](https://github.com/google-deepmind/formal-conjectures/pull/8406) duplicated statements already proved in open-math-agents; do not repeat that. - If GitHub rejects the Open Math Agents repository qualifier, resolve its stable repository ID with `ghx --no-cache api repositories/1471973920 --jq .full_name` and repeat the search with the returned `repo:` value. A redirected PR URL can work even when search rejects the former name. - Look up the indexed declaration ID when a tracker returns `unknown_problem`. For example, Left to Solve drops Lean’s `«»` around arXiv identifiers. Confirm matches against the statement and the linked proof. - Inspect relevant open PRs on the host and linked proof projects at their head commits. Search their changed Lean files for the proposed helper or construction as well as the named target. GitHub’s default-branch code search can miss a proof embedded in a related PR. If a helper overlaps, credit it and choose a distinct remaining step. - When a PR diff or file listing is too large to load, resolve `refs/pull//head` in the base repository with `git ls-remote`. For a known path, read `contents/?ref=` through the GitHub API. To locate a file, read `git/commits/`, follow each directory through nonrecursive `git/trees/` responses, then read `git/blobs/`. Check the declarations in the decoded source and record its head, path and blob ID. A missing entry in a truncated tree leaves the comparison open. - Check the personal notebook, active assignments and proofs awaiting release. Compare declaration types and unfold the definitions they use. If a queued theorem already implies the proposed result, reuse it and any matching replay receipt. Preserve its release order. 5. For hard problems, read the pinned statement and its primary source. If the paper has changed, compare the pinned and revised claims clause by clause. When the target depends on a published theorem, also check later papers citing it. Read their current theorem statements and compare constants, assumptions and conclusions before choosing which bound to formalize. Cite the version and exact coverage, including a single inequality of a two-sided conjecture. Extend the strongest applicable result or isolate a missing hypothesis that would imply the target. Record the precise implication, construction or counterexample being attempted. Test values alone rarely advance a research question. - When the proof changes mathematical language, search the equivalent statement in that field before describing it as new. For example, “five independent binary relations” becomes “corank five”, and a deletion-minimal obstruction to two linear functionals is a “minimal 2-block”. These terms lead directly to [Oxley’s Theorem 3.6.4](https://ora.ox.ac.uk/objects/uuid%3A7c99a546-32d3-4206-a3a1-25c60fe7cf72/files/m05e3c0de751ad84ff55ab72e27c183f3). Credit the mathematical result and state what the Lean proof or application adds. 6. Claim or start work only after the pre-claim check is clean. Follow that project's claim protocol (comment to claim, `tools/oma.sh next`, and so on). 7. Prove or formalize on a branch off a freshly fast-forwarded default branch. For `open-math-agents`, fetch and fast-forward the owner's fork `main` from upstream before branching; the fork can lag by hundreds of commits. Keep the change scoped: one problem, or a tight cluster of tests and variants, per PR. 8. Check before opening a PR: - Before freezing sources for a long kernel replay, include new Lean files in the whitespace check. Stage just the intended proof paths with `git add -- `, then run `git diff --cached --check -- `. If the files need to stay unstaged, check their contents directly. Plain `git diff --check` skips untracked files. - Before a long independent replay, elaborate the exact generated comparison file against the compiled development modules. Check every typed example and match each `#print axioms` result to the expected fully qualified name. If a note embeds several Lean bridges, select each block by its declared namespace and compare its bytes with the checked source. Pass the same comparison file to the independent replay. - `lake build` the changed file(s). - No `sorry` or `admit` in changed declarations, unless the project is a statement repository and the leftover `sorry` is the intended open conjecture. - `#print axioms` of new proofs lists only `propext`, `Classical.choice`, and `Quot.sound`. - For Left to Solve, run `tools/oma.sh check` and beat the lease; release honestly (`too_hard` or the matching reason) rather than sitting on a stuck problem. - For a large lemma, split it with `tools/oma.sh reduce` (or the project's equivalent). Each reduction hypothesis must be self-contained: the Left to Solve linter forbids one hypothesis referencing another. Keep a `NOTES.md` per deep target. Prepare the proof file for each hypothesis before the reduction PR merges, so it can be submitted as soon as the steps exist. 9. For an authorized host submission, repeat the pre-claim check immediately before submitting. Open a **full** (non-draft) pull request when the result meets that host’s contribution rules. Disclose AI assistance the way that project requires. Do not write AI-authored review comments or Zulip messages. Track review and respond; do not open a second PR for the same target. 10. **Update the contribution catalogue.** When an external PR opens, merges or closes, or a dead-end note is published on its host, update [vincentkoc/solved-conjectures](https://github.com/vincentkoc/solved-conjectures). Start from the catalogue’s current default branch. Verify the live PR status or Left to Solve note ID immediately before recording it. Run the catalogue's add-entry script to upsert the index and regenerate the README (columns: Project, Problem/step, Status, PR). Copy Lean files into the proofs directory for merged or open proofs (and for a superseded proof that is still ours). Do not put names, emails, timezone, location, or local paths in the catalogue; the public GitHub handle is enough, and dates are plain `YYYY-MM-DD`. Publish the signed change through the catalogue’s authorized landing workflow. The exact command is in [the catalogue update procedure](https://github.com/vincentkoc/solved-conjectures/blob/main/scripts/README.md). 11. Report the checked declaration, exact coverage, remaining gap and landed commit or PR. In a finite batch, stop at the cap. In continuous mode, take the next eligible step without awaiting a reply. ### Continuous research - Resume from the live notebook, active branches, PRs and leases. Give each worker a distinct target, worktree and result directory. Keep the problem name, upstream revision and next mathematical question with its proof. If the owner names tmux panes, verify the current pane ID and foreground program, submit the literal assignment once, and confirm the worker received it. Never reconstruct a dispatch from shell history. Pass the verified pane ID explicitly to later commands such as `tt title "$pane_id" "workstream"` and `tt sync "$pane_id"`. Shells launched by a shared app server can inherit another client’s `TMUX_PANE`. - When workers share a worktree lifecycle lock, give all lanes on that host the same queue or a separate campaign-owned lock for native enrollment and closeout commands. Keep proofs running in parallel. Set the outer wait longer than a measured native checkout on the same volume. If the wait expires before GWT starts, check registration once and wait for the observed holder to change before retrying. A busy enrollment can leave the new branch and checkout already registered. Inspect their state before retrying. - When the owner requests a native `/goal` for workers, set it in each existing assigned thread. Check its thread ID, objective and active status. Give the goal the research scope and landing criteria, so a single merge leaves the campaign active. Once verified, retire any campaign-owned mechanism that sends continuation prompts to those threads. Keep ongoing proofs and PRs in place. - Replay the saved Lean file using the pinned dependencies. When reusing a cache from a different checkout revision, verify the toolchain, dependency pins and relevant upstream sources. If a shared checkout moves during a run, recover changed sources from the pinned Git blobs in the task’s dependency root. Rebuild and kernel-check the changed modules and their transitive importers in the active graph, including umbrella modules. A worker can reuse that rebuild after matching the pinned sources, imports and complete object families. Put the qualified roots first on `LEAN_SRC_PATH` and `LEAN_PATH`, then verify the compiler resolves every project source there. Keep earlier receipts tied to their original inputs. Check the theorem’s type against the upstream definitions, its quantifiers and its axioms. Distinguish a solved host declaration, a known theorem newly formalized, a conditional implication and a partial bound. - When you compile an external proof directly with `lean`, read the package and target `leanOptions` at the pinned revision. A direct invocation can miss a setting that `lake build` would pass. If the proof fails, compare the first failing declaration with those options before editing its source. Record the effective options and replay the compiled module in the kernel. - When an external proof keeps a needed definition or lemma `private`, append a small `namespace` and `export OriginalNamespace (helper)` to a replay copy of its pinned source. Import that module in the caller. `export` preserves the original definition, so lemmas about it still rewrite matching expressions. Check the original blob before appending, keep its license and credit, and replay the caller as a separate module. [Checked source appendix and replay instructions](https://github.com/vincentkoc/solved-conjectures/blob/09d6cf6b59f29eaf7f13aca65d3ae5591096b34b/research/green/WEIGHTED-CUBE-SEPARATORS.md#sources-and-replay) - For a transitive source manifest, follow the paths returned by `lake env lean --src-deps FILE` recursively and deduplicate resolved paths before checking their Git blobs against the pin. Quoted Lean name components can contain literal dots. For example, `Arxiv.«1104.1579»` resolves to the directory `Arxiv/1104.1579`. Include root-level FC modules such as `FormalConjecturesUtil.lean` when Lean resolves them. For a signed notebook revision, read its path and blob IDs with one `git ls-tree -rz REV -- research`. Match every replayed path. Verify the complete path set inside the process that reads the manifest. Return its count, digest and any mismatches. A tool can shorten a path list while preserving valid JSON. If the manifest uses SHA-256 of file contents, send the matched IDs to one `git cat-file --batch` process and hash each size-delimited blob. To verify the squash and current main, compare the same paths and blob IDs in their trees. - When several proofs use the same large external theorem, assign its pinned build to one worker. Share the checked import paths, source manifest and axiom report. Record the output files each pinned module emitted and match their hashes when reusing a build. On Lean 4.33.1, `LeanChecker.replayFromImports` checks the last available part of a split module. An exported `.olean` alone can pass while private declarations go unchecked. Before replay, verify the original `.olean`, `.olean.server` and `.olean.private` parts and retain any emitted `.ir` and `.ir.sig` files. If a part was omitted, restore it from the checked build and replay that module and any consumers whose dependency receipts changed. Each consumer checks the theorem against its own definitions and replays the application. If two dependency revisions contain different sources under the same Lean module name, build the application with only the compatible revision on its search path. [Worked Bombieri–Vinogradov application](https://github.com/vincentkoc/solved-conjectures/blob/1f716355b7a82293e2104e77772d6a567744e8b0/research/arxiv/theta-sum/UNCONDITIONAL-PRIME-WINDOWS.md#external-proof-and-reproducibility) - When rebuilding compatible pinned modules under the same top-level import prefix, write their `.olean` files into one temporary root with their original module paths. On Lean 4.33.1, if two `LEAN_PATH` entries contain `FormalConjectures/`, the first directory shadows the second. Verify the layout by importing the required declarations’ modules together. - When an independently rebuilt `.olean` hash differs, compare the source and dependency hashes. If they agree, compile the affected module from the original source path into a separate output directory. Lean can embed that path in an object. Record whether the hashes then agree and replay the exact module in the kernel. - For a module with several claimed results, match each full declaration name to its `#print axioms` report, including trailing primes such as `f'`. Before a long replay, run the complete generated `#check` and `#print axioms` file against the development objects. Use the same file for the independent comparison. Lean resolves names in the active namespace. For example, inside `namespace Example`, `#print axioms Perfect.sidon` can report `Example.Perfect.sidon`. Compare the name Lean prints with the intended declaration. If a report is missing, query the fully qualified declaration from the compiled module and check its axioms. - For an imported private declaration, build its kernel name with `Lean.mkPrivateNameCore moduleName userName`. The `0` in a printed `_private` name is a numeric component. Check that `env.getModuleIdxFor?` identifies the defining module, then pass the kernel name to `Lean.collectAxioms`. - For a note with multiple Lean code blocks, match each expected module to exactly one block by its declared namespace or source label. Compile each selected block under its module name and check its own named axiom reports. A first-match search can replay the same block twice. [Two independent modules in one note](https://github.com/vincentkoc/solved-conjectures/blob/dc4b5a1bc695431df47943f8fe0fe67ae1d9862a/research/arxiv/theta-sum/DOUBLE-EXPONENTIAL-TAILS.md) - For a notebook proof, set `runner="$PWD/scripts/replay-research"` at the notebook root. From the pinned Formal Conjectures checkout, run `lake env python3 "$runner" ModuleName`. Supply the filename stem of each result you changed. The runner discovers its imports, rebuilds the closure and checks each compiled module in a fresh kernel process. Omit module names for a full notebook replay. For separate dependencies checked with `leanchecker -v`, run one name at a time and inspect the matches. Lean 4.33.1 treats CLI names as prefixes. To inspect flags, read `src/lean/LeanChecker.lean` under the pinned toolchain prefix. Running `leanchecker --help` on this version selects the default target and can scan every object on the search path. - For a supplemental `replayFromImports` check, load `LeanChecker` from the toolchain and restore the compilation search path with `Lean.initSearchPath`. Pass a quoted Lean name for a fixed module. For a name assembled from source path components, use `parts.foldl Lean.Name.str .anonymous`. This preserves numeric filenames such as `FormalConjectures.GreensOpenProblems.«51»`. Run each object in a fresh process. - Before the first elaboration of a draft module, compare its resolved Lean name and source bytes with the signed base and pending proofs. Build that name inventory from every tracked Lean source on the base, including modules outside the proof’s import closure. Rename a conflicting draft and update its imports before building. A draft that shadows a transitive ancestor can create an import cycle in a previously acyclic build. If import-time memory grows unexpectedly, read the resolved objects’ direct imports with `Lean.readModuleData` and track names on the current DFS path to identify a cycle without importing it. - If development runs ahead of independent replay, register each development-checked result in the existing queue before rotating targets. Match its declaration and place it after any pending prerequisites. Keep its status as awaiting replay until the independent receipt passes. - Before creating a release worktree, trace the queued proof’s imports against its sources and the proposed base. Land any missing queued prerequisite first. - When a proof imports work from a pending notebook PR, a clean replay can start from that PR’s signed head. Record paths and contents for every source in the import closure, along with the toolchain and upstream pin. Resolve the disposable source root to its physical path before discovering Lean imports. Reuse the replay after merge when the entire manifest matches. Rebuild the affected closure if an input changed. - A successor proof can reuse an earlier kernel check for an unchanged module. Walk the compiler-resolved imports in dependency order. Match the toolchain and external pins, source path and bytes (including any generated appendix), compiled object hash, named axiom report and receipts for all imports. Rebuild and replay new modules and every dependent of a changed input. On resume, revalidate each saved module receipt in place. Leave matching records untouched. Write any changed object and receipt parts before atomically replacing their completion record. Check the current host theorem and report fresh and reused module counts separately. [Worked prime-factor proof](https://github.com/vincentkoc/solved-conjectures/pull/718) - In generated Lean comparisons, leave spaces on both sides of `<` and `≤`. With mathlib loaded, `(1 : ℝ) SelectMode SelectMode --> VerifyWorkerGoals: owner requests worker goals VerifyWorkerGoals --> SelectTarget: goal active in each assigned thread VerifyWorkerGoals --> Report: wrong thread or unavailable goal SelectMode --> SelectTarget: finite batch or other continuous run SelectTarget --> CheckPriorWork CheckPriorWork --> Next: duplicate or claimed CheckPriorWork --> Prove: eligible Prove --> Verify Verify --> Prove: repairable proof failure Prove --> Next: record obstruction and release lease Verify --> ChooseDestination: type and axioms checked ChooseDestination --> Next: local result retained ChooseDestination --> PublishNotebook: authorized notebook result ChooseDestination --> RecheckHost: eligible host contribution RecheckHost --> Next: another submission found RecheckHost --> Submit: authorized and still eligible Submit --> Catalogue: verified host event PublishNotebook --> Next: verify landing Catalogue --> Next Next --> SelectTarget: continuous or below cap Next --> Report: cap or no eligible work SelectTarget --> Report: owner stop or all routes blocked Report --> [*] ```