Skip to content

Commit b13d8d4

Browse files
Implement delaborators for non-standard topology notation
Added delaborators for unary and binary notation related to non-standard topologies in the TopologicalSpace namespace.
1 parent 29692a9 commit b13d8d4

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

Mathlib/Topology/Defs/Basic.lean

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,47 @@ scoped[Topology] notation (name := closure_of) "closure[" t "]" => @closure _ t
195195
scoped[Topology] notation (name := Continuous_of) "Continuous[" t₁ ", " t₂ "]" =>
196196
@Continuous _ _ t₁ t₂
197197

198+
namespace TopologicalSpace
199+
open Topology Lean Meta PrettyPrinter.Delaborator SubExpr
200+
201+
/-- Delaborate unary notation referring to non-standard topologies. -/
202+
def delabUnary (mkStx : Term → DelabM Term) : Delab :=
203+
withOverApp 2 <| whenPPOption Lean.getPPNotation do
204+
let α ← withNaryArg 0 getExpr
205+
let .some synthInst ← Meta.trySynthInstance (← Meta.mkAppM ``TopologicalSpace #[α]) | failure
206+
let inst ← withNaryArg 1 getExpr
207+
if ← Meta.isDefEq inst synthInst then failure
208+
let instD ← withNaryArg 1 delab
209+
mkStx instD
210+
211+
/-- Delaborate binary notation referring to non-standard topologies. -/
212+
def delabBinary (mkStx : Term → Term → DelabM Term) : Delab :=
213+
withOverApp 4 <| whenPPOption Lean.getPPNotation do
214+
let α ← withNaryArg 0 getExpr
215+
let β ← withNaryArg 1 getExpr
216+
let .some synthInstα ← Meta.trySynthInstance (← Meta.mkAppM ``TopologicalSpace #[α]) | failure
217+
let .some synthInstβ ← Meta.trySynthInstance (← Meta.mkAppM ``TopologicalSpace #[β]) | failure
218+
let instα ← withNaryArg 2 getExpr
219+
let instβ ← withNaryArg 3 getExpr
220+
if (← Meta.isDefEq instα synthInstα) ∧ (← Meta.isDefEq instβ synthInstβ) then failure
221+
let instDα ← withNaryArg 2 delab
222+
let instDβ ← withNaryArg 3 delab
223+
mkStx instDα instDβ
224+
225+
/-- Delaborator for `IsOpen[_]`. -/
226+
@[app_delab IsOpen] def delabIsOpen : Delab := delabUnary fun x ↦ `(IsOpen[$x])
227+
228+
/-- Delaborator for `IsClosed[_]`. -/
229+
@[app_delab IsClosed] def delabIsClosed : Delab := delabUnary fun x ↦ `(IsClosed[$x])
230+
231+
/-- Delaborator for `closure[_]`. -/
232+
@[app_delab closure] def delabClosure : Delab := delabUnary fun x ↦ `(closure[$x])
233+
234+
/-- Delaborator for `Continuous[_, _]`. -/
235+
@[app_delab Continuous] def delabContinuous : Delab := delabBinary fun x y ↦ `(Continuous[$x, $y])
236+
237+
end TopologicalSpace
238+
198239
/-- The property `BaireSpace α` means that the topological space `α` has the Baire property:
199240
any countable intersection of open dense subsets is dense.
200241
Formulated here when the source space is ℕ.

0 commit comments

Comments
 (0)