Skip to content

feat: feature flags for inductive declarations - #16595

Open
arthur-adjedj wants to merge 28 commits into
leanprover:masterfrom
arthur-adjedj:indData
Open

arthur-adjedj wants to merge 28 commits into
leanprover:masterfrom
arthur-adjedj:indData

Conversation

@arthur-adjedj

@arthur-adjedj arthur-adjedj commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds various flags to inductive declarations, as defined in #14977.
The PR also changes the following:

@arthur-adjedj
arthur-adjedj force-pushed the indData branch 2 times, most recently from 18fd39e to 0899b42 Compare November 19, 2026 14:05
@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 Nov 19, 2026
@arthur-adjedj

Copy link
Copy Markdown
Contributor Author

downstream

@downstream-lean4 downstream-lean4 Bot added the downstream Request a downstream-lean4 adaptation PR. label Nov 20, 2026
@arthur-adjedj

Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar

leanprover-radar commented Nov 21, 2026 •

Copy link
Copy Markdown

Benchmark results for 01161fb against 8009d0a are in. There are significant results. @arthur-adjedj

  • 🟥 build//instructions: +4.8G (+0.05%)

Large changes (1✅, 4🟥)

  • 🟥 compiled/async/http_h1_client//instructions: +626.7k (+0.01%)
  • ✅ compiled/async/http_h1_server//instructions: -274.4k (-0.00%)
  • 🟥 elab/bitvec_zero_counts//instructions: +368.3M (+1.86%)
  • 🟥 elab/grind_field_kernel_cancel//instructions: +817.3M (+2.47%)
  • 🟥 elab/trailingZeros//instructions: +435.4M (+1.72%)

Medium changes (5🟥)

  • 🟥 elab/grind_ring_5//instructions: +7.2M (+0.63%)
  • 🟥 elab/irDeclLookup//instructions: +100.1M (+8.07%)
  • 🟥 elab/reduceMatch//instructions: +52.0M (+0.63%)
  • 🟥 elab/whnfMatcherImplicitTransparencyCaching//instructions: +29.5M (+0.48%)
  • 🟥 vcgen/MatchesJP/40/kernel//wall-clock: +9ms (+12.75%)

Small changes (21✅, 50🟥)

  • 🟥 elab/big_match_lits//instructions: +308.3M (+0.12%)
  • 🟥 elab/big_struct_dep//instructions: +11.3M (+0.13%)
  • 🟥 elab/bv_stress_structures_1//instructions: +46.5M (+0.43%)
  • 🟥 elab/bv_stress_structures_2//instructions: +63.5M (+0.50%)
  • 🟥 elab/cbv_leroy//instructions: +87.1M (+0.26%)
  • 🟥 elab/grind_bitvec2//instructions: +233.8M (+0.22%)
  • 🟥 elab/lia_case_splits//instructions: +144.7M (+0.74%)
  • 🟥 elab/realizations//instructions: +1.1G (+0.32%)
  • 🟥 elab/simp_arith1//instructions: +3.6M (+0.32%)
  • 🟥 elab/string_simp_ne//instructions: +7.6M (+0.31%)
  • 🟥 elab/sym_arith_expand//instructions: +2.2M (+0.17%)
  • 🟥 misc/import Init.Data.BitVec.Lemmas//instructions: +217.4M (+0.27%)
  • 🟥 misc/leanchecker --fresh Init//instructions: +689.3M (+0.27%)
  • 🟥 vcgen/MatchesJP/40/vcgen//wall-clock: +8ms (+10.13%)
  • and 57 hidden

@arthur-adjedj

Copy link
Copy Markdown
Contributor Author

downstream

@arthur-adjedj

Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar

leanprover-radar commented Nov 21, 2026 •

Copy link
Copy Markdown

Benchmark results for b35dde6 against 8009d0a are in. There are significant results. @arthur-adjedj

  • 🟥 build//instructions: +4.4G (+0.05%)

