leanprover / leanprover/lean4

“implicit lambda” works with `exact`, but not `apply`

Open
#5,366 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-low
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

I find this surprising:

example : {a : Nat} → a+1 = a.succ := rfl -- works
example : {a : Nat} → a+1 = a.succ := by exact rfl -- works
example : {a : Nat} → a+1 = a.succ := by apply rfl -- does not work

As a user I expect to apply work when exact works.

By using a wrong term we can see a bit more what’s happening:

example : {a : Nat} → a+1 = a.succ := by exact Iff.rfl

type mismatch
  Iff.rfl
has type
  ?m.960 ↔ ?m.960 : Prop
but is expected to have type
  a✝ + 1 = a✝.succ : Prop
the following variables have been introduced by the implicit lambda feature
  a✝ : Nat
you can disable implicit lambdas using `@` or writing a lambda expression with `{}` or `[]` binder annotations.

So exact somehow triggers “implicit lambda feature” but apply doesn’t. Should it?

Versions

4.12.0-nightly-2024-09-16

Additional Information

This causes unexpected(?) regressions(?) when using @[refl] rather than extending the rfl macro, #5359.

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the three examples from the issue on Lean 4 version 4.12.0-nightly-2024-09-16, comparing exact and apply with implicit lambdas enabled and disabled. Investigate the elaboration paths for these tactics and the interaction with @[refl] noted in #5359. Done means the intended behavior is decided and the examples either agree or the discrepancy is documented and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.