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

A "declaration has metavariables" error #5925

Open
3 tasks done
mik-jozef opened this issue Nov 2, 2024 · 2 comments · May be fixed by #6414
Open
3 tasks done

A "declaration has metavariables" error #5925

mik-jozef opened this issue Nov 2, 2024 · 2 comments · May be fixed by #6414
Labels
bug Something isn't working P-low We are not planning to work on this issue

Comments

@mik-jozef
Copy link

Prerequisites

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

  • Check that your issue is not already filed.
  • Reduce the issue to a minimal, self-contained, reproducible test case.
  • Test your test case against the latest nightly release.

Description

The following code

structure ValVar (D: Type) where
  d: D
  x: Nat

def Set (T : Type) := T → Prop

structure Salg where
  D: Type
  I: Nat

def natSalg: Salg := { D := Nat, I := 42 }

inductive HasMem (salg: Salg): Set (Set (ValVar salg.D))
| hasMem
  (set: Set (ValVar salg.D))
  (isElem: set ⟨d, x⟩)
:
  HasMem salg set

def valVarSet: Set (ValVar Nat) :=
  fun ⟨d, x⟩ => x = 0 ∧ d = 0 ∧ d ∉ []

def valVarSetHasMem: HasMem natSalg valVarSet :=
  HasMem.hasMem
    valVarSet
    (show valVarSet _ from ⟨rfl, rfl, nofun⟩)

throws (kernel) declaration has metavariables 'valVarSetHasMem'.

There is a list of things that make the issue go away (which is also why I couldn't come up with a more specific title -- I've no idea what the underlying cause is :sorry:):

  • removing x from ValVar, along with its occurences in the rest of the program
  • removing I from Salg
  • removing the salg param from HasMem & replacing occurences with natSalg
  • removing d ∉ [] from the definition of valVarSet
  • replacing HasMem.hasMem valVarSet with HasMem.hasMem _ in valVarSetHasMem.
  • replacing show valVarSet _ from with show _ from, show valVarSet ⟨0, 0⟩ from, or removing it entirely.

Expected behavior: The code throws no errors.

Versions

Version: Lean 4.14.0-nightly-2024-11-01
Platform: 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.

@mik-jozef mik-jozef added the bug Something isn't working label Nov 2, 2024
@leanprover-bot leanprover-bot added the P-low We are not planning to work on this issue label Nov 8, 2024
@Komyyy
Copy link

Komyyy commented Dec 5, 2024

We have the similar issue:

open Function

theorem my_mul_right_injective {M₀ : Type} [Mul M₀] [Zero M₀] {a : M₀} (ha : a ≠ 0) :
  Injective fun (x : M₀) ↦ a * x := sorry

-- (kernel) declaration has metavariables 'mul2'
def mul2 : { f : Nat → Nat // Injective f } := ⟨fun x : Nat ↦ 2 * x, mul_right_injective nofun⟩

@kmill
Copy link
Collaborator

kmill commented Dec 19, 2024

Note: this issue's example doesn't typecheck on a recent Lean, I think because of the changes in #6024. In the tests for #6414 I added the following unification hint to make up for the difference:

unif_hint (s : Salg) where
  s =?= natSalg
  |-
  Salg.D s =?= Nat

Unfortunately, this covers up the issue in 4.14. I figure it's still worth including the example in #6414 as a regression test, but it would be better if we could observe that this issue has been fixed.

testing on stable mathlib live-lean, which is currently 4.14

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-low We are not planning to work on this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants