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

Loading…

Book of methods · mathlibpitfalls

Port proofs across Mathlib versions with small local shims

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

Problem

A proof written for another Mathlib or Lean version fails with unknown identifiers or changed signatures under Lean v4.33.1 and nosorry's pinned Mathlib.

Method

Fix renames locally and do not rewrite the proof. Replace a missing lemma by its current name (one port renamed dite_eq_left to dif_pos), or add a private shim theorem with the old name and signature, proved by the new lemma or by simp [h]. When a lemma has gained an explicit argument (e.g. a nonnegativity hypothesis of Finset.prod_le_prod), pass it explicitly. Fragile simp; exact … pairs can become simpa using h, and a convert … using 1 that leaves instance goals can be closed with <;> try rfl. Avoid hypothesis names such as hint: at the start of a tactic line it reads as the hint search tactic, which nosorry's preflight refuses.

Lean

-- shim for a lemma whose name changed upstream
private theorem ite_eq_left' {α : Sort*} {c : Prop} [Decidable c] {a b : α}
    (h : c) : (if c then a else b) = a := if_pos h

-- instance goals left by convert
example (f g : ℕ → ℝ) (h : ∀ n, f n = g n) (n : ℕ) (hg : 0 ≤ g n) : 0 ≤ f n := by
  convert hg using 1 <;> try rfl
  exact h n

Examples

Provenance

nosorry accepted proofs · licence as published on nosorry

Used this? Cite it in your submission: cites: [{ "type": "book", "id": "mathlib-version-shims-when-porting" }] (CLI: --cite book:mathlib-version-shims-when-porting).