PhyslibSearch

Physlib.Meta.Sorry

8 declarations

abbrev

Monad MM for collecting axiom-dependent results

#M

The monad MM is defined as M:=ReaderT(Environment,StateM(State))M := \text{ReaderT}(\text{Environment}, \text{StateM}(\text{State})). It provides a computational context that combines read-only access to the Lean Environment\text{Environment} with a mutable State\text{State} for the purpose of traversing and collecting the names of constants that depend on the axioms sorryAx\texttt{sorryAx} (representing "sorry" proofs) and Lean.ofReduceBool\texttt{Lean.ofReduceBool} (representing pseudo-definitions).

definition

Update Monad MM with Axiom Dependencies of Name cc

#collect

Given a Lean name cc and a set of names representing its ancestors in the dependency graph, parents\text{parents}, the function updates the state within the monad MM by determining if the constant cc or its dependencies rely on the axioms sorryAx\texttt{sorryAx} (indicating "sorry" proofs) or Lean.ofReduceBool\texttt{Lean.ofReduceBool} (indicating pseudo-definitions).

definition

Update Monad MM with Axiom Dependencies for Array cc

#allSorryPseudo

Given an array of Lean names cc, the function iterates through each name xcx \in c and applies the collect\texttt{collect} function with an empty set of ancestor names. This operation updates the internal state of the monad MM by identifying whether the constants corresponding to the names in cc and their recursive dependencies rely on the axioms sorryAx\texttt{sorryAx} (representing "sorry" proofs) or Lean.ofReduceBool\texttt{Lean.ofReduceBool} (representing pseudo-definitions).

definition

Collect `sorryAx` and `ofReduceBool` dependencies for cc

#collectSorryPseudo

Given an array of names cc, this function identifies all constants in the dependency closure of cc that rely on the sorryAx\texttt{sorryAx} or Lean.ofReduceBool\texttt{Lean.ofReduceBool} axioms. It returns a pair of arrays (A,B)(A, B) in the `CoreM` monad, where AA contains the names of results depending on sorryAx\texttt{sorryAx} (representing "sorry" proofs) and BB contains the names of results depending on Lean.ofReduceBool\texttt{Lean.ofReduceBool} (representing pseudo-definitions).

definition

All user-defined constants with sorryAx\texttt{sorryAx} or Lean.ofReduceBool\texttt{Lean.ofReduceBool} dependencies

#allWithSorryPseudo

This function, operating within the Lean core environment monad (CoreM\text{CoreM}), identifies all user-defined constants in the current environment that depend on either the sorryAx\texttt{sorryAx} or Lean.ofReduceBool\texttt{Lean.ofReduceBool} axioms. It returns a pair of arrays (A,B)(A, B), where AA is the collection of names of constants whose definitions or proofs rely on the sorryAx\texttt{sorryAx} axiom (indicating the presence of sorry\texttt{sorry}), and BB is the collection of names of constants relying on the Lean.ofReduceBool\texttt{Lean.ofReduceBool} axiom (indicating pseudo-definitions).

definition

Names attributed `sorryful`

#allSorryfulAttributed

The computation retrieves and returns an array containing all names nn in the current environment that have been explicitly marked with the `sorryful` attribute.

definition

Array of all names attributed as `pseudo`

#allPseudoAttributed

Within the context of the Lean core environment monad (CoreM\text{CoreM}), this function retrieves an array of all constant identifiers (names) that have been assigned the `pseudo` attribute.

definition

Consistency test for `sorryful` and `pseudo` attributes

#sorryfulPseudoTest

Within the meta-programming monad (MetaM\text{MetaM}), this procedure verifies the consistency of the `sorryful` and `pseudo` attributes for all user-defined constants in the environment. Specifically, it checks that a constant is attributed `sorryful` if and only if its definition or proof depends on the `sorryAx` axiom. Simultaneously, it verifies that a constant is attributed `pseudo` if and only if it depends on the `Lean.ofReduceBool` axiom (typically associated with `native_decide`). If any discrepancies are found—either a constant possessing an attribute without the corresponding dependency or a constant having the dependency without the attribute—the function terminates with a detailed error message listing the inconsistent identifiers. Otherwise, it prints a success message indicating that the metadata is correctly applied.