Zulip Chat Archive

Stream: mathlib4

Topic: What is a good name for theorems in mathlib?


Stepan Holub (Sep 05 2025 at 20:03):

Hello,
I have an open PR with the following theorem:

theorem name1 (w : List α) (p q : ) (per_p : HasPeriod w p) (per_q : HasPeriod w q)
    (len : p + q - p.gcd q  w.length) : HasPeriod w (p.gcd q)

It is known as the Periodicity Lemma, or as the Fine and Wilf Theorem.

I also plan to submit its generalization for more periods:

 theorem name2 (P : Finset ) (w : List ) (len: fwlength P < w.length) (periods:  p  P\{0}, HasPeriod w p) : HasPeriod w (P.gcd id)

I wanted to call the name1 periodicity_lemma, and the name2 multiperiodicity_lemma. But
@Martin Dvořák suggested name1 to be hasPeriod_gcd.

What is more suitable for mathlib? And what should be name2 then?

Robin Arnez (Sep 05 2025 at 20:47):

The convention is usually to name theorems structurally so you find them more easily.
name1 should probably even be HasPeriod.gcd so you can use hp.gcd hq hlen here.
name2 could be named hasPeriod_finsetGcd or hasPeriod_gcd_of_fwlength_lt (or, really, any contraction of hasPeriod_finsetGcd_id_of_fwlength_lt_length_of_forall_mem_sdiff_singleton_zero_hasPeriod)

Alfredo Moreira-Rosa (Sep 06 2025 at 00:51):

maybe, Finset.HasPeriod.gcd would also work for name2 ?

Aaron Liu (Sep 06 2025 at 00:58):

I suggested HasPeriod.finsetGcd

Stepan Holub (Sep 06 2025 at 04:18):

Aaron Liu said:

I suggested HasPeriod.finsetGcd

How would that work? There is no HasPeriod in assumptions, so I see no possible h.finsetGcd. Perhaps something like HasAllPeriods.finsetGcd with

def HasAllPeriods (P : Finset ) (w : List α) :=  x  P, HasPeriod w x

Jakub Nowak (Sep 06 2025 at 09:55):

So maybe hasPeriod_finsetGcd? Though, even if it cannot be used with dot syntax it can still be named HasPeriod.finsetGcd just because of analogy with HasPeriod.gcd.

Robin Arnez (Sep 06 2025 at 09:55):

I guess you could still use .finsetGcd ... though

Stepan Holub (Sep 06 2025 at 10:06):

Robin Arnez said:

I guess you could still use .finsetGcd ... though

Can you explain how?

Robin Arnez (Sep 06 2025 at 10:15):

Well there are two kinds of dot notation:

#check (3).succ
#check (.succ 3 : Nat)

The first one works based on the type of the inner expression and the second one works based on the expected type. So if you had the expected type HasPeriod x (P.gcd id), you could use .finsetGcd to refer to HasPeriod.finsetGcd

Stepan Holub (Sep 06 2025 at 10:47):

I see, like in

example (P : Finset ) (w : List ) : HasPeriod w (P.gcd id) := by
   refine .finsetGcd ?_ ?_ ?_ ?_
   ...

Although I do not see much of an advantage here.


Last updated: Dec 20 2025 at 21:32 UTC