Skip to content

chore: use terminology "non-recursive structure" instead of "struct-like"#12749

Merged
kmill merged 1 commit intomasterfrom
kmill_nonrecstruct_5891
Mar 9, 2026
Merged

chore: use terminology "non-recursive structure" instead of "struct-like"#12749
kmill merged 1 commit intomasterfrom
kmill_nonrecstruct_5891

Conversation

@kmill
Copy link
Copy Markdown
Collaborator

@kmill kmill commented Mar 1, 2026

This PR changes "structure-like" terminology to "non-recursive structure" across internal documentation, error messages, the metaprogramming API, and the kernel, to clarify Lean's type theory. A structure is a one-constructor inductive type with no indices — these can be created by either the structure or inductive commands — and are supported by the primitive Expr.proj projections. Only non-recursive structures have an eta conversion rule. The PR description contains the APIs that were renamed.

Addresses RFC #5891, which proposed this rename. The change is motivated by the need to distinguish between structure-defined structures, structures, and non-recursive structures. Especially since #5783, which enabled the structure command to define recursive structures, "structure-like" has been easy to misunderstand.

Changes:

  • Kernel: is_structure_like() -> is_non_rec_structure()
  • Lean.isStructureLike -> Lean.isNonRecStructure
  • Lean.matchConstStructLike -> Lean.matchConstNonRecStructure
  • Lean.getStructureLikeCtor? -> Lean.getNonRecStructureCtor?
  • Lean.getStructureLikeNumFields -> Lean.getNonRecStructureNumFields
  • Lean.Expr.proj: extended and corrected documentation (note: despite the fact that not every projection can be written as a recursor application, I left in this claim since it seems good to document a more-restrictive specification, and some users have requested the kernel be more restrictive in this way)

Closes #5891

…ke".

This PR addresses RFC #5891, changing occurrences of "structure-like" to "non-recursive structure" in documentation, the metaprogramming API, and the kernel; there are no functional changes. (Recall: A *structure* is a one-constructor inductive type with no indices. One-constructor inductive types can make use of `Expr.proj` projections, even if they have indices or are recursive. Non-recursive structures have an eta rule.)

Changes:
- Kernel: `is_structure_like()` -> `is_non_rec_structure()`
- `Lean.Expr.proj`, extended and corrected documentation (note: despite the fact that not every projection can be written as a recursor application, I left in this claim since it seems good to document a more-restrictive specification, and some users have requested the kernel be more restrictive)
- `Lean.isStructureLike` -> `Lean.isNonRecStructure`
- `Lean.matchConstStructLike` -> `Lean.matchConstNonRecStructure`
- `Lean.getStructureLikeCtor?` -> `Lean.getNonRecStructureCtor?`
- `Lean.getStructureLikeNumFields` -> `Lean.getNonRecStructureNumFields`

Closes #5891
@kmill kmill requested a review from leodemoura as a code owner March 1, 2026 18:43
@kmill kmill added the changelog-language Language features and metaprograms label Mar 1, 2026
@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 Mar 1, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase ec565f3bf7a3985b6b8592f5cb5fa063b86a0ecf --onto 87ec768a509c45987a7d73258da0cc1ef047925c. You can force Mathlib CI using the force-mathlib-ci label. (2026-03-01 19:31:08)

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase ec565f3bf7a3985b6b8592f5cb5fa063b86a0ecf --onto 8038a8b8904f89ad9542c8eda11379f8f006eab1. You can force reference manual CI using the force-manual-ci label. (2026-03-01 19:31:09)

@Rob23oba
Copy link
Copy Markdown
Contributor

Rob23oba commented Mar 1, 2026

Terminology question: Is Exists a non-recursive structure? At least the function says yes but Exists doesn't have an eta rule. For my project that meant adding a new function, isStructureLikeWithLargeElim, that does a better job at figuring these things out.

@kmill
Copy link
Copy Markdown
Collaborator Author

kmill commented Mar 1, 2026

@Rob23oba Yes, Exists is a non-recursive structure. The eta rule applies for non-recursive structures, if the projections all exist, but they don't exist for Exists since it doesn't have large elimination.

@kmill kmill changed the title feat: use terminology "non-recursive structure" instead of "struct-like" chore: use terminology "non-recursive structure" instead of "struct-like" Mar 9, 2026
@kmill kmill added this pull request to the merge queue Mar 9, 2026
Merged via the queue into master with commit d8accf4 Mar 9, 2026
31 checks passed
sgraf812 pushed a commit that referenced this pull request Mar 9, 2026
…ike" (#12749)

This PR changes "structure-like" terminology to "non-recursive
structure" across internal documentation, error messages, the
metaprogramming API, and the kernel, to clarify Lean's type theory. A
*structure* is a one-constructor inductive type with no indices — these
can be created by either the `structure` or `inductive` commands — and
are supported by the primitive `Expr.proj` projections. Only
*non-recursive* structures have an eta conversion rule. The PR
description contains the APIs that were renamed.

Addresses RFC #5891, which proposed this rename. The change is motivated
by the need to distinguish between `structure`-defined structures,
structures, and non-recursive structures. Especially since #5783, which
enabled the `structure` command to define recursive structures,
"structure-like" has been easy to misunderstand.

Changes:
- Kernel: `is_structure_like()` -> `is_non_rec_structure()`
- `Lean.isStructureLike` -> `Lean.isNonRecStructure`
- `Lean.matchConstStructLike` -> `Lean.matchConstNonRecStructure`
- `Lean.getStructureLikeCtor?` -> `Lean.getNonRecStructureCtor?`
- `Lean.getStructureLikeNumFields` -> `Lean.getNonRecStructureNumFields`
- `Lean.Expr.proj`: extended and corrected documentation (note: despite
the fact that not every projection can be written as a recursor
application, I left in this claim since it seems good to document a
more-restrictive specification, and some users have requested the kernel
be more restrictive in this way)

Closes #5891
kim-em added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Mar 10, 2026
Adapts to leanprover/lean4#12749

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-language Language features and metaprograms 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.

RFC: rename "structure-like" to "non-rec structure"

3 participants