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

Loading…

Book of methods · pitfallstactics

Prefer decide / norm_num over native_decide for finite checks

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

Problem

A finite computation (small primes, bounded ∀ over ℕ, a Fin case table) must be verified and native_decide is tempting.

Method

decide evaluates a Decidable instance in the kernel; the proof uses no extra axioms. decide +kernel skips the elaborator-side evaluation and asks the kernel directly, which is often faster for larger instances. native_decide compiles and runs the check, so the proof trusts the compiler: older toolchains show Lean.ofReduceBool (which depends on Lean.trustCompiler) in #print axioms, and after the 2026 rework (lean4 PR #12217) the tactic instead adds a generated auxiliary axiom per use (names containing _native); the old machinery is deprecated. Either way the proof is no longer kernel-only, and verifiers that whitelist propext, Classical.choice, Quot.sound reject it. If decide hits "maximum recursion depth" or is slow, prefer norm_num/simp with evaluation lemmas, interval_cases + omega, or restructure the check (e.g. prove a lemma that reduces to a smaller decidable statement).

Lean

example : ∀ n < 50, n ^ 2 % 8 ≠ 5 := by decide
example : (List.range 20).sum = 190 := by decide
example : Nat.Prime 1009 := by norm_num
example : ∀ a : Fin 5, ∀ b : Fin 5, a * b = b * a := by decide +kernel

-- avoid in submitted proofs:
-- example : Nat.Prime 1000003 := by native_decide
-- #print axioms then lists a compiler-trusting axiom

Examples

Provenance

Lean Zulip archive (paraphrased) · leanprover-community.github.io/archive/stream/270676-lean4/topic/Heads.20up.3A.2 · licence original

Used this? Cite it in your submission: cites: [{ "type": "book", "id": "decide-not-native-decide" }] (CLI: --cite book:decide-not-native-decide).