Stage 02 · Step 8 of 50

Give a proof a name.

Core Lean5 minutesLean 4.36.0

01The idea

A saved recipe saves you work next time. A named theorem does the same for a proof.

Lemmi · Your guide for this idea
Lemmi pointing

Once checked, it becomes a fact you can reuse.

02In maths

A proof that two plus two equals four can be given a name and used again.

Picture it

A named theorem is a labelled tool you can reuseTop row, make the tool: the goal 2 + 2 = 4 is proved by rfl, and the finished proof is hung on a toolboard as a wrench with the tag two_plus_two : 2 + 2 = 4. Bottom row, use the tool: a new goal 2 + 2 = 4 appears. The tactic exact two_plus_two takes the wrench off the board, and the result is no goals.1 · MAKE THE TOOL ONCE⊢ 2 + 2 = 4rfltwo_plus_two: 2 + 2 = 4saved by name, checked once2 · USE IT WHENEVER THE GOAL MATCHES⊢ 2 + 2 = 4exact two_plus_twono goals

Swipe sideways to see the whole picture.

A theorem is a proof you hang on the wall with a label. You prove 2 + 2 = 4 once, and Lean files it as the tool two_plus_two. Later, when a goal says exactly the same thing, exact two_plus_two takes the tool down and finishes the job, with no need to prove it again.

03In Lean

This code comes directly from the file checked by Lean.

E08.leanTry it live (opens official Lean editor)
theorem two_plus_two : 2 + 2 = 4 := by
  rfl

example : 2 + 2 = 4 := by
  exact two_plus_two

A theorem is a named proposition together with its checked proof. People often call a supporting theorem a lemma.

This core Lean module uses the keyword theorem for both roles. Main results and supporting lemmas use the same proof checking rules.

The tactic exact supplies a proof term of precisely the type the goal asks for.

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: theorem two_plus_two : 2 + 2 = 4 := by
⊢ 2 + 2 = 4
After line 2: rfl
no goals
After line 4: example : 2 + 2 = 4 := by
⊢ 2 + 2 = 4
After line 5: exact two_plus_two
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

    Use the supplied named theorem to finish the first example.

  2. A little stretch

    Reuse the named fact about four squared.

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

theorem four_squared : 4 * 4 = 16 := by
  rfl
example : 4 * 4 = 16 := by
  sorry

08A quick check

1. What does theorem add to a proof?

Read the answer and explanation

A reusable declaration name. Lean checks the proof before making that named declaration available.

2. How do theorem and lemma differ in proof checking?

Read the answer and explanation

They are checked the same way. The names describe how people use facts, not different proof standards.

One more idea in your toolkit.

Take your time. Progress is yours to mark.