Zulip Chat Archive

Stream: lean4

Topic: have syntax without ":= by"


Jakob von Raumer (Mar 06 2024 at 13:35):

Just updated some of my projects from 4.3.0 to 4.6.0 and it seems like the syntax for have is now more restrictive? I used to be able to write

  have h : x + y = z
  · skip

But that doesn't seems to be parsed anymore, why is that?

Jakob von Raumer (Mar 06 2024 at 13:36):

Or better: Where should I be looking for a documentation of breaking changes like that before upgrading?

Mauricio Collares (Mar 06 2024 at 13:43):

In this particular case you can import Mathlib.Tactic.Have to recover it (see #10534). I don't think there is documentation for Mathlib breaking changes.

Jakob von Raumer (Mar 06 2024 at 13:44):

Ah, didn't know mathlib changed the syntax, thought it came directly from lean4

Mauricio Collares (Mar 06 2024 at 14:08):

In general https://github.com/leanprover/lean4/blob/master/RELEASES.md should list breaking upstream changes.

Jakob von Raumer (Mar 06 2024 at 14:15):

So the := by ... is the form that's recommended now? It seems a bit silly to go out and into tactic mode unnecessarily

Michael Stoll (Mar 06 2024 at 14:20):

You can still write have h : ... := <proof term>.

Jakob von Raumer (Mar 06 2024 at 14:26):

Yes, but I rarely write proofs terms directly when using haves

Ruben Van de Velde (Mar 06 2024 at 14:28):

The := form is the only one that exists in core lean 4 at this point; I don't know if there's appetite to add another spelling there

Michael Stoll (Mar 06 2024 at 14:58):

Jakob von Raumer said:

Yes, but I rarely write proofs terms directly when using haves

But then you want to be in tactic mode anyway.

Ruben Van de Velde (Mar 06 2024 at 15:00):

I think Jakob's point is that you use := to go from tactic to term mode and then immediately use by to return to tactic mode, which seems wasteful(?) in a way

Eric Wieser (Mar 06 2024 at 15:41):

You can always stay in tactic mode with

have foo : Bar := ?_

Eric Wieser (Mar 06 2024 at 15:41):

Which is consistent with things like

cases s with
| inl => ?_
| inr => ?_

Chris Wong (Mar 07 2024 at 00:05):

I didn't know ?_ worked there too!

Chris Wong (Mar 07 2024 at 00:06):

Does that mean refine is redundant now, if exact foo ?_ does the same thing :thinking:

Johan Commelin (Mar 07 2024 at 01:20):

But I don't think exact foo ?_ works...

Kevin Buzzard (Mar 07 2024 at 07:01):

Right -- exact is the redundant one as it can be replaced with refine, as can use, constructor,... .


Last updated: May 02 2025 at 03:31 UTC