Zulip Chat Archive
Stream: lean4
Topic: simpLocation
Scott Morrison (Nov 11 2021 at 06:36):
Currently in src/Lean/Elab/Tactic/Simp.lean the definition evalSimp is doing two different types of work:
- munging the tactic
Syntaxto extract arguments - delegating to other lower level tactics based on the form of the
locationargument extracted from theSyntax.
I'd prefer if these were separate, in particular so that in another tactic I can run the simplifier by specifying a location. As evalSimp is currently written, I'd either have to reproduce most of its logic, or synthesize a Syntax expression in order to actually use evalSimp.
Is it reasonable to want this separation? Perhaps I'm not yet used to "the Lean 4 way"!
https://github.com/leanprover/lean4/compare/master...semorrison:semorrison/simpLocation?expand=1 is my proposed modification, introducing a simpLocation tactic.
Mario Carneiro (Nov 11 2021 at 06:53):
the "lean 4 way" seems to be to construct syntax to run the tactic frontend. I'm also not particularly happy with this state of affairs
Mario Carneiro (Nov 11 2021 at 06:55):
similar observations also apply to most command parsers, they parse their syntax and delegate right away, so you can't really run them unless you have a syntax, it's not like lean 3 where there is a backend tactic that takes exprs and such
Scott Morrison (Nov 11 2021 at 07:33):
The local reason I wanted this was experimenting with porting split_ifs. Part of split_ifs delegates to simp only [if_pos, if_neg, dif_pos, dif_neg] along with a discharger.
It is set up so that that list of lemmas is obtained from an attribute. The "syntactical" simp tactic in Lean 4 implemented by evalSimp doesn't support passing lemmas by attribute. It seems like it would be quite unpleasant to synthesize a Syntax after you've done whatever work is required to assemble the list of lemmas.
Scott Morrison (Nov 11 2021 at 07:34):
The alternative would be to directly call the underlying tactics in src/Lean/Meta/Tactic/Simp/Main.lean but none of those are set up to deal with location already (whereas evalSimp has the logic).
Scott Morrison (Nov 11 2021 at 07:35):
Hence my desire to separate the code the deals with Syntax and the code the deals with location.
Jannis Limperg (Nov 11 2021 at 09:41):
+1. I've copy-pasted a few definitions because I don't want to bother constructing Syntax for what should be a function call. If this sort of refactoring is wanted, I'd be happy to do (some of) it.
Scott Morrison (Nov 15 2021 at 23:38):
This is now a PR as https://github.com/leanprover/lean4/pull/797.
Last updated: May 02 2025 at 03:31 UTC