Skip to content

feat: add lake check as a comparator frontend - #14885

Draft
Kha wants to merge 3 commits into
masterfrom
lake-check
Draft

feat: add lake check as a comparator frontend#14885
Kha wants to merge 3 commits into
masterfrom
lake-check

Conversation

@Kha

@Kha Kha commented Aug 21, 2026

Copy link
Copy Markdown
Member

This PR ships lake check as a frontend to comparator, significantly simplifying its setup. landrun remains a hard requirement with no unsandboxed mode, so the command is available on Linux only for now.

The configuration is unchanged from comparator, passed with --config. Exit codes have become more fine-grained: 2 for failing to start at all, such as a missing landrun or a configuration that is absent or malformed, and 1 for a rejected solution, so that a caller can tell an environment problem from a judgment.

lean4export becomes the leanexport toolchain binary, vendored at 3de59f10, and comparator's libraries land under Lake.Check (no separate executable), vendored at 4c921f7ab3ce.

To follow: additional checking modes and configurations.

@Kha Kha added the changelog-lake Lake label Aug 21, 2026
@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Aug 21, 2026
@leanprover-bot

leanprover-bot commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-08-13 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-08-21 16:49:25)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 71a4d9a3e573916b2bbcb49ad9e1ca62851b77da --onto 16e77c407779fde9a649adf3478204d1915371a3. You can force reference manual CI using the force-manual-ci label. (2026-08-25 08:36:51)

@github-actions github-actions Bot added the mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN label Aug 21, 2026
@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Aug 21, 2026
@mathlib-lean-pr-testing

mathlib-lean-pr-testing Bot commented Aug 21, 2026

Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❌ Mathlib branch lean-pr-testing-14885 built against this PR, but linting failed. (2026-08-21 18:14:24) View Log
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 71a4d9a3e573916b2bbcb49ad9e1ca62851b77da --onto fd0efc4306a7773c2cd4e079ddaa907426d0f5da. You can force Mathlib CI using the force-mathlib-ci label. (2026-08-25 08:36:49)

@Kha Kha changed the title feat: add lake check as a leanchecker/comparator frontend feat: add lake check as a comparator frontend Aug 24, 2026
@Kha
Kha marked this pull request as ready for review August 24, 2026 12:36
@Kha
Kha requested a review from tydeu as a code owner August 24, 2026 12:36
@Kha
Kha requested a review from hargoniX August 24, 2026 12:36
@Kha
Kha marked this pull request as draft August 24, 2026 13:55
Kha and others added 3 commits August 25, 2026 12:07
This PR ships the Lean NDJSON exporter as a new `leanexport` toolchain binary and vendors the proof-comparison libraries of [Comparator](https://github.com/leanprover/comparator) into Lake. There is no user-visible behavior change yet; `lake challenge` follows.

The exporter lands under a single `LeanExport` module prefix (`src/LeanExport.lean` plus `src/LeanExport/{Basic,Parse}.lean`) and is built like `leanchecker`/`leanir`. Since `Lake.Check` imports `LeanExport.Parse`, `libLake_shared` additionally links `libLeanExport.a.export`; the archive is linked without `--whole-archive` so the exporter's `main` stays out of the shared library. `tests/lake/lakefile.toml`, which builds Lake standalone, gains a matching `LeanExport` library for the same reason.

Every vendored file is byte-identical to its upstream source once the module header and the `LeanExport`/`Lake.Check` namespace wrapper are removed, so the diff can be checked mechanically rather than read. The sources are `lean4export` at `3de59f10` and Comparator at `8d84e678`. `leanexport` accordingly produces byte-identical output to upstream `lean4export` built against the same toolchain.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This PR vendors Comparator's `Main.lean` as `Lake/CLI/Check.lean`. There is no user-visible behavior change: nothing calls it yet, and `lake check` follows in the next commit.

The code is transliterated rather than rewritten, so that it diffs cleanly against upstream: only the module header, the `Lake.Check` namespace, the `LeanExport` names and `Kernel.Environment.replay` (which `Environment.replay` is now deprecated in favor of) differ. The executable `main` is dropped, since this is a library module.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This PR ships Comparator as `lake challenge`, so judging a solution no longer means cloning a repository, matching its toolchain to the one that built the `.olean` files, and hand-writing the wiring: a challenge author distributes the project and its configuration, and a solver runs one command. `landrun` remains a hard requirement with no unsandboxed mode, so the command is available on Linux only.

The configuration is Comparator's, unchanged, passed with `--config`. Exit codes now split three ways instead of raising a `userError` for everything: 2 for failing to start at all, such as a missing `landrun` or a configuration that is absent or malformed, and 1 for a rejected solution, so that a caller can tell an environment problem from a judgment.

`lean4export` becomes the `leanexport` toolchain binary, so third-party checkers can keep using it standalone, and Comparator's libraries land under `Lake.Check`. Both are vendored from `lean4export` at `3de59f10` and Comparator at `4c921f7ab3ce`, byte-identical to their sources once the module header and the namespace wrapper are removed, so that part of the diff can be checked mechanically rather than read. `leanexport` accordingly produces byte-identical output to upstream built against the same toolchain.

The commits separate the vendoring from the changes: the libraries, then Comparator's `Main.lean` as `Lake/CLI/Check.lean` wired to nothing, then the departures from that baseline, so that the third diff is the review surface. Those departures are the exit codes above; `LeanInstall.sysroot`, `LakeInstall.lake` and the bundled `leanexport` in place of `PATH` lookups, which removes a weak link inside the sandbox; `LEAN_PATH` taken from the loaded workspace rather than requiring a `lake env` wrapper; and a `git` lookup that reports absence instead of throwing.

`COMPARATOR_LEAN4EXPORT` is deliberately not honored. The export format has to match the compiler that produced the `.olean` files, which is exactly the pinning this change removes, so honoring a stale setting from an existing CI configuration would quietly reintroduce it. `COMPARATOR_LANDRUN` and `COMPARATOR_NANODA` keep working, since neither tool is bundled.

Comparator's test projects become `tests/lake/tests/check-*`, along with its `fake-landrun.sh` stand-in, which the tests select through `COMPARATOR_LANDRUN` since Landlock cannot be assumed available in CI containers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@tydeu
tydeu removed their request for review August 25, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan changelog-lake Lake mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants