Don't know how to synthesize placeholder (Lean 4)
Lean could not work out the value of an _ or an implicit argument from the context, so the term is still incomplete.
What it looks like
Main.lean:4:20: error: don't know how to synthesize placeholder
context:
x : ℕ
⊢ ℕ
What does "Don't know how to synthesize placeholder (Lean 4)" mean?
Every _ and every implicit argument becomes a metavariable that Lean must solve by unification. If one is still unsolved when the declaration is finished, and there were no other errors, Lean reports it with the context it had: the local hypotheses and, after ⊢, the type the missing value must have. The implicit-argument form (don't know how to synthesize implicit argument) names the argument and prints the application with ?m placeholders in it.
What causes "Don't know how to synthesize placeholder (Lean 4)"?
- A _ was left in a term where nothing tells Lean what to put there.
- An implicit argument cannot be inferred — e.g. the element type of an empty list [] or of none with no annotation.
- A numeric literal or function whose type could be several things, with nothing else pinning it down.
How do I confirm the cause?
- Read the type after ⊢ in the context — that is what Lean needs you to supply.
- Check whether anything in the expression determines that type; if nothing does, an annotation is required.
How do I fix "Don't know how to synthesize placeholder (Lean 4)"?
- Add a type annotation: ([] : List ℕ), (none : Option ℕ), (0 : ℝ).
- Give the argument explicitly with @foo or a named argument (α := ℕ).
- Replace the _ with the actual term, or use ?_ in refine to turn it into a new goal.
- Read the context: part of the message — after ⊢ is the type the missing value must have.
How do I stop it happening again?
- Annotate empty collections, none and bare numeric literals when nothing else fixes their type.
- In tactic proofs, use refine with ?_ rather than _, so missing pieces become goals you can see.