Stage 03 · Step 14 of 50
Choose a side.
01The idea
A pass may accept a student card or a library card. One valid option is enough.
To prove an “or” statement, choose the side you can prove.
02In maths
A proof of P gives a proof of P ∨ Q. A proof of Q also gives a proof of P ∨ Q.
Picture it
Swipe sideways to see the whole picture.
left says “I’ll prove P” and right says “I’ll prove Q”. Pick the door your key fits: with hP go left, with hQ go right. The other door can stay shut.03In Lean
This code comes directly from the file checked by Lean.
example (P Q : Prop) (hP : P) : P ∨ Q := by
left
exact hP
example (P Q : Prop) (hQ : Q) : P ∨ Q := by
right
exact hQ
The symbol ∨ means “or.” Type it with \or. The technical name is disjunction.
The tactics left and right choose a constructor of a disjunction. The chosen proposition becomes the new goal.
This is inclusive or. It does not say that exactly one side holds.
04Step by step
Choose a line to see Lean’s recorded goal state after that line.
P Q : Prop hP : P ⊢ P ∨ Q
After line 1: example (P Q : Prop) (hP : P) : P ∨ Q := by
P Q : Prop hP : P ⊢ P ∨ Q
After line 2: left
P Q : Prop hP : P ⊢ P
After line 3: exact hP
no goals
After line 5: example (P Q : Prop) (hQ : Q) : P ∨ Q := by
P Q : Prop hQ : Q ⊢ P ∨ Q
After line 6: right
P Q : Prop hQ : Q ⊢ Q
After line 7: exact hQ
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) (hQ : Q) : P ∨ Q := by
left
exact hQ
Type mismatch hQ has type Q but is expected to have type P
The left choice asks for P. The available hypothesis proves Q.
The fix: Choose right to use the proof of Q.
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 P or Q using the supplied proof of Q.
Show a hint
Choose the right-hand alternative.
One more hint
Then use the hypothesis for Q.
- A little stretch
Prove P or (Q or R) using R.
Show a hint
First choose the outer right side.
One more hint
Choose right once more to reach R.
example (P Q : Prop) (hQ : Q) : P ∨ Q := by
sorry
example (P Q R : Prop) (h : R) : P ∨ (Q ∨ 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) (hQ : Q) : P ∨ Q := by
right
exact hQ
example (P Q R : Prop) (h : R) : P ∨ (Q ∨ R) := by
right
right
exact h
no goals
08A quick check
09New words & tools
Take your time. Progress is yours to mark.