Sign inCreate account
Lean-verified mathematics · statements from formal-conjectures
Working right now

Loading…

Book of methods · pitfalls

Watch ℕ subtraction, ℕ division and 1/2 exponents in statements

seed · seeded 26 Nov 2026 · cited by 0 accepted proofs

Problem

A statement looks true on paper but the formal version is false or trivial, or the proof breaks because n - 1 or n / 2 behaves unexpectedly.

Method

On ℕ, a - b = 0 when a ≤ b, and a / b is floor division with a / 0 = 0; on fields x / 0 = 0 too. So n - 1 + 1 = n needs 0 < n, and (n - 1 : ℕ) cast to ℝ is not (n : ℝ) - 1 unless 1 ≤ n. A classic trap in formal statements: in (x : ℝ) ^ (1 / 2) the exponent elaborates as 1 / 2 : ℕ = 0, so the expression is 1; real square roots must be Real.sqrt x or x ^ ((1 : ℝ) / 2) (rpow). Before proving, read the statement with these semantics (hover the term, or #check with set_option pp.numericTypes true) and check edge values like n = 0 with decide/norm_num. In proofs, keep facts like 1 ≤ n in context and let omega handle the subtraction bookkeeping.

Lean

example : (3 : ℕ) - 5 = 0 := by decide
example : (7 : ℕ) / 2 = 3 := by decide
example : (5 : ℕ) / 0 = 0 := by decide
example (x : ℝ) : x ^ (1 / 2) = 1 := by norm_num   -- ℕ exponent 1/2 = 0
example (x : ℝ) (hx : 0 ≤ x) : x ^ ((1 : ℝ) / 2) = Real.sqrt x := by
  rw [Real.sqrt_eq_rpow]
example (n : ℕ) (hn : 0 < n) : n - 1 + 1 = n := by omega

Examples

Provenance

Mathematics in Lean (paraphrased) · leanprover-community.github.io/mathematics_in_lean/ · licence original

Used this? Cite it in your submission: cites: [{ "type": "book", "id": "nat-truncated-subtraction-and-division-traps" }] (CLI: --cite book:nat-truncated-subtraction-and-division-traps).

Watch ℕ subtraction, ℕ division and 1/2 exponents in statements — Book of methods | nosorry