On the period mod $m$ of polynomially-recursive sequences: a case study
Cyril Banderier, Florian Luca

TL;DR
This paper investigates the periodic behavior modulo m of second order polynomially-recursive sequences, linking number theory concepts and providing generalized supercongruences for these sequences.
Contribution
It introduces new results on the period mod m of polynomially-recursive sequences and extends supercongruences to a broader class of recurrences.
Findings
Analysis of period mod m for second order sequences
Connection with number theory concepts like Carmichael function and Wieferich primes
Generalization of supercongruences to broader recurrence classes
Abstract
Polynomially-recursive sequences generally have a periodic behavior mod . In this paper, we analyze the period mod of a second order polynomially-recursive sequence. The problem originally comes from an enumeration of avoiding pattern permutations and appears to be linked with nice number theory notions (the Carmichael function, Wieferich primes, algebraic integers). We give the mod supercongruences, and generalize these results to a class of recurrences.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAlgorithms and Data Compression · Advanced Combinatorial Mathematics · semigroups and automata theory
On the period mod of
polynomially-recursive sequences: a case study
Cyril Banderier1 https://lipn.fr/~banderierhttps://orcid.org/0000-0003-0755-3022
Florian Luca2,3,4 https://scholar.google.com/https://orcid.org/0000-0001-8581-449X
(March 5, 2019)
Abstract
Polynomially-recursive sequences generally have a periodic behavior mod . In this paper, we analyze the period mod of a second order polynomially-recursive sequence. The problem originally comes from an enumeration of avoiding pattern permutations and appears to be linked with nice number theory notions (the Carmichael function, Wieferich primes, algebraic integers). We give the mod supercongruences, and generalize these results to a class of recurrences.
Keywords and phrases. D-finite function, Modular properties, P-recursive sequence, supercongruence, Carmichael function, Wieferich primes.
2010 Mathematics Subject Classification. 11B39, 11B50, 11B85, 05A15.
1: LIPN (UMR CNRS 7030), Université Paris Nord, France.
2: School of Mathematics, University of the Witwatersrand, South Africa.
3: King Abdulaziz University, Jeddah, Saudi Arabia.
4: Department of Mathematics, University of Ostrava, Czech Republic.
1 Introduction
In his analysis of sorting algorithms, Knuth introduced the notion of forbidden pattern in permutations, which later became a field of interest per se [10]. By studying the basis of such forbidden patterns for permutations reachable with right-jumps from the identity permutation, the authors of [1] discovered that the permutations of size in this basis were enumerated by the sequence of integers given by ,
[TABLE]
This is sequence A265165 in the OEIS111On-Line Encyclopedia of Integer Sequences, https://oeis.org., it starts like 0, 1, 2, 7, 32, 179, 1182, 8993, 77440, 744425, 7901410, 91774375…
Such a sequence satisfying a recurrence with polynomial coefficients in is called P-recursive (for polynomially recursive), D-finite, or holonomic, depending on the authors (see e.g. [13, 5, 7, 11]). P-recursive sequences are ubiquitous in combinatorics, number theory, analysis of algorithms, computer algebra, etc. It is always the case that the corresponding generating function satisfies a linear differential equation, but it is not always the case that it has a closed form. The generating function of has in fact a nice closed form involving the golden ratio. Indeed, putting
[TABLE]
for the two roots of the quadratic equation , it was shown in [1] that the exponential generating function of the , namely
[TABLE]
This is a noteworthy sequence in analytic combinatorics (see [5] for a nice presentation of this field), as it is one of the rare sequences exhibiting an irrational exponent in its asymptotics:
[TABLE]
where is the Euler gamma function.
There is a vast literature in number theory analyzing the modular congruences of famous sequences (Pascal triangle, Fibonacci, Catalan, Motzkin, Apéry numbers, see [6, 3, 14, 12, 8]). The properties of are sometimes called “supercongruences” when is the power of a prime number: many articles consider , or . We now restate an important result which holds for any (not necessarily the power of a prime number).
Theorem 1** (Supercongruences for D-finite functions, Theorem 7 of [1]).**
Consider any P-recurrence of order :
[TABLE]
where the polynomials belong to , and where the polynomial is ultimately invertible (i.e., for all large enough). Then the sequence is eventually periodic222In the sequel, we will omit the word “eventually”: a periodic sequence of period is thus a sequence for which for all large enough . Some authors use the terminology “ultimately periodic” instead. . In particular, recurrences such that are periodic . Additionally, the period is always bounded by , therefore there is an algorithm to compute it.
N.B.: It is not always the case that P-recursive sequences are periodic mod . E.g., it was proven in [9] that Motzkin numbers are not periodic mod , and it seems that
[TABLE]
is also not periodic mod , for any (this P-recursive sequence counts a famous class of permutations, namely, the Baxter permutations). This is coherent with Theorem 1, as the leading term in the recurrence (the factor ) is not invertible mod , for infinitely many .
For our sequence (defined by recurrence (1)), this theorem explains the periodic behavior of . By brute-force computation, we can get , for any given . For example is periodic of period :
[TABLE]
The period can be quite large, for example has period . More generally, for every positive integer , the sequence is eventually periodic: there exist and such that, for all , one has . We write for the smallest such period. In this paper, we study some of the properties of .
This is sequence A306699 in the OEIS, here are its first values :
2, 12, 8, 1, 12, 84, 8, 36, 2, 1, 24, 104, 84, 12, 16, 544, 36, 1, 8, 84, 2, 1012, 24, 1, 104, 108, 168, 1, 12, 1, 32, 12, 544, 84, 72, 2664, 2, 312, 8, 1, 84, 3612, 8, 36, 1012, 4324, 48, 588, 2, 1632, 104, 5512, 108, 1, 168, 12, 2, 1, 24, 1, 2, 252, 64, 104, 12, 2948, 544, 3036, 84, 1, 72, 10512, 2664, 12, 8, 84, 312, 1, 16, 324, 2, 13612, 168, 544, 3612, 12, 8, 1, 36, 2184, 2024, 12, 4324, 1, 96, 18624, 588, 36, 8.
Do you detect the hidden patterns in this sequence? This is what we tackle in the next section.
2 Periodicity mod , supercongruences and links with number theory
Our main result is the following.
Theorem 2**.**
Let be the sequence defined by the recurrence of Formula 1. The period of this sequence mod satisfies:
- a)
If (where are distinct primes), then333As usual, lcm stands for the least common multiple.**
[TABLE]
- b)
We have if and only if is the product of primes .
- c)
For every prime , we have (and thus ).
- d)
If then is even (and a multiple of 4 if is prime).
- e)
For , we have if and only if is even and is the product of primes .
- f)
For any prime not , we have .
The function thus shares some similarities with the Carmichael function introduced in [2, p. 39], and it is expected that its asymptotic behavior is also similar (following e.g. the lines of [4]). In this article, we focus on the rich arithmetic properties of this function. Note that it allows to compute in a much faster way than the brute-force algorithm mentioned in Section 1: the complexity goes from via brute-force to e.g. via Shor’s algorithm (or some other sub-exponential complexity in with other efficient algorithms).
Proof of Part a). The proof will use a little preliminary result and the following definition. We call the “eventual period of the sequence mod ”, or for short with a slight abuse of terminology, the “period of the sequence mod ” (even if the sequence starts with some terms which does not satisfy the periodic pattern). The following lemma holds for all eventually periodic sequences of integers.
Lemma 1**.**
* divides all other periods of modulo .*
Proof.
Let and assume there is (not a multiple of ) which is also a period modulo . Thus, there are such that for all and for all . Let . By Bézout’s identity, one has then for some integers . Let and assume that . Then so is a period of modulo , contradicting the minimality of . ∎
An immediate consequence is the following444We use the notation for the least common multiple of integers .:
Corollary 1**.**
We have .
Proof.
First consider , and let , . Since is a multiple of both and , it follows that it is a period of modulo both and , so modulo . It remains to prove that it is the minimal one. To this aim, suppose that . Then either or . Since the two cases are similar, we only deal with the first one. In this case we would have that both and would be periods modulo . By the previous lemma, this would force , which would obviously be a contradiction. Now, a trivial induction on the number gives that
[TABLE]
holds for all positive integers . ∎
In particular Part a) of Theorem 2 holds: . Let us now tackle the proofs of Parts b)–f).
Proof of Part b). We use the generating function (2), which tells us that
[TABLE]
Thus,
[TABLE]
By Fermat’s little theorem,
[TABLE]
Assume now that . Then
[TABLE]
where for the last congruence we used the law of quadratic reciprocity: since , we have
[TABLE]
where is the Legendre symbol. Thus,
[TABLE]
because by Euler’s criterion.
In the above and in what follows, for two algebraic integers and an integer we write if the number is an algebraic integer. This shows that
[TABLE]
is an algebraic integer. The same is true with replaced by . Now take be any integer and take . Then, for each , we have that both
[TABLE]
are algebraic integers. Thus, if , then
[TABLE]
is an algebraic integer. Thus, is an algebraic integer and a rational number, so an integer. Since , it follows that , so for . This shows that for all such primes and positive integers . The same is true for . There we use that , so . Thus, if , we have that
[TABLE]
which in turn is a multiple of in . Thus, if , then . This shows that also and in fact, for all if is made up only of primes . This finishes the proof of b).
Proof of Part c). The claim is satisfied for , as , thus . Now consider . Evaluating Formula (5) at , one has
[TABLE]
Since , the argument from (6) shows that . Thus
[TABLE]
The same is true for replaced by . Thus, it follows that for , we have
[TABLE]
Applying this times, we get
[TABLE]
Taking and applying Fermat’s little theorem , we get . In fact, taking , where is the order of modulo (the smallest such that ) gives the slightly stronger claim: .
Proof of Part d). There are more things to learn from the above argument. We first prove by contradiction the second claim of d): , for a prime such that . Assume , where is the exponent of in the factorization of . That is, is either odd or times an odd number. Since , it follows that if we write , where is odd, then . Thus,
[TABLE]
for all . Since is not a quadratic residue, it follows that (since ). So, the above congruence (7) implies that but , so for all large . Take and and rewrite the information that in as
[TABLE]
We treat this as a linear system in the two unknowns
[TABLE]
in the field with elements . This is homogeneous. None of or is [math] since cannot divide . Thus, it must be that the determinant of the above matrix is [math] modulo , but this is
[TABLE]
which is invertible modulo . Thus, indeed, it is not possible that and is a multiple of for all large , getting a contradiction. This shows that is a multiple of .
Proof of Part e) (and first claim in Part d). Now let which is not like in b), i.e. one has at least one prime such that . Then by what we have done above, and so by a). Thus, such cannot participate in the situations described either at d) or e). Further, one has as . Thus, if , then . Hence, if , then the only possibility is that and is a product of primes congruent to modulo . Conversely, if has such structure then by a) and the fact that and for all odd prime power factors of . This ends the proof of e) and d).
Proof of Part f). Finally, f) is based on a slight generalization of (5) namely
[TABLE]
valid for all odd primes and . Let us prove (8). We first prove it for . We return to (5) and write
[TABLE]
where . Changing to for , we get that
[TABLE]
In the above, we used the fact that . Thus,
[TABLE]
In the above, we used the fact that is odd so is a multiple of . This proves (8) for . Assuming and that (8) holds for , we get that for all , we have
[TABLE]
where . Thus,
[TABLE]
which is what we wanted. Letting be congruent to , we and evaluating the above in and using that , we get easily that
[TABLE]
This shows that
[TABLE]
The same is true for leading to
[TABLE]
Thus, applying this times we get
[TABLE]
Taking and applying Euler’s theorem , we get that . Thus, . As in c), we can replace by and the divisibility holds.
Finally, it remains to prove f) for . Here, by inspection, we have
[TABLE]
By induction on , one shows that
[TABLE]
Evaluating this in , we get
[TABLE]
The same holds for , so
[TABLE]
showing that for all .
3 Comments and generalizations
Along the proof of our main result we showed that if , then
[TABLE]
From here we deduced that via the fact that . One may ask whether it can be the case that for some prime . Well, first of all, we will need that . This makes a base Wieferich prime. There is a conjecture that there are infinitely many such primes. The smallest known which is also congruent to is . However, the condition of condition of being base Wieferich is not sufficient. A close analysis of our arguments show that in addition to this condition, it should also hold that
[TABLE]
and if this is the case then indeed . Since the integer in should be the zero element in the finite field , with elements, it could be that the “probability” that this condition happens is . By the same logic, the “probability” that is base Wieferich should be . Assuming these events to be independent, we could infer that the probability that both these conditions hold is and the series
[TABLE]
is convergent, which seems to suggest, heuristically, that there should be only finitely many primes such that .
Finally, our results apply to other sequences as well. More precisely, let be integers and let be the roots of . Let
[TABLE]
The sequence satisfies , , and, for
[TABLE]
In case and are rational (hence, integers), is a rational function, so , where is binary recurrent with constant coefficients. It then follows that for all provided is sufficiently large. Thus, . In case are irrational, then a similar result holds as for the case when . Namely, for all sufficiently large whenever is the product of odd primes for which , where is the discriminant of the quadratic . In case is odd and , we have that and is a multiple of . Also, for all in this case. The proofs are similar. In the case of the prime one needs to distinguish cases according to the parities of . For example, if and are odd, then , so is not a quadratic residue modulo , so for all , whereas if is odd and is even then . This concludes our analysis of the periodicity of such P-recursive sequences .
Acknowledgments: This work was initiated when the second author was invited professor at the Paris Nord University, in April 2018. In addition, Florian Luca was supported in part by grant CPRR160325161141 and an A-rated scientist award both from the NRF of South Africa and by grant no. 17-02804S of the Czech Granting Agency.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] Cyril Banderier, Jean-Luc Baril, and Céline Moreira Dos Santos. Right-jumps and pattern avoiding permutations . Discrete Mathematics & Theoretical Computer Science , 18(2):1–17, 2017.
- 2[2] Robert D. Carmichael. The theory of numbers . John Wiley & Sons, 1914. (Gutenberg project pdf version).
- 3[3] Emeric Deutsch and Bruce E. Sagan. Congruences for Catalan and Motzkin numbers and related sequences . J. Number Theory , 117(1):191–215, 2006.
- 4[4] Paul Erdős, Carl Pomerance, and Eric Schmutz. Carmichael’s lambda function . Acta Arith. , 58(4):363–385, 1991.
- 5[5] Philippe Flajolet and Robert Sedgewick. Analytic combinatorics . Cambridge University Press, 2009.
- 6[6] Ira M. Gessel. Combinatorial proofs of congruences . In Enumeration and design (Waterloo, Ont., 1982) , pages 157–197. Academic Press, Toronto, ON, 1984.
- 7[7] Ira M. Gessel. Symmetric functions and P-recursiveness . J. Combin. Theory Ser. A , 53(2):257–285, 1990. · doi ↗
- 8[8] Manuel Kauers, Christian Krattenthaler, and Thomas W. Müller. A method for determining the mod - 2 k mod - superscript 2 𝑘 {\rm mod}\text{-}2^{k} behaviour of recursive sequences, with applications to subgroup counting . Electron. J. Combin. , 18(2):Paper 37, 83p., 2011.
