Zulip Chat Archive
Stream: lean4
Topic: Implicit arguments after explicit arguments
Yury G. Kudryashov (Jul 27 2023 at 03:58):
Is it intentional that I have to use _k _n
in the first example but not in the second one?
example : ∀ {m : Nat}, 0 < m → ∀ {k n : Nat}, m < k → k < n → 0 < n := fun hm _k _n hk hn ↦
Nat.lt_trans hm <| Nat.lt_trans hk hn
example : ∀ {m : Nat}, 0 < m → ∀ {k n : Nat}, m < k → k < n → 0 < n := fun hm ↦ fun hk hn ↦
Nat.lt_trans hm <| Nat.lt_trans hk hn
Jireh Loreaux (Jul 27 2023 at 04:06):
sorry, what's the difference there?
Yury G. Kudryashov (Jul 27 2023 at 04:21):
In the first example I use one fun
, then Lean hides m
from fun
but I have to use _k _n
. In the second example, I use two fun
s, no _k _n
.
Jireh Loreaux (Jul 27 2023 at 05:38):
oh sorry, I was looking at the statements. got it.
Yury G. Kudryashov (Aug 07 2023 at 18:52):
So, is it a bug or a feature? Is it documented somewhere?
Eric Wieser (Aug 07 2023 at 19:11):
This looks like a feature to me
Mario Carneiro (Aug 07 2023 at 19:21):
not to me, it is inconsistent with the implicitness of the arguments passed to the function - you would have to write _example hm hk hn
as equivalent to @_example _ hm _ _ hk hn
Yury G. Kudryashov (Aug 19 2023 at 01:56):
So, should I open a Lean 4 github issue?
Eric Wieser (Aug 19 2023 at 12:59):
Oh, is your claim that the first line is misbehaving, Mario?
Yury G. Kudryashov (Aug 19 2023 at 16:42):
I think that it should be either changed to require fun hm hk hn
in the first line or should be clearly documented (and the inconsistency with application syntax should be explained somehow).
Ruben Van de Velde (Aug 19 2023 at 16:56):
Somewhat related: if you do fun a => ...
, lean happily introduces any implicit arguments before a, but if you want to abstract over only implicit arguments, you need fun {...}
Yury G. Kudryashov (Aug 20 2023 at 01:41):
Can't you just omit fun =>
in this case?
Last updated: Dec 20 2023 at 11:08 UTC