Zulip Chat Archive
Stream: new members
Topic: beginner question: imports
Dean Young (Feb 21 2023 at 20:22):
Here's an example that works:
import data.int.basic
What happens when I import something? Where on my computer is data.int.basic?
Shreyas Srinivas (Feb 21 2023 at 20:26):
There is an elan folder usually in the home directory, that contains all your toolchains.
Shreyas Srinivas (Feb 21 2023 at 20:28):
Within it, you would find, among other things, some basic library files. Mathlib imports (and anything else downloaded by lake as a dependency) are stored inside a folder called lake-packages inside the project directory.
James Gallicchio (Feb 21 2023 at 20:29):
(^ at least in Lean4 if you're using Lake; lean3 package system was a lot more ad-hoc I believe)
Notification Bot (Feb 21 2023 at 20:55):
This topic was moved here from #mathlib4 > beginner question: imports by Floris van Doorn.
Floris van Doorn (Feb 21 2023 at 20:56):
This seems to be a question about Lean 3, so moving it to a different stream.
Floris van Doorn (Feb 21 2023 at 20:58):
In Lean 3 every project is supposed to have a leanpkg.toml file which contains all the dependencies. Then, if you import a file, it will look at:
- The current project
- Any dependency as marked by the
leanpkg.tomlfile, which usually exists in a_targetsubdirectory. - The Lean core library itself (the
elantool should take care of putting these in a subfolder of your home directory).
Eric Wieser (Feb 21 2023 at 21:02):
Slightly more precisely, when you run leanpkg configure it reads your leanpkg.toml and outputs a leanpkg.path. It is this .path file (or the LEAN_PATH environment variable in its absence) that is what is used to resolve import data.int.basic to some_folder/data/int/basic.lean.
Eric Wieser (Feb 21 2023 at 21:03):
You can run lean --path to see how lean processed the leanpkg.path file.
Dean Young (Feb 21 2023 at 22:17):
Thanks for all of your help, this is good info!
Last updated: May 02 2025 at 03:31 UTC