Zulip Chat Archive
Stream: Equational
Topic: Refactoring with Equation Command
Shreyas Srinivas (Oct 05 2024 at 01:21):
I am undertaking the refactoring using equation command. One thing right off the bat is that docstring comments don't recognise the equation
command as a valid declaration succeeding a docstring.
Shreyas Srinivas (Oct 05 2024 at 01:22):
Is there a quick fix for this?
Shreyas Srinivas (Oct 05 2024 at 01:38):
See PR equational#295
Joachim Breitner (Oct 05 2024 at 01:44):
Actually now that we fixed the conflict with the function composition operator, I would suggest to remove the equation
command completely and go back to normal lean definitions.
Joachim Breitner (Oct 05 2024 at 01:44):
Given that the main motivation for the command was to work around the slow elaboration
Shreyas Srinivas (Oct 05 2024 at 01:45):
https://github.com/teorth/equational_theories/issues/290
The issue description says this is to collect these equations easily
Shreyas Srinivas (Oct 05 2024 at 01:45):
Although the command itself at present only creates abbrevs
Shreyas Srinivas (Oct 05 2024 at 01:46):
I guess that later the command can be modified to add the equations to an external database automatically
Terence Tao (Oct 05 2024 at 01:46):
One reason I thought equation
might still be useful is when we finally link up "shallow" EquationX
propositions with "deep" LawX
objects of type MagmaLaw
, since one could use metaprogramming to define both automatically. But I guess we could just autogenerate both lists once by some external script and not have any metaprogramming for this. But it might also help with the hypothetical Equation<->Law tactics in https://github.com/teorth/equational_theories/issues/147 . These in turn could help implement duality within Lean, rather than through implicit implications.
Terence Tao (Oct 05 2024 at 01:48):
But perhaps there are better ways to establish all this. In particular I have no experience with metaprogramming and tactic writing, so I don't know what is the most feasible path here.
Joachim Breitner (Oct 05 2024 at 01:50):
Sure, that might be useful (although maybe more naturally done as an attribute). I'm just a bit wary of (now) unnecessary extra layers of complexity. I think either path is reasonable, and it doesn't matter much either way
Shreyas Srinivas (Oct 05 2024 at 01:50):
I like the equation command. If only someone can help me make docstrings work with it
Terence Tao (Oct 05 2024 at 01:52):
One minor nice thing about the equation
approach is (once the docstring issue is solved) that it becomes really easy to move an equation from AllEquations.lean
to Equations.lean
. I guess if we instead spell out EquationX
and LawX
directly (with all attendant attributes, and API to convert back and forth) one just cut and pastes ten lines instead of one, so it's sort of the same, but I like the current elegant look of AllEquations.lean
Shreyas Srinivas (Oct 05 2024 at 01:55):
That file is rather large and some renumbering will be needed to move its contents into Equations.lean
Shreyas Srinivas (Oct 05 2024 at 01:55):
I think it is best to leave that file as is
Terence Tao (Oct 05 2024 at 01:56):
I don't plan to move all 4694 equations into Equations.lean. Only the ones for which we have specialized theorems about, which can be proved by just loading Equations.lean and not AllEquations.lean
Shreyas Srinivas (Oct 05 2024 at 01:57):
Okay I see what you mean now.
Joachim Breitner (Oct 05 2024 at 02:03):
Shreyas Srinivas said:
I like the equation command. If only someone can help me make docstrings work with it
On the phone and sleepless in the bed right now, so can't hack on it, but maybe look at similar commands on mathlib, like lemma
, and cargo cult. Probably just a matter of adding the right non-terminal to the syntax and including it in the final command splice
Shreyas Srinivas (Oct 05 2024 at 02:24):
lemma uses a macro and the others use leading_parser
Shreyas Srinivas (Oct 05 2024 at 02:25):
I will look into this after getting a night's sleep. If someone wishes to try the file to modify is equational_theories/EquationsCommand.lean
Shreyas Srinivas (Oct 05 2024 at 14:41):
This is done
Shreyas Srinivas (Oct 05 2024 at 14:42):
I upgraded the equation
command to handle docstrings thanks to @Yury
Last updated: May 02 2025 at 03:31 UTC