Stage 09 · Step 41 of 50
Reason from a missing badge.
01The idea
A school rule says every club member has a badge. If Jo has no badge, could Jo be a member?
Assume membership for a moment and the rule produces exactly the badge that is missing.
02In maths
If P implies Q and Q is impossible, then P is impossible.
Picture it
Swipe sideways to see the whole picture.
rule : P → Q says every member gets a badge. To show Jo is not a member, suppose Jo is, and watch the rule produce the very badge that is missing. missing : ¬Q turns that badge into False. A road from P to False is exactly what ¬P means.03In Lean
This code comes directly from the file checked by Lean.
example (P Q : Prop) (rule : P → Q) (missing : ¬ Q) : ¬ P := by
intro hp
exact missing (rule hp)
Read ¬ P as a request for a function from P to False. The line intro hp gives the assumed membership a name.
Evaluate the last line from the inside out. First rule hp supplies Q. Then missing uses that proof to produce the contradiction.
04Step by step
Choose a line to see Lean’s recorded goal state after that line.
P Q : Prop rule : P → Q missing : ¬Q ⊢ ¬P
After line 1: example (P Q : Prop) (rule : P → Q) (missing : ¬ Q) : ¬ P := by
P Q : Prop rule : P → Q missing : ¬Q ⊢ ¬P
After line 2: intro hp
P Q : Prop rule : P → Q missing : ¬Q hp : P ⊢ False
After line 3: exact missing (rule 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 Q : Prop) (rule : P → Q) (hq : Q) : P := by
exact rule hq
Application type mismatch: The argument hq has type Q but is expected to have type P in the application rule hq
The rule takes a proof of P as its input. The attempted proof gives it a proof of Q.
The fix: To prove ¬ P, assume P, use the rule to get Q, then apply the evidence against 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
Use a rule and its starting fact to reach the conclusion.
Show a hint
Read the type of rule from left to right.
One more hint
Apply rule to hp.
- A little stretch
Two rules lead from P to Q to R. Show that ruling out R rules out P.
Show a hint
Assume hp : P and build the chain forward.
One more hint
Apply hr to the R produced by g (f hp).
example (P Q : Prop) (rule : P → Q) (hp : P) : Q := by
sorry
example (P Q R : Prop) (f : P → Q) (g : Q → R) (hr : ¬ R) : ¬ 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 Q : Prop) (rule : P → Q) (hp : P) : Q := by
exact rule hp
example (P Q R : Prop) (f : P → Q) (g : Q → R) (hr : ¬ R) : ¬ P := by
intro hp
exact hr (g (f hp))
no goals
08A quick check
09New words & tools
Take your time. Progress is yours to mark.