Skip to content

Commit 5a89224

Browse files
committed
fix: respect pp options in delaboration of max/min notation (#29312)
This fixes an issue where `⊔` and `⊓` notation did not respect `pp.explicit` and `pp.notation`. As discussed [on Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/.60pp.2Eexplicit.60.20in.20.60rw.60.20error.20message), this implements the fix suggested by @kmill.
1 parent 34de6fa commit 5a89224

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

Mathlib/Order/Notation.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private def hasLinearOrder (u : Level) (α : Q(Type u)) (cls : Q(Type u → Type
100100

101101
/-- Delaborate `max x y` into `x ⊔ y` if the type is not a linear order. -/
102102
@[delab app.Max.max]
103-
def delabSup : Delab := do
103+
def delabSup : Delab := whenNotPPOption getPPExplicit <| whenPPOption getPPNotation do
104104
let_expr f@Max.max α inst _ _ := ← getExpr | failure
105105
have u := f.constLevels![0]!
106106
if ← hasLinearOrder u α q(Max) q($(linearOrderToMax u)) inst then
@@ -112,7 +112,7 @@ def delabSup : Delab := do
112112

113113
/-- Delaborate `min x y` into `x ⊓ y` if the type is not a linear order. -/
114114
@[delab app.Min.min]
115-
def delabInf : Delab := do
115+
def delabInf : Delab := whenNotPPOption getPPExplicit <| whenPPOption getPPNotation do
116116
let_expr f@Min.min α inst _ _ := ← getExpr | failure
117117
have u := f.constLevels![0]!
118118
if ← hasLinearOrder u α q(Min) q($(linearOrderToMin u)) inst then

MathlibTest/Delab/SupInf.lean

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import Mathlib
1313
#guard_msgs in
1414
#check (max (min (max (max {0} {1}) (max {2} {3})) (max {4} {5})) (min (min {6} {7}) (min {8} {9})) : Set ℕ)
1515

16-
1716
section
1817

1918
variable {α : Type*} (a b : α)
@@ -62,3 +61,24 @@ info: fun α [ConditionallyCompleteLinearOrder α] a b =>
6261
-/
6362
#guard_msgs in
6463
#check fun (α : Type u) [ConditionallyCompleteLinearOrder α] (a b : α) => max a b
64+
65+
-- In this section we check that the delaborator respects the options `pp.explicit` and `pp.notation`.
66+
section
67+
68+
variable [Min α] [Max α] (a b c : α)
69+
70+
/-- info: (a ⊔ b) ⊓ c : α -/
71+
#guard_msgs in
72+
#check min (max a b) c
73+
74+
set_option pp.notation false in
75+
/-- info: min (max a b) c : α -/
76+
#guard_msgs in
77+
#check min (max a b) c
78+
79+
set_option pp.explicit true in
80+
/-- info: @min α inst✝¹ (@max α inst✝ a b) c : α -/
81+
#guard_msgs in
82+
#check min (max a b) c
83+
84+
end

0 commit comments

Comments
 (0)