Stage 02 · Step 7 of 50
Prove a difference.
01The idea
Some questions have a finite checking procedure. Lean can run such a procedure and turn its verified result into a proof.
This tactic is called decide.
02In maths
Two plus two is not equal to five.
Picture it
Swipe sideways to see the whole picture.
decide is a referee who doesn't take your word for it. It runs a checking procedure: work out 2 + 2, compare with 5, and see that they differ. Because the check comes out right, Lean accepts it as a proof. Hand it a false claim like 2 + 2 ≠ 4 and the referee refuses, so the tactic fails.03In Lean
This code comes directly from the file checked by Lean.
example : 2 + 2 ≠ 5 := by
decide
04Step by step
Choose a line to see Lean’s recorded goal state after that line.
⊢ 2 + 2 ≠ 5
After line 1: example : 2 + 2 ≠ 5 := by
⊢ 2 + 2 ≠ 5
After line 2: decide
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 : 2 + 2 ≠ 4 := by
decide
Tactic `decide` proved that the proposition 2 + 2 ≠ 4 is false
This concrete proposition is false. A decision procedure cannot prove it.
The fix: Check the mathematical statement before choosing a tactic.
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 the natural numbers three and four are different.
Show a hint
This is a concrete comparison.
One more hint
Ask the decision procedure to check it.
- A little stretch
Prove that seven is smaller than three times three.
Show a hint
The arithmetic contains no unknown variables.
One more hint
The same tactic can decide this comparison.
example : (3 : Nat) ≠ 4 := by
sorry
example : (7 : Nat) < 3 * 3 := by
sorry
Compare with the checked solutions
There are often several valid proofs. These solutions were compiled with the same pinned Lean version.
example : (3 : Nat) ≠ 4 := by
decide
example : (7 : Nat) < 3 * 3 := by
decide
no goals
08A quick check
09New words & tools
Take your time. Progress is yours to mark.