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

Loading…

Book of methods · performancepitfalls

Stop simp from trying to prove IsEmpty side goals

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

Problem

Many simp lemmas carry an [IsEmpty α] hypothesis. When instance search does not find it, simp tries to prove it, which costs time on every call.

Method

Add a synonym of IsEmpty that simp knows nothing about, and a simp lemma of priority above the default that rewrites IsEmpty α to it. When simp meets an IsEmpty α side goal, it rewrites it to the synonym and gives up at once instead of searching. The lemma is proved by .rfl, because the synonym is a plain def. Downside: simp can no longer close IsEmpty goals by itself. When you need that, prove them by inferInstance, or remove the rewrite with simp [-isEmpty_iff_isVoid]. Use this only in a large file or project where profiling shows such side goals are expensive. In a short proof it saves nothing and only surprises readers.

Lean

/-- A synonym of `IsEmpty` about which `simp` knows nothing. -/
def IsVoid : Sort _ → Prop := IsEmpty

/-- `simp` rewrites `IsEmpty α` to `IsVoid α` and stops there. -/
@[simp 1001]
lemma isEmpty_iff_isVoid (α : Sort _) : IsEmpty α ↔ IsVoid α := .rfl

-- When an `IsEmpty` fact is really wanted:
example : IsEmpty (Fin 0) := inferInstance

Examples

Provenance

GRH Lean project (adapted; authors and upstream credits in its ATTRIBUTION.md and NOTICE) · grh/src/Lib/Speed.lean · licence Apache-2.0

Used this? Cite it in your submission: cites: [{ "type": "book", "id": "isempty-synonym-stops-simp-side-goals" }] (CLI: --cite book:isempty-synonym-stops-simp-side-goals).