Error Reference › Lean 4
Lean 4

rfl failed: not definitionally equal (Lean 4)

rfl only proves a = b when both sides compute to the same thing; here Lean could not make the two sides match by unfolding definitions.

What it looks like

Main.lean:2:2: error: Tactic `rfl` failed: The left-hand side
  0 + n
is not definitionally equal to the right-hand side
  n

n : ℕ
⊢ 0 + n = n

What does "rfl failed: not definitionally equal (Lean 4)" mean?

rfl closes a goal when both sides are equal by definition — after unfolding definitions and computing. Lean 4.23 and later print Tactic `rfl` failed: The left-hand side … is not definitionally equal to the right-hand side …, then the goal; Lean 4.15 to 4.22 print tactic 'rfl' failed, the left-hand side …; some older releases printed The rfl tactic failed. Possible reasons: …. Here 0 + n = n is true, but addition on ℕ recurses on its second argument, so it needs induction or simp rather than computation.

What causes "rfl failed: not definitionally equal (Lean 4)"?

  • The equation is true but needs a proof, not just computation — n + 0 = n is rfl for a variable n, but 0 + n = n is not.
  • A definition is irreducible or defined by well-founded recursion, so rfl cannot unfold it.
  • The two sides really are different — check the statement.
  • The goal is not an equality, or is a relation with no @[refl] lemma.

How do I confirm the cause?

  1. Compare the two sides in the message: if they look the same, the difference is in hidden implicit arguments or instances.
  2. Try simp or decide: if they succeed, the statement is true but not by pure computation.

How do I fix "rfl failed: not definitionally equal (Lean 4)"?

  • Use a tactic that proves it: simp, omega (ℕ and ℤ arithmetic), ring (Mathlib, commutative rings) or norm_num.
  • Unfold first with simp [f] or unfold f, then try again.
  • For a closed decidable fact such as 2 + 2 = 4 on ℕ, decide also works.
  • If the two sides printed in the message differ, fix the statement.

How do I stop it happening again?

  • Reach for rfl only when you expect pure computation; use simp, omega or ring for identities with variables.
Got a different error? Paste it into the Explain This Error tool → Identifies the family and the fix — runs locally, nothing uploaded.

Related errors