Zulip Chat Archive
Stream: mathlib4
Topic: Porting local tactics
David Ang (Jun 20 2023 at 16:20):
I have multiple simp only
tactics in a local file that simply chains together multiple lemmas:
private meta def map_simp : tactic unit :=
`[simp only [map_one, map_bit0, map_bit1, map_neg, map_add, map_sub, map_mul, map_pow]]
What do I do with these for the corresponding file in mathlib4?
Patrick Massot (Jun 20 2023 at 16:22):
You can have a macro doing that.
Patrick Massot (Jun 20 2023 at 16:22):
A more annoying thing is the name map_bit0
and map_bit1
suggest relying on the way computation with Nat is implemented in Lean 3.
Moritz Doll (Jun 20 2023 at 16:25):
untested, but it should be something along the lines of
macro "map_simp " : tactic =>
`(tactic|simp only [foo, bar])
Jireh Loreaux (Jun 20 2023 at 16:48):
Regarding the handling of numerals, I had to do some similar fidgeting when I ported the noncomm_ring
tactic. I think I did it right (at least, it seemed to work on tests for noncomm_ring
). If you want to have a look it's Tactic.NoncommRing
.
David Ang (Jun 24 2023 at 12:41):
How would I make the macro private/local/scoped? I don't want it to be visible outside my file.
EDIT: seems like adding local
might work? #lint doesn't complain that it doesn't have a docstring anymore.
Yury G. Kudryashov (Jun 24 2023 at 17:53):
Instead of bit0
/bit1
lemmas, you should use lemmas for 0
, 1
, and docs#OfNat.ofNat
Yury G. Kudryashov (Jun 24 2023 at 17:53):
The latter is defeq to Nat.cast n
given [n.AtLeastTwo]
Yury G. Kudryashov (Jun 24 2023 at 17:54):
Last updated: Dec 20 2023 at 11:08 UTC