Stage 02 · Step 6 of 50

Your first proof.

Core Lean5 minutesLean 4.36.0

01The idea

Imagine checking both sides of a balance. You can calculate each side and see that they match.

Tacto · Your guide for this idea
Tacto pointing

Lean can do this too. The tactic rfl closes an equality when both sides are definitionally equal.

02In maths

2 + 2 = 4. Both sides describe the same natural number.

Picture it

rfl weighs both sides after computing themLeft: a balance scale. The left pan holds 2 + 2, which computes to 4. The right pan holds 4, which is already 4. Both sides compute to the same value, so the scale is level. Right: the goal 2 + 2 = 4, the tactic rfl, and then no goals.2 + 24computes to4computes to4level: same value on both sidesTHE CLAIM⊢ 2 + 2 = 4rflno goals

Swipe sideways to see the whole picture.

rfl works like a balance scale. It computes both sides and checks that they land on exactly the same value: 2 + 2 becomes 4, and 4 is already 4. When the scale is level, the proof is done and Lean says “no goals.”

03In Lean

This code comes directly from the file checked by Lean.

E06.leanTry it live (opens official Lean editor)
example : 2 + 2 = 4 := by
  rfl

An equality says that two expressions describe the same thing. A proof gives Lean a reason to accept a statement.

The word example starts an unnamed declaration. The colon introduces its statement. The text := by starts a tactic proof.

Read rfl as “check definitional equality.” Definitional equality means Lean can identify the two expressions by its computation rules.

Not every true equality works this way. Some need facts and additional proof steps. You will meet those in the next lessons.

04Step by step

Choose a line to see Lean’s recorded goal state after that line.

After line 1
⊢ 2 + 2 = 4
After line 1: example : 2 + 2 = 4 := by
⊢ 2 + 2 = 4
After line 2: rfl
no goals

05Lean says

Captured from Lean 4.36.0
no goals

A goal is what remains to prove. The symbol ⊢ points to it. Meet the turnstile.

07Your turn

sorry is a placeholder for unfinished work. Replace it as you solve each task. A finished proof has no placeholders.

  1. Warm-up

    Easy: prove that three plus three equals six. Replace sorry with a tactic.

  2. A little stretch

    Stretch: prove that the sum of two and three, multiplied by four, equals twenty.

Exercises/E06.leanTry it live (opens official Lean editor)
example : 3 + 3 = 6 := by
  sorry

example : (2 + 3) * 4 = 20 := by
  sorry

08A quick check

1. What does the symbol ⊢ point to in a goal state?

Read the answer and explanation

What is still left to prove. The turnstile ⊢ separates your available information from the current goal.

2. Why can rfl finish this proof?

Read the answer and explanation

Both sides are definitionally equal. Lean reduces the arithmetic while checking definitional equality. A false equation will fail.

3. What does no goals mean?

Read the answer and explanation

This proof has no remaining goals. The proof is complete. There is nothing left for a tactic to prove here.

One more idea in your toolkit.

Take your time. Progress is yours to mark.