Zulip Chat Archive
Stream: mathlib4
Topic: analogue of local tidy attribute
Adam Topaz (Feb 15 2023 at 17:41):
What's the aesop_cat
analogue of local attribute [tidy] foobar
?
Matthew Ballard (Feb 15 2023 at 17:41):
I don't think it exists yet
Adam Topaz (Feb 15 2023 at 17:42):
I'm specifically working on the file category_theory.discrete_category
where we have the following:
/-- A simple tactic to run `cases` on any `discrete α` hypotheses. -/
meta def _root_.tactic.discrete_cases : tactic unit :=
`[cases_matching* [discrete _, (_ : discrete _) ⟶ (_ : discrete _), plift _]]
run_cmd add_interactive [``tactic.discrete_cases]
local attribute [tidy] tactic.discrete_cases
Adam Topaz (Feb 15 2023 at 17:43):
porting the tactic is easy enough, e.g. as
macro (name := discrete_cases) "discrete_cases" : tactic =>
`(tactic|casesm* Discrete _, (_ : Discrete _) ⟶ (_ : Discrete _), PLift _)
Adam Topaz (Feb 15 2023 at 17:43):
but I don't know how to only activate it locally within aesop_cat
Matthew Ballard (Feb 15 2023 at 17:44):
Let me conjure up the error it fed me
Matthew Ballard (Feb 15 2023 at 17:46):
attribute [local aesop safe tactic (rule_sets [CategoryTheory])] Std.Tactic.Ext.extCore'
gives local and scoped Aesop rules are not supported
Adam Topaz (Feb 15 2023 at 17:53):
yeah that's the same error I got.
Adam Topaz (Feb 15 2023 at 17:54):
but I wonder if there is some way to simulate this in some other way without modifying aesop
itself. @Jannis Limperg any hints?
Matthew Ballard (Feb 15 2023 at 17:55):
Perhaps you can feed it in the config?
Matthew Ballard (Feb 15 2023 at 18:07):
Apparently there is this erase_aesop_rules [safe apply foo, bar (rule_sets [A])]
Matthew Ballard (Feb 15 2023 at 18:33):
You can feed it into aesop
call but aesop_cat
needs a refactor to accommodate this.
Matthew Ballard (Feb 15 2023 at 20:02):
!4#2299 has convinced me I need to improve my aesop care and feeding
Jannis Limperg (Feb 15 2023 at 21:33):
Currently, the only way to get local rules is to declare an Aesop rule set and use it only locally. Local and scoped Aesop rules require specific support from Aesop. This is something I've wanted to do for a while, but I've been putting it off because it's a decently big rewrite of that part of Aesop. But if there's now a need for it, I can do it.
Once Aesop supports local and scoped rules, is there still a need for rule sets? If not, I would like to remove this functionality. CC'ing some people who I know use Aesop: @Marc Huisinga @Frédéric Dupuis @Scott Morrison @Moritz Doll
Matthew Ballard (Feb 15 2023 at 21:42):
Is there a way to union rule sets?
Scott Morrison (Feb 15 2023 at 22:02):
Oh, I think rule sets are very helpful when setting up aesop wrapper tactics, e.g. aesop_cat
.
Frédéric Dupuis (Feb 15 2023 at 22:17):
I agree rulesets are very useful to write "specialized" versions of aesop, we definitely don't want to give that up!
Moritz Doll (Feb 15 2023 at 22:58):
I was about to ask how something like continuity
and measurability
should work without rulesets. It might be possible to replace them just by calling aesop, but that sounds like a possible performance problem to me.
Frédéric Dupuis (Feb 15 2023 at 23:48):
Right, especially if we want to try to make these capable of proving statements like ContinuousAt f x
, which might require doing things like putting linarith as a last resort unsafe 1%
rule to show x
is in the right subset.
Gabriel Ebner (Feb 16 2023 at 01:05):
Once Aesop supports local and scoped rules, is there still a need for rule sets?
I think it's a good design choice to be consistent with simp. And simp supports all three.
Jannis Limperg (Feb 16 2023 at 10:57):
Okay, thanks everyone for the feedback! I'll follow the simp
model then.
Adam Topaz (Feb 17 2023 at 00:35):
I got the file to build in !4#2326 but I still haven't done any linting. And I also feel like the automation isn't as nice as it should be (given the fact that we can't add to aesop locally just yet as discussed above). Any help to get this file in shape would be much appreciated!
Matthew Ballard (Feb 23 2023 at 04:34):
In the meantime, I tried adding and then erasing tactics !4#2453 for the rule set. It went pretty well.
Jannis Limperg (Feb 24 2023 at 17:22):
Local and scoped rules are now supported. Mathlib bump PR: !4#2484
Last updated: Dec 20 2023 at 11:08 UTC