Skip to content

refactor: move inductive information in compiler from lazily filled local caches to eager persistent environment extensions#13882

Open
Kha wants to merge 1 commit into
leanprover:masterfrom
Kha:push-nuyxqomztlon
Open

refactor: move inductive information in compiler from lazily filled local caches to eager persistent environment extensions#13882
Kha wants to merge 1 commit into
leanprover:masterfrom
Kha:push-nuyxqomztlon

Conversation

@Kha
Copy link
Copy Markdown
Member

@Kha Kha commented May 29, 2026

This is in preparation for - and already enables in part - correctly compiling code using public types with private constructors and thus potentially inaccessible type references. A follow-up PR will have to further restrict the trivial structure optimization, which is the only case where even this early analysis can still lead to dangling references.

@Kha
Copy link
Copy Markdown
Member Author

Kha commented May 29, 2026

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented May 29, 2026

Benchmark results for 52e598e against c47a0c7 are in. There are significant results. @Kha

  • 🟥 build exited with code 1
  • 🟥 other exited with code 1

No significant changes detected.

@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label May 29, 2026
@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-05-28 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-05-29 10:45:41)

@Kha Kha force-pushed the push-nuyxqomztlon branch from 52e598e to a9515da Compare May 29, 2026 11:21
@Kha
Copy link
Copy Markdown
Member Author

Kha commented May 29, 2026

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented May 29, 2026

Benchmark results for a9515da against c47a0c7 are in. There are significant results. @Kha

  • build//instructions: -4.4G (-0.04%)

Small changes (20✅, 4🟥)

Too many entries to display here. View the full report on radar instead.

mathlib-nightly-testing Bot pushed a commit to leanprover-community/batteries that referenced this pull request May 29, 2026
@github-actions github-actions Bot added the mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN label May 29, 2026
@Kha Kha force-pushed the push-nuyxqomztlon branch from a9515da to 6fae8d0 Compare May 29, 2026 12:57
@Kha Kha marked this pull request as ready for review May 29, 2026 12:57
@Kha Kha requested review from hargoniX and leodemoura as code owners May 29, 2026 12:57
@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added the builds-mathlib CI has verified that Mathlib builds against this PR label May 29, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

mathlib-lean-pr-testing Bot commented May 29, 2026

Mathlib CI status (docs):

mathlib-nightly-testing Bot pushed a commit to leanprover-community/batteries that referenced this pull request May 29, 2026
mathlib-nightly-testing Bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request May 29, 2026
This PR lets the compiler handle public types whose constructor field types are not available in
importing modules — for example a public structure with a `private` field whose type is only
privately imported. Compiling code that uses such a type in another module previously failed
because the compiler tried to inspect field types it could not see.

The LCNF representation information derived from constructor fields — trivial-structure info, mono
and impure types, and constructor layouts — is now computed and persisted in each inductive's
defining module and reused by importers instead of being recomputed there. Inductive types are
compiled eagerly (`compileInductives`) from `compileDecls`, and the information is stored in
`MapDeclarationExtension`s read by strict lookups.
@Kha Kha force-pushed the push-nuyxqomztlon branch from 6fae8d0 to 79779f6 Compare May 29, 2026 15:32
@Kha Kha changed the title feat: support compiling types with non-imported field types refactor: move inductive information in compiler from lazily filled local caches to eager persistent environment extensions May 29, 2026
@Kha
Copy link
Copy Markdown
Member Author

Kha commented May 29, 2026

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented May 29, 2026

Benchmark results for 79779f6 against c47a0c7 are in. There are significant results. @Kha

  • build//instructions: -9.8G (-0.09%)

Large changes (1🟥)

  • 🟥 size/all/.olean//bytes: +3MiB (+0.80%)

Medium changes (1🟥)

  • 🟥 size/Init/.olean//bytes: +399kiB (+0.42%)

Small changes (383✅, 45🟥)

Too many entries to display here. View the full report on radar instead.

mathlib-nightly-testing Bot pushed a commit to leanprover-community/batteries that referenced this pull request May 29, 2026
mathlib-nightly-testing Bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request May 29, 2026
@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan and removed builds-mathlib CI has verified that Mathlib builds against this PR labels May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants