Skip to content
LeanLearn
Level 3~30 minLean 4

Equality and rewriting

Some equalities hold by computation, others need reasons. Learn rfl, rewriting with rw, and step-by-step chains with calc.

You will be able to
  • Explain when rfl works: both sides compute to the same value.
  • Rewrite a goal with an equation using rw, in either direction.
  • Write a calc chain in which every step has a justification.

Recommended first: Proving with ∀ and ∃. You can start anyway. Nothing is locked.

EncounterActivity 1 of 9

Encounter

In school, "=" often means "now calculate". In proofs, an equation is a claim that two expressions name the same thing, and every claim needs a reason.

There are three common reasons:

  1. Computation: both sides evaluate to the same value (2 + 2 = 4). Lean's rfl.
  2. Substitution: you know a = b, so you may replace a by b. Lean's rw.
  3. A chain: a = b, b = c, c = d, so a = d. Lean's calc.