Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c08a5c0
(Git wrangling) Revert "Fix test; tweak error message"
thorimur Oct 4, 2025
5c44849
(Git wrangling) Revert "Fix"
thorimur Oct 4, 2025
66c7cdb
(Git wrangling) Revert "chore: move getUniverse to Lean/Meta/ElabTerm"
thorimur Oct 4, 2025
aa083bd
(Git wrangling) Revert "chore: move mkApp12 to a Lean"
thorimur Oct 4, 2025
e0bea74
style: remove `>>=`
thorimur Oct 1, 2025
45b0619
chore: reduce `etype` to get `.forallE`
thorimur Oct 4, 2025
76765aa
chore: `whnfR` after `instantiateMVars`
thorimur Oct 1, 2025
753bf77
chore: remove `getUniverse` in favor of `mkAppOptM`
thorimur Oct 1, 2025
54d24fa
chore: `PrettyPrinter.delab` -> `Term.exprToSyntax`
thorimur Oct 2, 2025
39195b9
chore(Elaborators): change trace class names
thorimur Oct 2, 2025
5513488
feat: move trace classes into main file; make collective trace class;…
thorimur Oct 2, 2025
bd08a3d
chore: rename `find_model` -> `findModel`, `_find_models` -> `findMod…
thorimur Oct 2, 2025
61b350b
chore: use Qq to construct `WithTop ℕ∞`
thorimur Oct 2, 2025
a0587df
refactor: factor out loops into (private) definitions for readability…
thorimur Oct 2, 2025
38b2737
chore: remove unnecessary `m!`s
thorimur Oct 2, 2025
73c361f
style: use `withLocalDeclD`
thorimur Oct 2, 2025
c5c51c5
chore: append `Elab` namespace
thorimur Oct 2, 2025
3b34391
style: fix `findModel` body indentation
thorimur Oct 2, 2025
f4a788d
chore: grammar
thorimur Oct 2, 2025
d2be1b9
style: code fencing instead of quotes in messages
thorimur Oct 2, 2025
98d4eaf
chore: typo
thorimur Oct 2, 2025
8c30410
fix: don't use `BEq` to compare expressions
thorimur Oct 2, 2025
0f85d74
fix: do not use `arg` precedence in brackets
thorimur Oct 2, 2025
d61a7ed
fix: reset `TermElabM` state in `findModel` appropriately when trying…
thorimur Oct 3, 2025
9148311
chore: use `match_expr` in `findModel`
thorimur Oct 3, 2025
542daa2
chore: use `match_expr` in `T%`
thorimur Oct 3, 2025
7208266
chore: remove `mkApp12`
thorimur Oct 3, 2025
95c9baf
style: use dot notation for `hasLooseBVars`
thorimur Oct 3, 2025
eca902d
chore: move `findSomeLocalInstanceOf?` above `T%`
thorimur Oct 3, 2025
1ed3ba2
chore: comment for `findSomeLocalInstanceOf?`
thorimur Oct 4, 2025
e6af20c
chore: use `findSomeLocalInstanceOf?` in `T%`, and explain why we don…
thorimur Oct 3, 2025
915bb32
chore: perform cheapest check first
thorimur Oct 3, 2025
a96e441
chore: use `pureIsDefEq` or explain why not
thorimur Oct 3, 2025
77f1023
chore: comment out (fixed) `MDiffAt2` and remove test
thorimur Oct 2, 2025
32bfff5
chore: use commented-out code instead of syntax re-elab
thorimur Oct 3, 2025
8fc91f3
chore: TODO comments
thorimur Oct 3, 2025
d2be66b
fix: make elaborators `scoped`, as promised
thorimur Oct 3, 2025
9d4bcbe
docs: clean up module docstring
thorimur Oct 4, 2025
3866f8a
docs: misc. style, typos, wording
thorimur Oct 4, 2025
3edd779
style(`T%`): `e.app`
thorimur Oct 4, 2025
11b39ab
style: line reflow
thorimur Oct 4, 2025
81cd4e0
fix: scope `T%` to `Manifold`
thorimur Oct 4, 2025
6bbacad
chore: refactor `findModels` to clean up elabs
thorimur Oct 3, 2025
95f24ae
style: indent second line of multiline errors
thorimur Oct 5, 2025
d56601d
chore: improve error message for trivial bundle
thorimur Oct 5, 2025
1976265
test: tracing
thorimur Oct 6, 2025
0fa0ca7
chore: affirm that this check is fine!
thorimur Oct 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3936,7 +3936,6 @@ import Mathlib.Geometry.Manifold.Riemannian.PathELength
import Mathlib.Geometry.Manifold.Sheaf.Basic
import Mathlib.Geometry.Manifold.Sheaf.LocallyRingedSpace
import Mathlib.Geometry.Manifold.Sheaf.Smooth
import Mathlib.Geometry.Manifold.Traces
import Mathlib.Geometry.Manifold.VectorBundle.Basic
import Mathlib.Geometry.Manifold.VectorBundle.FiberwiseLinear
import Mathlib.Geometry.Manifold.VectorBundle.Hom
Expand Down
602 changes: 333 additions & 269 deletions Mathlib/Geometry/Manifold/Elaborators.lean

Large diffs are not rendered by default.

25 changes: 0 additions & 25 deletions Mathlib/Geometry/Manifold/Traces.lean

This file was deleted.

11 changes: 1 addition & 10 deletions Mathlib/Lean/Elab/Term.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller
-/
import Mathlib.Init
import Lean.Elab.Term
import Lean.Elab.SyntheticMVars

/-!
# Additions to `Lean.Elab.Term`
Expand All @@ -23,13 +23,4 @@ def elabPattern (patt : Term) (expectedType? : Option Expr) : TermElabM Expr :=
synthesizeSyntheticMVars (postpone := .no) (ignoreStuckTC := true)
instantiateMVars t

open Meta

/-- Try to infer the universe of an expression `e` -/
def _root_.Lean.Expr.getUniverse (e : Expr) : TermElabM (Level) := do
if let .sort (.succ u) ← inferType e >>= instantiateMVars then
return u
else
throwError m!"Could not find universe of {e}."

end Lean.Elab.Term
4 changes: 0 additions & 4 deletions Mathlib/Lean/Expr/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,6 @@ namespace Expr

/-! ### Declarations about `Expr` -/

/-- Call `mkApp` recursively with 12 arguments -/
@[match_pattern] def _root_.mkApp12 (f a b c d e g e₁ e₂ e₃ e₄ e₅ e₆ : Expr) :=
mkApp6 (mkApp6 f a b c d e g) e₁ e₂ e₃ e₄ e₅ e₆

def bvarIdx? : Expr → Option Nat
| bvar idx => some idx
| _ => none
Expand Down
127 changes: 75 additions & 52 deletions MathlibTest/DifferentialGeometry/Elaborators.lean
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,6 @@ variable {f : M → M'} {s : Set M} {m : M}
#guard_msgs in
#check MDiffAt f

-- TODO: understand why this fails and fix it!
/--
error: Application type mismatch: The argument
a✝
has type
M
of sort `Type u_4` but is expected to have type
Type ?u.63952
of sort `Type (?u.63952 + 1)` in the application
@modelWithCornersSelf a✝
-/
#guard_msgs in
#check MDiffAt2 f

/-- info: MDifferentiableAt I I' f m : Prop -/
#guard_msgs in
#check MDiffAt f m
Expand Down Expand Up @@ -322,63 +308,63 @@ section

/--
error: Term X is a dependent function, of type (m : M) → TangentSpace I m
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check MDiff X

/--
error: Term σ is a dependent function, of type (x : M) → V x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check MDiff σ

/--
error: Term σ' is a dependent function, of type (x : E) → Trivial E E' x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check MDiff σ'

/--
error: Term σ' is a dependent function, of type (x : E) → Trivial E E' x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check MDiff[s] σ'

/--
error: Term X is a dependent function, of type (m : M) → TangentSpace I m
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check MDiffAt (X)

/--
error: Term σ is a dependent function, of type (x : M) → V x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check MDiffAt ((σ))

/--
error: Term σ' is a dependent function, of type (x : E) → Trivial E E' x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check MDiff[s] σ'

/--
error: Term σ' is a dependent function, of type (x : E) → Trivial E E' x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check MDiffAt σ'

/--
error: Term σ' is a dependent function, of type (x : E) → Trivial E E' x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check MDiffAt[s] σ'
Expand Down Expand Up @@ -418,7 +404,11 @@ of sort `Type (max u_10 u_4)` but is expected to have type
WithTop ℕ∞
of sort `Type`
---
error: Term m is not a function.
error: Expected
m
of type
M
to be a function
-/
#guard_msgs in
#check CMDiffAt[s] f m
Expand All @@ -432,7 +422,11 @@ of sort `Type (max u_10 u_4)` but is expected to have type
WithTop ℕ∞
of sort `Type`
---
error: Term m is not a function.
error: Expected
m
of type
M
to be a function
-/
#guard_msgs in
#check CMDiffAt[s] f m
Expand Down Expand Up @@ -591,63 +585,63 @@ variable (X : (m : M) → TangentSpace I m) [IsManifold I 1 M]

/--
error: Term X is a dependent function, of type (m : M) → TangentSpace I m
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check CMDiff 0 X

/--
error: Term σ is a dependent function, of type (x : M) → V x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check CMDiff 0 σ

/--
error: Term σ' is a dependent function, of type (x : E) → Trivial E E' x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check CMDiff 0 σ'

/--
error: Term σ' is a dependent function, of type (x : E) → Trivial E E' x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check CMDiff[s] 0 σ'

/--
error: Term X is a dependent function, of type (m : M) → TangentSpace I m
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check CMDiffAt 0 (X)

/--
error: Term σ is a dependent function, of type (x : M) → V x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check CMDiffAt 0 ((σ))

/--
error: Term σ' is a dependent function, of type (x : E) → Trivial E E' x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check CMDiff[s] 0 σ'

/--
error: Term σ' is a dependent function, of type (x : E) → Trivial E E' x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check CMDiffAt 0 σ'

/--
error: Term σ' is a dependent function, of type (x : E) → Trivial E E' x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check CMDiffAt[s] 0 σ'
Expand Down Expand Up @@ -844,27 +838,15 @@ info: mfderiv 𝓘(𝕜, E) 𝓘(𝕜, EM') f sorry : TangentSpace 𝓘(𝕜, E)
#guard_msgs in
#check mfderiv% f m'

-- TODO: is the old error message better?
/-
error: Application type mismatch: The argument
s'
has type
Set.{u_4} M
of sort `Type u_4` but is expected to have type
Set.{u_2} E
of sort `Type u_2` in the application
mfderivWithin 𝓘(𝕜, E) 𝓘(𝕜, EM') f s'
-/

-- Error messages: argument s has mismatched type.
/--
error: The domain E of f is not definitionally equal to the carrier of the type 'Set M' of the set 's' passed in
error: The domain E of f is not definitionally equal to the carrier type of the set s' : Set M
-/
#guard_msgs in
#check mfderiv[s'] f

/--
error: The domain E of f is not definitionally equal to the carrier of the type 'Set M' of the set 's' passed in
error: The domain E of f is not definitionally equal to the carrier type of the set s' : Set M
-/
#guard_msgs in
#check mfderiv[s'] f m
Expand All @@ -875,14 +857,14 @@ section

/--
error: Term X is a dependent function, of type (m : M) → TangentSpace I m
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check mfderiv% X x

/--
error: Term σ is a dependent function, of type (x : M) → V x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check mfderiv% σ x
Expand All @@ -891,18 +873,59 @@ variable {t : Set E} {p : E}

/--
error: Term σ' is a dependent function, of type (x : E) → Trivial E E' x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check mfderiv[t] σ' p

/--
error: Term σ' is a dependent function, of type (x : E) → Trivial E E' x
Hint: you can use the 'T%' elaborator to convert a dependent function to a non-dependent one
Hint: you can use the `T%` elaborator to convert a dependent function to a non-dependent one
-/
#guard_msgs in
#check mfderiv[t] σ'

end

end mfderiv

section trace

/- Test that basic tracing works. -/

set_option trace.Elab.DiffGeo true

variable {f : Unit → Unit}

/--
error: Could not find models with corners for Unit
---
trace: [Elab.DiffGeo.MDiff] Finding a model for: Unit
[Elab.DiffGeo.MDiff] ❌️ TotalSpace
[Elab.DiffGeo.MDiff] Failed with error:
Unit is not a `Bundle.TotalSpace`.
[Elab.DiffGeo.MDiff] ❌️ NormedSpace
[Elab.DiffGeo.MDiff] Failed with error:
Couldn't find a `NormedSpace` structure on Unit among local instances.
[Elab.DiffGeo.MDiff] ❌️ ChartedSpace
[Elab.DiffGeo.MDiff] Failed with error:
Couldn't find a `ChartedSpace` structure on Unit among local instances.
[Elab.DiffGeo.MDiff] ❌️ NormedField
[Elab.DiffGeo.MDiff] Failed with error:
failed to synthesize
NontriviallyNormedField Unit
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
-/
#guard_msgs in
#check mfderiv% f

/--
info: fun a ↦ TotalSpace.mk' Unit a (f a) : Unit → TotalSpace Unit (Trivial Unit Unit)
---
trace: [Elab.DiffGeo.TotalSpaceMk] Section of a trivial bundle as a non-dependent function
-/
#guard_msgs in
#check T% f

end trace
1 change: 0 additions & 1 deletion scripts/noshake.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"Mathlib.Data.Vector.Basic",
"Mathlib.Geometry.Manifold.Instances.Real",
"Mathlib.Geometry.Manifold.Elaborators",
"Mathlib.Geometry.Manifold.Traces",
"Mathlib.Init",
"Mathlib.LinearAlgebra.AffineSpace.Basic",
"Mathlib.LinearAlgebra.Matrix.Notation",
Expand Down
Loading