Skip to content

Commit 06f8a51

Browse files
committed
fix: (f ⊔ g) i isn't pretty-printed (leanprover-community#34670)
To see; [`Pi.sup_apply`](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Order/Lattice.html#Pi.sup_apply) This can be easily fixed by `withOverApp`. On the way, I minimized imports of the test. Co-authored-by: Komyyy <pol_tta@outlook.jp>
1 parent ef94202 commit 06f8a51

2 files changed

Lines changed: 48 additions & 20 deletions

File tree

Mathlib/Order/Notation.lean

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,27 +113,33 @@ private meta def hasLinearOrder (u : Level) (α : Q(Type u)) (cls : Q(Type u →
113113

114114
/-- Delaborate `max x y` into `x ⊔ y` if the type is not a linear order. -/
115115
@[delab app.Max.max]
116-
meta def delabSup : Delab := whenNotPPOption getPPExplicit <| whenPPOption getPPNotation do
117-
let_expr f@Max.max α inst _ _ := ← getExpr | failure
118-
have u := f.constLevels![0]!
119-
if ← hasLinearOrder u α q(Max) q($(linearOrderToMax u)) inst then
120-
failure -- use the default delaborator
121-
let x ← withNaryArg 2 delab
122-
let y ← withNaryArg 3 delab
123-
let stx ← `($x ⊔ $y)
124-
annotateGoToSyntaxDef stx
116+
meta def delabSup : Delab :=
117+
whenNotPPOption getPPExplicit <|
118+
whenPPOption getPPNotation <|
119+
withOverApp 4 do
120+
let_expr f@Max.max α inst _ _ := ← getExpr | failure
121+
have u := f.constLevels![0]!
122+
if ← hasLinearOrder u α q(Max) q($(linearOrderToMax u)) inst then
123+
failure -- use the default delaborator
124+
let x ← withNaryArg 2 delab
125+
let y ← withNaryArg 3 delab
126+
let stx ← `($x ⊔ $y)
127+
annotateGoToSyntaxDef stx
125128

126129
/-- Delaborate `min x y` into `x ⊓ y` if the type is not a linear order. -/
127130
@[delab app.Min.min]
128-
meta def delabInf : Delab := whenNotPPOption getPPExplicit <| whenPPOption getPPNotation do
129-
let_expr f@Min.min α inst _ _ := ← getExpr | failure
130-
have u := f.constLevels![0]!
131-
if ← hasLinearOrder u α q(Min) q($(linearOrderToMin u)) inst then
132-
failure -- use the default delaborator
133-
let x ← withNaryArg 2 delab
134-
let y ← withNaryArg 3 delab
135-
let stx ← `($x ⊓ $y)
136-
annotateGoToSyntaxDef stx
131+
meta def delabInf : Delab :=
132+
whenNotPPOption getPPExplicit <|
133+
whenPPOption getPPNotation <|
134+
withOverApp 4 do
135+
let_expr f@Min.min α inst _ _ := ← getExpr | failure
136+
have u := f.constLevels![0]!
137+
if ← hasLinearOrder u α q(Min) q($(linearOrderToMin u)) inst then
138+
failure -- use the default delaborator
139+
let x ← withNaryArg 2 delab
140+
let y ← withNaryArg 3 delab
141+
let stx ← `($x ⊓ $y)
142+
annotateGoToSyntaxDef stx
137143

138144
end Mathlib.Meta
139145

MathlibTest/Delab/SupInf.lean

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import Mathlib
2-
1+
module
2+
import Mathlib.Data.Real.Archimedean
33

44
/-- info: max 1 2 : ℕ -/
55
#guard_msgs in
@@ -82,3 +82,25 @@ set_option pp.explicit true in
8282
#check min (max a b) c
8383

8484
end
85+
86+
section Apply
87+
88+
variable {ι α : Type*} [Lattice α] (f g : ι → α) (i : ι)
89+
90+
/-- info: (f ⊔ g) i : α -/
91+
#guard_msgs in
92+
#check (f ⊔ g) i
93+
94+
/-- info: (f ⊔ g) i : α -/
95+
#guard_msgs in
96+
#check max f g i
97+
98+
/-- info: (f ⊓ g) i : α -/
99+
#guard_msgs in
100+
#check (f ⊓ g) i
101+
102+
/-- info: (f ⊓ g) i : α -/
103+
#guard_msgs in
104+
#check min f g i
105+
106+
end Apply

0 commit comments

Comments
 (0)