Large changes (30✅, 5🟥)

  • 🟥 compiled/async/http_h1_client//instructions: +629.8k (+0.01%)
  • ✅ compiled/async/http_h1_server//instructions: -271.4k (-0.00%)
  • ✅ elab/big_beq//maxrss: -120MiB (-6.83%)
  • ✅ elab/big_beq_rec//maxrss: -120MiB (-6.78%)
  • ✅ elab/big_deceq//maxrss: -120MiB (-6.87%)
  • ✅ elab/big_deceq_rec//maxrss: -120MiB (-6.85%)
  • ✅ elab/big_match//maxrss: -121MiB (-6.77%)
  • ✅ elab/big_match_nat//maxrss: -117MiB (-6.72%)
  • ✅ elab/big_match_nat_split//maxrss: -122MiB (-6.92%)
  • ✅ elab/big_match_partial//maxrss: -119MiB (-6.67%)
  • 🟥 elab/bitvec_zero_counts//instructions: +368.8M (+1.86%)
  • ✅ elab/bv_decide_incremental//maxrss: -121MiB (-6.03%)
  • ✅ elab/cbv_decide//maxrss: -125MiB (-6.81%)
  • ✅ elab/cbv_divisors//maxrss: -118MiB (-6.77%)
  • ✅ elab/cbv_merge_sort//maxrss: -121MiB (-6.66%)
  • ✅ elab/delayed_assign//maxrss: -117MiB (-6.71%)
  • ✅ elab/delayed_lift//maxrss: -121MiB (-6.87%)
  • ✅ elab/delayed_sharing//maxrss: -120MiB (-6.90%)
  • ✅ elab/deriving_mutual_block//maxrss: -118MiB (-6.06%)
  • 🟥 elab/grind_field_kernel_cancel//instructions: +806.7M (+2.44%)
  • and 15 more

Medium changes (20✅, 6🟥)

  • 🟥 compiled/nat_repr//task-clock: +139ms (+11.57%)
  • 🟥 compiled/nat_repr//wall-clock: +139ms (+11.48%)
  • ✅ elab/big_match_lits//maxrss: -119MiB (-5.92%)
  • ✅ elab/big_match_string//maxrss: -116MiB (-6.30%)
  • ✅ elab/bitvec_zero_counts//maxrss: -34MiB (-3.67%)
  • ✅ elab/cbv_system_f//maxrss: -116MiB (-5.05%)
  • ✅ elab/do_nested_match_bind//maxrss: -125MiB (-6.86%)
  • ✅ elab/grind_cases_next//maxrss: -117MiB (-6.40%)
  • 🟥 elab/grind_ring_5//instructions: +7.1M (+0.62%)
  • ✅ elab/inferTypeCache//maxrss: -29MiB (-3.21%)
  • 🟥 elab/irDeclLookup//instructions: +100.2M (+8.07%)
  • ✅ elab/irDeclLookup//maxrss: -32MiB (-3.53%)
  • ✅ elab/many_commands//maxrss: -120MiB (-2.75%)
  • ✅ elab/many_opens//maxrss: -119MiB (-6.77%)
  • ✅ elab/matcherInferTypeCache//maxrss: -31MiB (-3.29%)
  • ✅ elab/realizations//maxrss: -126MiB (-3.13%)
  • 🟥 elab/reduceMatch//instructions: +47.1M (+0.57%)
  • ✅ elab/string_simp_ne//maxrss: -122MiB (-6.97%)
  • ✅ elab/sym_arith_norm//maxrss: -118MiB (-6.73%)
  • ✅ elab/sym_let_to_have_closed_body//maxrss: -115MiB (-5.27%)
  • and 6 more

Small changes (37✅, 48🟥)

  • ✅ compiled/async/http_h1_incremental//instructions: -20.5k (-0.00%)
  • 🟥 elab/big_match_lits//instructions: +347.6M (+0.14%)
  • 🟥 elab/big_struct_dep//instructions: +13.5M (+0.15%)
  • ✅ elab/bv_decide_rewriter//maxrss: -22MiB (-3.72%)
  • ✅ elab/bv_epr_veil_paxos_first_order_join_round_one_b_max_vote_properties2//maxrss: -23MiB (-4.16%)
  • ✅ elab/bv_epr_veil_reliable_broadcast_net_byz_send_echo_vote_sent//maxrss: -25MiB (-4.73%)
  • ✅ elab/bv_epr_veil_ring_dec_recv_single_leader//maxrss: -23MiB (-4.21%)
  • ✅ elab/bv_epr_veil_suzuki_kasami_rcv_privilege_unique_tokens//maxrss: -22MiB (-4.23%)
  • ✅ elab/bv_normalize_cast//maxrss: -21MiB (-4.28%)
  • 🟥 elab/bv_stress_structures_1//instructions: +48.0M (+0.44%)
  • 🟥 elab/bv_stress_structures_2//instructions: +68.7M (+0.54%)
  • ✅ elab/cbv_leroy//maxrss: -100MiB (-5.26%)
  • ✅ elab/charactersIn//maxrss: -23MiB (-2.42%)
  • 🟥 elab/grind_bitvec2//instructions: +239.9M (+0.22%)
  • ✅ elab/grind_field_kernel_cancel//maxrss: -35MiB (-3.58%)
  • 🟥 elab/grind_field_kernel_cancel//task-clock: +94ms (+3.35%)
  • 🟥 elab/grind_field_kernel_cancel//wall-clock: +92ms (+3.27%)
  • 🟥 elab/let_to_have_closed_body//wall-clock: +17ms (+5.63%)
  • 🟥 elab/lia_case_splits//instructions: +157.2M (+0.81%)
  • ✅ elab/list_literal_nat//maxrss: -137MiB (-3.55%)
  • and 12 more
  • and 53 hidden

