Stage 02 · Step 7 of 50

Prove a difference.

Core Lean5 minutesLean 4.36.0

01The idea

Some questions have a finite checking procedure. Lean can run such a procedure and turn its verified result into a proof.

Tacto · Your guide for this idea
Tacto pointing

This tactic is called decide.

02In maths

Two plus two is not equal to five.

Picture it

decide is a referee who works the answer outTop lane: the claim 2 + 2 ≠ 5 is handed to a referee labelled decide. The referee computes 2 + 2 = 4 and checks: is 4 equal to 5? No. So the claim is true, the referee gives a green check, and the goal is closed. Bottom lane, faded: a false claim, 2 + 2 ≠ 4, goes to the same referee. The referee computes 4 and finds 4 equals 4, so the claim is false and decide fails with a red cross.decideTHE CLAIM2 + 2 ≠ 5compute:2 + 2 = 44 = 5 ? noprovedA FALSE CLAIM2 + 2 ≠ 44 = 4 ? yesthe claim is false, so decide fails

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.

E07.leanTry it live (opens official Lean editor)
example : 2 + 2 ≠ 5 := by
  decide

The symbol ≠ means “not equal.” Type it with \ne followed by a space.

A proposition is decidable when Lean has a procedure that either proves it or proves its negation.

For these concrete arithmetic statements, core Lean already provides the procedure. A false statement makes the tactic fail.

04Step by step

Choose a line to see Lean’s recorded goal state after that line.

After line 1
⊢ 2 + 2 ≠ 5
After line 1: example : 2 + 2 ≠ 5 := by
⊢ 2 + 2 ≠ 5
After line 2: decide
no goals

05Lean says

Captured from Lean 4.36.0
no goals

A goal is what remains to prove. The symbol ⊢ points to it. Meet the turnstile.

07Your turn

sorry is a placeholder for unfinished work. Replace it as you solve each task. A finished proof has no placeholders.

  1. Warm-up

    Prove that the natural numbers three and four are different.

  2. A little stretch

    Prove that seven is smaller than three times three.

Exercises/E07.leanTry it live (opens official Lean editor)
example : (3 : Nat) ≠ 4 := by
  sorry

example : (7 : Nat) < 3 * 3 := by
  sorry

08A quick check

1. What does ≠ mean?

Read the answer and explanation

Not equal. The symbol negates equality. Type it with \ne.

2. Can decide prove an arbitrary proposition without a decision procedure?

Read the answer and explanation

No. The tactic requires a Decidable instance and must compute the result to true.

One more idea in your toolkit.

Take your time. Progress is yours to mark.