8000 feat: Upstream `MPL.SPred.*` from `mpl` by sgraf812 · Pull Request #8745 · leanprover/lean4 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Upstream MPL.SPred.* from mpl #8745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2025
Merged

feat: Upstream MPL.SPred.* from mpl #8745

merged 1 commit into from
Jun 20, 2025

Conversation

sgraf812
Copy link
Contributor
@sgraf812 sgraf812 commented Jun 12, 2025

This PR adds a logic of stateful predicates SPred to Std.Do in order to support reasoning about monadic programs. It comes with a dedicated proof mode the tactics of which are accessible by importing Std.Tactic.Do.

@sgraf812 sgraf812 added the changelog-library Library label Jun 12, 2025
Comment on lines 16 to 18

Note that this does not contain meta programs that implement tactics themselves because these would
rely on importing things from `Lean` which cannot done in `Std`.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this comment block, Std.Tactic might be a strange to put the proof mode.
I also don't understand the comment. Can you implement a tactic without depending on Lean?
Besides, the definitions I added depend on Lean without introducing any cycles (apparently).
Is this comment perhaps out of date?

Indepdently, I don't like Std.Tactic.Do.ProofMode.Tactic.Refine much. Quite long and the initial Tactic is redundant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, probably you shoud just move the tactic stuff from Std.Tactic to Lean.Elab.Tactic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the permitted dependency ordering is Lean -> Std -> Init (and no other edges). Makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lean.Elab.Tactic.Do.ProofMode.Tactic.Refine isn't exactly an improvement, but I take solice in the fact there also is Lean.Meta.Tactic.Simp.Arith.Nat.Simp.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, spent quite some time refactoring elaborators in terms of @[builtin_tactic] and moving modules around. Would appreciate if you could give the directory outline a quick glance and nod.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid it's not quite right yet.

If you are using @[builtin_tactic] (which is the right thing to do in this case), then one of the following must still be true:

  • the corresponding syntax must be a builtin_parser, and all lemmas that are referenced by the terms generated by your tactic are part of Init, or
  • the user must import the module where the syntax is declared and the contains all auxiliary lemmas.

Now, I'm pretty sure we don't want to ask users to import something from Lean to get access to your tactics, as Lean.* is reserved for metaprogramming and implementation details. Instead, we will want to follow the bv_decide route, where you import Std.Tactic.BVDecide. So I suggest moving the syntax of your tactics to Std.Tactic.Do and make sure that Std.Do gets transitively imported from there.

In addition, bv_decide defines a macro in Init directing users to the correct import. I think this is a good idea that you should copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I think now I've got it.

the corresponding syntax must be a builtin_parser, and all lemmas that are referenced by the terms generated by your tactic are part of Init, or

(Not relevant to this PR, but FYI intro is a counterexample (Lean.Elab.Tactic.evalIntro), because it combines regular, non-builtin syntax with a @[builtin_tactic]. I think that's OK because intro syntax is not expected to change. But maybe your rule does not apply to syntax defined in Init.)

In addition, bv_decide defines a macro in Init directing users to the correct import. I think this is a good idea that you should copy.

Done. I added the erroring stub macros including docstrings to src/Init/Tactics.lean and the actual syntax definitions to src/Std/Tactic/Do/Syntax.lean. My test file seems to be happy.

If there isn't anything else, I'll merge today. There will be follow-up MRs next week to do touch ups.

@sgraf812 sgraf812 force-pushed the sg/upstream-spred branch 2 times, most recently from 9b48813 to 43875af Compare June 13, 2025 08:16
@sgraf812 sgraf812 force-pushed the sg/upstream-spred branch 2 times, most recently from 6aa1fb7 to 4dd37ba Compare June 13, 2025 15:41
@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 Jun 13, 2025
@leanprover-community-bot
Copy link
Collaborator
leanprover-community-bot commented Jun 13, 2025

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase c2876a1a6a42e6df458ffb37abbc3868632beb58 --onto faffe863343211d03d07d4ef19d90a2aa9d6fc8c. You can force Mathlib CI using the force-mathlib-ci label. (2025-06-13 16:07:38)
  • ❗ Batteries CI can not be attempted yet, as the nightly-testing-2025-06-12 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Batteries CI should run now. You can force Mathlib CI using the force-mathlib-ci label. (2025-06-13 16:42:09)

@sgraf812 sgraf812 force-pushed the sg/upstream-spred branch 3 times, most recently from 7e9cb89 to 80b9764 Compare June 20, 2025 10:37
@sgraf812 sgraf812 marked this pull request as ready for review June 20, 2025 10:38
@sgraf812 sgraf812 requested a review from kim-em as a code owner June 20, 2025 10:38
@sgraf812 sgraf812 force-pushed the sg/upstream-spred branch from 80b9764 to 17b13fd Compare June 20, 2025 14:47
@sgraf812 sgraf812 added this pull request to the merge queue Jun 20, 2025
Merged via the queue into master with commit 61ee83f Jun 20, 2025
15 checks passed
@sgraf812 sgraf812 deleted the sg/upstream-spred branch June 20, 2025 16:42
@sgraf812 sgraf812 restored the sg/upstream-spred branch June 22, 2025 08:35
sgraf812 pushed a commit that referenced this pull request Jun 22, 2025
sgraf812 added a commit that referenced this pull request Jun 22, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jun 22, 2025
Reverts #8745 until I take a closer look on its breakage
in Mathlib on Monday
wkrozowski pushed a commit to wkrozowski/lean4 that referenced this pull request Jun 24, 2025
This PR adds a logic of stateful predicates `SPred` to `Std.Do` in order
to support reasoning about monadic programs. It comes with a dedicated
proof mode the tactics of which are accessible by importing
`Std.Tactic.Do`.

Co-authored-by: Sebastian Graf <sg@lean-fro.org>
wkrozowski pushed a commit to wkrozowski/lean4 that referenced this pull request Jun 24, 2025
)

Reverts leanprover#8745 until I take a closer look on its breakage
in Mathlib on Monday
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-library Library 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.

3 participants
0