Zulip Chat Archive

Stream: new members

Topic: unknown free variable error


Snir Broshi (Nov 02 2025 at 05:54):

import Mathlib

theorem foo {α : Type*} [DecidableEq α] (z : Sym2 α) (h : z.toFinset.Nonempty) : True := by
  let z' := z
  let s := z'.toFinset
  have h' : s.Nonempty := h
  let x, hx := h'

results in this error:

unknown free variable `_fvar.61`

There are a few bug reports about this error message, but none of them seem like the same scenario to me.
Is this one of the known issues? Is it a new bug? Or am I doing something wrong?

Yongxi Lin (Aaron) (Nov 02 2025 at 06:48):

You should use obtain instead of let in your last line.

Ruben Van de Velde (Nov 02 2025 at 07:10):

You probably should, but this still looks like a bug.

Aaron Liu (Nov 02 2025 at 11:03):

https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/unknown.20free.20variable.20on.20.60obtain.60

Aaron Liu (Nov 02 2025 at 11:03):

this could be the same thing?

Snir Broshi (Nov 02 2025 at 11:08):

Yongxi Lin (Aaron) said:

You should use obtain instead of let in your last line.

Inlining any of the 3 definitions also gets rid of the error, but I think all of these (admittedly weird since it's a #mwe) operations are legitimate

Snir Broshi (Dec 12 2025 at 02:43):

Reported as lean4#11626

Snir Broshi (Dec 16 2025 at 06:08):

Somehow ran into another unknown free variable for unrelated reasons: lean4#11692


Last updated: Dec 20 2025 at 21:32 UTC