Skip to content

Commit e220b87

Browse files
committed
chore: move to Geometry.Manifold.Notation and use
1 parent 346ae70 commit e220b87

1 file changed

Lines changed: 87 additions & 12 deletions

File tree

Mathlib/Geometry/Manifold/Notation.lean

Lines changed: 87 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -807,20 +807,45 @@ def findModels (e : Expr) (es : Option Expr) : TermElabM (Expr × Expr) := do
807807

808808
end Elab
809809

810+
-- TODO: is there a better location for this?
811+
open Doc in
812+
/-- Writing `{insertDocstringOf foo}` inside a verso doc-string inserts the doc-string of
813+
declaration `foo` (if there is one) in the current environment, as a separate paragraph.
814+
-/
815+
@[doc_command] meta def _root_.insertDocstringOf (n : Ident) :
816+
DocM <| Block ElabInline ElabBlock := do
817+
let doc ← realizeGlobalConstNoOverloadWithInfo n
818+
let some docStr ← findDocString? (← getEnv) doc
819+
| throwError "No doc-string for `{.ofConstName doc}`"
820+
-- Future: once there is a better auto-converter between markdown and verso doc-strings,
821+
-- rewrite this code accordingly!
822+
-- Perhaps, it could be nice to write .verso here.
823+
return .para #[.text docStr]
824+
810825
open Elab
811826

827+
set_option doc.verso true in
828+
set_option doc.verso.suggestions false in
812829
/-- `MDiffAt[s] f x` elaborates to `MDifferentiableWithinAt I J f s x`,
813830
trying to determine `I` and `J` from the local context.
814-
The argument `x` can be omitted. -/
831+
The argument `x` can be omitted.
832+
833+
{insertDocstringOf MDifferentiableWithinAt}
834+
-/
815835
scoped elab:max "MDiffAt[" s:term "]" ppSpace f:term:arg : term => do
816836
let es ← Term.elabTerm s none
817837
let ef ← ensureIsFunction <| ← Term.elabTerm f none
818838
let (srcI, tgtI) ← findModels ef es
819839
mkAppM ``MDifferentiableWithinAt #[srcI, tgtI, ef, es]
820840

841+
set_option doc.verso true in
842+
set_option doc.verso.suggestions false in
821843
/-- `MDiffAt f x` elaborates to `MDifferentiableAt I J f x`,
822844
trying to determine `I` and `J` from the local context.
823-
The argument `x` can be omitted. -/
845+
The argument `x` can be omitted.
846+
847+
{insertDocstringOf MDifferentiableAt}
848+
-/
824849
scoped elab:max "MDiffAt" ppSpace t:term:arg : term => do
825850
let e ← ensureIsFunction <| ← Term.elabTerm t none
826851
let (srcI, tgtI) ← findModels e none
@@ -845,16 +870,26 @@ scoped elab:max "MDiffAt" ppSpace t:term:arg : term => do
845870
-- else
846871
-- throwErrorAt t "Expected{indentD e}\nof type{indentD etype}\nto be a function"
847872

873+
set_option doc.verso true in
874+
set_option doc.verso.suggestions false in
848875
/-- `MDiff[s] f` elaborates to `MDifferentiableOn I J f s`,
849-
trying to determine `I` and `J` from the local context. -/
876+
trying to determine `I` and `J` from the local context.
877+
878+
{insertDocstringOf MDifferentiableOn}
879+
-/
850880
scoped elab:max "MDiff[" s:term "]" ppSpace t:term:arg : term => do
851881
let es ← Term.elabTerm s none
852882
let et ← ensureIsFunction <| ← Term.elabTerm t none
853883
let (srcI, tgtI) ← findModels et es
854884
mkAppM ``MDifferentiableOn #[srcI, tgtI, et, es]
855885

