Stage 04 · Step 20 of 50

Find one witness.

Core Lean8 minutesLean 4.36.0

01The idea

To show that a treasure exists, showing one treasure is enough. An existence proof supplies a witness.

Lemmi · Your guide for this idea
Lemmi pointing

It also proves that the witness has the requested property.

02In maths

There exists a natural number n such that n + 1 = 4.

Picture it

“There exists”: point at one witnessTop: a row of natural numbers 0, 1, 2, 3, 4, 5, 6, 7 and so on. An arrow labelled the witness points at 3, which is highlighted, and under it is the check 3 + 1 = 4 with a tick. The other numbers do not need to be checked: one witness is enough. Bottom: the start card has goal there exists n with n + 1 = 4. The tactic exists 3 supplies the witness 3, Lean checks 3 + 1 = 4 by computing, and no goals remain.the witness01234567…3 + 1 = 4 ✓one witness is enoughSTART⊢ ∃ n, n + 1 = 4exists 33 + 1 = 4 CHECKEDno goals

Swipe sideways to see the whole picture.

To prove that something exists, you don’t need every example, just point at one. exists 3 names 3 as the witness, and Lean checks 3 + 1 = 4 by computing it. Pointing at the wrong number, like 2, would leave you stuck proving 2 + 1 = 4, which is false.

03In Lean

This code comes directly from the file checked by Lean.

E20.leanTry it live (opens official Lean editor)
example : ∃ n : Nat, n + 1 = 4 := by
  exists 3

The symbol ∃ means “there exists.” Type it with \exists. It is the existential quantifier.

A witness is the value you choose. The rest of the proof checks its property.

The tactic exists supplies a witness and tries to finish by definitional equality. If that is not enough, the property remains as a goal.

04Step by step

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

After line 1
⊢ ∃ n, n + 1 = 4
After line 1: example : ∃ n : Nat, n + 1 = 4 := by
⊢ ∃ n, n + 1 = 4
After line 2: exists 3
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

    Find a natural number whose double is ten.

  2. A little stretch

    Find one number satisfying both supplied equations.

Exercises/E20.leanTry it live (opens official Lean editor)
example : ∃ n : Nat, n * 2 = 10 := by
  sorry

example : ∃ n : Nat, n + 1 = 4 ∧ n * 2 = 6 := by
  sorry

08A quick check

1. What does ∃ mean?

Read the answer and explanation

There exists. You must supply at least one witness. Type it with \exists.

2. Does an existence proof need a unique witness?

Read the answer and explanation

No. There may be several witnesses. Existence asks for at least one.

One more idea in your toolkit.

Take your time. Progress is yours to mark.