Error Reference › Lean 4
Lean 4

Unknown identifier (Lean 4)

Lean cannot find a definition, lemma or variable with that name in the current scope.

What it looks like

Main.lean:5:8: error(lean.unknownIdentifier): Unknown identifier `nat.succ_le_succ`

What does "Unknown identifier (Lean 4)" mean?

Raised while elaborating a term when a name does not resolve. Since Lean 4.23 the message is Unknown identifier `name` with backticks, and the command line adds the label error(lean.unknownIdentifier); Lean 4.22 and earlier print unknown identifier 'name'. Lean 3 and mathlib3 names (lowercase nat., real., set.) do not exist in Lean 4 — Mathlib renamed them (Nat., Real., Set.).

What causes "Unknown identifier (Lean 4)"?

  • A typo, or wrong capitalisation (Lean names are case-sensitive).
  • The import that defines it is missing (for Mathlib names: import Mathlib or the specific Mathlib file).
  • The name lives in a namespace you have not opened — Nat.succ_le works, succ_le needs open Nat.
  • The lemma was renamed in a newer Mathlib, or it is a Lean 3 / mathlib3 name.

How do I confirm the cause?

  1. Run #check with the full name — if that works, the problem is a missing open or namespace.
  2. If #check also fails, the import is missing or the name does not exist in your Mathlib version.
  3. If it is a variable, check it is in scope: bound by intro, fun, a match, or the theorem's own binders.

How do I fix "Unknown identifier (Lean 4)"?

  • Check spelling and capitalisation, and try #check with the full name.
  • Add the import, or use the full name (Nat.foo) instead of relying on open.
  • Use exact? to find the current lemma by its statement.
  • For an old name, search the Mathlib docs; renamed lemmas usually keep a deprecated alias for a while that points to the new name.

How do I stop it happening again?

  • Pin your Mathlib version and read the deprecation warnings before you update.
  • Find lemmas with exact? or the Mathlib docs search instead of guessing names.
Got a different error? Paste it into the Explain This Error tool → Identifies the family and the fix — runs locally, nothing uploaded.

Related errors