Skip to content

unknown free variable for recursive grind terms #11930

@chenson2018

Description

@chenson2018

Prerequisites

Description

Consider the following example:

@[grind =]
def f : Nat → Nat
  | 0 => 0
  | n + 1 => f n

theorem foo (n : Nat) : f n = 0 := by
  match n with
  | 0 => grind
  | n + 1 => grind [foo n]

On 4.27.0-rc1 the proof fails (correctly according to Kim), but has an uninformative unknown free variable ... error. Especially because a user might expect this to work following #11268, it would be nice to give an informative error message, maybe indicating to try using have with the provided term.

On 4.28.0-nightly-2026-01-07 however, this example and another provided on Zulip both seem to pass. Given that Kim mentioned this should fail, I decided to still open this issue.

Context

Reported at #lean4>grind in recursive proofs

Steps to Reproduce

  1. Run the above example

Expected behavior: fail with a more informative error

Actual behavior: fails with a unknown free variable error

Versions

Version: 4.27.0-rc1, 4.28.0-nightly-2026-01-07
Target: x86_64-unknown-linux-gnu

Additional Information

[Additional information, configuration or data that might be necessary to reproduce the issue]

Impact

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions