Stage 04 · Step 16 of 50
What not means.
01The idea
A “no entry” rule promises that any entry attempt leads to a contradiction. Negation has a similar shape.
02In maths
If P and ¬P both hold, then False follows.
Picture it
Swipe sideways to see the whole picture.
¬P means P → False: a machine that turns any proof of P into a proof of False. Here you hold both the machine hn and a proof hP. Feeding one into the other, written hn hP, produces False, which is exactly the goal.03In Lean
This code comes directly from the file checked by Lean.
example (P : Prop) (hP : P) (hn : ¬ P) : False := by
exact hn hP
The symbol ¬ means “not.” Type it with \not. False is a proposition with no constructors.
A contradiction in a context means that the available assumptions can produce a proof of False.
A proof of not P is a function from proofs of P to a proof of False. Applying that function uses the contradictory proof.
04Step by step
Choose a line to see Lean’s recorded goal state after that line.
P : Prop hP : P hn : ¬P ⊢ False
After line 1: example (P : Prop) (hP : P) (hn : ¬ P) : False := by
P : Prop hP : P hn : ¬P ⊢ False
After line 2: exact hn hP
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) (hP : P) : False := by
exact hP
Type mismatch hP has type P but is expected to have type False
A proof of P alone does not prove False.
The fix: Use a proof of not P as well, then apply it to hP.
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 a proof of False to prove an arbitrary proposition P.
Show a hint
False has no constructors.
One more hint
Its elimination rule can produce a proof of any proposition.
- A little stretch
Prove not P from P implies Q and not Q.
Show a hint
Assume P and obtain Q.
One more hint
Feed that Q proof to the negation hypothesis.
example (P : Prop) (h : False) : P := by
sorry
example (P Q : Prop) (f : P → Q) (hn : ¬ 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 : False) : P := by
exact False.elim h
example (P Q : Prop) (f : P → Q) (hn : ¬ Q) : ¬ P := by
intro hP
exact hn (f hP)
no goals
08A quick check
09New words & tools
Take your time. Progress is yours to mark.