Stage 03 · Step 11 of 50
If this, then that.
01The idea
A promise can say, “Give me a ticket, and I will let you in.” An implication describes what follows from an assumption. To prove one, temporarily accept its premise.
02In maths
For every proposition P, P implies P.
Picture it
Swipe sideways to see the whole picture.
P → P is a promise: “give me a proof of P, and I’ll give you a proof of P.” To prove a promise, pretend you were just handed the input. intro h names it h and puts it in your backpack. Now the goal is only P, and h is exactly that.03In Lean
This code comes directly from the file checked by Lean.
example (P : Prop) : P → P := by
intro h
exact h
The symbol → means “implies” between propositions. Type it with \to.
The left side is the premise. The right side is the conclusion. A proof of the implication must work for any proof of its premise.
The tactic intro names the assumed proof. It changes the goal from an implication to its conclusion.
04Step by step
Choose a line to see Lean’s recorded goal state after that line.
P : Prop ⊢ P → P
After line 1: example (P : Prop) : P → P := by
P : Prop ⊢ P → P
After line 2: intro h
P : Prop h : P ⊢ P
After line 3: 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 : True := by
intro h
Tactic `introN` failed: There are no additional binders or `let` bindings in the goal to introduce ⊢ True
This goal has no implication premise or function input to introduce.
The fix: Use intro when the goal exposes the appropriate input or binder.
07Your turn
sorry is a placeholder for unfinished work. Replace it as you solve each task. A finished proof has no placeholders.
- Warm-up
Prove that P implies that Q implies P.
Show a hint
Introduce both assumptions.
One more hint
Keep and return the proof of P.
- A little stretch
Chain a proof from P to Q with one from Q to R.
Show a hint
Introduce a proof of P.
One more hint
Apply the first implication, then the second.
example (P Q : Prop) : P → Q → P := by
sorry
example (P Q R : Prop) (f : P → Q) (g : Q → R) : P → R := by
sorry
Compare with the checked solutions
There are often several valid proofs. These solutions were compiled with the same pinned Lean version.
example (P Q : Prop) : P → Q → P := by
intro hP _hQ
exact hP
example (P Q R : Prop) (f : P → Q) (g : Q → R) : P → R := by
intro h
exact g (f h)
no goals
08A quick check
09New words & tools
Take your time. Progress is yours to mark.