Skip to content

Commit d554a18

Browse files
grunwegVierkantor
andcommitted
refactor: make library notes a definition (#23767)
Make library notes a definition of `Unit` type, whose doc-string is the note's content. As a consequence, - doc-gen will display all library notes without any custom logic, - library notes are shown upon hover (via the use of the doc-string), - go to definition for library notes is easy Automate this using a macro, which also enforces that all library notes are inside the Mathlib.LibraryNote namespace. *Temporarily*, we use the `library_note2` name; if/when the batteries version is changed, we can reclaim the original name. This PR does not address how to *refer* to library notes nicely (in a way that is shown in the documentation, checked for typos, with sufficient imports ensured etc.). That is left to a future PR. This is proposal 2a from this zulip discussion: [#mathlib4 > library notes @ 💬](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/library.20notes/near/510614740) Co-authored-by: grunweg <rothgami@math.hu-berlin.de> Co-authored-by: Anne C.A. Baanen <vierkantor@vierkantor.com> Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
1 parent 14d639d commit d554a18

File tree

28 files changed

+77
-52
lines changed

28 files changed

+77
-52
lines changed

Archive/Imo/Imo2019Q2.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ as `(2 : ℤ) • ∡ _ _ _ = (2 : ℤ) • ∡ _ _ _`.
3434
-/
3535

3636

37-
library_note "IMO geometry formalization conventions"/--
37+
library_note2 «IMO geometry formalization conventions» /--
3838
We apply the following conventions for formalizing IMO geometry problems. A problem is assumed
3939
to take place in the plane unless that is clearly not intended, so it is not required to prove
4040
that the points are coplanar (whether or not that in fact follows from the other conditions).

Mathlib/Algebra/BigOperators/Group/Finset/Defs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ theorem prod_val [CommMonoid M] (s : Finset M) : s.1.prod = s.prod id := by
7575

7676
end Finset
7777

78-
library_note "operator precedence of big operators"/--
78+
library_note2 «operator precedence of big operators» /--
7979
There is no established mathematical convention
8080
for the operator precedence of big operators like `∏` and `∑`.
8181
We will have to make a choice.

Mathlib/Algebra/Category/Ring/Limits.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ the underlying types are just the limits in the category of types.
1818

1919

2020
-- We use the following trick a lot of times in this file.
21-
library_note "change elaboration strategy with `by apply`"/--
21+
library_note2 «change elaboration strategy with `by apply`» /--
2222
Some definitions may be extremely slow to elaborate, when the target type to be constructed
2323
is complicated and when the type of the term given in the definition is also complicated and does
2424
not obviously match the target type. In this case, instead of just giving the term, prefixing it

Mathlib/Algebra/Group/Action/Defs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export AddAction (add_vadd)
124124
export SMulCommClass (smul_comm)
125125
export VAddCommClass (vadd_comm)
126126

127-
library_note "bundled maps over different rings"/--
127+
library_note2 «bundled maps over different rings» /--
128128
Frequently, we find ourselves wanting to express a bilinear map `M →ₗ[R] N →ₗ[R] P` or an
129129
equivalence between maps `(M →ₗ[R] N) ≃ₗ[R] (M' →ₗ[R] N')` where the maps have an associated ring
130130
`R`. Unfortunately, using definitions like these requires that `R` satisfy `CommSemiring R`, and

Mathlib/Algebra/Group/Conj.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ theorem map_surjective {f : α →* β} (hf : Function.Surjective f) :
164164
obtain ⟨a, rfl⟩ := hf b
165165
exact ⟨ConjClasses.mk a, rfl⟩
166166

167-
library_note "slow-failing instance priority"/--
167+
library_note2 «slow-failing instance priority» /--
168168
Certain instances trigger further searches when they are considered as candidate instances;
169169
these instances should be assigned a priority lower than the default of 1000 (for example, 900).
170170

Mathlib/Algebra/Group/Defs.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Mathlib.Data.Nat.BinaryRec
1111
import Mathlib.Logic.Function.Defs
1212
import Mathlib.Tactic.MkIffOfInductiveProp
1313
import Mathlib.Tactic.OfNat
14-
import Mathlib.Tactic.Simps.Basic
14+
import Mathlib.Tactic.Basic
1515

1616
/-!
1717
# Typeclasses for (semi)groups and monoids
@@ -265,7 +265,7 @@ end CommMagma
265265
@[ext]
266266
class LeftCancelSemigroup (G : Type u) extends Semigroup G, IsLeftCancelMul G
267267

268-
library_note "lower cancel priority" /--
268+
library_note2 «lower cancel priority» /--
269269
We lower the priority of inheriting from cancellative structures.
270270
This attempts to avoid expensive checks involving bundling and unbundling with the `IsDomain` class.
271271
since `IsDomain` already depends on `Semiring`, we can synthesize that one first.
@@ -378,7 +378,7 @@ include hn ha
378378

379379
end
380380

381-
library_note "forgetful inheritance"/--
381+
library_note2 «forgetful inheritance» /--
382382
Suppose that one can put two mathematical structures on a type, a rich one `R` and a poor one
383383
`P`, and that one can deduce the poor structure from the rich structure through a map `F` (called a
384384
forgetful functor) (think `R = MetricSpace` and `P = TopologicalSpace`). A possible

Mathlib/Algebra/Group/Hom/Defs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ instance OneHom.funLike : FunLike (OneHom M N) M N where
193193
instance OneHom.oneHomClass : OneHomClass (OneHom M N) M N where
194194
map_one := OneHom.map_one'
195195

196-
library_note "hom simp lemma priority"
196+
library_note2 «hom simp lemma priority»
197197
/--
198198
The hom class hierarchy allows for a single lemma, such as `map_one`, to apply to a large variety
199199
of morphism types, so long as they have an instance of `OneHomClass`. For example, this applies to

Mathlib/Algebra/Group/Pointwise/Set/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pointwise subtraction
4949

5050
assert_not_exists Set.iUnion MulAction MonoidWithZero OrderedAddCommMonoid
5151

52-
library_note "pointwise nat action"/--
52+
library_note2 «pointwise nat action» /--
5353
Pointwise monoids (`Set`, `Finset`, `Filter`) have derived pointwise actions of the form
5454
`SMul α β → SMul α (Set β)`. When `α` is `ℕ` or `ℤ`, this action conflicts with the
5555
nat or int action coming from `Set β` being a `Monoid` or `DivInvMonoid`. For example,

Mathlib/Algebra/Group/Pointwise/Set/Scalar.lean

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,6 @@ pointwise subtraction
4949

5050
assert_not_exists Set.iUnion MulAction MonoidWithZero OrderedAddCommMonoid
5151

52-
library_note "pointwise nat action"/--
53-
Pointwise monoids (`Set`, `Finset`, `Filter`) have derived pointwise actions of the form
54-
`SMul α β → SMul α (Set β)`. When `α` is `ℕ` or `ℤ`, this action conflicts with the
55-
nat or int action coming from `Set β` being a `Monoid` or `DivInvMonoid`. For example,
56-
`2 • {a, b}` can both be `{2 • a, 2 • b}` (pointwise action, pointwise repeated addition,
57-
`Set.smulSet`) and `{a + a, a + b, b + a, b + b}` (nat or int action, repeated pointwise
58-
addition, `Set.NSMul`).
59-
60-
Because the pointwise action can easily be spelled out in such cases, we give higher priority to the
61-
nat and int actions.
62-
-/
63-
6452
open Function MulOpposite
6553

6654
variable {F α β γ : Type*}

Mathlib/Algebra/Group/Submonoid/Operations.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ variable {F : Type*} [FunLike F M N] [mc : MonoidHomClass F M N]
610610

611611
open Submonoid
612612

613-
library_note "range copy pattern"/--
613+
library_note2 «range copy pattern» /--
614614
For many categories (monoids, modules, rings, ...) the set-theoretic image of a morphism `f` is
615615
a subobject of the codomain. When this is the case, it is useful to define the range of a morphism
616616
in such a way that the underlying carrier set of the range subobject is definitionally

0 commit comments

Comments
 (0)