Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown free variable '_fvar.639' #6927

Open
3 tasks done
dplyukhin opened this issue Feb 3, 2025 · 1 comment · May be fixed by #7304
Open
3 tasks done

Unknown free variable '_fvar.639' #6927

dplyukhin opened this issue Feb 3, 2025 · 1 comment · May be fixed by #7304
Labels
bug Something isn't working P-medium We may work on this issue if we find the time

Comments

@dplyukhin
Copy link

Prerequisites

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

Description

(Could be a duplicate of #4548 or any of the other "unknown free variable" issues, but I'm a beginner at Lean so I can't verify.)

This MWE causes the Lean compiler to throw an error, unknown free variable '_fvar.639', at the definition of goList:

  inductive Tree : Type where
    | leaf
    | node (p : Nat) (brs : List Tree)

  def Tree.substNats (M: Tree) (σ : Nat → Nat) : Tree :=
    let rec go M : Tree := match M with
      | .leaf => leaf
      | .node p brs =>
        let rec goList: List Tree → List Tree   -- unknown free variable '_fvar.639'
          | [] => []
          | M :: Ms => go M :: goList Ms
        .node (σ p) (goList brs)
    go M

Context

Prior discussion on Zulip: https://leanprover.zulipchat.com/#narrow/channel/113489-new-members/topic/Termination.20check.20bug.3F.20unknown.20free.20variable.20'_fvar.2E35433'

Versions

  • 4.13.0 on MacOS 15.3
  • 4.16.0-nightly-2025-02-03 on the Lean Live Editor
@dplyukhin dplyukhin added the bug Something isn't working label Feb 3, 2025
@nomeata
Copy link
Collaborator

nomeata commented Feb 3, 2025

Had a brief look: We get the error also with partial, and we don’t get it when using where:

  inductive Tree : Type where
    | leaf
    | node (p : Nat) (brs : List Tree)

 def Tree.substNats (M: Tree) (σ : Nat → Nat) : Tree := go M
   where
    go M : Tree := match M with
      | .leaf => leaf
      | .node p brs =>
        .node (σ p) (goList brs)
    
    goList: List Tree → List Tree
          | [] => []
          | M :: Ms => go M :: goList Ms

So it seems related to the elaboration of let rec specifically. Didn’t look further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-medium We may work on this issue if we find the time
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants