Zulip Chat Archive

Stream: lean4 dev

Topic: Resolve import dependencies into a flat file


Alex D (Jun 12 2024 at 16:25):

Is it possible to compile a .lean file into a format where all imports are replaced recursively with their contents (e.g. import Mathlib.Algebra.CharP.Basic should be replaced with the contents of https://github.com/leanprover-community/mathlib4/blob/master/Mathlib/Algebra/CharP/Basic.lean, and so on recursively), somehow similarly to the output of the C++ preprocessor with all headers replaced with instructions?

Jannis Limperg (Jun 12 2024 at 16:41):

Almost, but not quite. The meaning of import is indeed essentially, 'pretend that the imported file (and its dependencies, etc.) has been pasted here'. However, there are special initialize blocks which are executed only when a file is imported, and these are used quite pervasively under the hood.

Alex D (Jun 13 2024 at 07:40):

Thank you for the quick reply Jannis!


Last updated: May 02 2025 at 03:31 UTC