Stage 02 · Step 10 of 50
Use what you know.
01The idea
Sometimes the key you need is already in your pocket. A hypothesis can already prove the goal.
02In maths
If P is known, then P can be concluded.
Picture it
Swipe sideways to see the whole picture.
⊢ 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.
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.
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
no goals
A goal is what remains to prove. The symbol ⊢ points to it. Meet the turnstile.
06A common slip
Lean is telling us something useful here.
example (P Q : Prop) (h : P) : Q := by
exact h
Type mismatch h has type P but is expected to have type Q
The hypothesis proves P, but the goal asks for Q.
The fix: Supply a proof of the actual target proposition.
07Your turn
sorry is a placeholder for unfinished work. Replace it as you solve each task. A finished proof has no placeholders.
- Warm-up
Use the given equality without changing it.
Show a hint
The hypothesis has exactly the target type.
One more hint
Give its name to exact.
- A little stretch
Use a proof of P and a function that turns P into Q.
Show a hint
Apply the implication proof to the proof of P.
One more hint
Pass that resulting proof to exact.
example (n : Nat) (h : n = 8) : n = 8 := by
sorry
example (P Q : Prop) (hP : P) (h : P → Q) : Q := by
sorry
Compare with the checked solutions
There are often several valid proofs. These solutions were compiled with the same pinned Lean version.
example (n : Nat) (h : n = 8) : n = 8 := by
exact h
example (P Q : Prop) (hP : P) (h : P → Q) : Q := by
exact h hP
no goals
08A quick check
09New words & tools
Take your time. Progress is yours to mark.