Stage 05 · Step 25 of 50

Let omega handle the arithmetic.

Core Lean8 minutesLean 4.36.0

01The idea

A calculator is good at routine arithmetic. A specialized proof procedure can handle routine inequalities too.

Tacto · Your guide for this idea
Tacto pointing

omega reasons about linear constraints on natural numbers and integers.

02In maths

If a + 3 ≤ b for natural numbers, then a < b.

Picture it

omega: a referee for linear facts about whole numbersTop: a number line with marks at a, a + 1, a + 2 and a + 3, a gap of 3 steps. The hypothesis h : a + 3 ≤ b means b lies somewhere in a green zone that starts at a + 3 and goes on to the right. Every spot in the green zone is past a, so a < b. Bottom: the goal card a b : Nat, h : a + 3 ≤ b, goal a < b. The tactic omega closes it, leaving no goals. A side panel lists omega's rule book: it works with whole numbers, Nat and Int, with plus, minus, equals, less-or-equal and less-than, and with fixed multiples like 2 * a, but it does not reason about a * b.aa + 1a + 2a + 3a gap of 3h : a + 3 ≤ bputs b in the green zoneevery spot in the green zone is past a, so a < bTHE GOALa b : Nath : a + 3 ≤ b⊢ a < bomegano goalsomega’s rule book✓ whole numbers: Nat, Int✓ + and −, and =, ≤, <✓ fixed multiples like 2 * a✗ reasoning about a * b

Swipe sideways to see the whole picture.

The hypothesis 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.

E25.leanTry it live (opens official Lean editor)
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.

After line 1
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

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

    Use the upper bound on n plus two to bound n.

  2. A little stretch

    Prove equality from a ≤ b and b ≤ a.

Exercises/E25.leanTry it live (opens official Lean editor)
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

08A quick check

1. Which inputs does omega primarily handle here?

Read the answer and explanation

Natural numbers and integers. Its domain is arithmetic over Nat and Int.

2. Can omega generally solve arbitrary variable multiplication?

Read the answer and explanation

No. It handles linear arithmetic. General nonlinear arithmetic needs other reasoning.

One more idea in your toolkit.

Take your time. Progress is yours to mark.