On p/q-recognisable sets

Let p/q be a rational number. Numeration in base p/q is defined by a function that evaluates each finite word over A_p={0,1,...,p-1} to some rational number. We let N_p/q denote the image of this evaluation function. In particular, N_p/q contains all nonnegative integers and the literature on base p/q usually focuses on the set of words that are evaluated to nonnegative integers; it is a rather chaotic language which is not context-free. On the contrary, we study here the subsets of (N_p/q)^d that are p/q-recognisable, i.e. realised by finite automata over (A_p)^d. First, we give a characterisation of these sets as those definable in a first-order logic, similar to the one given by the B\"uchi-Bruy\`ere Theorem for integer bases numeration systems. Second, we show that the natural order relation and the modulo-q operator are not p/q-recognisable.


Introduction
Let p and q be two coprime integers such that p > q > 1, hence p q is an irreducible fraction greater than 1. The base-p q (numeration system) was introduced in [AFS08]. The study of such rational base numeration systems have enabled progress to be made in solving deep problems from number theory (Josephus and Mahler problems [Aki08]). Like other numerations systems, base p q gives a way to represent numbers by words, and to evaluate words to numbers. Here, we consider only finite words over the canonical alphabet A p = { 0, 1, . . . , p − 1 }; it is the smallest digit-set X such that all nonnegative integers have representations using only digits from X.
One paradox of base p q is that simple number-sets are represented by complicated languages and that simple languages are evaluated to complicated number sets. For instance, N is represented by a rather chaotic language, L p q , that does not fit well in the usual hierarchy of formal languages. On the other hand, the evaluations of all words over A p form a set of numbers, N p Literature on base p q mostly focuses on L p q . It is not a context-free language [AFS08] and even defeats any kind of iteration lemma [MS13]. However, there is a very simple periodic procedure to generate L p q that is similar to a breadth-first search [MS17]. Some effort have also been made to study L p q from the perspective of combinatorics on words (frequency of patterns, sum-of-digit function, etc. [MST13,EOvA17,Dub09]).
On the contrary, there has been little work on N p q . Here, we start exploring this area by studying the subsets of N p q d that are realised by finite automata reading synchronously on d tapes. We call such sets p q -recognisable. In the original article introducing base p q [AFS08], it is shown that addition is p q -recognisable (in fact, normalisation of representations from any finite alphabet). This is a strong property which, in the case of integer base b leads to the following characterisation of b-recognisable sets. Similar statements are also known for other numeration systems (e.g. Pisot U-systems, Pisot β-numerations) and in other settings (e.g. characterising the sets of infinite words realised by Büchi automata) [Cha18]. In the present article, we show such a logic characterisation of p q -recognisable sets, stated below. It could seem strange that in our case, the universe is N p q instead of N. However, since L p q is not a regular language, the classical generalisation of Theorem 1 to rational base would clearly not hold. Note also that something is hidden in this statement. In most numerations systems, natural order may be expressed using addition (y z may be expressed by ∃x, x + y = z) and the proofs of the logic characterisations (e.g. the one of Theorem 1.1) rely on this fact. On the contrary, this is not true in base p q (see below) and we introduce another pre-order relation (denoted by ) in our proof.
Very little is known about the expressive power of automata with respect to base p q . In section 4, we begin to investigate this area. First, we show that the natural order relation over N p q is not p q -recognisable. This is quite surprising since 1) the contrary is true in almost all numeration systems, and 2) the natural order relation over N is recognised by a trivial finite automaton, provided that we are ensured that input words belong to L p q . Second, we consider the modulo-n operator, where n is an integer constant. This class of operators is related to the periodic subsets of N which, since the work of Cobham, have a particular place within the study of numeration systems. In fact, most numeration systems S are such that 1) N is "S-recognisable", and 2) periodic subsets of N are S-recognisable. (These properties hold if S belongs to the very large class of regular abstract numeration systems [LR10].) In base p q , neither Item 1 nor 2 hold; it is not surprising since the relevant set of numbers is N p q rather than N. By definition, the set N p q is p q -recognisable, and the last part of this work is about adapting Item 2. If n is coprime with q, then the modulo-n operator is easy to generalise as a function N p q → Z/nZ and we show that it is p q -recognisable (Corollary 4.7). On the other hand, when n is not coprime with q, no generalisation of the modulo-n operator is obvious. Nevertheless, we show that there is no p q -recognisable set that separates qN from its complement in N (Proposition 4.8). It follows that no generalisation of the modulo-n operator would be p q -recognisable if n is a multiple of q (Corollary 4.10).

