Zulip Chat Archive
Stream: new members
Topic: Using "by" with "have"
Auguste Poiroux (Jul 30 2020 at 13:13):
Hello everyone!
I have a quick question about the use of "have" in a tactic mode. When you use it, you get a new goal (and an hypothesis) added to the panel. But when I use "by" right after to prove it, the panel is completely empty. On the other hand if I use "begin"-"end" or "{"-"}", the goals are in the panel.
I made a little trivial example on the online version of Lean: https://leanprover.github.io/live/3.3.0/#code=example%20:%20(1%20=%201)%20:=%0Abegin%0A%20%20have%20:%201=1,%0A%20%20refl,%0A%20%20exact%20this,%0Aend%0A%0Aexample%20:%20(1%20=%201)%20:=%0Abegin%0A%20%20have%20:%201=1,%0A%20%20begin%20refl%20end,%0A%20%20exact%20this,%0Aend%0A%0Aexample%20:%20(1%20=%201)%20:=%0Abegin%0A%20%20have%20:%201=1,%0A%20%20by%20refl,%0A%20%20exact%20this,%0Aend
If I place my cursor at the end of line 3 or line 10, I get two goals that appear in the panel. But if I place my cursor at the end of line 17, nothing is displayed.
Yet according to https://leanprover.github.io/reference/tactics.html, "by" is equivalent to a "begin"-"end" with a single tactic.
Is there something I missed?
Thank you in advance!
Patrick Massot (Jul 30 2020 at 13:16):
This is a quirk of the Lean server info request. You can use by { }
to get back info.
Patrick Massot (Jul 30 2020 at 13:16):
And you shouldn't be using this web editor which uses a very badly outdated Lean, but rather https://leanprover-community.github.io/lean-web-editor/
Auguste Poiroux (Jul 30 2020 at 13:20):
Patrick Massot (Jul 30 2020 at 13:22):
It works for me
Patrick Massot (Jul 30 2020 at 13:22):
Putting the cursor after {
in by { refl }
Bryan Gin-ge Chen (Jul 30 2020 at 13:23):
Note that if you are already in tactic mode, by
doesn't really do anything. See e.g. https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/library_search.20bug.3F/near/204334342
Patrick Massot (Jul 30 2020 at 13:24):
It does something if you put a single tactic, without curly braces: it clearly signals that a goal is meant to be closed here (which is good for maintainence).
Bryan Gin-ge Chen (Jul 30 2020 at 13:26):
Yes, that's true. My habit is to always write have ... :=
(instead of using a comma) in which case adding by
also changes from term mode to tactic mode.
Auguste Poiroux (Jul 30 2020 at 13:26):
Oh ok! I meant about getting "2 goals
⊢ 1 = 1
this: 1 = 1
⊢ 1 = 1" at the end of the "have" line (22 or 30 here).
Bryan Gin-ge Chen (Jul 30 2020 at 13:34):
I would chalk this up to what Patrick said. There are some quirks in how the tactic state is saved and returned.
[If you really want to dig into it, you could (after learning about tactic writing) look at the definition of the tactic have
and see whether some save_info
s should be inserted.]
Auguste Poiroux (Jul 30 2020 at 13:38):
Ok, thank you!
Last updated: Dec 20 2023 at 11:08 UTC