lean4-htt/src
Joachim Breitner 2f8c85af89
fix: ensure etaStruct is enabled during type inference (#12507)
This PR fixes #12495 where equational theorem generation fails for
structurally recursive definitions using a Box-like wrapper around
nested inductives.

## Root Cause

`withInferTypeConfig` (in `InferType.lean`) ensures various MetaM config
settings (`beta`, `iota`, `zeta`, `zetaHave`, `zetaDelta`, `proj`) are
enabled during type inference, but was missing `etaStruct`. When
`inferType` is called from a context where `etaStruct` is disabled —
such as inside `simpMatch` (which sets `etaStruct := .none` via
`SimpM.run` → `withSimpContext`) — `whnf` cannot eta-expand structure
values needed for recursor iota reduction.

Concretely, projecting from a type like `Rec.rec_2 ... base` (where
`base : Box Rec`) requires eta-expanding `base` to `Box.mk base.data` so
the `Box` recursor can reduce. With `etaStruct := .none`,
`toCtorWhenStructure` skips the eta-expansion, leaving `whnf` stuck and
`inferProjType` unable to recognize the resulting type as a structure.

## Fix

Add `etaStruct := .all` to the config settings ensured by
`withInferTypeConfig`, alongside the existing `beta`, `iota`, `zeta`,
`zetaHave`, `zetaDelta`, and `proj` settings. This also allows reverting
the workaround (`try/catch` around `simpMatch?`) that was added in the
first commit.

## Test plan

- [x] Existing test `tests/lean/run/issue12495.lean` passes
- [x] Full test suite (3561 tests) passes with 0 failures

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 20:27:57 +00:00
..
bin
cmake chore: reformat all cmake files (#12218) 2026-01-28 18:23:08 +00:00
include/lean chore: delete commented code (#12498) 2026-02-16 10:27:46 +00:00
Init feat: backward.isDefEq.respectTransparency (#12179) 2026-02-16 15:57:21 +00:00
initialize feat: zero cost BaseIO (#10625) 2025-10-22 10:55:12 +02:00
kernel perf: cache unfold_definition in the kernel (#12259) 2026-01-31 03:44:50 +00:00
lake fix: type class resolution cache (#12286) 2026-02-15 03:07:15 +00:00
Lean fix: ensure etaStruct is enabled during type inference (#12507) 2026-02-16 20:27:57 +00:00
LeanChecker feat: re-integrate lean4checker as leanchecker (#11887) 2026-01-08 09:41:33 +00:00
library refactor: don't use shared_timed_mutex when not required anymore (#12434) 2026-02-11 12:53:42 +00:00
runtime fix: handle 0 sized reads from handles correctly (#12466) 2026-02-13 10:56:00 +00:00
shell chore: move test suite setup to tests/CMakeLists.txt (#12278) 2026-02-03 13:22:20 +00:00
Std chore: cleanup backwards compat annotations in the LRAT checker (#12511) 2026-02-16 20:23:27 +00:00
util chore: update to c++20 (#12117) 2026-02-11 01:17:40 +00:00
cadical.mk
CMakeLists.txt chore: update to c++20 (#12117) 2026-02-11 01:17:40 +00:00
config.h.in
githash.h.in
Init.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
lakefile.toml.in feat: re-integrate lean4checker as leanchecker (#11887) 2026-01-08 09:41:33 +00:00
lean-toolchain
Lean.lean refactor: move getOriginalConstKind? into its own module to avoid future import cycle (#12265) 2026-02-01 16:18:51 +00:00
lean.mk.in chore: further split libleanshared on Windows to avoid symbol limit (#10136) 2025-08-26 16:01:57 +00:00
Leanc.lean fix: Unicode path support for Lean Windows executables (#10133) 2025-08-27 11:28:55 +00:00
LeanChecker.lean feat: re-integrate lean4checker as leanchecker (#11887) 2026-01-08 09:41:33 +00:00
out feat: ac normalization in grind (#10146) 2025-08-27 03:28:30 +00:00
Std.lean chore: more module system fixes and refinements for finishing batteries port (#10819) 2025-10-21 08:19:50 +00:00
stdlib.make.in feat: re-integrate lean4checker as leanchecker (#11887) 2026-01-08 09:41:33 +00:00
stdlib_flags.h Revert "chore: temporarily disable proofs for bootstrap" 2026-02-05 13:41:34 +11:00
version.h.in