Physlib.Meta.Sorry
Meta results regarding `sorry` and `pseudo` attributions
i. Overview
The purpose of this module is to collect all results which depend on the `sorryAx` axiom and the `Lean.ofReduceBool` axiom, and check that these results are correctly attributed `sorryful` and `pseudo` respectively.
ii. Key results
- `sorryfulPseudoTest` : A test that all results attributed `sorryful` depend on the `sorryAx` axiom and vice versa, and all results attributed `pseudo` depend on the `Lean.ofReduceBool` axiom and vice versa.
iii. Table of contents
- A. Collectings results depending on `sorryAx` and `Lean.ofReduceBool` - A.1. The state information to be collected - A.2. The monad for collecting names - A.3. The collection function - A.4. Given an array updating the state with all names depending on axioms - A.5. Given an array getting all names depending on axioms - A.6. Getting all names depending on axioms from all user defined constants - B. Collecting all names attributed `sorryful` and `pseudo` - C. Testing the `sorryful` and `pseudo` attributions are correctly applied
iv. References
Some of the code here is adapted from from the file: `Lean.Util.CollectAxioms` copyright (c) 2020 Microsoft Corporation. Authored by Leonardo de Moura.
A. Collectings results depending on `sorryAx` and `Lean.ofReduceBool`
A.1. The state information to be collected
A.2. The monad for collecting names
A.3. The collection function
A.4. Given an array updating the state with all names depending on axioms
A.5. Given an array getting all names depending on axioms
A.6. Getting all names depending on axioms from all user defined constants
B. Collecting all names attributed `sorryful` and `pseudo`
C. Testing the `sorryful` and `pseudo` attributions are correctly applied
8 declarations
Monad for collecting axiom-dependent results
The monad is defined as . It provides a computational context that combines read-only access to the Lean with a mutable for the purpose of traversing and collecting the names of constants that depend on the axioms (representing "sorry" proofs) and (representing pseudo-definitions).
Update Monad with Axiom Dependencies of Name
Given a Lean name and a set of names representing its ancestors in the dependency graph, , the function updates the state within the monad by determining if the constant or its dependencies rely on the axioms (indicating "sorry" proofs) or (indicating pseudo-definitions).
Update Monad with Axiom Dependencies for Array
Given an array of Lean names , the function iterates through each name and applies the function with an empty set of ancestor names. This operation updates the internal state of the monad by identifying whether the constants corresponding to the names in and their recursive dependencies rely on the axioms (representing "sorry" proofs) or (representing pseudo-definitions).
Collect `sorryAx` and `ofReduceBool` dependencies for
Given an array of names , this function identifies all constants in the dependency closure of that rely on the or axioms. It returns a pair of arrays in the `CoreM` monad, where contains the names of results depending on (representing "sorry" proofs) and contains the names of results depending on (representing pseudo-definitions).
All user-defined constants with or dependencies
This function, operating within the Lean core environment monad (), identifies all user-defined constants in the current environment that depend on either the or axioms. It returns a pair of arrays , where is the collection of names of constants whose definitions or proofs rely on the axiom (indicating the presence of ), and is the collection of names of constants relying on the axiom (indicating pseudo-definitions).
Names attributed `sorryful`
The computation retrieves and returns an array containing all names in the current environment that have been explicitly marked with the `sorryful` attribute.
Array of all names attributed as `pseudo`
Within the context of the Lean core environment monad (), this function retrieves an array of all constant identifiers (names) that have been assigned the `pseudo` attribute.
Consistency test for `sorryful` and `pseudo` attributes
Within the meta-programming monad (), 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.
