PhyslibSearch

Physlib.Meta.Basic

27 declarations

definition

Size of a flattened array of arrays

#flatSize

Given an array of arrays A=[a0,a1,,an1]A = [a_0, a_1, \dots, a_{n-1}] where each element aia_i is an array of elements of type α\alpha, this function computes the total number of elements contained within all the inner arrays. Mathematically, it returns the sum of the sizes of the constituent arrays: i=0n1size(ai)\sum_{i=0}^{n-1} \text{size}(a_i) This corresponds to the size of the resulting array if AA were to be flattened into a single-dimensional array.

definition

Size of a flattened array after monadic filtering by pp

#flatFilterSizeM

Given a monad mm and a monadic predicate p:αm(Bool)p : \alpha \to m(\text{Bool}), this function calculates the total number of elements in an array of arrays AA that satisfy pp. Specifically, it iterates through each inner array in AA, applies the monadic filter pp to its elements, and returns the sum of the sizes of the resulting filtered arrays within the monad mm. This is equivalent to the size of the flattened array after element-wise filtering.

definition

Array of `Physlib` imports (excluding `Init`)

#allImports

The function `Physlib.allImports` is an IO operation that retrieves an array containing all modules imported by the `Physlib` library, excluding the core `Init` module. It achieves this by locating the compiled object file (`.olean`) for the `Physlib` module, reading its metadata, and filtering the list of dependencies.

definition

Number of module imports in `Physlib`

#noImports

The function `Physlib.noImports` is an IO operation that returns a natural number representing the total number of modules (files) within the `Physlib` library. It calculates this value by determining the size of the array of all module imports associated with `Physlib`, excluding the core `Init` module.

definition

Constants from a module import impimp

#getConsts

Given a module import impimp, this function retrieves an array containing the metadata (represented as `ConstantInfo` objects) for all constants, such as definitions, theorems, and axioms, defined within that module.

definition

User-defined constants from a module import impimp

#getUserConsts

Given a Lean module import impimp, this function retrieves an array of `ConstantInfo` objects representing the user-defined constants (such as definitions, theorems, and axioms) within that module. It filters the complete set of constants in the module to exclude internal names, auto-generated recursors (including `casesOn`, `recOn`, `noConfusion`, and `brecOn`), and specific syntax-related declarations such as `TensorTree.indexExprTT.quot`. The result is returned within the `CoreM` monad.

definition

Conversion of a Lean name to a `.lean` file path

#toFilePath

The function converts a Lean name cc into a system file path. It processes the name by splitting its string representation at each dot (".") to create a sequence of directory segments and then appends the ".lean" file extension.

definition

Read lines from an imported module's source file

#getLines

For a given import impimp, the function returns an IOIO action that reads the content of the corresponding `.lean` source file and provides it as an array of strings, where each element represents a line from the file. It accomplishes this by converting the module name associated with impimp into a file path and retrieving the lines from that file.

definition

Relative file path of Lean name cc

#toRelativeFilePath

The function converts a Lean name cc into a relative system file path. It does so by joining the current directory path `.` with the file path derived from the name cc. Effectively, this transforms a hierarchical Lean identifier into a string representing the relative path of its corresponding `.lean` source file.

definition

Line number of declaration cc

#lineNumber

Given a declaration name cc, this function retrieves and returns the line number in the source file where cc is defined as a natural number nNn \in \mathbb{N}. The function operates within a monad mm that provides access to the environment's declaration metadata.

definition

Module name of a declaration cc

#fileName

Given a declaration name cc, this function returns the name of the module (or file) where cc is defined, as recorded in the current environment of the monad mm.

definition

Source location string of declaration cc

#location

For a given declaration name cc, this function retrieves its source code location and returns it as a string. The output string is formatted by concatenating the relative file path of the module where cc is defined, the line number of the declaration, and the name cc itself (e.g., `"path/to/file.lean:line_number c"`). The function operates within a monad mm that provides access to the global environment and metadata.

definition

Whether name cc has a source location

#hasPos

For a given declaration name cc, this function returns a boolean value indicating whether cc has an associated source code location (position information) within the environment.

definition

Check if a name cc has an associated docstring

#hasDocString

Given a declaration name cc, this function checks the current environment to determine whether cc has an associated documentation string, returning a boolean value within the `CoreM` monad.

definition

Documentation string of the identifier cc

#getDocString

Given a declaration identifier cc of type `Name`, the function `Lean.Name.getDocString` retrieves its associated documentation string from the current environment. If a standard documentation string exists for cc, it is returned as a `String`; otherwise, if no documentation is found or if it is in an alternative format (such as a Verso docstring), the function returns an empty string. This computation is performed within the `CoreM` monad.

definition

Source code of the declaration nn

#getDeclString