Preliminaries
2.1. Words, automata. An alphabet A is a finite set of symbols, called indifferently letters or digits. A word over A is a finite sequence u = a k−1 · · · a 1 a 0 of letters from A. We let |u| denote the length of u, that is |u| = |a k−1 · · · a 1 a 0 | = k. For each i, 0 i |u|, we denote the prefix of u of length i by Pref i (u) that is Pref i (u) = a k−1 . . . a k−i ; similarly Suff i (u) = a i−1 . . . a 0 denotes the suffix of u of length i. We denote the set of all words over A by A * and subsets of A * are called languages over A. The set A * is endowed with the concatenation, usually denoted implicitly as in uv, or explicitly by a middle dot when it helps readability, is a set of final states. As usual, we extend δ A as a function Q A × A * → Q A by δ A (q, ε) = q and δ A (q, au) = δ A (δ A (q, a), u). We call the run of u, if it exists, the sequence of states reached during the execution of A on u, namely, the finite sequence (δ A (i A , Pref i (u))) 0 i |u| ; in particular, the phrase the run of u reaches state s means that δ A is defined on (i A , u) and that δ A (i A , u) = s. A word u is said to be accepted by A if its run exists and reaches a final state; the accepted language of A, denoted by Lang(A) is the set of the words accepted by A. An automaton is complete if its transition function is total.
It is sometimes more convenient to have an automaton read number representations most significant digit first (MSDF), and sometimes least significant digit first (LSDF). Since the position of a digit is meaningful for evaluation, we try to keep consistent the indexing of words throughout the article, hence we want to avoid mirroring words and languages. Thus, we say that an automaton is left-to-right if it reads its input in a normal fashion, and right-to-left if it reads its input from right to left. Since we usually represent numbers MSDF (cf. Section 2.3), left-to-right automata work on MSDF representations, while right-to-left automata work on LSDF representations. In a right-to-left automaton, the function δ A is actually generalised as δ A (q, ua) = δ A (δ A (q, a), u), and the run of a word u refers to the state sequence (δ A (i A , Suff i (u))) 0 i |u| .
We will always consider automata in relation with a rational base numeration system, hence automata will all be over the alphabet (A p ) d for some number d of tapes. (Rational bases and the digit set A p are defined in Section 2.3.) A word u in A d p * may be divided component-wise as u = (u 0 , u 1 , . . . , u d−1 ) where u 0 , u 1 , . . . , u d−1 are words in (A p ) * that are of equal length.
The digit 0 always belongs to A p and when d is clear from context, we let 0 denote the letter (0, . . . , 0) which is part of A d p . Moreover, we say that a d-tape automaton is padded if for every word u in A d p * , u is accepted by A if and only if 0 · u is also accepted. Intuitively, 12:4

