Skip to content

Commit 2dc7a2c

Browse files
committed
wip: more robust implementation, as discussed with Floris
1 parent a5e703c commit 2dc7a2c

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Mathlib/Geometry/Manifold/Elaborators.lean

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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`,
287305
trying to determine `I` and `J` from the local context. -/
288306
elab:max "MDiff[" s:term:arg "]" t:term:arg : term => do

0 commit comments

Comments
 (0)