886+
set_option doc.verso true in
887+
set_option doc.verso.suggestions false in
856888
/-- `MDiff f` elaborates to `MDifferentiable I J f`,
857-
trying to determine `I` and `J` from the local context. -/
889+
trying to determine `I` and `J` from the local context.
890+
891+
{insertDocstringOf MDifferentiable}
892+
-/
858893
scoped elab:max "MDiff" ppSpace t:term:arg : term => do
859894
let e ← ensureIsFunction <| ← Term.elabTerm t none
860895
let (srcI, tgtI) ← findModels e none
@@ -865,63 +900,98 @@ scoped elab:max "MDiff" ppSpace t:term:arg : term => do
865900
-- TODO: provide better error messages if just `n` is forgotten (say, by making `n` optional in
866901
-- the parser and erroring later in the elaborator); currently, this yields just a parser error.
867902

903+
set_option doc.verso true in
904+
set_option doc.verso.suggestions false in
868905
/-- `CMDiffAt[s] n f x` elaborates to `ContMDiffWithinAt I J n f s x`,
869906
trying to determine `I` and `J` from the local context.
870907
`n` is coerced to `WithTop ℕ∞` if necessary (so passing a `ℕ`, `∞` or `ω` are all supported).
871-
The argument `x` can be omitted. -/
908+
The argument `x` can be omitted.
909+
910+
{insertDocstringOf ContMDiffWithinAt}
911+
-/
872912
scoped elab:max "CMDiffAt[" s:term "]" ppSpace nt:term:arg ppSpace f:term:arg : term => do
873913
let es ← Term.elabTerm s none
874914
let ne ← Term.elabTermEnsuringType nt q(WithTop ℕ∞)
875915
let ef ← ensureIsFunction <| ← Term.elabTerm f none
876916
let (srcI, tgtI) ← findModels ef es
877917
mkAppM ``ContMDiffWithinAt #[srcI, tgtI, ne, ef, es]
878918

919+
set_option doc.verso true in
920+
set_option doc.verso.suggestions false in
879921
/-- `CMDiffAt n f x` elaborates to `ContMDiffAt I J n f x`
880922
trying to determine `I` and `J` from the local context.
881923
`n` is coerced to `WithTop ℕ∞` if necessary (so passing a `ℕ`, `∞` or `ω` are all supported).
882-
The argument `x` can be omitted. -/
924+
The argument `x` can be omitted.
925+
926+
{insertDocstringOf ContMDiffAt}
927+
-/
883928
scoped elab:max "CMDiffAt" ppSpace nt:term:arg ppSpace t:term:arg : term => do
884929
let e ← ensureIsFunction <| ← Term.elabTerm t none
885930
let ne ← Term.elabTermEnsuringType nt q(WithTop ℕ∞)
886931
let (srcI, tgtI) ← findModels e none
887932
mkAppM ``ContMDiffAt #[srcI, tgtI, ne, e]
888933

934+
set_option doc.verso true in
935+
set_option doc.verso.suggestions false in
889936
/-- `CMDiff[s] n f` elaborates to `ContMDiffOn I J n f s`,
890937
trying to determine `I` and `J` from the local context.
891-
`n` is coerced to `WithTop ℕ∞` if necessary (so passing a `ℕ`, `∞` or `ω` are all supported). -/
938+
`n` is coerced to `WithTop ℕ∞` if necessary (so passing a `ℕ`, `∞` or `ω` are all supported).
939+
940+
{insertDocstringOf ContMDiffOn}
941+
-/
892942
scoped elab:max "CMDiff[" s:term "]" ppSpace nt:term:arg ppSpace f:term:arg : term => do
893943
let es ← Term.elabTerm s none
894944
let ne ← Term.elabTermEnsuringType nt q(WithTop ℕ∞)
895945
let ef ← ensureIsFunction <| ← Term.elabTerm f none
896946
let (srcI, tgtI) ← findModels ef es
897947
mkAppM ``ContMDiffOn #[srcI, tgtI, ne, ef, es]
898948

