Lean4
/-- For terms that match the `CoeSort` instance's body, pretty print as `↥S`
rather than as `{ x // x ∈ S }`. The discriminating feature is that membership
uses the `SetLike.instMembership` instance. -/
@[app_delab Subtype]
def delabSubtypeSetLike : Delab :=
whenPPOption getPPNotation do
let #[_, .lam n _ body _] := (← getExpr).getAppArgs |
failure
guard <| body.isAppOf ``Membership.mem
let #[_, _, inst, _, .bvar 0] := body.getAppArgs |
failure
guard <| inst.isAppOfArity ``instMembership 3
let S ← withAppArg <| withBindingBody n <| withNaryArg 3 delab
`(↥$S)