Stage 02 · Step 10 of 50

Use what you know.

Core Lean5 minutesLean 4.36.0

01The idea

Sometimes the key you need is already in your pocket. A hypothesis can already prove the goal.

Goalie · Your guide for this idea
Goalie pointing

The tactic exact hands that proof to Lean.

02In maths

If P is known, then P can be concluded.

Picture it

A hypothesis is something already in your backpackLeft: a backpack labelled what you have. Inside are two cards: P : Prop, meaning P is a statement, and h : P, meaning h is a proof of P. Middle: the goal card ⊢ P, labelled what you need. An arrow carries the card h from the backpack to the goal, marked exact h. Because h proves exactly P, it fits, and the result is no goals.WHAT YOU HAVEP : PropP is a statementh : Ph is a proof of Pexact hWHAT YOU NEED⊢ Ph fits exactlyno goals

Swipe sideways to see the whole picture.

Everything above the ⊢ line is already in your backpack. P : Prop only says that P is a statement, while h : P is an actual proof of P. The goal asks for a proof of P, so exact h takes out h and hands it over. It fits exactly, so the proof is done.

03In Lean

This code comes directly from the file checked by Lean.

E10.leanTry it live (opens official Lean editor)
example (P : Prop) (h : P) : P := by
  exact h

A proposition is a statement that can have a proof. The type Prop contains propositions.

The goal state lists available hypotheses above the turnstile. The proposition after the turnstile is still to be proved.

The proof term supplied to exact must fit that proposition. A proof of a different statement will not do.

04Step by step

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

After line 1
P : Prop
h : P
⊢ P
After line 1: example (P : Prop) (h : P) : P := by
P : Prop
h : P
⊢ P
After line 2: exact h
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 given equality without changing it.

  2. A little stretch

    Use a proof of P and a function that turns P into Q.

Exercises/E10.leanTry it live (opens official Lean editor)
example (n : Nat) (h : n = 8) : n = 8 := by
  sorry

example (P Q : Prop) (hP : P) (h : P → Q) : Q := by
  sorry

08A quick check

1. What follows the name of a hypothesis in a goal state?

Read the answer and explanation

Its type or proposition. The context records the name and what that name represents.

2. Does exact search for a missing argument for you in every case?

Read the answer and explanation

It must check the supplied term against the goal. Lean checks that the supplied term has the requested type.

One more idea in your toolkit.

Take your time. Progress is yours to mark.