Skip to content

feat: allow a general evalTac at evalSepTactics #7702

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

JovanGerb
Copy link
Contributor

@JovanGerb JovanGerb commented Mar 27, 2025

This PR generalizes evalSepTactics, so that users can use incremental elaboration in their own proof environment.

#lean4 > custom incremental elaboration

This was suggested by @mirefek

@JovanGerb JovanGerb requested a review from kim-em as a code owner March 27, 2025 18:39
@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 Mar 27, 2025
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Mar 27, 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 7bd937580494311ecdb9502a7b5ab0ccf473bd44 --onto 1465c23e12f6f8b608ef944be4559b1b5e38f40a. You can force Mathlib CI using the force-mathlib-ci label. (2025-03-27 19:02:53)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 7bd937580494311ecdb9502a7b5ab0ccf473bd44 --onto 060b2fe46fe728934744ee52271b92ab74cbd5b4. You can force Mathlib CI using the force-mathlib-ci label. (2025-03-29 13:19:18)

@JovanGerb
Copy link
Contributor Author

changelog-language

@github-actions github-actions bot added the changelog-language Language features, tactics, and metaprograms label Mar 28, 2025
@leanprover-bot leanprover-bot added the P-medium We may work on this issue if we find the time label Apr 1, 2025
-/
partial def evalSepTactics : Tactic := goEven

The user can provide their own tactic evaluation function `evalTac`.
Copy link
Member

Choose a reason for hiding this comment

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

Could you please expand this comment with an example of why one might want to do this? Otherwise future maintainers will be absolutely puzzled.

Copy link

Choose a reason for hiding this comment

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

I would write something like this:

Assume a tactic developer writes a new general modified tactic execution,
for example calling automation each step, displaying the goal in a specific
way, modifying the behavior of some tactics...

def customEvalTactic : Tactic :=

Then it is possible to create a tactic scope in which this tactic is called
on each line of the scope, while preserving the incremental elaboration by

@[tactic my_scope, incremental]
def myScopeElab : Tactic := fun stx => do
  withNarrowedArgTacticReuse 1 (
    withNarrowedArgTacticReuse 0 (
      withNarrowedArgTacticReuse 0 (
        (evalSepTactics customEvalTactic)
      )
    )
  ) stx

@@ -120,7 +123,7 @@ where
Term.withNarrowedTacticReuse (fun stx => (stx[0], mkNullNode stx.getArgs[1:])) goEven stx

@[builtin_tactic seq1] def evalSeq1 : Tactic := fun stx =>
evalSepTactics stx[0]
(evalSepTactics) stx[0]
Copy link
Member

Choose a reason for hiding this comment

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

Please just pass the argument explicitly, in which case we may as well remove the default value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-language Language features, tactics, and metaprograms P-medium We may work on this issue if we find the time 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.

5 participants