Zulip Chat Archive

Stream: general

Topic: obtain


Johan Commelin (Nov 09 2018 at 04:59):

I just realised there is obtain:
https://github.com/leanprover/mathlib/search?q=obtain&unscoped_q=obtain

Johan Commelin (Nov 09 2018 at 05:00):

I have not yet figured out what it does.

Bryan Gin-ge Chen (Nov 09 2018 at 05:01):

I think I looked it up before and I concluded it was a lean 2 thing?

Mario Carneiro (Nov 09 2018 at 05:24):

it is a lean 2 thing. obtain x h, from expr, expr' is the lean 2 way of writing let <x, h> := expr in expr', at least when expr has exists type. I forget how general it is

Mario Carneiro (Nov 09 2018 at 05:26):

the style guide also uses take, which is no longer a keyword and is the same as λ

Johan Commelin (Nov 09 2018 at 05:28):

Ok, thanks for explaining!

Floris van Doorn (Nov 09 2018 at 05:34):

obtain used to work on all inductive types with a single constructor. It was the way to do cases in term mode.

Scott Morrison (Aug 14 2019 at 08:11):

I just found myself writing

 obtain ⟨V, ⟨m,h₂⟩⟩ : _ := f.r U h₁

i.e. using obtain, but not wanting to specify the type. This is synonymous with

rcases f.r U h₁ with ⟨V, ⟨m,h₂⟩⟩,

but I wonder if we should just support dropping the type specification in obtain, if the proof is given after :=.

Scott Morrison (Aug 14 2019 at 08:11):

(Really I'd like have to just do this...)

Rob Lewis (Aug 14 2019 at 09:07):

Hah, I was confused about how this topic started in November, since I just added the obtain tactic last month. We should probably get rid of the Lean 2 syntax in the style guide...

Rob Lewis (Aug 14 2019 at 09:09):

I didn't support that syntax in obtain because it is literally just reordering arguments to rcases. But I'll grant that it reads better with obtain sometimes.

Rob Lewis (Aug 14 2019 at 09:09):

And it doesn't really hurt to handle it.

Reid Barton (Aug 14 2019 at 13:24):

I haven't had a chance to use obtain yet but I quite like the uniformity of its syntax relative to have and let. I guess let can't do this in tactic mode?

Rob Lewis (Aug 14 2019 at 13:33):

I think tactic mode let doesn't destruct things at all, right?

Rob Lewis (Aug 14 2019 at 13:35):

https://github.com/leanprover-community/mathlib/pull/1327 by the way.


Last updated: Dec 20 2023 at 11:08 UTC