Zulip Chat Archive
Stream: mathlib4
Topic: Reference
Xavier Roblot (Mar 09 2025 at 15:46):
I am not sure I understand how bibliographic references work in Mathlib docs. For example, looking at the Function field file. Only one reference listed there actually points to the corresponding entry of the References
page. However, looking at the file references.bib
in the docs
folder, I can see that a reference with the key marcus1977number
is indeed there. (The reference to Samuel's book is incorrect though since the key should be samuel1967
). Something similar happens in this file.
So, why isn't the reference to Marcus found and how to fix that?
Kevin Buzzard (Mar 09 2025 at 16:25):
I am really quite surprised that even though mathlib has many many references https://leanprover-community.github.io/mathlib4_docs/references.html the last one alphabetically apparently starts with L. This might have something to do with it...
Ruben Van de Velde (Mar 09 2025 at 16:28):
I meant to debug this a while ago but didn't get around to it, so thanks for bringing it up!
Ruben Van de Velde (Mar 09 2025 at 16:32):
Hmm, I thought we'd see that no references after the last one in references.bib were included, but that's not it
Ruben Van de Velde (Mar 09 2025 at 16:36):
Hypothesis: something throws an exception (or similar) while processing the references, after they've been sorted by author, on the reference that comes after Lack
Xavier Roblot (Mar 09 2025 at 16:36):
That sounds like a reasonable hypothesis
Ruben Van de Velde (Mar 09 2025 at 16:40):
Can't test it right now, and the ci logs don't seem to have anything obviously wrong
Xavier Roblot (Mar 09 2025 at 16:50):
I created a LaTex file and used references.bib
and everything works fine :thinking:
Kevin Buzzard (Mar 09 2025 at 16:59):
What is the reference after Lack--Sobocinski alphabetically? Does your experiment reveal that?
Xavier Roblot (Mar 09 2025 at 17:07):
If I get it right, it's
@Book{ lam_1999,
series = {Graduate Texts in Mathematics},
title = {Lectures on Modules and Rings},
doi = {10.1007/978-1-4612-0525-8},
publisher = {Springer New York, NY},
author = {T. Y. Lam},
year = {1999}
}
Kevin Buzzard (Mar 09 2025 at 17:18):
looks fine to me :shrug:
Xavier Roblot (Mar 09 2025 at 17:19):
I came to the same conclusion.
Xavier Roblot (Mar 09 2025 at 17:20):
How is the page Reference generated from this file?
Kevin Buzzard (Mar 09 2025 at 17:30):
short answer is https://github.com/leanprover/doc-gen4 ; longer answer is "I have no idea"
Kevin Buzzard (Mar 09 2025 at 17:32):
Heh, FLT also uses doc-gen4 and in the FLT version of the mathlib function field file all three of the references are broken
Ruben Van de Velde (Mar 09 2025 at 17:58):
Maybe it's just looking for the bib file in the wrong place in that case
Jz Pan (Mar 10 2025 at 06:07):
Most probably https://github.com/dupuisf/BibtexQuery does not like the bib files in mathlib. Unfortunately the bib processing code in it does not print messages if it encounters thing it cannot process; it just silently quits.
Run lake exe bibtex-query l references.bib > output.txt
to see what entry makes it unhappy.
Jz Pan (Mar 10 2025 at 06:18):
The bug was introduced in #21688. The reason is simple: bibkey contains non-ASCII characters!
Jz Pan (Mar 10 2025 at 06:19):
bibtex-query
should really report errors on such things, instead of silently errors.
Jz Pan (Mar 10 2025 at 06:27):
Ruben Van de Velde (Mar 10 2025 at 06:57):
Can we have a comment at the top of the file to warn people as well?
Jz Pan (Mar 10 2025 at 07:10):
Ruben Van de Velde said:
Can we have a comment at the top of the file to warn people as well?
Sure.
Jz Pan (Mar 10 2025 at 07:11):
Maybe we can add scripts to https://github.com/leanprover-community/mathlib4/blob/master/scripts/lint-bib.sh to detect such things
Jz Pan (Mar 10 2025 at 07:12):
bibtool --pass.comments=on -- 'select{$key "[^-.:A-Za-z0-9_]+"}' references.bib -o out.bib
can filter entries whose key contains non-ASCII characters.
Jz Pan (Mar 10 2025 at 07:13):
There are any such entries if and only if the out.bib
is not 0 bytes
Jz Pan (Mar 10 2025 at 07:44):
the linter is at #22757
Jz Pan (Mar 10 2025 at 07:46):
Run ./scripts/lint-bib.sh
+ bibtool --pass.comments=on -- 'select{$key "[^-.:A-Za-z0-9_]+"}' docs/references.bib -o docs/non-ascii.bib
+ '[' -s docs/non-ascii.bib ']'
+ echo 'ERROR: There are items in references.bib with keys containing non-ASCII characters:'
+ echo
+ cat docs/non-ascii.bib
ERROR: There are items in references.bib with keys containing non-ASCII characters:
@Book{ hytönen_vanneerven_veraar_wies_2016,
author = {Hytönen, Tuomas and Van Neerven, Jan and Veraar, Mark and
Weis, Lutz},
title = {Analysis in Banach spaces},
series = {A Series of Modern Surveys in Mathematics},
publisher = {Springer Cham},
year = {2016},
pages = {xvii+614},
isbn = {978-3-319-48520-1},
doi = {10.1007/978-3-319-48520-1},
url = {https://doi.org/10.1007/978-3-319-48520-1}
}
+ rm docs/non-ascii.bib
+ exit 1
Error: Process completed with exit code 1.
It works
Jz Pan (Mar 10 2025 at 07:58):
The linter is at #22757 and is ready for review.
Xavier Roblot (Mar 10 2025 at 08:35):
References are now fixed! Thanks
Ruben Van de Velde (Mar 10 2025 at 08:53):
Ruben Van de Velde said:
Hypothesis: something throws an exception (or similar) while processing the references, after they've been sorted by author, on the reference that comes after Lack
(so this was wrong)
Ruben Van de Velde (Mar 10 2025 at 08:54):
Xavier Roblot said:
(The reference to Samuel's book is incorrect though since the key should be
samuel1967
).
You want to fix this, then? :)
Xavier Roblot (Mar 10 2025 at 08:56):
Ruben Van de Velde said:
Xavier Roblot said:
(The reference to Samuel's book is incorrect though since the key should be
samuel1967
).You want to fix this, then? :smile:
I'll put it on my TODO list but you're welcome to do it first :wink:
Ruben Van de Velde (Mar 10 2025 at 08:56):
Ditto :innocent:
Michael Rothgang (Mar 10 2025 at 09:39):
I just did it: #22763
Michael Rothgang (Mar 10 2025 at 09:40):
The first commit should be clearly good; the second commit (to file#Mathlib/RingTheory/Spectrum/Prime/Basic) is more speculative: I'd be glad if a domain expert could double-check.
Xavier Roblot (Mar 10 2025 at 09:45):
It looks good to me
Ruben Van de Velde (Mar 10 2025 at 10:31):
Much more comprehensive than I would have been, thanks :)
Jz Pan (Mar 10 2025 at 13:47):
I have to say that, if I remembered correctly, the syntax [samuel1967, § 3.3, Lemma 3]
is not recognized by doc-gen and will be rendered as-is.
Jz Pan (Mar 10 2025 at 13:49):
[samuel1967], § 3.3, Lemma 3
is not ideal, but at least the [samuel1967]
will be linked correctly to bibliography (with system auto-generated last name + year tag).
Ruben Van de Velde (Mar 10 2025 at 13:49):
I think you're right, I should've caught that (but it's no worse than before)
Jz Pan (Mar 10 2025 at 13:54):
Michael Rothgang said:
the second commit (to file#Mathlib/RingTheory/Spectrum/Prime/Basic) is more speculative
In order to link from docstring to the bibliography page, it's not necessary to always add a References
section to module docstring. For example, if your sole purpose is to make the following samuel1967
works, then it's enough to write a [samuel1967], § 3.3, Lemma 3
in the theorem docstring, and that's enough. Hope this clarifies.
Michael Rothgang (Mar 10 2025 at 14:08):
(I added that reference also for good measure: if a file follows a reference, we might as well say so.)
Last updated: May 02 2025 at 03:31 UTC