V. Marsault
Vol. 17:3 a padded automaton accepts words by value; indeed, the i-th component of u and of 0 · u have the same value. In the following, we will exclusively consider automata that are padded.
2.2. First-order logic. We briefly recall the definition of first-order formulas. Let X be a countable set of variables. Let Ω be a set called the domain, let f i i∈I be a family of functions, let R j j∈J be a family of relations on Ω, and c k k∈K be a family of constants in Ω. We let FO Ω, f i i∈I , R j j∈J , (c k k∈K (2.1) denote the logic in which terms and formulas are defined recursively as follows.
• Each constant c k , with k ∈ K, and each variable x ∈ X is a term.
• If f i is a n-ary function and t 0 , . . . , t n−1 are terms, then f i (t 0 , . . . , t n−1 ) is a term.
• If t and t are two terms, then t = t is a formula.
• If R j is a n-ary relation and t 0 , . . . , t n−1 are terms, then R j (t 0 , . . . , t n−1 ) is a formula.
• If ϕ is a formula, then ¬ϕ is a formula.
• If ϕ is a formula and x is a variable, then ∃x ϕ and ∀x ϕ are formulas A variable x is called free in a formula ϕ if it appears outside the scope of any quantifier ∃x or ∀x. If a formula ϕ has d free variables, we usually make them explicit by writing ϕ as ϕ(x 0 , x 1 , . . . , x d−1 ). We do not define in all generality the interpretation of relations, functions and formulas since we will always use the straightforward interpretations. Hence we assume that it is clear what it means for a closed formula to be true and we say that a subset S of Ω d is defined by the formula ϕ if the following holds.
2.3. Rational base numeration systems. Let p and q be two coprime integers such that p > q > 1; they will be fixed throughout the article. Note that p q is thus an irreducible fraction greater than 1. We define below base-p q (numeration system) ; for more details see [FS10,Mar16]. Let us stress that it is not the special case of a β-numeration where β is a rational number.
2.3.1. Evaluation. The canonical alphabet associated with base p q , denoted by A p , is the set A p = { 0, 1, . . . , p −1 }. The evaluation function maps every word u = a k−1 · · · a 1 a 0 in (A p ) * to a rational number as follows.
The number Val(u) is called the value of u. Note that the value of a word may be computed recursively: for every u, w ∈ (A p ) * , the following holds.  The set N p q is hard to describe in another way than its definition, and in general little is known about it. Of course, Equation (2.3) implies that N p q contains only rational numbers that have for denominator a power of q. Moreover, one may show that for a given power q k , only finitely many numbers in N q k do not belong to N p q (see [MS13] or Lemma 4.3, later on).
Example 2.2. Figure 1 gives an intuition of the content of N p q for base 3 2 : the k-th line represent N p q ∩ N q k and each number n q k in N p q is represented by a black segment of length 1 q k centred around abscissa n q k ; in each line, the highlighted segment always represents the number 5. The figure highlights the fact that as we refine the approximation of N p q , more and more holes appear in a seemingly chaotic fashion.
2.3.2. Representation. Given a number x, we call expansion of x any word u in (A p ) * such that Val(u) = x. By definition, each number in N p q has at least one expansion, and it is known that it is unique up to leading 0's: Notation 2.4. We let L p q denote the set of the representations of nonnegative integers, that is L p q = Rep(N) As briefly recalled in the introduction, L p q has been well studied; in the present work we will use only the following two properties: L p q is prefix-closed (follows from (2.5)) and it is not a regular language (cf. [FS10,Mar16]). Note that 0 * L p q is also a prefix-closed language that is not regular.
it is realised by some automaton. Note that item (a) implies in particular that A is padded and that, since the expansions of a number are equal up to leading 0's, A accepts by value: is not a regular language.
Theorem 2.7 [AFS08]. Addition is p q -recognisable. Since it is central to our logic characterisation, we give without proof the definition of C p q , the 3-tape right-to-left automaton that realises addition in base p q .
where the state set is Q C = { 0, . . . , m } with m = 1 + p−2 p−q ; the initial state is i C = 0; the final-state set is F C = { 0 }; and the transition function is defined as follows.
For instance, Figure 2 shows C p q for base 3 2 . Note that δ C is not a total function. In fact, if s, a and b are fixed, there is exactly one c in A p such that δ C (s, (a, b, c)) is defined. Hence, for each length i, there is exactly word u i of length i such that δ C s, (0 i , 0 i , u i is defined. Moreover, if i m, it may be shown that δ C s, (0 i , 0 i , u i = 0. In particular, the following holds. 1 An algorithm computing Rep(x), for x in N p q and beyond, is given in [FK12]. (1, 2, 0) (2, 1, 0) (2, 2, 1) , a 3-tape right-to-left automaton that realises addition in base 3 2 Property 2.8. N p q is stable by addition : ∀x, y ∈ N p q x + y ∈ N p q .

Different definition of rational bases.
In this article, we use the original definition of rational bases [AFS08]. In [FK12], the author define them differently. Let us stress that the two definitions are not equivalent, although they define two objects that are close. Each has properties that the other has not, hence one object is more convenient than the other depending on the context.
To make things precise, we give below the evaluation of a word u = a k−1 · · · a 0 in (A p ) * , as defined in [FK12].
With this definition, the (rather strange) factor 1 q from Equation (2.3) does not appear. The representation algorithm is modified as follows (the difference is underlined).
The main statements of this article (that is, Theorem 1.2, Proposition 4.5, 4.6, 4.9, and their corollaries) also hold, mutadis mutandis, for this alternative notion of rational base numeration systems.
3. Characterisation of p q -recognisable sets The purpose of section 3 is to show our main result. We restate it after a few definitions.
The forward direction of Theorem 1.2 is shown in Section 3.2 (Proposition 3.11) and the backward direction in Section 3.3 (Proposition 3.12). First, we show some preliminary results in Section 3.1.
3.1. Constants and the length preorder are p q -definable. Property 3.2. Let x be a number in N p q such that x = 0, and let i be a nonnegative integer. The following are equivalent. (a) There exists a letter a ∈ A p , a = 0, such that a0 i is a suffix of Rep(x).   Proof of the claim.
• The forward direction is immediate.
• Backward direction. The case x = 0 and the case y = 0 are trivial. If x = 0 and y = 0 the representations of x and y are respectively written as Rep(x) = q0 i and Rep(y) = q0 j for some nonnegative integers i and j. Hypothesis implies that i j and it may be The number 0 is the neutral element for addition, hence the set {0} is defined by the following formula.
zero(x) := ∀y x + y = y Claim 3.3.1 allows us to define the set {1} with the following formula.
Then, for every other number z in N p q , written as z = n m , the set {z} is p q -definable by the following formula.
(Note that the formula constant z is well formed for any z ∈ Q. However, if z does not belong to N p q , this formula defines the empty set.) Since all constants are p q -definable, in the following, we use in formulas, directly numbers as terms. For instance we will write ϕ(x, y) := x+ p q = y instead of ϕ(x, y) Definition 3.4. We denote the length preorder over N p The remainder of this subsection 3.1 is dedicated to showing that relation is definable in FO N p q , +, V p q (Proposition 3.8). The general idea is that 1) the natural order is p q -definable if it is restricted to the set of the numbers whose representations use only the digit (p − 1), and 2) the function that maps a number x ∈ N p q to (p − 1) | Rep(x)| is also p q -definable. Definition 3.5. Let us define a formula all a (x), for each letter a ∈ A p , a = 0. Equation (3.1) defines the case a = (p − q) and Equation (3.2) the other cases.
Lemma 3.6. For each a∈A p , a = 0, formula all a (x) defines the set x ∈ N p q Rep(x) ∈ a * . Proof.
(1) Case a = p − q. First, note that Equation (3.3), below, is a direct consequence of how carry is propagated in base p q . See the definition of the additionner (Equation (2.6)); and recall that the number 1 is represented by the one-letter word q in base p q . ∀x ∈ N p q , n ∈ N Rep(x) = (p − q) n =⇒ Rep(x + 1) = q0 n implies that the number z = x + 1 is equal to ( p q ) i , for some nonnegative integer i, hence written Rep(z) = q 0 i . From (3.3), the number x = Val((p − q) i ) is such that x + 1 = z, hence x = x . Since p q -representation is unique up to leading zeroes, it holds Rep(x) = (p − q) i . • Backward direction is a direct consequence of (3.3).
(2) Case a = p − q (and a = 0). Let x be a number in N p q and n be a non-negative integer. The following equivalences conclude the proof.
(Note that in (3.2), the equality already implies that y is necessarily equal to p−q a x, if this number indeed belongs to N p q .) We now define a formula that enables to mask the actual value of a number, but keeps the length of its representation. Effectively, it replaces each digit by p −1 (that is, by the greatest digit). This is done in two steps: mask(x, z) is true if there is a word w such that Val(w) = x and Val(w ) = z, where w is the word resulting from replacing every digit in w by p −1; note that w may contain leading 0's. We say that z masks x if mask(x, z) is true. Then, smallest-mask(x, y) is true if y is the smallest mask of x, that is, if it is masked by every mask of x.
mask(x, z) := all p−1 (z) ∧ ∃y x + y = z (3.5) smallest-mask(x, y) := mask(x, y) ∧ ∀z mask(x, z) → mask(y, z) (3.6) Now, let us show that mask has the intended behavior. . It is clear that x + y = z since no carry will be risen during this addition; hence y is the witness that mask(x, z) holds. Now, all is set to show that relation is p q -definable.
Proof. Let us show that the following formula defines .
From Lemma 3.7a, since mask(x , y ) is true, it holds n m, hence x y.
• Backward direction. Let x, y ∈ N p q be two numbers such that x y. We let n and m denote the length of the representation of x and y, respectively; hence n m. The numbers x = Val((p − 1) n ) and y = Val((p − 1) m ) are the witnesses that Φ true.
3.2. Every p q -recognisable set is p q -definable. Section 3.2 is dedicated to the proof of Proposition 3.11. It is adapted from the proof of Theorem 1.1 given in [BHMV94]. The main idea is to code the run of a d-state automaton, that is a sequence of elements from Definition 3.9, below, gives a few relations and functions that will be useful in the proof and Lemma 3.10 shows that they are p q -definable. In particular, it gives the formula that computes the digit at a given position in the representation of a given number. First, let us clarify what we mean by position in a representation. Let x be a number in N p q , the representation of which we write Rep(x) = a n−1 · · · a 1 a 0 . For every nonnegative integer i, the digit at position i in Rep(x) refers to a i if i < n, and to 0 otherwise. (d) For each digit a ∈ A p , we let * a (y, z) denote the multiplication-by-a-digit relation: it holds * a (y, z) and z = a × y.

∧ ∃ ∃m ∃r
Assume that digit a (x, y), as defined by (e) is true. Term (i) implies that there is an integer i such that Rep(y) = 10 i . The variable , m and r will contain the left, middle and right parts of x where the split is done at position i of the representation of x. Term (iii) ensures that Val(a0 i ) = m. Term (iv) ensures that there is a word u ∈ (A p ) * such that Val(u0 i+1 ) = . Term (v) ensures that Rep(r) = v for some word v such that |v| i. Then, (ii) implies that Proposition 3.11. Every p q -recognisable set is p q -definable.
Proof. Let S be a subset of N p q d that is p q -recognisable, hence realised by a d-tape automaton A. We let m denote the number of states in A. Without loss of generality, we assume that A is right-to-left, complete, that the state-set is {0, 1, . . . , m − 1} and that the initial state is 0. We moreover denote by F the set of final states and by δ the transition function. In summary, A = A d p , {0, 1, . . . , m − 1}, 0, δ, F . Let x = (x 0 , x 1 , . . . , x d−1 ) be a d-tuple of numbers. The formulas will describe the run of the word u = Rep(x). First, we introduce a variable k equal to Val(10 K ) where K is Proof of the claim. It is a routine to establish the following equivalence. The following claim immediately follows. Claim 3.11.3. The formula (Λ(x 0 , x 1 , . . . , x d−1 , k) ∧ Φ(s 0 , s 1 , . . . , s m−1 , k)) is true if and only if the following two conditions hold.
There exists an integer i ∈ F , such that the digit at position K in s i is 1 .   Equation (3.12), below, defines ∆(···) that will ensure that Equation (3.8) is inductively satisfied. (Recall that δ is the transition function of A). (3.12) Claim 3.11.4. Let J be a nonnegative integer. We assume that Equation (3.8) holds for n = J, and we write j = 1 q ( p q ) J . The formula ∆(x 0 , · · · , x d−1 , s 0 , · · · , s m−1 , j) is true if and only if Equation (3.8) holds for n = (J + 1).
Proof of the claim. Since Equation (3.8) holds for n = J, there is exactly one integer i in {0, . . . , m − 1} such that digit 1 (s i , j) is true; and i is the state reached by the run of Suff J (u), the suffix of length J of u. Moreover for each , 0 < d, we let b denote the digit such that digit b (x , j) is true. Finally, we write i = δ(i, (b 0 , . . . , b d−1 )), or, in other words, i is the state reached by the run of Suff (J +1) (u).
∃h j + · · · + j p times The each (a, q) a ∈ A p \ {0} Figure 3. Right-to-left automaton that realises V p q 3.3. Every p q -definable set is p q -recognisable. The backward direction of Theorem 1.2 is proved in a very classical way. We only give a sketch of the proof. It amounts to showing that 1) each atomic set or relation of the logic is realised by an automaton 2) the inductive constructs of first-order formulas preserves p q -recognisability. For more details, see for instance [BHMV94].
Proposition 3.12. Every p q -definable set is p q -recognisable. Sketch of proof. Let A be a d-tape complete automaton that realises a d-free-variable formula Φ.
(1) The set defined by the formula ¬Φ(x) is realised by the automaton resulting from inverting final and non-final states in A.
(2) The set defined by the formula ∃x i Φ(x) is realised by the automaton resulting from erasing the i-th tape from A. (Note that the resulting automaton needs to be determinised and made padded.) (3) The formula ∀x i Φ(x) is equivalent to ¬ ∃x i ¬Φ(x) . that is, where the "free" variable y is added without being used. S is realised by C defined as follows. C is a d + 1-tape automaton and it has the same state set, initial state and final-state set as A. The transition function of C is defined by, for all appropriate a i 's, b and s, (a 0 , . . . a i , b, a i+1 , . . . , a d−1 ) = δ A s, (a 0 , . . . , a d−1 ) . (3.14) (5) It is a routine to build the automaton that realises the set S defined by that is, where the variables at positions i and k have swapped positions. Let B be a second d-tape complete automaton that realises a d-free-variable formulas Ψ. (Note that we may assume that Ψ and Φ have the same free variables in the same order thanks to items (d) and (e), above.) that realises addition in base p q . The function V p q is realised by a simple automaton with two states, the definition of which is given as a prototype in Figure 3. 4. Notable sets that are or are not p q -recognisable During the research leading to Theorem 1.2, it became apparent that very little was known on the expressive power of automata with respect to base p q . After recalling a few known or obvious p q -recognisability results, we show that the natural order relation over N p q is not p q -recognisable. Then, we study generalisations of the modulo-n operator in Sections 4.3 and 4.4. We show that it is p q -recognisable if n is coprime with q, and that it is not if n is a multiple of q. These results are not immediate consequences of Theorem 1.2, although it is sometimes useful in the proofs.

