Zulip Chat Archive
Stream: mathlib4
Topic: rename Nat.prime_def_lt'' to Nat.prime_def
Jon Eugster (Nov 19 2024 at 16:22):
While writing a little tutorial about prime numbers, I noticed particularly one theorem which seems named peculiarly:
theorem Nat.prime_def_lt'' {p : ℕ} : Nat.Prime p ↔ 2 ≤ p ∧ ∀ m, m ∣ p → m = 1 ∨ m = p
It seems to me, this should simply be Nat.prime_def
. Especially since there is no "lt" in the statement, and because the docstring of the definition says the following:
/-- `Nat.Prime p` means that `p` is a prime number, that is, a natural number
at least 2 whose only divisors are `p` and `1`. -/
def Nat.Prime (p : ℕ) :=
Irreducible p
I've created #19255. Are there good reasons for the current naming or objections against renaming it to Nat.prime_def
?
Mario Carneiro (Nov 19 2024 at 16:25):
sounds reasonable to me (without having looked at all the competitors for that name)
Daniel Weber (Nov 19 2024 at 16:26):
I agree that this name isn't good, but I feel that _def
lemmas should be literally the definition, which is Irreducible p
here. I'm not sure about an alternative name, though
Mario Carneiro (Nov 19 2024 at 16:26):
it's probably best to rename all the prime_def theorems at once, and make sure the naming scheme makes sense across the board
Mario Carneiro (Nov 19 2024 at 16:26):
(even if the conclusion is that all of them are named correctly except that one)
Daniel Weber (Nov 19 2024 at 16:27):
@loogle Iff (Nat.Prime _) _
loogle (Nov 19 2024 at 16:27):
:search: Nat.prime_iff, Nat.prime_def_minFac, and 9 more
Jon Eugster (Nov 19 2024 at 16:27):
There are a few theorems Nat.prime_def_X
, where X
is one of minFac, le_sqrt, lt
Mario Carneiro (Nov 19 2024 at 16:28):
Daniel Weber said:
I agree that this name isn't good, but I feel that
_def
lemmas should be literally the definition, which isIrreducible p
here. I'm not sure about an alternative name, though
I disagree on this. The actual definition should be the one that makes defeq work out nicely, and the thing that is called foo_def is the thing that people are most likely to guess is the definition
Ruben Van de Velde (Nov 19 2024 at 16:29):
That's probably my fault; anything is fine with me
Mario Carneiro (Nov 19 2024 at 16:30):
maintaining a strict correspondence with foo
and foo_def
is missing an opportunity to make mathlib less confusing for people (newcomers and otherwise). Plus, the thing that is literally the definition is already autogenerated as foo.def_eq
, we don't need to duplicate that
Last updated: May 02 2025 at 03:31 UTC