Lean 4Proof tacticsMathematics

Lean 4 tactics: when rfl, simp and exact fit

October 16, 2026 · Oyren AI Team (AI-written)

Lean 4 tactics: when rfl, simp and exact fit

The Lean 4 tactics rfl, exact and simp are easier to learn as answers to different proof-state questions. Is the equality true by computation? Is suitable evidence already available? Can known simplification rules reduce the goal? A tactic name becomes useful when its role in the current proof can be explained.

Lean's tactic-proof documentation describes proofs as a sequence of goals and tactic steps. This article uses small built-in examples and a suggested diagnostic routine. The examples are teaching fragments, not a claim that these three tactics handle every beginner theorem or every mathlib proof.

The current goal before the next command

A useful proof note begins with the goal and the local hypotheses. It then records why a particular step should help. The note does not need to reproduce the entire editor display; the important part is the relationship between available evidence and the required conclusion.

For an illustrative session, a learner can pause before each tactic and write one sentence about its intended effect. After the step, the new goal is compared with that sentence. An unexpected result becomes a question to investigate, rather than an invitation to insert more commands until the error disappears.

This approach is a suggested study method. It is especially helpful when reading a generated tactic sequence, because a short accepted proof can still contain steps whose purpose is unclear to its author.

Reflexive equality with rfl

The following example uses an equality that reduces by the definition of natural-number addition:

example (marker : Nat) : marker + 0 = marker := by
  rfl

Lean's quantifiers and equality chapter explains reflexivity and equality reasoning. Here the useful question is whether the two sides are definitionally equal. A proof that follows by reduction does not need an independently supplied equality hypothesis.

A learning note can record the statement, the type of marker and the reason reduction applies. That explanation matters more than memorizing that an equality involving zero once worked. A superficially similar expression can have a different reduction behavior, so the tactic should be chosen from the actual statement.

Evidence with exact

A different example supplies the required evidence directly:

example (Statement : Prop) (known : Statement) : Statement := by
  exact known

The tactic reference documents exact as a way to close a goal with a term of the required type. The key question is whether the supplied term has the type the goal requires. Its name or apparent mathematical relevance is not enough.

For a larger proof, the term may be an application of a lemma to suitable arguments. The same reading discipline applies: what does the lemma require, what evidence is supplied and what conclusion results? A useful note can spell out those three parts before compressing the proof into a short application.

A failed exact can therefore reveal a mismatch in assumptions, a different target or an incorrectly supplied argument. The first diagnostic should inspect the types, rather than replace the tactic with a more automated command without understanding the difference.

Simplification with simp

This example asks Lean to use its simplification rules:

example (marker : Nat) : 0 + marker = marker := by
  simp

The Lean community's simp guide explains rewriting by simplification lemmas and the role of the simp set. A successful simplification is therefore connected to available rules, rather than a claim that the system freely discovers every mathematical identity.

A useful proof note can identify the shape of the goal before and after simplification. If the result is surprising, the next task is to inspect the relevant rule or definition. The saved explanation should state what changed, rather than describing simp only as something that made the error vanish.

The same guide covers more targeted forms of simplification. Those forms are useful when a proof needs to state which facts are being used. Their suitability depends on the project and goal; this article does not prescribe one command as universally preferable.

A selection table

The following table is a suggested reading aid:

Question about the current goalCandidateEvidence to inspect
Do both sides reduce to the same expression?rflDefinitions and types
Is a term of the required type available?exactHypotheses or lemma application
Can known rewrite rules reduce the expression?simpSimplification rules and resulting goal
Is the intended statement still unclear?More statement workDomains, quantifiers and assumptions

The last row is a useful stopping point. An unclear formal statement should not be repaired by searching for a tactic that happens to close it. The mathematical question has to remain recognizable throughout the proof.

A bounded diagnostic routine

A small troubleshooting record can contain the exact declaration, its imports, the toolchain and the first relevant message. The attempted tactic and the expected effect belong beside that record. This is a suggested way to make a proof question reproducible.

One useful exercise changes a single part of a working example. A learner might replace the available hypothesis with evidence for another proposition and explain why the goal is no longer satisfied. The exercise is about reading the type mismatch, not about finding an unrelated way to complete a different claim.

Another exercise compares two accepted proofs of a small statement and explains the evidence used by each. Shortness can be useful, but an unexplained short proof is a poor learning record. The explanation should remain connected to the statement and local context.

The proof and the surrounding note

A completed tactic proof still needs comparison with the informal claim. The AI theorem-proving overview discusses the separation between generated proof proposals and formal checking. The intended mathematical statement remains a separate responsibility.

Oyren's maths notes feature places written reasoning beside formal work in a separate Lean environment. The matching destination is Oyren's Lean overview, where the Codespace option supports continuing from these teaching examples into a project.