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.
35 lines
565 B
Text
35 lines
565 B
Text
def foo (n : Nat) : Nat :=
|
|
if n = 0 then 0 else
|
|
let x := n - 1
|
|
have := match () with | _ => trivial
|
|
foo x
|
|
termination_by n
|
|
decreasing_by sorry
|
|
|
|
theorem ex : foo 0 = 0 := by
|
|
unfold foo
|
|
sorry
|
|
|
|
/--
|
|
info: foo.eq_def (n : Nat) :
|
|
foo n =
|
|
if n = 0 then 0
|
|
else
|
|
have x := n - 1;
|
|
have this := foo._proof_4;
|
|
foo x
|
|
-/
|
|
#guard_msgs in
|
|
#check foo.eq_def
|
|
|
|
/--
|
|
info: foo.eq_unfold :
|
|
foo = fun n =>
|
|
if n = 0 then 0
|
|
else
|
|
have x := n - 1;
|
|
have this := foo._proof_4;
|
|
foo x
|
|
-/
|
|
#guard_msgs in
|
|
#check foo.eq_unfold
|