Stage 05 · Step 25 of 50
Let omega handle the arithmetic.
01The idea
A calculator is good at routine arithmetic. A specialized proof procedure can handle routine inequalities too.
omega reasons about linear constraints on natural numbers and integers.
02In maths
If a + 3 ≤ b for natural numbers, then a < b.
Picture it
Swipe sideways to see the whole picture.
h says b sits at least 3 steps past a, so of course a < b. omega is a referee for this kind of linear fact about whole numbers: adding, comparing, and multiplying by fixed numbers. It finds the argument automatically, and Lean still checks the proof it builds. It is not built for multiplying two unknowns together.03In Lean
This code comes directly from the file checked by Lean.
example (a b : Nat) (h : a + 3 ≤ b) : a < b := by
omega
Linear arithmetic uses sums, inequalities, and multiplication by fixed integers. Multiplication of two arbitrary unknowns is nonlinear.
The tactic omega can also reason about many natural-number division and remainder constraints.
It remains a proof-producing tactic. Lean checks the proof it constructs. It does not make false inequalities true.
04Step by step
Choose a line to see Lean’s recorded goal state after that line.
a b : Nat h : a + 3 ≤ b ⊢ a < b
After line 1: example (a b : Nat) (h : a + 3 ≤ b) : a < b := by
a b : Nat h : a + 3 ≤ b ⊢ a < b
After line 2: omega
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 (a b : Nat) (h : a ≤ b) : a < b := by
omega
omega could not prove the goal: a possible counterexample may satisfy the constraints c ≥ 0 where c := ↑a
The assumption allows a and b to be equal.
The fix: A strict conclusion needs stronger information, such as the positive gap in the worked example.
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 the upper bound on n plus two to bound n.
Show a hint
Move the constant contribution into the bound.
One more hint
omega understands natural-number inequalities.
- A little stretch
Prove equality from a ≤ b and b ≤ a.
Show a hint
Both inequalities constrain the same pair.
One more hint
Ask omega to combine them.
example (n : Nat) (h : n + 2 ≤ 10) : n ≤ 8 := by
sorry
example (a b : Nat) (h₁ : a ≤ b) (h₂ : b ≤ a) : a = b := by
sorry
Compare with the checked solutions
There are often several valid proofs. These solutions were compiled with the same pinned Lean version.
example (n : Nat) (h : n + 2 ≤ 10) : n ≤ 8 := by
omega
example (a b : Nat) (h₁ : a ≤ b) (h₂ : b ≤ a) : a = b := by
omega
no goals
08A quick check
09New words & tools
Take your time. Progress is yours to mark.