Documentation

ImportGraph.Tools.FindHome

#find_home for ... #

This module provides the #find_home for <cmd> utility, which suggests the highest places a given command (and its dependencies from the current file) can live in the import hierarchy. #find_home respects the module system.

Future work #

UI #

Functionality #

⚠️ #find_home is currently experimental. Please report any wish-list features, possible ergonomic improvements, or errors on GitHub or Zulip.


#find_home for <cmd> finds the highest modules in the import hierarchy in which <cmd> (and the declarations produced during it) can live. This accounts for the syntax, constants, and executable code produced during <cmd>, and respects the module system.

This includes any declarations which are dependencies of <cmd> from the current file, which should be moved along with it. (Currently, #find_home does not account for the syntax of those dependencies, nor does it suggest moving such dependencies individually.)

Note that #find_home may take a long time on its first run. It caches data about the module hierarchy both in the .lake folder and interactively to make subsequent runs faster.

Known limitations #

  • #find_home does not yet handle meta definitions.
  • #find_home does not yet account for the syntax of dependent definitions.
  • #find_home may not function correctly outside of the module system.
  • For smaller miscellaneous limitations, see the module docstring.
Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Non-module #find_home #

    This code is a fallback since #find_home for does not yet work outside the module system.

    Warning: this declaration does not respect the module system, and should only be used outside of it.

    Find locations as high as possible in the import hierarchy where the named declaration could live.

    Instances For

      #find_home <ident> is in the process of being deprecated. Instead, use

      #find_home for
      <command>
      

      where <command> declares <ident>. This ensures that the imports necessary for the syntax and tactics used in the declaration are present too.

      The following describes the functionality outside of the module system, which may not work:

      Find locations as high as possible in the import hierarchy where the named declaration could live. Using #find_home! will forcefully remove the current file. Note that this works best if used in a file with import Mathlib.

      The current file could still be the only suggestion, even using #find_home! lemma. The reason is that #find_home! scans the import graph below the current file, selects all the files containing declarations appearing in lemma, excluding the current file itself and looks for all least upper bounds of such files.

      For a simple example, if lemma is in a file importing only A.lean and B.lean and uses one lemma from each, then #find_home! lemma returns the current file.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For