949+
set_option doc.verso true in
950+
set_option doc.verso.suggestions false in
899951
/-- `CMDiff n f` elaborates to `ContMDiff I J n f`,
900952
trying to determine `I` and `J` from the local context.
901-
`n` is coerced to `WithTop ℕ∞` if necessary (so passing a `ℕ`, `∞` or `ω` are all supported). -/
953+
`n` is coerced to `WithTop ℕ∞` if necessary (so passing a `ℕ`, `∞` or `ω` are all supported).
954+
955+
{insertDocstringOf ContMDiff}
956+
-/
902957
scoped elab:max "CMDiff" ppSpace nt:term:arg ppSpace f:term:arg : term => do
903958
let ne ← Term.elabTermEnsuringType nt q(WithTop ℕ∞)
904959
let e ← ensureIsFunction <| ← Term.elabTerm f none
905960
let (srcI, tgtI) ← findModels e none
906961
mkAppM ``ContMDiff #[srcI, tgtI, ne, e]
907962

963+
set_option doc.verso true in
964+
set_option doc.verso.suggestions false in
908965
/-- `mfderiv[u] f x` elaborates to `mfderivWithin I J f u x`,
909-
trying to determine `I` and `J` from the local context. -/
966+
trying to determine `I` and `J` from the local context.
967+
968+
{insertDocstringOf mfderivWithin}
969+
-/
910970
scoped elab:max "mfderiv[" s:term "]" ppSpace t:term:arg : term => do
911971
let es ← Term.elabTerm s none
912972
let e ← ensureIsFunction <| ← Term.elabTerm t none
913973
let (srcI, tgtI) ← findModels e es
914974
mkAppM ``mfderivWithin #[srcI, tgtI, e, es]
915975

976+
set_option doc.verso true in
977+
set_option doc.verso.suggestions false in
916978
/-- `mfderiv% f x` elaborates to `mfderiv I J f x`,
917-
trying to determine `I` and `J` from the local context. -/
979+
trying to determine `I` and `J` from the local context.
980+
981+
{insertDocstringOf mfderiv}
982+
-/
918983
scoped elab:max "mfderiv%" ppSpace t:term:arg : term => do
919984
let e ← ensureIsFunction <| ← Term.elabTerm t none
920985
let (srcI, tgtI) ← findModels e none
921986
mkAppM ``mfderiv #[srcI, tgtI, e]
922987

988+
set_option doc.verso true in
989+
set_option doc.verso.suggestions false in
923990
/-- `HasMFDerivAt[s] f x f'` elaborates to `HasMFDerivWithinAt I J f s x f'`,
924-
trying to determine `I` and `J` from the local context. -/
991+
trying to determine `I` and `J` from the local context.
992+
993+
{insertDocstringOf HasMFDerivWithinAt}
994+
-/
925995
scoped elab:max "HasMFDerivAt[" s:term "]" ppSpace
926996
f:term:arg ppSpace x:term:arg ppSpace f':term:arg : term => do
927997
let es ← Term.elabTerm s none
@@ -931,8 +1001,13 @@ scoped elab:max "HasMFDerivAt[" s:term "]" ppSpace
9311001
let (srcI, tgtI) ← findModels ef es
9321002
mkAppM ``HasMFDerivWithinAt #[srcI, tgtI, ef, es, ex, ef']
9331003

1004+
set_option doc.verso true in
1005+
set_option doc.verso.suggestions false in
9341006
/-- `HasMFDerivAt% f x f'` elaborates to `HasMFDerivAt I J f x f'`,
935-
trying to determine `I` and `J` from the local context. -/
1007+
trying to determine `I` and `J` from the local context.
1008+
1009+
{insertDocstringOf HasMFDerivAt}
1010+
-/
9361011
scoped elab:max "HasMFDerivAt%" ppSpace
9371012
f:term:arg ppSpace x:term:arg ppSpace f':term:arg : term => do
9381013
let ef ← ensureIsFunction <|← Term.elabTerm f none

0 commit comments

Comments
 (0)