File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,11 @@ initialize registerBuiltinAttribute {
4646 let r ← Push.pullCore .lambda type none
4747 if r.expr == type then
4848 throwError "`@[to_fun]` failed to eta-expand any part of `{.ofConstName src}`."
49- return (← r.mkCast value, levels)
49+ -- Ensure that the returned `value` has type `r.expr`.
50+ let value ← match r.proof? with
51+ | none => mkExpectedTypeHint value r.expr
52+ | some proof => mkAppOptM ``cast #[type, r.expr, proof, value]
53+ return (value, levels)
5054 | _ => throwUnsupportedSyntax }
5155
5256end Mathlib.Tactic
Original file line number Diff line number Diff line change @@ -24,3 +24,17 @@ Look I am the doc-string of `foo`.
2424run_meta
2525 let some doc ← findDocString? (← getEnv) ``fun_foo | throwError "no docstring found"
2626 logInfo doc
27+
28+
29+ -- Test that it also works when the generated proof is not a `rfl` proof:
30+
31+ @ [to_additive (attr := push ← high)]
32+ lemma Pi.mul_def' {ι : Type *} {M : ι → Type *} [∀ i, Mul (M i)] (f g : ∀ i, M i) :
33+ f * g = fun i ↦ f i * g i := (rfl)
34+
35+ @[to_fun]
36+ theorem Function.mul_comm' (f g : ℝ → ℝ) : f * g = g * f := _root_.mul_comm f g
37+
38+ /-- info: Function.fun_mul_comm' (f g : ℝ → ℝ) : (fun i => f i * g i) = fun i => g i * f i -/
39+ #guard_msgs in
40+ #check Function.fun_mul_comm'
You can’t perform that action at this time.
0 commit comments