@@ -283,6 +283,24 @@ elab:max "MDiffAt" t:term:arg : term => do
283283 return ← mkAppM ``MDifferentiableAt #[srcI, tgtI, e]
284284 | _ => throwError m! "Term { e} is not a function."
285285
286+ -- temporary copy to try a more robust implementation
287+ /-- `MDiffAt2 f x` elaborates to `MDifferentiableAt I J f x`,
288+ trying to determine `I` and `J` from the local context.
289+ The argument `x` can be omitted. -/
290+ elab :max "MDiffAt2" t:term:arg : term => do
291+ let e ← Term.elabTerm t none
292+ let etype ← inferType e >>= instantiateMVars
293+ forallBoundedTelescope etype (some 1 ) fun src tgt ↦ do
294+ if let some src := src[0 ]? then
295+ let srcI ← find_model src
296+ if Lean.Expr.occurs src tgt then
297+ throwError m! "Term { e} is a dependent function, of type { etype} \n \
298+ Note: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one"
299+ let tgtI ← find_model tgt (src, srcI)
300+ return ← mkAppM ``MDifferentiableAt #[srcI, tgtI, e]
301+ else
302+ throwError m! "Term { e} is not a function."
303+
286304/-- `MDiff[s] f` elaborates to `MDifferentiableOn I J f s`,
287305trying to determine `I` and `J` from the local context. -/
288306elab :max "MDiff[" s:term:arg "]" t:term:arg : term => do
0 commit comments