Given a declaration identifier nn of type `Name`, the function `Lean.Name.getDeclString` retrieves the literal source code defining nn from its corresponding `.lean` file. The function determines the file location and the character range (from the starting position to the end position) associated with the definition of nn in the current environment, reads the file's content, and extracts the specific substring, including any associated documentation strings. The result is returned as a `String` within the `CoreM` monad.

definition

Source code of declaration nn without documentation

#getDeclStringNoDoc

Given a declaration identifier nn of type `Name`, the function `Lean.Name.getDeclStringNoDoc` retrieves the source code of the declaration nn from its corresponding `.lean` file, excluding any preceding documentation strings or comments. The function first obtains the full declaration string, then identifies the first line starting with a keyword such as `def`, `lemma`, `theorem`, `inductive`, `structure`, `instance`, or `abbrev`, and returns the content starting from that line. The result is returned as a `String` within the `CoreM` monad.

definition

Total number of definitions in `Physlib`

#noDefs

The function `Physlib.noDefs` calculates the total count of user-defined definitions within the `Physlib` library. It retrieves all constants from the modules imported by `Physlib` and filters for those that are classified as definitions (where `isDef` is true) and possess an associated source code location. The resulting sum is returned as a natural number nNn \in \mathbb{N} within the `CoreM` monad.

definition

Total number of lemmas in `Physlib`

#noLemmas

The function `Physlib.noLemmas` computes the total number of lemmas (theorems) contained within the `Physlib` library. It aggregates all user-defined constants from the modules imported by `Physlib` and returns the count of those that are not classified as definitions (where `isDef` is false) and possess an associated source code location. The result is returned as a natural number nNn \in \mathbb{N} within the `CoreM` monad.

definition

Array of all documentation strings in `Physlib`

#allDocStrings

The function `Physlib.allDocStrings` retrieves a collection of all documentation strings associated with user-defined constants (such as definitions and theorems) within the `Physlib` library. It operates by identifying all modules imported by `Physlib`, gathering the user-defined constants from each module, and then extracting the documentation string for every constant. The result is returned as an array of strings, Array(String)\text{Array}(\text{String}), within the `CoreM` monad.

definition

Number of definitions in `Physlib` without docstrings

#noDefsNoDocString

The function `Physlib.noDefsNoDocString` calculates the total number of user-defined definitions within the `Physlib` library that lack an associated documentation string. It retrieves all constants from the modules imported by `Physlib` and counts those that satisfy three conditions: the constant is a definition (rather than a theorem or axiom), it has an associated source code location, and it does not have a docstring. The result is returned as a natural number nNn \in \mathbb{N} within the `CoreM` monad.

definition

Number of lemmas in `Physlib` without docstrings

#noLemmasNoDocString

The function `Physlib.noLemmasNoDocString` calculates the total number of user-defined lemmas and theorems within the `Physlib` library that lack an associated documentation string. It retrieves all constants from the modules imported by `Physlib` and counts those that satisfy three criteria: the constant is not a definition (indicating it is a theorem or lemma), it has an associated source code location, and it does not have a docstring. The final count is returned as a natural number nNn \in \mathbb{N} within the `CoreM` monad.

definition

Total number of lines in `Physlib`

#noLines

The function `Physlib.noLines` is an IOIO action that computes the total number of lines of source code in the `Physlib` library. It retrieves the set of all modules MM imported by `Physlib` (excluding the core `Init` library), reads the content of the source file for each module mMm \in M as an array of strings representing its lines LmL_m, and returns the total count mMLm\sum_{m \in M} |L_m| as a natural number nNn \in \mathbb{N}.

definition

Number of TODO items in `Physlib`

#noTODOs

The function `Physlib.noTODOs` is an IOIO action that calculates the total number of "TODO" items within the `Physlib` library. It retrieves the set of all modules MM imported by `Physlib` (excluding the core `Init` library) and, for each module mMm \in M, reads the lines LmL_m of its source code. The function then counts and returns the total number of lines across all files that start with the prefix "TODO " as a natural number nNn \in \mathbb{N}.

definition

Number of `Physlib` files containing "TODO" items

#noFilesWithTODOs

The function `Physlib.noFilesWithTODOs` is an IOIO action that calculates the number of source files within the `Physlib` library that contain at least one "TODO" item. It identifies the set of all modules MM imported by `Physlib` (excluding the core `Init` library), retrieves the lines LmL_m of the source code for each module mMm \in M, and filters for the subset of files where at least one line lLml \in L_m starts with the prefix "TODO ". The final result is the size of this subset as a natural number nNn \in \mathbb{N}.

definition

Array of user-defined constants in `Physlib`

#allUserConsts

The function `Physlib.allUserConsts` retrieves an array of all user-defined declarations (such as definitions, theorems, and axioms) within the `Physlib` library. This is achieved by aggregating the constants from all modules returned by `Physlib.allImports`, filtering them via `Physlib.Imports.getUserConsts` to exclude internal names and auto-generated recursors. The operation is performed within the `CoreM` monad.