Stage 04 · Step 17 of 50
Proof by contradiction.
01The idea
Suppose every attempt to deny a claim leads to a contradiction. Classical reasoning lets you conclude the claim.
Lean keeps that classical step explicit here.
02In maths
In classical logic, ¬¬P implies P.
Picture it
Swipe sideways to see the whole picture.
P by contradiction, suppose P is false and show that leads to nonsense. Classical.byContradiction turns the goal into ¬P → False, and intro hn makes the supposition. Now two clues clash: hn says P is false, but h turns any such claim into False. So h hn proves False, and the supposition must have been wrong.03In Lean
This code comes directly from the file checked by Lean.
example (P : Prop) (h : ¬ ¬ P) : P := by
apply Classical.byContradiction
intro hn
exact h hn
Classical logic allows reasoning by excluded middle: a proposition holds or its negation holds.
The theorem Classical.byContradiction turns a proof that not P is impossible into a proof of P.
The tactic apply uses a theorem whose conclusion matches the goal. It leaves the required premises as new goals.
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: apply Classical.byContradiction
P : Prop h : ¬¬P ⊢ ¬P → False
After line 3: intro hn
P : Prop h : ¬¬P hn : ¬P ⊢ False
After line 4: exact h hn
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 : Prop) (h : ¬ ¬ P) : P := by
exact h
Type mismatch h has type ¬¬P but is expected to have type P
Double negation and P are not definitionally the same proposition.
The fix: Use the explicit classical contradiction theorem to turn the double negation into P.
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 Classical.byContradiction directly on the supplied double-negation proof.
Show a hint
The theorem expects a proof that not P leads to False.
One more hint
That is exactly what the hypothesis supplies.
- A little stretch
Show that denying P or Q also denies P.
Show a hint
Assume P.
One more hint
Build the left side of the disjunction and apply the negation.
example (P : Prop) (h : ¬ ¬ P) : P := by
sorry
example (P Q : Prop) (h : ¬ (P ∨ Q)) : ¬ P := 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 : Prop) (h : ¬ ¬ P) : P := by
exact Classical.byContradiction h
example (P Q : Prop) (h : ¬ (P ∨ Q)) : ¬ P := by
intro hP
exact h (Or.inl hP)
no goals
08A quick check
09New words & tools
Take your time. Progress is yours to mark.