lean4-htt/tests/lean/run/structInstExtraEta.lean
Kyle Miller 68c006a95b
feat: transform nondependent lets into haves in declarations and equation lemmas (#8373)
This PR enables transforming nondependent `let`s into `have`s in a
number of contexts: the bodies of nonrecursive definitions, equation
lemmas, smart unfolding definitions, and types of theorems. A motivation
for this change is that when zeta reduction is disabled, `simp` can only
effectively rewrite `have` expressions (e.g. `split` uses `simp` with
zeta reduction disabled), and so we cache the nondependence calculations
by transforming `let`s to `have`s. The transformation can be disabled
using `set_option cleanup.letToHave false`.

Uses `Meta.letToHave`, introduced in #8954.
2025-06-29 19:45:45 +00:00

42 lines
609 B
Text

/-!
# Testing eta reduction for structure instances
Implemented in PR #2478 for issue #2451.
-/
set_option pp.structureInstances.flatten false
structure A where
x : Nat
structure B extends A
structure C extends B
structure D extends B
def a : A := ⟨ 0 ⟩
def b : B := { a with }
/--
info: def b : B :=
have __src := a;
{ toA := __src }
-/
#guard_msgs in #print b
def c : C := { a with }
/--
info: def c : C :=
have __src := a;
{ toB := { toA := __src } }
-/
#guard_msgs in #print c
def d : D := { c with }
/--
info: def d : D :=
have __src := c;
{ toB := __src.toB }
-/
#guard_msgs in #print d