A few known results.
Proposition 4.1. The following are p q -recognisable. (d) Interval bounded by constants: z ∈ N p q r < z < s , where r and s belong to R.
Item 4.1a is given in Section 2.3. Item 4.1b and 4.1c follows immediately from the fact that addition is p q -recognisable (Theorem 2.7). Item 4.1d follows from the fact that such an interval contains a finite number of elements from N p q .
Proposition 4.2. The following are not p q -recognisable. Proof. The words 10 k−1 and 1 are evaluated to p k−1 q k and 1 q , respectively; hence, both numbers belong to N p q . Since N p q is stable by addition, it contains 1 q k (p k−1 i+q k−1 j), for every nonnegative integers i and j. Since p and q are coprime, when j runs through {0, 1, . . . , p k−1 }, then q k−1 j runs through all residue classes modulo p k−1 . It follows that we may choose m k = (pq) k−1 .
The bound m k given is the proof is far from tight; a better, and seemingly tight, bound is given by [Mar16,Lemme 5.15]. In the following, we will use Lemma 4.3 under a different form, given below.
Lemma 4.4. For all real numbers α and β, such that 0 α < β, there exist two numbers x, y in N p q such that α < x − y < β .
Proof. There exist two integers k and h such that α < h q k < β. Then, we set x = m k +h q k and y = m k q k , where m k is the bound given by Lemma 4.3.
Proposition 4.5. The set (x, y) ∈ N p q 2 x < y is not p q -recognisable.
The proof amounts to showing that L is not a regular language. For the sake of contradiction, we assume that L is accepted by a n-state automaton A that we assume left-to-right, complete and minimal.
We We have just defined n +1 words in A 2 p * such that (4.1) Let i and j be integers such that 0 i, j n. We write u j = 0 −k Rep(j), 0 , with k = | Rep(j)|. It follows that the two components of (v i , w i ) · u j are evaluated to Val(v i 0 ) + j and Val(w i 0 ), respectively. Hence, from (4.1), (v i , w i ) · u j belongs to L if and only if i j.
Let M = { u 1 , . . . , u n }. The next equation sums up the previous paragraph.
On the other hand, since A is minimal and complete, its state set is precisely Q, hence Card(Q) = n, a contradiction.
4.3. Equivalence modulo n, where n is an integer coprime with q. The function x → (x mod n) classically maps integers to elements of Z/nZ. If n is coprime with q, we may extend this function to N p q → Z/nZ as follows. We let q −1 denote the element of Z/nZ such that qq −1 mod n = 1. Let x be a number in N p q . There exist integers m, k such that x = m q k , and we set x mod n = m q k mod n = m(q −1 ) k mod n . It may be verified that this generalised modulo-n operator still distributes over addition and multiplication. It is then quite elementary to show that the computation of equivalence classes modulo n is p q -recognisable.
Proposition 4.6. Let n be an integer coprime with q, and let R ⊆ Z/nZ be a set of remainders modulo n. Then, the set P n,R = z ∈ N p q (z mod n) ∈ R is p q -recognisable.
Sketch of proof. Once again, q −1 denotes the element of Z/nZ such that (qq −1 ) is equivalent to 1 modulo n. Let A be the left-to-right automaton defined as follows.
Using Equation (2.4) and (4.3), one may show with an induction over the length of u that, for every word u in (A p ) * the run of u in A exists and reaches the state Val(u) mod n .
Corollary 4.7. Let n be an integer coprime with q. The following relation is p q -recognisable.
(x, y) ∈ N p q 2 x mod n = y mod n ∧ y ∈ { 0, 1, . . . , n − 1 } (4.4) Proof. For every r in Z/nZ, Proposition 4.6 yields that the set P n,{r} is p q -recognisable, hence it follows from Theorem 1.2, that it is p q -definable by a formula Ψ r (x). The relation of the statement is definable by the following formula. 4.4. Equivalence modulo q. Unlike in the previous case, it is not obvious to extend the modulo-q operator to N p q . However, as far as p q -recognisability is concerned, the question is irrelevant: any such generalisation is not p q -recognisable. It is the Corollary 4.10 of the next statement.
Proof. For the sake of contradiction, we assume that there exists A 0 , an automaton realising a set S ⊆ N p q that satisfies S ∩ N = qN. Theorem 1.2 yields that there exists, for every integer i, 0 i < q, an automaton A i = A p , Q i , δ i , i i , F i that realises S + i. Note in particular that the A i 's are correct if the input is the expansion of an integer: ∀i, 0 i < q, ∀u ∈ (A p ) * , Val(u) ∈ N, We assume without loss of generality that the A i 's are complete and left-to-right.
Let B be the left-to-right automaton: where the state-set is Q B = Q 0 × · · · × Q q−1 , the initial state is i B = (i 0 , . . . , i q−1 ), all states are final: F B = Q B , and δ B is defined as follows. Let s = (s 0 , s 1 , . . . , s q−1 ) be a state in Q B and let a be a letter in A p .
The important part of the definition of B is Equation (4.7); it should be compared with Equation (2.5) (which gives the algorithm to compute the representation of integers). Intuitively, Equation (4.7) ensures that taking a transition in B preserves the property of being evaluated to an integer ; it will yield Claim 4.8.2 thanks to a proof by induction. The rest of the definition of B is simply such that Claim 4.8.1 holds.
Claim 4.8.1. Let u be a word in (A p ) * . If the run of u in B exists and reaches the state (s 0 , s 1 , . . . , s q−1 ), then for every i, 0 i < q, the run of u in A i exists and reaches s i .
Proof of the claim. From its definition, the automaton B is the result of two transformation applied to the classical automaton product A 0 × A 1 × · · · × A q−1 : deleting some transitions and setting all states as final. Since the A i 's are all complete, Claim 4.8.1 follows. Proof of the claim. By induction over the length of u; the case u = ε is trivial.
Let u = v a be a non-empty word in (A p ) * . Induction hypothesis then rewrites as v has a run in B (4.8a) Val(v) belongs to N (4.8b) Note that u has a run in B implies (4.8a), since v is a prefix of u; and that Val(v a) ∈ N implies (4.8b), since 0 * L p q is a prefix-closed language. Hence, in both directions of the proof, both sides of the equivalence of (4.8) hold.
Then, we let s = (s 0 , s 1 , · · · , s q−1 ) denote the state reached by the run of v in B. Hence, for every integer i, 0 i < q, the run of v in A i reaches s i (Claim 4.8.1). From (4.6), since Val(v) is an integer, v is accepted by A k , where k = Val(v) mod q, and rejected by each A i such that i = k. In other words, s k ∈ F k and for every i = k, s i / ∈ F i . Then, the following are equivalent.
u has a run in B ⇐⇒ δ(s, a) = t for some t ∈ Q B ⇐⇒ s i ∈ F i and ip + a ≡ 0 [q] (from (4.7)) ⇐⇒ k p + a ≡ 0 [q] (since necessarily, k = i) ⇐⇒ Val(v)p + a ≡ 0 [q] (from the definition of k) ⇐⇒ The inseparability result stated by Proposition 4.8 may be generalised to every periodic set whose smallest period is a multiple of q.
Proposition 4.9. Let P be a periodic set of integers, the smallest period of which is a multiple of q. Then, there is no p q -recognisable set S such that S ∩ N = P . Proof. Since bounded intervals are p q -recognisable (Proposition 4.1d), we may assume that P is purely periodic. First, we assume moreover that the smallest period of P is exactly q. In this case, there exists a remainder set R ⊆ Z/qZ such that S = R + qN. Using that q is the smallest period of P , simple arithmetics shows that the following claim holds.
Claim 4.9.1. An integer i is divisible by q if and only if, for every r in R, (i + r) mod q belongs to R For the sake of contradiction, we assume that there exists a set S as in the statement. We denote the formula that defines S by Φ(x).
Let ξ(x) := r∈R Φ(x + r) and let X be the set definable by ξ. Claim 4.9.1 yields that N ∩ X = qN, From Theorem 1.2, X is p q -recognisable, a contradiction to Proposition 4.8. If the period of P is k q, k > 1, a similar ab absurdo reasoning yields a p q -recognisable set X such that N ∩ X = k q N. Then, using Theorem 1.2, it is easy to show that the set Y = X ∪ (X + q) ∪ · · · ∪ (X + (k − 1)q) is also p q -recognisable and satisfies Y ∩ N = q N, a contradiction to Proposition 4.8.
Corollary 4.10. Let k be a positive integer. Let f be a function N p q → N p q such that, for every integer n, f (n) = n mod k q. The function f is not p q -recognisable. In Sections 4.3 and 4.4, we studied the p q -recognisability of the modulo-n operator when n is coprime with q (Corollary 4.7) and when n is a multiple of q (Corollary 4.10). These results do not cover all cases, and in general we conjecture the following.
Conjecture 4.11. Let n be an integer. Let f be a function N p q → N p q . We assume that, for every number x y in N p q such that y is coprime with n, then f ( x y ) = (xy −1 ) mod n, where y −1 is the inverse of y in Z/nZ.
Then, the function f is p q -recognisable if and only if n is coprime with q.

Conclusion and future work
In this work, we took a perspective which is classical for other numeration systems (integer base, U-systems), but quite new in the studies on rational base numeration systems. Instead of exploring the intricacies of the language L p q , we indeed started to determine what may or may not be computed by automata. It is very encouraging that the logic characterisation given by Theorem 1.2 is similar to the corresponding statements in other settings [BHMV94,BH97,Cha18].
This opens for base p q a lot of questions that have been answered for others numerations systems. For instance, it is natural to confront p q -recognisability to sets definable in Presburger arithmetic. Indeed Cobham Theorem and its generalisations [DR11] showed that a set realised by automata in "sufficiently different" numerations systems is necessarily definable in that