@arthur-adjedj
arthur-adjedj marked this pull request as ready for review November 22, 2026 01:45
@arthur-adjedj

Copy link
Copy Markdown
Contributor Author

changelog-language

@github-actions github-actions Bot added the changelog-language Language features and metaprograms label Nov 22, 2026
@arthur-adjedj

Copy link
Copy Markdown
Contributor Author

ci-release

@nomeata nomeata added the release-ci Enable all CI checks for a PR, like is done for releases label Nov 22, 2026
nomeata and others added 7 commits November 22, 2026 21:59
Conflict resolutions:
* Init/WF.lean, Init/WFComputable.lean: take nightly's `Acc.ndrec` (Prop motive) / `Acc.ndrec'` naming, dropping this branch's rename.
* Lean/Meta/WHNF.lean: `isMajorProof` keeps the `isImpredicative` shortcut and uses nightly's universe check against the first type of the mutual block.
* kernel/inductive.cpp: keep the flag-based `check_large_elim` (it already rules out large elimination of recursive Prop types); run the flag checks before nightly's reordered `check_constructors`/`declare_inductive_types`.
* tests/elab/16648.lean, tests/elab/16649.lean: add the new `InductiveType` flags; tests/elab/accRecPrime.lean: take nightly's version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This reads the inductive feature flags in the export format.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This reads the inductive feature flags in the export format.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This builds on Windows again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
arthur-adjedj and others added 9 commits November 23, 2026 23:24
Inductive types now carry the feature flags and no longer `isReflexive`, and recursors of types without large elimination have no rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WD3k8hwfVBznY9FEMvR4xw
con-leche and con-ron accept exports without `isReflexive`; nanoda and lean4lean additionally accept `Quot` in `Sort (max 1 u)`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WD3k8hwfVBznY9FEMvR4xw
Conflict resolutions:
* Lean/Meta/WHNF.lean: `reduceRec` is public (master) and keeps the early exits for recursors without rules or large elimination.
* kernel/type_checker.cpp, Lean/Meta/ExprDefEq.lean: the recursor eta-expansion of leanprover#15374 tests structure eta with `has_eta`/`hasEta`, as the rest of the branch does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WD3k8hwfVBznY9FEMvR4xw
With the inductive flags, a `Prop` inductive large-eliminates only if it is structure-like or K-like, and reducing such a recursor does not unfold the major premise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WD3k8hwfVBznY9FEMvR4xw
Conflict resolutions:
* Lean/Replay.lean: keep leanprover#16717's validated `InductiveVal`s and pass their feature flags to the kernel.
* tests/elab/issue16698.lean: the forged `InductiveVal`s carry the feature flags instead of `isReflexive`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WD3k8hwfVBznY9FEMvR4xw
downstream-green is green again on nightly-2026-11-25 (downstream-lean4 run 45801655564).

Conflict resolutions:
* kernel/inductive.cpp: keep leanprover#16742's order (check the nested applications before adding the constructors) and pass the inductive feature flags to `inductive_val`.
* tests/elab/16736.lean: the inductive type carries the feature flags.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@downstream-lean4

Copy link
Copy Markdown

The adaptation PR for this PR is leanprover/downstream-lean4#287.

This branch has not been deployed

No deployments
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 downstream Request a downstream-lean4 adaptation PR. release-ci Enable all CI checks for a PR, like is done for releases 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