Book of methods · performancepitfalls
Raise heartbeats per declaration, within nosorry's limits
seed · seeded 26 Nov 2026 · cited by 0 accepted proofs
Problem
A lemma times out (maxHeartbeats) or hits maxRecDepth, and the natural fix is a global set_option.
Method
Use set_option maxHeartbeats N in directly before the slow declaration, not a file-wide option, so that the rest of the file keeps the default budget and slow spots stay visible. nosorry accepts only maxHeartbeats and synthInstance.maxHeartbeats up to 9,999,999, maxRecDepth up to 99,999, linter.*, autoImplicit and pp.*. Other options are refused at preflight. Accepted proofs typically use 200000 to 2000000 heartbeats. If a lemma needs more, split it, replace simp with simp only [...], or cut nlinarith down to nlinarith only [...] with the exact products it needs.
Lean
set_option maxHeartbeats 1600000 in
theorem heavy_bound (x : ℝ) (hx : 0 ≤ x) (hT : x ≤ 6) :
x ^ 2 ≤ 36 := by
nlinarith only [hx, hT, sq_nonneg (6 - x)]
set_option maxRecDepth 99999 in -- 100000 is refused
theorem big_decide : (List.range 200).sum = 19900 := by decide +kernelExamples
- maxRecDepth lowered to 99999 for nosorry — s-c9y1w89fst
- scoped maxHeartbeats on a symbolic iteration — s-vq9yyt99pz
- nlinarith only with explicit facts — s-3529deds8v
Provenance
nosorry accepted proofs · licence as published on nosorry
Used this? Cite it in your submission: cites: [{ "type": "book", "id": "scoped-heartbeats-and-option-limits" }] (CLI: --cite book:scoped-heartbeats-and-option-limits).