Skip to content

Commit 2f324b4

Browse files
committed
chore: add exception for Data.Set.Subset to noshake.json. (#14196)
We add `Data.Set.Subset` to the set of files ignored by the shake linter, which gives a false positive when this file is just imported for the notation.
1 parent 2d9a177 commit 2f324b4

File tree

6 files changed

+61
-43
lines changed

6 files changed

+61
-43
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,6 +2329,7 @@ import Mathlib.Data.Set.List
23292329
import Mathlib.Data.Set.MemPartition
23302330
import Mathlib.Data.Set.MulAntidiagonal
23312331
import Mathlib.Data.Set.NAry
2332+
import Mathlib.Data.Set.Notation
23322333
import Mathlib.Data.Set.Opposite
23332334
import Mathlib.Data.Set.Pairwise.Basic
23342335
import Mathlib.Data.Set.Pairwise.Lattice

Mathlib/Data/Matroid/Map.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Peter Nelson
55
-/
66
import Mathlib.Data.Matroid.Constructions
7-
import Mathlib.Data.Set.Subset
7+
import Mathlib.Data.Set.Notation
88

99
/-!
1010
# Maps between matroids

Mathlib/Data/Set/Functor.lean

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Authors: Leonardo de Moura
66
import Mathlib.Data.Set.Lattice
77
import Mathlib.Init.Set
88
import Mathlib.Control.Basic
9-
import Mathlib.Lean.Expr.ExtraRecognizers
9+
import Mathlib.Data.Set.Notation
1010

1111
#align_import data.set.functor from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432"
1212

@@ -18,7 +18,7 @@ This file defines the functor structure of `Set`.
1818

1919
universe u
2020

21-
open Function
21+
open Function Set.Notation
2222

2323
namespace Set
2424

@@ -106,32 +106,11 @@ theorem image_coe_eq_restrict_image {δ : Type*} {f : α → δ} : f '' γ = β.
106106
end with_instance
107107

108108
/-! ### Coercion applying functoriality for `Subtype.val`
109-
110109
The `Monad` instance gives a coercion using the internal function `Lean.Internal.coeM`.
111-
In practice this is only used for applying the `Set` functor to `Subtype.val`.
112-
We define this coercion here. -/
113-
114-
/-- Coercion using `(Subtype.val '' ·)` -/
115-
instance : CoeHead (Set s) (Set α) := ⟨fun t => (Subtype.val '' t)⟩
116-
117-
namespace Notation
118-
119-
open Lean PrettyPrinter Delaborator SubExpr in
120-
/--
121-
If the `Set.Notation` namespace is open, sets of a subtype coerced to the ambient type are
122-
represented with `↑`.
123-
-/
124-
@[scoped delab app.Set.image]
125-
def delab_set_image_subtype : Delab := whenPPOption getPPCoercions do
126-
let #[α, _, f, _] := (← getExpr).getAppArgs | failure
127-
guard <| f.isAppOfArity ``Subtype.val 2
128-
let some _ := α.coeTypeSet? | failure
129-
let e ← withAppArg delab
130-
`(↑$e)
131-
132-
end Notation
110+
In practice this is only used for applying the `Set` functor to `Subtype.val`,
111+
as was defined in `Data.Set.Notation`. -/
133112

134-
/-- The coercion from `Set.monad` as an instance is equal to the coercion defined above. -/
113+
/-- The coercion from `Set.monad` as an instance is equal to the coercion in `Data.Set.Notation`. -/
135114
theorem coe_eq_image_val (t : Set s) :
136115
@Lean.Internal.coeM Set s α _ Set.monad t = (t : Set α) := by
137116
change ⋃ (x ∈ t), {x.1} = _

Mathlib/Data/Set/Notation.lean

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/-
2+
Copyright (c) 2024 Peter Nelson. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Peter Nelson
5+
-/
6+
import Mathlib.Mathport.Notation
7+
import Mathlib.Lean.Expr.ExtraRecognizers
8+
9+
/-!
10+
# Set Notation
11+
12+
This file defines two pieces of scoped notation related to sets and subtypes.
13+
14+
The first is a coercion; for each `α : Type*` and `s : Set α`, `(↑) : Set s → Set α`
15+
is the function coercing `t : Set s` into a set in the ambient type; i.e. `↑t = Subtype.val '' t`.
16+
17+
The second, for `s t : Set α`, is the notation `s ↓∩ t`, which denotes the intersection
18+
of `s` and `t` as a set in `Set s`.
19+
20+
These notations are developed further in `Data.Set.Functor` and `Data.Set.Subset` respectively.
21+
They are defined here separately so that this file can be added as an exception to the shake linter
22+
and can thus be imported without a linting false positive when only the notation is desired.
23+
-/
24+
25+
namespace Set.Notation
26+
/--
27+
Given two sets `A` and `B`, `A ↓∩ B` denotes the intersection of `A` and `B` as a set in `Set A`.
28+
29+
The notation is short for `((↑) ⁻¹' B : Set A)`, while giving hints to the elaborator
30+
that both `A` and `B` are terms of `Set α` for the same `α`.
31+
This set is the same as `{x : ↑A | ↑x ∈ B}`.
32+
-/
33+
scoped notation3 A:67 " ↓∩ " B:67 => (Subtype.val ⁻¹' (B : type_of% A) : Set (A : Set _))
34+
35+
/-- Coercion using `(Subtype.val '' ·)` -/
36+
instance {α : Type*} {s : Set α} : CoeHead (Set s) (Set α) := ⟨fun t => (Subtype.val '' t)⟩
37+
38+
open Lean PrettyPrinter Delaborator SubExpr in
39+
/--
40+
If the `Set.Notation` namespace is open, sets of a subtype coerced to the ambient type are
41+
represented with `↑`.
42+
-/
43+
@[scoped delab app.Set.image]
44+
def delab_set_image_subtype : Delab := whenPPOption getPPCoercions do
45+
let #[α, _, f, _] := (← getExpr).getAppArgs | failure
46+
guard <| f.isAppOfArity ``Subtype.val 2
47+
let some _ := α.coeTypeSet? | failure
48+
let e ← withAppArg delab
49+
`(↑$e)
50+
51+
end Set.Notation

Mathlib/Data/Set/Subset.lean

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Let `α` be a `Type`, `A B : Set α` two sets in `α`, and `C : Set A` a set in
2323
- `A ↓∩ B` denotes `(Subtype.val ⁻¹' B : Set A)` (that is, `{x : ↑A | ↑x ∈ B}`).
2424
- `↑C` denotes `Subtype.val '' C` (that is, `{x : α | ∃ y ∈ C, ↑y = x}`).
2525
26-
This notation, (together with the `↑` notation for `Set.CoeHead` in `Mathlib.Data.Set.Functor`)
27-
is scoped to the `Set.Notation` namespace.
26+
This notation, (together with the `↑` notation for `Set.CoeHead`)
27+
is defined in `Mathlib.Data.Set.Notation` and is scoped to the `Set.Notation` namespace.
2828
To enable it, use `open Set.Notation`.
2929
3030
@@ -42,19 +42,6 @@ open Set
4242
variable {ι : Sort*} {α : Type*} {A B C : Set α} {D E : Set A}
4343
variable {S : Set (Set α)} {T : Set (Set A)} {s : ι → Set α} {t : ι → Set A}
4444

45-
namespace Set.Notation
46-
47-
/--
48-
Given two sets `A` and `B`, `A ↓∩ B` denotes the intersection of `A` and `B` as a set in `Set A`.
49-
50-
The notation is short for `((↑) ⁻¹' B : Set A)`, while giving hints to the elaborator
51-
that both `A` and `B` are terms of `Set α` for the same `α`.
52-
This set is the same as `{x : ↑A | ↑x ∈ B}`.
53-
-/
54-
scoped notation3 A:67 " ↓∩ " B:67 => (Subtype.val ⁻¹' (B : type_of% A) : Set (A : Set _))
55-
56-
end Set.Notation
57-
5845
namespace Set
5946

6047
open Notation

scripts/noshake.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"Mathlib.Data.Matrix.Notation",
4343
"Mathlib.Data.Matroid.Init",
4444
"Mathlib.Data.Rat.Init",
45+
"Mathlib.Data.Set.Notation",
4546
"Mathlib.Data.Sym.Sym2.Init",
4647
"Mathlib.Data.Vector.Basic",
4748
"Mathlib.Geometry.Manifold.Instances.Real",
@@ -309,7 +310,6 @@
309310
"Mathlib.Data.Seq.Parallel": ["Mathlib.Init.Data.Prod"],
310311
"Mathlib.Data.Ordmap.Ordnode": ["Mathlib.Data.Option.Basic"],
311312
"Mathlib.Data.Multiset.Bind": ["Mathlib.GroupTheory.GroupAction.Defs"],
312-
"Mathlib.Data.Matroid.Map": ["Mathlib.Data.Set.Subset"],
313313
"Mathlib.Data.List.TFAE": ["Batteries.Tactic.Classical"],
314314
"Mathlib.Data.List.ProdSigma": ["Mathlib.Data.List.Basic"],
315315
"Mathlib.Data.List.Lemmas": ["Mathlib.Data.List.InsertNth"],

0 commit comments

Comments
 (0)