tryAtEachStep

tryAtEachStep is a tool that runs a tactic at every proof step in a given Lean 4 file, reporting cases where the tactic closes the goal.

With a tactic like exact? and rw_search, this can help to find ways in which your existing proofs can be improved.

howto

Add this to your lakefile.lean:

require tryAtEachStep from git "https://github.com/dwrensha/tryAtEachStep" @ "main"

Then do this:

$ lake exe tryAtEachStep exact? Foo/Bar.lean --outfile /tmp/out.json

Progress will be displayed via stderr as it happens. Upon completion, /tmp/out.json will contain JSON describing the results.

running on all files in a directory

The tryAtEachStepInDirectory tool runs tryAtEachStep on all .lean files under a given directory. For example:

$ lake exe tryAtEachStepInDirectory "with_reducible exact?" YourLibrary -j 31

The -j 31 argument specifies that 31 jobs should be run in parallel.

Results are written as JSON in a directory with name tryAtEachStep-out-XXXXXXXX, where the X's get filled in randomly. You can specify a different output directory via --outdir.

Example findings:

TODO

  • Tests
  • Support tactics that aren't imported by the input file.
  • Better handling of situations where there are multiple active goals.
  • Report performance statistics of existing and new tactic.
  • Operate on terms. (Currently only operates on the tactic steps of the given file.)