Zulip Chat Archive

Stream: lean4

Topic: custom incremental tactic and commands


Tomas Skrivan (Jul 02 2024 at 00:09):

Having incrementality in the new Lean version is really nice!

I'm interested in writing my own incremental commands and tactics. Are there any simple examples of incremental commands? Also, I have noticed that conv is not incremental, how would I go about implementing an incremental elaborator for convSeq?

Tomas Skrivan (Jul 02 2024 at 00:16):

I'm trying to make sense of https://github.com/leanprover/lean4/blob/d5a45dfa8b2600e300bd1968e91f2b17951d5e98/src/Lean/Elab/Tactic/BuiltinTactic.lean#L280 and https://github.com/leanprover/lean4/blob/d5a45dfa8b2600e300bd1968e91f2b17951d5e98/src/Lean/Elab/Term.lean#L356
I'm a bit unsure if I'm digging too deep or not.

Sebastian Ullrich (Jul 02 2024 at 09:43):

You can take a look at the existing builtin_incremental tactics but it is very much not simple. There is some high-level documentation in the library note "Incremental Command Elaboration".

Tomas Skrivan (Jul 11 2024 at 02:06):

Here is a simple macro #def_strings a b c which just expands into

def a := "a"
def b := "b"
def c := "c"

How can I make this incremental?

code

Tomas Skrivan (Jul 11 2024 at 05:12):

I have a solution! The command #def_strings a b c ... defines def a := "a", def b := "b", ... incrementally. To see the effect I made sure that each new definition takes 1s to elaborate.

One big missing thing is to update the info tree, but I have no experience with that.

The solution is an extremely stripped down version of elabCommand

code


Last updated: May 02 2025 at 03:31 UTC