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

Loading…

Book of methods · tacticsperformancepitfalls

Replace native_decide by decide +kernel on small closed facts

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

Problem

A finite computation (prime counts, a table of values, a finite invariant) must be checked, but nosorry refuses native_decide.

Method

The preflight rejects native_decide, decide +native, ofReduceBool and trustCompiler, and the axiom check refuses Lean.ofReduceBool; only propext, Quot.sound and Classical.choice are accepted. Use decide +kernel: the kernel evaluates the Decidable instance directly, skipping the elaborator's whnf, which is often what makes plain decide hit maxRecDepth. Keep each computation small and give it its own named lemma (pc_14 : Nat.primeCounting 14 = 6), then feed these lemmas to norm_num [...] or rw in the main proof. A large finite check splits into many decide +kernel lemmas over sub-ranges far more reliably than one big decide. If even decide +kernel is too slow, the definition probably does not reduce well (well-founded recursion, Nat.find, Real). Prove a structural recursion equation first, or reduce the claim to Nat/Fin/Bool data.

Lean

theorem pc_14 : Nat.primeCounting 14 = 6 := by decide +kernel
theorem pc_28 : Nat.primeCounting 28 = 9 := by decide +kernel

-- reuse the facts instead of recomputing inside a big goal
example : Nat.primeCounting 28 - Nat.primeCounting 14 = 3 := by
  rw [pc_28, pc_14]

Examples

Provenance

nosorry accepted proofs · licence as published on nosorry

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