Zulip Chat Archive
Stream: mathlib4
Topic: Slow import
tau (Nov 01 2025 at 11:56):
import Mathlib takes several minutes on my machine (MBP 2020 with M1). I found #24020 from which I concluded that cached builds are not optimized for my machine and decided to rebuild mathlib manually (which took almost 8 hours), but that didn't help. Is there anything I can do to speed up mathlib?
Ruben Van de Velde (Nov 01 2025 at 12:06):
Yeah, that issue is about when you want to compile a program that uses mathlib. I think you're just hitting the issue that mathlib is quite big. You can start by importing specific modules that look relevant
tau (Nov 01 2025 at 12:11):
I'm not really proficient with Lean, currently taking courses on formal verification in my uni. I'm still not sure which tactics come from Lean and which from Mathlib, considering there are some that come from both (e.g. apply x comes from Lean, but apply x at y from Mathlib IIRC). So figuring out which modules I need to import might take even more time than trying to prove a theorem.
Damiano Testa (Nov 01 2025 at 12:22):
If you use import Mathlib.Tactic you get a good selection of math results and all (most?) mathlib tactics.
Bryan Gin-ge Chen (Nov 01 2025 at 12:51):
It requires you to have a compiling file first so I don't know if it will work for your current issue, but there's also the #min_imports command which will tell you what the minimum imports you need are.
Last updated: Dec 20 2025 at 21:32 UTC