Error Reference › Lean 4
Lean 4

Unsolved goals (Lean 4)

The tactic proof ended while something was still left to prove; Lean lists each remaining goal after the ⊢ symbol.

What it looks like

Main.lean:3:44: error: unsolved goals
case right
p q : Prop
hp : p
hq : q
⊢ q

What does "Unsolved goals (Lean 4)" mean?

Lean reports it at the by keyword once the whole tactic block has run and goals remain. Each goal is printed as its hypotheses, then ⊢ and the statement still to prove; a line such as case right names the branch it came from (here constructor split p ∧ q and only the left half was proved). The unfinished part is filled with sorry, so the declaration is not proved.

What causes "Unsolved goals (Lean 4)"?

  • The by block stops before the last step — a tactic made progress but did not finish the goal.
  • A tactic such as constructor, cases or induction created several goals and only the first was handled.
  • A line meant to continue the proof is not indented under by, so it is not part of the proof.
  • A tactic like simp or rw turned the goal into something you did not expect.

How do I confirm the cause?

  1. Put the cursor after the last tactic and compare the goal in the Infoview with what you thought it would be.
  2. Count the goals: if there are several, an earlier tactic split the proof and only one branch was finished.
  3. Move the cursor up one tactic at a time to find the step where the goal stopped looking right.

How do I fix "Unsolved goals (Lean 4)"?

  • Click at the end of the proof and read the Infoview: everything after ⊢ is still to be proved, the lines above it are what you can use.
  • Add the missing step — exact h, simp, omega, or exact? to search for a lemma.
  • Handle every goal: a · bullet for each case after constructor, cases or induction, or all_goals to run one tactic on all of them.
  • If the goal is not what you expected, go back one tactic and check what it did.

How do I stop it happening again?

  • Structure multi-goal proofs with · bullets, so an unfinished branch is reported at its own bullet.
  • Sketch the proof with sorry for each branch first, then fill them in one at a time.

Further reading

Got a different error? Paste it into the Explain This Error tool → Identifies the family and the fix — runs locally, nothing uploaded.

Related errors