leanprover / leanprover/lean4

`exact?` suggests term that does not work

Open
#5,407 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

In this code:

inductive Odd : Nat → Prop
  | one : Odd 1
  | add_two : Odd n → Odd (n + 2)

theorem odd_iff {n : Nat} : Odd n ↔ n % 2 = 1 := by
  refine ⟨fun h => by induction h <;> omega, ?_⟩
  match n with
  | 0 => simp
  | 1 => exact fun _ => Odd.one
  | n + 2 => exact fun _ => Odd.add_two (odd_iff.mpr (by omega))

example {n : Nat} : n % 2 = 1 → Odd n := by exact?

the suggestion we get from exact? is Try this: exact fun a => (fun {n} => odd_iff.mpr) a, but this does not work. Accepting the suggestion leads to the two errors

failed to infer binder type

and

don't know how to synthesize implicit argument 'n'
  (@fun {n_1} => odd_iff.mpr) (?m.2120 a) a
context:
n : Nat
a : n % 2 = 1
⊢ ?m.2119 a

Expected behavior: exact? suggests some invocation of odd_iff that works

Actual behavior: Suggestion leads to error above

Versions

4.12.0-nightly-2024-09-19 on live.lean-lang.org

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 with the self-contained Odd/odd_iff reproducer and the exact? invocation described in the issue; reproduce it on the Lean nightly release using live.lean-lang.org. Trace the suggestion generation path for this case, then verify that the suggested invocation compiles and matches the expected behavior.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.