Skip to content

Commit

Permalink
fix: add missing withOverApps (#12022)
Browse files Browse the repository at this point in the history
This fixes the delaborators for sums, products, infimums, and supremums of pi types and matrices.

Also adds a missing `whenPPOption getPPNotation` to `Prefunctor.obj`.

[Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/delaborator.20for.20Finset.2Esun.20does.20not.20trigger/near/432068318).
  • Loading branch information
eric-wieser authored and uniwuni committed Apr 19, 2024
1 parent 3e175bb commit 078d254
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions Mathlib/Algebra/BigOperators/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ open Std.ExtendedBinder

/-- Delaborator for `Finset.prod`. The `pp.piBinderTypes` option controls whether
to show the domain type when the product is over `Finset.univ`. -/
@[scoped delab app.Finset.prod] def delabFinsetProd : Delab := whenPPOption getPPNotation do
@[scoped delab app.Finset.prod] def delabFinsetProd : Delab :=
whenPPOption getPPNotation <| withOverApp 5 <| do
let #[_, _, _, s, f] := (← getExpr).getAppArgs | failure
guard <| f.isLambda
let ppDomain ← getPPOption getPPPiBinderTypes
Expand All @@ -146,7 +147,8 @@ to show the domain type when the product is over `Finset.univ`. -/

/-- Delaborator for `Finset.prod`. The `pp.piBinderTypes` option controls whether
to show the domain type when the sum is over `Finset.univ`. -/
@[scoped delab app.Finset.sum] def delabFinsetSum : Delab := whenPPOption getPPNotation do
@[scoped delab app.Finset.sum] def delabFinsetSum : Delab :=
whenPPOption getPPNotation <| withOverApp 5 <| do
let #[_, _, _, s, f] := (← getExpr).getAppArgs | failure
guard <| f.isLambda
let ppDomain ← getPPOption getPPPiBinderTypes
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/CategoryTheory/Closed/Cartesian.lean
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ notation:20 A " ⟹ " B:19 => (exp A).obj B
open Lean PrettyPrinter.Delaborator SubExpr in
/-- Delaborator for `Prefunctor.obj` -/
@[delab app.Prefunctor.obj]
def delabPrefunctorObjExp : Delab := do
def delabPrefunctorObjExp : Delab := whenPPOption getPPNotation <| withOverApp 6 <| do
let e ← getExpr
guard <| e.isAppOfArity' ``Prefunctor.obj 6
let A ← withNaryArg 4 do
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/CategoryTheory/Monoidal/Category.lean
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ scoped notation "𝟙_ " C:max => (MonoidalCategoryStruct.tensorUnit : C)
open Lean PrettyPrinter.Delaborator SubExpr in
/-- Used to ensure that `𝟙_` notation is used, as the ascription makes this not automatic. -/
@[delab app.CategoryTheory.MonoidalCategoryStruct.tensorUnit]
def delabTensorUnit : Delab := whenPPOption getPPNotation do
def delabTensorUnit : Delab := whenPPOption getPPNotation <| withOverApp 3 do
let e ← getExpr
guard <| e.isAppOfArity ``MonoidalCategoryStruct.tensorUnit 3
let C ← withNaryArg 0 delab
Expand Down
1 change: 1 addition & 0 deletions Mathlib/LinearAlgebra/Matrix/PosDef.lean
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ open Lean PrettyPrinter.Delaborator SubExpr in
def delabSqrt : Delab :=
whenPPOption getPPNotation <|
whenNotPPOption getPPAnalysisSkip <|
withOverApp 7 <|
withOptionAtCurrPos `pp.analysis.skip true do
let e ← getExpr
guard <| e.isAppOfArity ``Matrix.PosSemidef.sqrt 7
Expand Down
5 changes: 2 additions & 3 deletions Mathlib/Order/SetNotation.lean
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ open Lean Lean.PrettyPrinter.Delaborator

/-- Delaborator for indexed supremum. -/
@[delab app.iSup]
def iSup_delab : Delab := whenPPOption Lean.getPPNotation do
def iSup_delab : Delab := whenPPOption Lean.getPPNotation <| withOverApp 4 do
let #[_, ι, _, f] := (← SubExpr.getExpr).getAppArgs | failure
unless f.isLambda do failure
let prop ← Meta.isProp ι
Expand Down Expand Up @@ -129,7 +129,7 @@ def iSup_delab : Delab := whenPPOption Lean.getPPNotation do

/-- Delaborator for indexed infimum. -/
@[delab app.iInf]
def iInf_delab : Delab := whenPPOption Lean.getPPNotation do
def iInf_delab : Delab := whenPPOption Lean.getPPNotation <| withOverApp 4 do
let #[_, ι, _, f] := (← SubExpr.getExpr).getAppArgs | failure
unless f.isLambda do failure
let prop ← Meta.isProp ι
Expand Down Expand Up @@ -299,4 +299,3 @@ theorem iSup_eq_iUnion (s : ι → Set α) : iSup s = iUnion s :=
theorem iInf_eq_iInter (s : ι → Set α) : iInf s = iInter s :=
rfl
#align set.infi_eq_Inter Set.iInf_eq_iInter

0 comments on commit 078d254

Please sign in to comment.