Physlib.Meta.TransverseTactics
4 declarations
`processCommands` returns pre-command environments and info states
#processCommandsOperating within the Lean frontend monad `Frontend.FrontendM`, this function processes the commands of a source file to produce a list of pairs . Each pair consists of the `Environment` and the `InfoState` representing the state of the system immediately before each command is processed.
Accumulate IO actions for tactic info nodes
#visitInfoThe function `transverseTactics.visitInfo` processes a node `info` from a Lean information tree. Given a file path , a Lean environment , a callback function (which operates on tactic information), context information , and an accumulator list of IO actions , the function checks if `info` corresponds to tactic information . If it does, the function prepends a new IO action to . This action, when executed, sets the environment to and invokes , while catching and reporting any metadata errors. If `info` is not a tactic node, the function returns the original list unchanged.
Flattened IO actions from info trees in
#traverseForestGiven a file path , a callback function for processing tactic information, and a list of steps where each is an environment and each is an information state, the function `traverseForest` iterates through each pair in . For every information tree within an information state , it performs a fold operation using the function `visitInfo` with the corresponding environment and callback . This process collects and flattens the resulting IO actions into a single list of type .
Apply a callback to every tactic in a Lean file
#transverseTacticsThe function `transverseTactics` processes a Lean source file located at path and applies a user-provided callback function to every tactic execution node within that file. Specifically, it performs the following steps: 1. **Environment Setup:** It initializes the Lean search path, reads the content of , and processes the file header to establish the required environment and module dependencies. 2. **Command Processing:** It elaborates the entire file within the `FrontendM` monad to generate a sequence of pairs , where each is the environment and is the information state (containing information trees) after each command. 3. **Tactic Traversal:** It utilizes `traverseForest` to iterate through the information trees. For every tactic information node with associated context found in these trees, it executes the callback within the `MetaM` monad. The function ensures that all IO actions resulting from the tactics are executed and handles any errors that arise during the import or traversal phases.
