feat: support #print axioms under the module system#13117
feat: support #print axioms under the module system#13117nomeata wants to merge 16 commits intonightly-with-mathlibfrom
#print axioms under the module system#13117Conversation
This reverts commit 4c497ea.
Record axiom dependencies eagerly at `addDecl` time in a persistent environment extension (`exportedAxiomsExt`) so that `#print axioms` can report them accurately even after declaration bodies have been stripped on export. Uses a non-blocking collection strategy that avoids accessing `env.checked` (which would deadlock with async `addDecl`), instead consulting previously-recorded axioms for current-module constants and the import env for imported constants. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
!radar |
|
Benchmark results for 3bd2969 against e6df474 are in. Significant changes detected! @nomeata
Large changes (14✅, 7🟥) Too many entries to display here. View the full report on radar instead. Medium changes (2✅, 37🟥) Too many entries to display here. View the full report on radar instead. Small changes (8✅, 1579🟥) Too many entries to display here. View the full report on radar instead. |
Instead of eagerly recording axiom dependencies at addDecl time, compute them lazily in the extension's exportEntriesFn when the olean is written. This is simpler because: - No writes to the extension during elaboration (no async concerns) - No special non-blocking collection logic needed - The extension is empty during local development (bodies are available) - Axiom data is only computed for declarations that actually need it At export time, we compare the exported and private views to find constants whose bodies were stripped, then walk their bodies (still available in env.checked.get) to compute axiom dependencies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
!radar |
|
Benchmark results for c94e491 against e6df474 are in. Significant changes detected! @nomeata
No significant changes detected. |
|
Reference manual CI status:
|
|
Mathlib CI status (docs):
|
…llection This PR changes the `exportedAxiomsExt` to use `registerPersistentEnvExtension` directly with a custom state type that holds a merged lookup map of all imported modules' extension entries. The `addImportedFn` builds this map at import time, making it available to both `exportEntriesFnEx` (at export time) and `collect` (at query time) without circular references or IO.Ref hacks. At export time, imported stripped declarations are resolved via their source modules' extension entries (containing only real axioms), while current-module declarations are traversed directly with caching to avoid redundant work. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…cation This PR rewrites the axiom collection logic to use a cleaner design: - State uses `seen : NameMap (Array Name)` as a per-constant cache and `axioms : NameSet` as a deduplicating accumulator - Each constant's axioms are computed by temporarily clearing the accumulator, recursing, then caching the sorted result and merging back - Extension state stores raw imported module entry arrays (no merge in addImportedFn), with lookup via getModuleIdxFor? + binary search - exportEntriesFnEx processes all stripped names via forM with shared cache Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…portEntriesFnEx Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
!radar |
|
Benchmark results for 7999de4 against e6df474 are in. Significant changes detected! @nomeata
Large changes (4🟥)
Medium changes (16🟥)
and 1 hidden Small changes (1877🟥) Too many entries to display here. View the full report on radar instead. |
This tests that `#print axioms` correctly reports axiom dependencies for imported stripped declarations across module boundaries, including diamond imports with same-named private axioms and import chains where axiom dependencies propagate through stripped definitions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This moves the `#print axioms` module tests from `pkg/module/PrintAxioms.lean` to the dedicated `pkg/collectAxioms` test and adds coverage for axiom-free defs, opaques, axioms whose types mention other axioms, and multiple axiom dependencies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Mathlib CI status (docs):
|
This pre-computes axiom dependencies for every exported declaration, not just stripped ones. Downstream modules can then look up any imported declaration in the extension without walking its body, keeping axiom collection module-local and avoiding redundant cross-module body traversal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
!radar |
|
Benchmark results for fe5e9a2 against e6df474 are in. Significant changes detected! @nomeata
Large changes (4🟥)
Medium changes (15🟥)
Small changes (893🟥) Too many entries to display here. View the full report on radar instead. |
This PR re-enables
#print axiomsunder the module system by computing axiom dependencies at olean export time. It reverts #8174 and replaces it with a proper fix.A
PersistentEnvExtensionwith a customexportEntriesFnExcomputes axiom dependencies when the olean is written. At export time, it walks bodies of all public declarations in the current module (still available viaenv.setExporting false) to collect axiom dependencies, and stores the results sorted for binary search. Downstream modules look up pre-computed axiom data from imported oleans, so axiom collection never crosses module boundaries. During elaboration of the current module,collectAxiomswalks bodies directly since they are always available locally.The extension exports entries for all public declarations (not just stripped ones) to ensure downstream
collectcalls terminate at module boundaries without redundant body traversal of imported declarations.Since axiom data is inherently body-dependent, the
pkg/rebuildtest (which checks that body-only changes don't trigger downstream rebuilds) requires stage2, where Init modules have extension entries. On stage1 (built with stage0 which lacks the extension), theorems in Init appear as axioms in the kernel environment, inflating the axiom sets.🤖 Generated with Claude Code