Decidability for Sturmian words
Philipp Hieronymi, Dun Ma, Reed Oei, Luke Schaeffer, Christian Schulz, Jeffrey Shallit
aa r X i v : . [ c s . L O ] F e b DECIDABILITY FOR STURMIAN WORDS
PHILIPP HIERONYMI, DUN MA, REED OEI, LUKE SCHAEFFER, CHRISTIAN SCHULZ,AND JEFFREY SHALLIT
Abstract.
We show that the first-order theory of Sturmian words over Presburgerarithmetic is decidable. Using a general adder recognizing addition in Ostrowski nu-meration systems by Baranwal, Schaeffer and Shallit, we prove that the first-order ex-pansions of Presburger arithmetic by a single Sturmian word are uniformly ω -automatic,and then deduce the decidability of the theory of the class of such structures. Using animplementation of this decision algorithm called Pecan, we automatically reprove manyclassical theorems about Sturmian words in seconds, and are able to obtain new resultsabout antisquares and antipalindromes in characteristic Sturmian words. Introduction
It has been known for some time that, for certain infinite words c = c c c · · · overa finite alphabet Σ, the first-order logical theory FO( N , <, + , , , n c n ) is decidable.In the case where c is a k -automatic sequence for k ≥
2, this is due to B¨uchi [5],although his original proof was flawed. The correct statement appears, for example,in Bruy`ere et al. [4]. Although the worst-case running time of the decision procedureis truly formidable (and non-elementary), it turns out that an implementation can, inmany cases, decide the truth of interesting and nontrivial first-order statements aboutautomatic sequences in a reasonable length of time. Thus, one can easily reprove knownresults, and obtain new ones, merely by translating the desired result into the appropri-ate first-order statement ϕ and running the decision procedure on ϕ . For an exampleof the kinds of things that can be proved, see, for example, Goˇc, Henshall, and Shallit [11].More generally, the same ideas can be used for other kinds of sequences defined in termsof some numeration system for the natural numbers. Such a numeration system pro-vides a unique (up to leading zeros) representation for n as a sum of terms of someother sequence ( s n ) n ≥ . If the sequence c = c c c · · · can be computed by a finiteautomaton taking the representation of n as input, and if further, the addition of repre-sented integers is computable by another finite automaton, then once again the first-ordertheory FO( N , <, + , , , n c n ) is decidable. This is the case, for example, for the so-called Fibonacci-automatic sequences in Mousavi, Schaeffer, and Shallit [19] and thePell-automatic sequences in Baranwal and Shallit [3]. This is a preprint version. Later versions might contain significant changes.
More generally, the same kinds of ideas can handle Sturmian words. For quadratic num-bers, this was first observed by Hieronymi and Terry [14]. In this paper we extend thoseresults to all Sturmian characteristic words. Thus, the first-order theory of Sturmiancharacteristic words is decidable. As a result, many classical theorems about Sturmianwords, which previously required intricate proofs, can be proved automatically by atheorem-prover in a few seconds. As examples, in Section 7 we reprove basic results suchas the balanced property and the subword complexity of these words.Let α, ρ ∈ R be such that α is irrational. The Sturmian word with slope α andintercept ρ is the infinite { , } -word c α,ρ = c α,ρ (1) c α,ρ (2) . . . such that for all n ∈ N c α,ρ ( n ) = ⌊ α ( n + 1) + ρ ⌋ − ⌊ αn + ρ ⌋ − ⌊ α ⌋ . When ρ = 0, we call c α, the characteristic word of slope α . Sturmian words andtheir combinatorical properties have been studied extensively. We refer the reader to thesurvey by Berstel and S´e´ebold [17, Chapter 2].Note that c α,ρ can be understood as a function from N to { , } . Let L be the signature ofthe first-order logical theory FO( N , <, + , ,
1) and denote by L c the signature obtainedby adding a single unary function symbol c to L . Now let N α,ρ be the L c -structures( N , <, + , , , n c α,ρ ( n )), where we expand Presburger arithmetic by a Sturmian wordinterpreted as a unary function. The main result of this paper is the decidability of thetheory of the collection of such expansions. Set Irr := (0 , \ Q . Theorem A.
The first-order logical theories of the following classes of structures aredecidable:(1) K sturmian := {N α,ρ : α ∈ Irr , ρ ∈ R } ,(2) K char := {N α, : α ∈ Irr } . So far, decidability was only known for individual FO( N α,ρ ), and only for very particular α . By [14] the logical theory FO( N α, ) is decidable when α is a quadratic irrational .Moreover, if the continued fraction of α is not computable, it can be seen rather easilythat FO( N α, ) is undecidable.Theorem A is rather powerful, as it allows to automatically decide combinatorial state-ments about all Sturmian words. Consider the L c -sentence ϕ ∀ p ( p > → (cid:16) ∀ i ∃ j j > i ∧ c ( j ) = c ( j + p ) (cid:17) In model theory this is usually called (or identified with) the language of the theory. However, herethis conflicts with the convention of calling an arbitrary set of words a language. Given a signature L and a class K of L -structures, the first-order logical theory of K is defined asthe set of all L -sentences that are true in all structures in K . This theory is denoted by FO( K ). A real number is quadratic if it is the root of a quadratic equation with integer coefficients.
ECIDABILITY FOR STURMIAN WORDS 3
We observe that N α,ρ | = ϕ if and only if c α,ρ is not eventually periodic. Thus the deci-sion procedure from Theorem A allows us to check that no Sturmian word is eventuallyperiodic. Of course, it is well-known that no Sturmian words is eventually periodic, butthis example indicates potential applications of Theorem A. We outline some of these inSection 7.We not only prove Theorem A, but instead establish a vastly more general theorem ofwhich Theorem A is an immediate corollary. To state this general result, let L m be thesignature of FO( R , <, + , Z ), and let L m,a be the extension of L m by a unary predicate.For α ∈ R > , we denote by R α the L m,a -structure ( R , <, + , Z , α Z ). When α ∈ Q , it haslong been known that FO( R α ) is decidable (arguably due to Skolem [24]). Recently thisresult was extended to quadratic numbers. Fact 1 (Hieronymi [12, Theorem A]) . Let α be a quadratic irrational. Then FO( R α ) isdecidable. See also Hieronymi, Nguyen and Pak [13] for a computational complexity analysis of thisdecision procedure. The proof of Fact 1 establishes that if α is quadratic, then R α isan ω -automatic structure; that is it can be represented by B¨uchi automata. Since every ω -automatic structure has a decidable first-order theory, so does R α . See Khoussainovand Minnes [15] for a survey on ω -automatic structures. The key insights needed to prove ω -automaticity of R α is that addition in the Ostrowski-numeration system based on α isrecognizable by a B¨uchi automaton when α is quadratic. See Section 2 for a definitionof Ostrowski numeration systems.As observed in [12], there are examples of non-quadratic irrationals α such that R α has an undecidable theory and hence is not ω -automatic. However, in this paper weshow that the commom theory of the R α is decidable. Let K be the following class of L m,a -structures: K := {R α : α ∈ Irr } . Theorem B.
The theory
FO( K ) is decidable. Indeed, we will even prove a substantial generalization of Theorem B. For each L m,a -sentence ϕ , we set M ϕ := { α ∈ Irr : R α | = ϕ } . Let
Irr quad be the set of all quadratic irrational real numbers in
Irr . Define M = ( Irr , <, (M ϕ ) ϕ , (q) q ∈ Irr quad )to be the expansion of the dense linear order (
Irr , < ) by(1) predicates for M ϕ for each L m,a -sentence ϕ ,(2) constant symbols for each quadratic irrational real number in Irr . Theorem C.
The theory
FO( M ) is decidable. ECIDABILITY FOR STURMIAN WORDS 4
Observe that Fact 1 and Theorem B follow immediately from Theorem C. We outlinehow Theorem B implies Theorem A. For every irrational α , the structure R α defines thefollowing set without parameters: { ( ρ, n, c α,ρ ( n )) : ρ ∈ R , n ∈ N } . It is now easy to see that for every L c -sentence ϕ there is an L m,a -formula ψ ( x ) such that ϕ ∈ FO( K sturmian ) if and only if ∀ x ψ (x) ∈ FO( K ) . Even Theorem C is not the most general result we prove. Its statement is more technicaland we postpone it until Section 6. However, we want to point out that we can addpredicates for interesting subsets of
Irr to M without changing the decidability of thetheory. Examples of such subsets are:(1) the set of all α ∈ Irr such that the terms in the continued fraction expansion of α are powers of 2,(2) the set of all α ∈ Irr such that the terms in the continued fraction expansion of α are not in some fixed finite set, and(3) the set of all α ∈ Irr such that the terms in the continued fraction expansion of α all even terms in their continued fraction expansion are 1,This means we can not only automatically prove theorems about all characteristic Stur-mian words, but also prove theorems about all characteristic Sturmian words whose slopeis one of these sets. There is a limit to this technique. If we add a predicate for the setof all α ∈ Irr such that the terms of continued fraction expansion of α are bounded,or add a predicate for the set of elements in Irr whose continued fractions has strictlyincreasing terms, then our method is unable to conclude whether the resulting structurehas a decidable theory. See Section 6 for a more precise statement about what kind ofpredicates can be added.The proof of Theorem C follows closely the proof from [12] of the ω -automaticity of R α for fixed quadratic α . Here we show that the construction of the B¨uchi automata neededto represent R α is actually uniform in α . Deduction of Theorem C from this result isthen rather straightforward. The key ingredient to establish the ω -automaticity of R α is an automaton that can perform addition in Ostrowski-numeration systems. By [14]there is an automaton that recognizes the addition relation for α -Ostrowski numerationsystems for fixed quadratic α . So for a fixed quadratic number, there exists an 3-inputautomaton that accepts the α -Ostrowski representations of all triples of natural numbers x, y, z with x + y = z . In order to prove Theorem C, we need a uniform version of suchan adder. This general adder is described in Baranwal, Schaeffer, and Shallit [2]. Therean 4-input automaton is constructed that accepts 4-tuples consisting on an encoding ofa real number α and three α -Ostrowski representations of natural numbers x, y, z with x + y = z . See Section 4 for details. ECIDABILITY FOR STURMIAN WORDS 5
As mentioned above, an implementation of the decision algorithm provided by TheoremA can be used to study Sturmian words. We created a software program called Pecan[20] that includes such an implementation. Pecan is inspired by Walnut [18] by Mousavi,an automated theorem-prover for deciding properties of automatic words. The main dif-ference is that Walnut is based on finite automata, while Pecan uses B¨uchi automata. Inour setting it is more convenient to work with B¨uchi automata instead of finite automata,since the infinite families of words we want to consider—like Sturmian words—are in-dexed by real numbers. Section 7 provides more information about Pecan and containsfurther examples how Pecan is used prove statements about Sturmian words. Pecan’simplementation is discussed in more detail in [21].
Acknowledgements.
Part of this work was done in the research project “Building atheorem-prover” at the Illinois Geometry Lab in Spring 2020. P.H. and C.S. were partiallysupported by NSF grant DMS-1654725. We thank Mary Angelica Gramcko-Tursi forcarefully reading a draft of this paper.2.
Preliminaries
Throughout, i, j, k, ℓ, m, n are used for natural numbers. Let
X, Y be two sets and Z ⊆ X × Y . For x ∈ X , we denote by Z x the set { y ∈ Y : ( x, y ) ∈ Z } . Similarly, givena function f : X × Y → W and x ∈ X , we write f x for the function f x : Y → W thatmaps y ∈ Y to f ( x, y ).Given a (possibly infinite word) w over an alphabet Σ, we write w i for the i -th letter of w , and w | n for w · · · w n . We write | w | for the length of w . We denote the set of infinitewords over Σ by Σ ω . If Σ is totally ordered by an ≺ , we denote by the correspondinglexicographic order on Σ ω by ≺ lex . Letting u, v ∈ Σ ω , we also write u ≺ colex v if there is amaximal i such that u i = v i , and u i < v i for this i . Note that while ≺ lex is a total orderon Σ ω , the order ≺ colex is only a partial order. However, for a given σ ∈ Σ, the order ≺ colex is a total order on the set of all words v ∈ Σ ω such that v j is eventually equal to σ .A B¨uchi automaton (over an alphabet Σ ) is a quintuple A = ( Q, Σ , ∆ , I, F ) where Q is a finite set of states, Σ is a finite alphabet, ∆ ⊆ Q × Σ × Q is a transition relation, I ⊆ Q is a set of initial states, and F ⊆ Q is a set of accept states.Let A = ( Q, Σ , ∆ , I, F ) be a B¨uchi automaton. Let σ ∈ Σ ω . A run of σ from p is aninfinite sequence s of states in Q such that s = p , ( s n , σ n , s n +1 ) ∈ ∆ for all n < | σ | . If p ∈ I , we say s is a run of σ . Then σ is accepted by A if there is a run s s . . . of σ such that { n : s n ∈ F } is infinite. We call this run an accepting run. We let L ( A )be the set of words accepted by A . There are other types of ω -automata with differentacceptance conditions, but in this paper we only consider B¨uchi automata. ECIDABILITY FOR STURMIAN WORDS 6
Let Σ be a finite alphabet. We say a subset X ⊆ Σ ω is ω -regular if it is recognized bysome B¨uchi automaton. Let u , . . . , u n ∈ Σ ω . We define the convolution c ( u , . . . , u n )of u , . . . , u n as the element of (Σ n ) ω whose value at position i is the n -tuple consistingof the values of u , . . . , u n at position i . We say that X ⊆ (Σ ω ) n is ω -regular if c ( X ) is ω -regular. Fact 2.
The collection of ω -regular sets is closed under union, intersection, complemen-tation and projection. Closure under complementation is due to B¨uchi [5]. We refer the reader to Khoussainovand Nerode [16] for more information and a proof of Fact 2. As consequence of Fact 2,we have that for every ω -regular subset W ⊆ (Σ ω ) m + n the set { s ∈ (Σ ω ) m : ∀ t ∈ (Σ ω ) n ( s, t ) ∈ W } is also ω -regular.2.1. ω -regular structures. Let U = ( U ; R , . . . , R m ) be a structure, where U is a non-empty set and R , . . . , R m are relations on U . We say U is ω -regular if its domain andits relations are ω -regular.B¨uchi’s theorem [5] on the decidability of monadic second-order theory of one successorimmediately gives the following well-known fact. Fact 3.
Let U be an ω -regular structure. Then the theory of U is decidable. In this paper, we will consider families of ω -regular structures that are uniform in thefollowing sense. Fix m ∈ N and a map ar : { , . . . , m } → N . Let Z be a set and for z ∈ Z let U z be a structure ( U z ; R ,z , . . . , R m,z ) such that R i,z ⊆ U ar ( i ) z . We say that ( U z ) z ∈ Z isa uniform family of ω -regular structures if • { ( z, y ) : y ∈ U z } is ω -regular, • { ( z, y , . . . , y ar ( i ) ) : ( y , . . . , y ar ( i ) ) ∈ R i,z } is ω -regular for each i ∈ { , . . . , m } .From B¨uchi’s theorem, we immediately obtain the following. Fact 4.
Let ( U z ) z ∈ Z be a uniform family of ω -regular structures, and let ϕ be a formulain the signature of these structures. Then the set { ( z, u ) : z ∈ Z, u ∈ U z , U z | = ϕ ( u ) } is ω -regular, and the theory of {U z : z ∈ Z } is decidable.Proof. When ϕ is an atomic formula, the statement follows immediately from the defini-tion of a uniform family of ω -regular structures and the ω -regularity of equality. By Fact2, the statement holds for all formulas. (cid:3) ECIDABILITY FOR STURMIAN WORDS 7
Binary representations.
For k ∈ N > and b = b b b . . . b n ∈ { , } ∗ , we define[ b ] k := n X i =0 b i k i . For N ∈ N we say b ∈ { , } ∗ is a binary representation of N if [ b ] = N .Throughout this paper, we will often consider infinite words over the (infinite) alphabet { , } ∗ . Let [ · ] : ( { , } ∗ ) ω → N ω be the function that maps u = u u · · · ∈ ( { , } ∗ ) ω to[ u ] [ u ] [ u ] . . . We will consider the following different relations on ( { , } ∗ ) ω .Let u, v ∈ ( { , } ∗ ) ω . We write u < lex, v if [ u ] is lexicographically smaller than [ v ] . Wewrite u < colex, v if there is a maximal i such that [ u i ] = [ v i ] , and [ u i ] < [ v i ] . Notethat while < lex, is a total order on ( { , } ∗ ) ω , the order < colex, is only a partial order.However, < colex, is a total order on the set of all words v ∈ ( { , } ∗ ) ω such that [ v ] j iseventually 0.Let u = u u . . . , v = v v · · · ∈ ( { , } ∗ ) ω . Let k be minimal such that [ u k ] = [ v k ] . Wewrite u < alex, v if either • k is even and [ u k ] < [ v k ] , or • k is odd and [ u k ] > [ v k ] .2.3. Ostrowski representations.
We now introduce Ostrowski representations basedon the continued fraction expansions of real numbers. We refer the reader to Alloucheand Shallit [1] and Rockett and Sz¨usz [23] for more details.A finite continued fraction expansion [ a ; a , . . . , a k ] is an expression of the form a + 1 a + a + ... + 1 ak For a real number α , we say [ a ; a , . . . , a k , . . . ] is the continued fraction expansionof α if α = lim k →∞ [ a ; a , . . . , a k ] and a ∈ Z , a i ∈ N > for i >
0. In this situation,we write α = [ a ; a , . . . ] . Every irrational number has precisely one continued fractionexpansion. We recall the following well-known fact about continued fractions.
Fact 5.
Let α = [ a ; a , . . . ] , α ′ = [ a ′ ; a ′ , . . . ] ∈ R be irrational. Let k ∈ N be minimalsuch that a k = a ′ k . Then α < α ′ if and only if • k is even and a k < a ′ k , or • k is odd and a k > a ′ k . ECIDABILITY FOR STURMIAN WORDS 8
For the rest of this subsection, fix a positive irrational real number α ∈ (0 ,
1) and let[ a ; a , a , . . . ] be the continued fraction expansion of α .Let k ≥
1. A quotient p k /q k ∈ Q is the k -th convergent of α if p k ∈ N , q k ∈ Z ,gcd( p k , q k ) = 1 and p k q k = [ a ; a , . . . , a k ] . Set p − := 1 , q − := 0 and p := a , q := 1. The convergents satisfy the followingequations for n ≥ p n = a n p n − + p n − , q n = a n q n − + q n − . The k -th difference β k of α is defined as β k := q k α − p k . We use the following factsabout k -th differences: for all n ∈ N (1) β n > n is even,(2) β > − β > β > − β > β > . . . , and(3) − β n = a n +2 β n +1 + a n +4 β n +3 + a n +6 β n +5 + . . . .We now recall a numeration system due to Ostrowski [22]. Fact 6 ([23, Ch. II- § . Let X ∈ N . Then X can be written uniquely as (1) X = N X n =0 b n +1 q n . where ≤ b < a , ≤ b n +1 ≤ a n +1 and b n = 0 whenever b n +1 = a n +1 . For X ∈ N satisfying (1) we write X = [ b b . . . b n b n +1 ] α and call the word b b . . . b n +1 an α -Ostrowski representation of X . This representationis unique up to trailing zeros. Let X, Y ∈ N and let b b . . . b n +1 and c c . . . c n +1 be α -Ostrowski representations of X and Y respectively. Since Ostrowski representations areobtained by a greedy algorithm, one can see easily that X < Y if and only if b b . . . b n +1 is co-lexicographically smaller than c c . . . c n +1 .We now introduce a similar way to represent real numbers, also due to Ostrowski [22].Let I α be the interval (cid:2) ⌊ α ⌋ − α, ⌊ α ⌋ − α (cid:1) . Fact 7 (cp. [23, Ch. II.6 Theorem 1]) . Let x ∈ I α . Then x can be written uniquely as (2) ∞ X k =0 b k +1 β k , where b k ∈ Z with ≤ b k ≤ a k , and b k − = 0 whenever b k = a k ,(in particular, b = a ),and b k = a k for infinitely many odd k . ECIDABILITY FOR STURMIAN WORDS 9
For x ∈ I α satisfying (2) we write x = [ b b . . . ] α and call the infinite word b b . . . the α -Ostrowski representation of x . This is closelyconnected to the integer Ostrowski representation. Note that for every real number therea unique element of I α such that that their difference is an integer. We define f α : R → I α to be the function that maps x to x − u , where u is the unique integer such that x − u ∈ I α . Fact 8 ([12, Lemma 3.4]) . Let X ∈ N be such that P Nk =0 b k +1 q k is the α -Ostrowskirepresentation of X . Then f α ( αX ) = ∞ X k =0 b k +1 β k is the α -Ostrowski representation of f α ( αX ) , where b k +1 = 0 for k > N . Since β k > k is even, the order of two elements in I α can be determinedby the Ostrowski representation as follows. Fact 9 ([12, Fact 2.13]) . Let x, y ∈ I α with x = y and let [ b b . . . ] α and [ c c . . . ] α be the α -Ostrowski representations of x and y . Let k ∈ N be minimal such that b k = c k . Then x < y if and only if(i) b k +1 < c k +1 if k is even;(ii) b k +1 > c k +1 if k is odd.
3. -binary encoding
In this section, we introduce := { , , } . Denoteby H ∞ the set of all infinite Σ -words in which H ∞ is ω -regular.Let C : ( { , } ∗ ) ω → H ∞ map an infinite word b = b b b . . . over { , } ∗ to the infiniteΣ -word b b b . . . We note that the map C is a bijection.Let u = u u u . . . , v = v v v · · · ∈ Σ ω . We say u and v are aligned if for all i ∈ N u i = v i = . This defines an ω -regular equivalence relation on Σ ω . We denote this equivalence relationby ∼ . The following fact follows easily. Fact 10.
The following sets are ω -regular: • { ( u, v ) ∈ H ∞ : u ∼ v and C − ( u ) < lex, C − ( v ) } , • { ( u, v ) ∈ H ∞ : u ∼ v and C − ( u ) < colex, C − ( v ) } , • { ( u, v ) ∈ H ∞ : u ∼ v and C − ( u ) < alex, C − ( v ) } . ECIDABILITY FOR STURMIAN WORDS 10
We now code the continued fractionexpansions of real numbers as infinite Σ -words.
Definition 1.
Let α ∈ (0 , be irrational such that [0; a , a , . . . ] is the continued frac-tion expansion of α . Let u = u u · · · ∈ ( { , } ∗ ) ω such that u i ∈ { , } ∗ is a binaryrepresentation of a i for each i ∈ Z ≥ . We say that C ( u ) is a -binary coding of thecontinued fraction of α . Let R be the set of elements of Σ ω of the form ( | ∗ | ∗ ) ω . Obviously, R is ω -regular. Lemma 1.
Let w ∈ R . Then there is a unique irrational number α ∈ [0 , such that w is a -binary coding of the continued fraction of α .Proof. By the definition of R , there is w w · · · ∈ ((0 | ∗ | ∗ ) ω such that w = w w · · · Since w i ∈ (0 | ∗ | ∗ , we have that w i is a { , } -word containing at least one 1.Let a i be the natural number that a i = [ w i ] . Because w i contains a 1, we must have a i = 0. Thus w is a α = [0; a , a , . . . ]. Uniqueness follows directly from the fact that both binary expansionsand continued fraction expansions only represent one number. (cid:3) For w ∈ R , let α ( w ) be the real number given by Lemma 1. When v = ( v , . . . , v n ) ∈ R n ,we write α ( v ) for ( α ( v ) , . . . , α ( v n )).Even though continued fractions are unique, their R n . Definition 2.
Let X ⊆ R n . The zero-closure of X is { u ∈ R n : ∃ v ∈ X α ( u ) = α ( v ) } . Lemma 2.
Let X ⊆ R n be ω -regular. Then the zero-closure of X is also ω -regular.Proof. Let A be a B¨uchi automaton recognizing X . We use Q to denote the set of statesof A . We create a new automaton A ′ that recognizes the zero-closure of X , as follows:(Step 1) Start with the automata A .(Step 2) For each transition on the n -tuple ( , . . . , p to a state q , we adda new state µ ( p, q ) that loops to itself on the n -tuple (0 , . . . ,
0) and transitions tostate q on ( , . . . , p to µ ( p, q ) on (0 , . . . , ECIDABILITY FOR STURMIAN WORDS 11 (Step 3) For every pair p, q of states of A for which p has a run to q on a word of the form(0 , . . . , m ( , . . . , m , we add a transition from state p to a new state ν ( p, q ) on ( , . . . , q , we create a copy ofthe transition that starts at state ν ( p, q ) instead. If any original run from state p to state q passes through a final state, we make ν ( p, q ) a final state.(Step 4) Denote the resulting automaton by A ′ and its set of states by Q ′ .We now show that L ( A ′ ) is the zero-closure of X .We first show that the zero-closure is contained in L ( A ′ ). Let v ∈ X and w ∈ R besuch that α ( v ) = α ( w ). Let b = b b . . . , c = c c ∈ ( { , } ∗ ) ω such that C ( b ) = v and C ( c ) = w . Since α ( v ) = α ( w ), we have that [ b i ] = [ c i ] for i ∈ N . Therefore, for each i ∈ N , the words b i and c i only differ by trailing zeroes. Let s = s s · · · ∈ Q ω be anaccepting run of v on A . We now transfer this run into an accepting run s ′ = s ′ s ′ . . . of w on A ′ . For i ∈ N , let y ( i ) be the position of the i -th ( , . . . , v and let z ( i ) be theposition of the i -th ( , . . . , w . For each i ∈ N , we define a sequence s ′ z ( i )+1 . . . s ′ z ( i +1) of states of A ′ as follows:(1) If | c i | = | b i | , then c i = b i . We set s ′ z ( i )+1 . . . s ′ z ( i +1) := s y ( i )+1 . . . s y ( i +1) . (2) If | c i | > | b i | , then c i = b i (0 , . . . , | c i |−| b i | . We set s ′ z ( i )+1 . . . s ′ z ( i +1) := s y ( i )+1 . . . s y ( i +1) − µ ( s y ( i +1) − , s y ( i +1) ) . . . µ ( s y ( i +1) − , s y ( i +1) | {z } ( | c i |−| b i | )-times s y ( i +1) Thus the new run follows the old run up to s y ( i +1) − and then transitions to one ofthe newly added states in the Step 2. It loops on (0 , . . . ,
0) for | c i | − | b i | − s y ( i +1) .(3) If | c i | < | b i | , then b i = c i (0 , . . . , | b i |−| c i | . We set s ′ z ( i )+1 . . . s ′ z ( i +1) := s y ( i )+1 . . . s y ( i )+ | c i | ν ( s y ( i )+ | c i | , s y ( i +1) )The new run utilizes one of the newly added ( , . . . , s ′ is an accepting run of w on A ′ .We now show that L ( A ′ ) is contained in the zero-closure of X . We prove that the onlyaccepting runs on A ′ are based on accepting runs on A with trailing zeroes either addedor removed. Let w = w w · · · ∈ L ( A ′ ) and let c = c c · · · ∈ ( { , } ∗ ) ω be such that C ( c ) = w . Let s ′ = s ′ s ′ · · · ∈ Q ′ ω be an accepting run of w on A ′ . We construct v ∈ X and a run s = s s · · · ∈ Q ω of w on A such that α ( v ) = α ( w ) and s is an accepting run ECIDABILITY FOR STURMIAN WORDS 12 of v . We start by setting v := w w . . . and s := s ′ s ′ . . . For each i ∈ N , we replace w i in v and s ′ i in s as follows:(1) If s ′ i ∈ Q , then we make no changes to s ′ i and w i .(2) If s ′ i = µ ( p, q ) for some p, q ∈ Q , we delete the s ′ i in s and delete w i in v .(3) If s i = ν ( p, q ) for some p, q ∈ Q , then we replace(a) s ′ i by a run t = t . . . t n +1 of (0 , . . . , n ( , ..., p to q , and(b) w i by (0 , . . . , n ( , ..., ν ( p, q ) is a final state of A ′ , we choose t such that it passed through a finalstate of A .It is clear that the resulting s is in Q ω . The reader can check s is an accepting run of v on A and that α ( v ) = α ( w ). Thus w is in the zero-closure of X . (cid:3) Lemma 3.
The set { ( w , w ) ∈ R : w ∼ w and α ( w ) < α ( w ) } is ω -regular.Proof. Let w , w ∈ R be such that w ∼ w . By Fact 5 we have that α ( w ) < α ( w ) ifonly C − ( w ) < alex, C − ( w ). Thus ω -regularity follows from Fact 10. (cid:3) Lemma 4.
Let a ∈ [0 , be a quadratic irrational. Then { w ∈ R : α ( w ) = a } is ω -regular.Proof. The continued fraction expansion of a is eventually periodic. Thus there is aneventually periodic u ∈ ( { , } ∗ ) ω such that C ( u ) is a a . The singleton set containing an eventually periodic string is ω -regular. Itremains to expand this set to contain all representations via Lemma 2. (cid:3) Lemma 5.
The set { w ∈ R : α ( w ) < } is ω -regular.Proof. Let α ( w ) = [0; a , a , . . . ]. It is easy to see that α ( w ) < if and only if a > a = 1. The set of w ∈ R for which this true is just R \ Y ,where Y ⊆ Σ ω is given by the regular expression ∗ ( ∪ ∗ ) ω . (cid:3) We now extend the
Definition 3.
Let v, w ∈ (Σ ) ω , let x = x x x · · · ∈ N ω and let b = b b b · · · ∈ ( { , } ∗ ) ω be such that w = C ( b ) and [ b i ] = x i for each i . • For N ∈ N , we say that w is a - v -Ostrowski representation of X if v and w are aligned and x is an α ( v ) -Ostrowski representation of N . ECIDABILITY FOR STURMIAN WORDS 13 • For c ∈ I α ( v ) , we say that w is a - v -Ostrowski representation of c if v and w are aligned and x is an α ( v ) -Ostrowski representation of c .We denote by A v the set of all words w ∈ Σ ω such that w is the - v -Ostrowski represen-tation of some c ∈ I α ( v ) , and similarly, by A fin v the set of all words w ∈ Σ ω such that w is the - v -Ostrowski representation of some N ∈ N . Lemma 6.
The following sets are ω -regular:(1) A fin := { ( v, w ) : v ∈ R, w ∈ A fin v } ,(2) A := { ( v, w ) : v ∈ R, w ∈ A v } . Moreover, A fin ⊆ A .Proof. The statement that A fin ⊆ A , follows immediately from the definitions of A fin and A and Fact 8. It is left to establish the ω -regularity of the two sets.For (1): Let B ⊇ A fin be the set of all pairs ( v, w ) such that v ∈ R and v ∼ w. Note that B is ω -regular. Let ( v, w ) ∈ B . Since v and w have infinitely many a = a a . . . , b = b b · · · ∈ ( { , } ∗ ) ω such that C ( a ) = v , C ( b ) = w and | a i | = | b i | for each i ∈ N . Then by Fact 6, ( v, w ) ∈ A fin if and only if(a) b has finitely many 1 characters;(b) b < colex a ;(c) b i ≤ colex a i for all i > b i = a i , then b i − = 0.It is easy to check that all four conditions are ω -regular.For (2): As above, let ( v, w ) ∈ B . Since v and w have infinitely many a = a a . . . , b = b b · · · ∈ ( { , } ∗ ) ω such that C ( a ) = v , C ( b ) = w and | a i | = | b i | for each i ∈ N . Then by Fact 7, ( v, w ) ∈ A if and only if(e) b < colex a ;(f) b i ≤ colex a i for all i > b i = a i , then b i − = 0;(h) b i = a i for infinitely many odd i .Again, it is easy to see that all for conditions are ω -regular. (cid:3) Definition 4.
Let v ∈ R . We define Z v : A fin v → N to be the function that maps w tothe natural number whose - v -Ostrowski representation is w .Similarly, we define O v : A v → I α ( v ) to be the function that maps w to the real numberwhose - v -Ostrowski representation is w . Lemma 7.
Let v ∈ R . Then Z v : A fin v → N and O v : A v → I α ( v ) are bijective.Proof. We first consider injectivity. By Fact 6 and Fact 7 a number in N or in I α ( v ) only has one α ( v )-Ostrowski representation. So we need only explain why such a rep-resentation will only have one encoding in A fin v (respectively A v ). This follows from the ECIDABILITY FOR STURMIAN WORDS 14 uniqueness of binary representations up to the length of the representation, and fromthe fact that the requirement of having the v determines thelength of each binary-encoded coefficient.For surjectivity we need only explain why an α ( v )-Ostrowski representation can alwaysbe encoded into a string in A fin v (respectively A v ). It suffices to show that the requirementof having the v will never result in needing to fit the binaryencoding of a number into too few characters, i.e. that it will never result in having toencode a natural number n in binary in fewer than 1 + ⌊ log n ⌋ characters. Since thefunction 1 + ⌊ log n ⌋ is monotone increasing, we can encode any natural number below n in k characters if we can encode n in binary in k characters. However, by Fact 6 and Fact7, the coefficients in an α ( v )-Ostrowski representation never exceed the correspondingcoefficients in the continued fraction for α ( v ), i.e. b n ≤ a n . (cid:3) Definition 5.
Let v ∈ R . We write v for Z − v (0) , and v for Z − v (1) . Lemma 8.
The relations ∗ = { ( v, v ) : v ∈ R } and ∗ = { ( v, v ) : v ∈ R } are ω -regular.Proof. Recognizing ∗ is trivial, as the Ostrowski representations of 0 are of the form0 . . . α . Thus ∗ is just the relation { ( v, w ) : v ∈ R, w is v with all 1 bits replaced by 0 bits } . This is clearly ω -regular.We now consider ∗ . Let α = [0; a , a , . . . ] be an irrational number. If a >
1, the α -Ostrowski representations of 1 are of the form 10 . . .
0. If a = 1, the α -Ostrowskirepresentations of 1 are of the form 010 . . .
0. Thus, in order to recognize ∗ , we onlyneed to be able to recognize if a number in binary representation is 0, 1, or greater than1. Of course, this is easily done on a B¨uchi automaton. (cid:3) Lemma 9.
Let s ∈ A fin v . Then α ( v ) Z v ( s ) − O v ( s ) ∈ Z and O v ( v ) = ( α ( v ) if α ( v ) < ; α ( v ) − otherwise.Proof. By Fact 8, O v ( s ) = f α ( α ( v ) Z v ( s )). Thus α ( v ) Z v ( s ) − O v ( s ) = α ( v ) Z v ( s ) − f α ( α ( v ) Z v ( s )) , which is an integer by the definition of f . By the definition of v and by Fact 8, we know O v ( v ) = f α ( α ) is the unique element of I α ( v ) that differs from α ( v ) by an integer. If0 < α ( v ) < , then − α ( v ) < α ( v ) < − α ( v ) . ECIDABILITY FOR STURMIAN WORDS 15
Thus in this case, α ( v ) ∈ I α ( v ) and O v ( v ) = α ( v ). When < α ( v ) <
1, then − α < α − < − α. Therefore α ( v ) − ∈ I α ( v ) and O v ( v ) = α ( v ) − (cid:3) Lemma 10.
The following sets are ω -regular:(1) ≺ fin := { ( v, s, t ) ∈ Σ : s, t ∈ A fin v ∧ Z v ( s ) < Z v ( t ) } ,(2) ≺ := { ( v, s, t ) ∈ Σ : s, t ∈ A v ∧ O v ( s ) < O v ( t ) } .Proof. For (1), first recall that for
X, Y ∈ N and α irrational, we have X < Y if and only ifthe α -Ostrowski representation of X is co-lexicographically smaller than the α -Ostrowskirepresentation of Y . Therefore, we need only recognize co-lexicographic ordering on thelist of coefficients, with each coefficient ordered according to binary. This follows imme-diately from Fact 10(1).For (2), note that by Fact 9 the usual order on real numbers corresponds to the al-ternative lexicographic ordering on real Ostrowski representations. Therefore, we needonly recognize the alternating lexicographic ordering on the list of coefficients, with eachcoefficient ordered according to binary. This follows immediately from Fact 10(2). (cid:3) We consider R n as a topological space using the usual order topology. For X ⊆ R n , wedenote its topological closure by X . Corollary 1.
Let W ⊆ (Σ n +1 ) ∗ be such that(1) W ⊆ { ( v, s , . . . , s n ) ∈ (Σ n +1 ) ∗ : s , . . . , s n ∈ A v } , and(2) W is ω -regular.Then the following set is also ω -regular: W := { ( v, s , . . . , s n ) ∈ (Σ n +1 ) ∗ : s , . . . , s n ∈ A v ∧ ( O v ( s ) , . . . , O v ( s n )) ∈ O ( W v ) } . Proof.
Let ( v, s , . . . , s n ) ∈ (Σ n +1 ) ∗ be such that s , . . . , s n ∈ A v . Let X i = O v ( s i ).By the definition of the topological closure, we have that ( X , . . . , X n ) ∈ O ( W v ) if andonly if for all Y , . . . Y n , Z , . . . , Z n ∈ R with Y i < X i < Z i for i = 1 , . . . , n there are X ′ = ( X ′ , . . . , X ′ n ) ∈ O ( W v ) such that Y i < X ′ i < Z i for i = 1 , . . . , n . Thus by Lemma10, ( v, s , . . . , s n ) ∈ W if and only if for all t , . . . t n , u , . . . , u n ∈ A v with t i ≺ s i ≺ u i ,there are s ′ = ( s ′ , . . . , s ′ n ) ∈ W v such that t i ≺ s ′ i ≺ Z i for i = 1 , . . . , n . The lattercondition is ω -regular by Fact 2. (cid:3) Recognizing addition in Ostrowski numeration systems
The key to the rest of this paper is a general automaton for recognizing addition ofOstrowski representations uniformly. We will prove the following.
ECIDABILITY FOR STURMIAN WORDS 16
Theorem 1.
The set ⊕ fin := { ( v, s , s , s ) : s , s , s ∈ A fin v ∧ Z v ( s ) + Z v ( s ) = Z v ( s ) } is ω -regular.Proof. In [2, Section 3] the authors generate an automaton A over the alphabet N suchthat a finite word ( d , x , y , z )( d , x , y , z ) ... ( d m , x m , y m , z m ) ∈ ( N ) ∗ is accepted by A if and only if there are d m +1 , · · · ∈ N and x, y, z ∈ N such that for α = [0; d , d , . . . ] • [ x x . . . x m ] α = x , • [ y y . . . y m ] α = y , • [ z z . . . z m ] α = z , and • x + y = z .We now describe how to adjust the the automaton A for our purposes. The inputalphabet will be Σ instead of N . The new automaton will take four inputs w, s , s , s ,where s , s , s ∈ A fin w . We can construct this automaton as follows:(1) Begin with the automaton A from [2].(2) Add an initial state that transitions to the original start state on ( , , , w, s , s , s in binary. As an example,one of the transitions in Figure 3 of [2] is given as “ − d i + 1,” meaning that itrepresents all cases where, letting w i , s i , s i , s i be the i th letter of w, s , s , s respectively, we have s i − s i − s i = − w i + 1. This is an affine and hence anautomatic relation. This it can be recognized by a sub-automaton.(4) The accept states in the resulting automaton are precisely the accept states fromthe original automaton.The resulting automaton recognizes ⊕ fin . (cid:3) The automaton constructed above has 82 states. Using our software Pecan, we canformally check that this automaton recognizes the set in Theorem 1. Following a strategyalready used in Mousavi, Schaeffer, and Shallit [19, Remark 2.1] we check that our addersatisfies the standard recursive definition of addition on the natural numbers; that is forall x, y ∈ N y = ys ( x ) + y = s ( x + y )where x, y ∈ N and s ( x ) denotes the successor of x in N . The successor function on N can be defined using only < as follows: s ( x ) = y if and only if ( x < y ) ∧ ( ∀ z ( z ≤ x ) ∨ ( z ≥ y )) . Thus in Pecan we define bco_succ(a,x,y) as ECIDABILITY FOR STURMIAN WORDS 17 bco_succ (a ,x , y ) : = b c o _ v a l i d(a , x ) ∧ b c o _ v a l i d(a , y ) ∧ bco_leq (x , y ) ∧ ¬ bco_eq (x , y ) ∧ ∀ z . b c o _ v a l i d(a , z ) = > ( bco_leq (z , x ) ∨ bco_leq (y , z )) where • bco_eq recognizes { ( x, y ) : x = y }• bco_leq recognizes { ( x, y ) : x ≤ colex y }• bco_valid recognizes A fin .We now confirm that our adder satisfies the above equations using the following Pecancode: Let x ,y , z be o s t r o w s k i( a ) .Theorem ( " Addition base case (0 + y = y ). " , {∀ a . ∀ x ,y , z . bco_zero ( x ) = > ( b c o _ a d d e r(a ,x ,y , z ) ⇔ bco_eq (y , z )) } ) .Theorem ( " Addition i n d u c t i v e case ( s ( x ) + y = s ( x + y )). " , {∀ a . ∀ x ,y ,z ,u , v . ( bco_succ (a ,u , x ) ∧ bco_succ (a ,v , z ))= > ( b c o _ a d d e r(a ,x ,y , z ) ⇔ b c o _ a d d e r(a ,u ,y , v )) } ) . In the above code • bco_adder recognizes ⊕ fin , • bco_zero recognizes ∗ , and • bco_succ recognizes { ( v, x, y ) : x, y ∈ A fin v , Z v ( x ) + 1 = Z v ( y ) } .Pecan confirms both statements are true. This proves Theorem 1 modulo correctness ofPecan and the correctness of the implementations of the automata for bco_eq , bco_leq , bco_valid and bco_zero . For more details about Pecan, see Section 7.We construct an automaton for addition modulo 1 on I α . Lemma 11.
The set ⊕ := { ( v, s , s , s ) : s , s , s ∈ A v ∧ O v ( s ) + O v ( s ) ≡ O v ( s ) (mod 1) } is ω -regular. Moreover, ⊕ fin ⊆ ⊕ .Proof. First, let v, s , s , s be such that s , s , s ∈ A fin v . We claim that on this domain,( s , s , s ) ∈ ⊕ v if and only if ( s , s , s ) ∈ ⊕ fin v . By Fact 8 we know that for all s ∈ A fin v (3) α ( v ) Z v ( s ) − O v ( s ) ≡ . Let ( s , s , s ) ∈ ⊕ fin v . Then by (3) O v ( s ) ≡ α ( v ) Z v ( s ) (mod 1)= α ( v ) Z v ( s ) + α ( v ) Z v ( s ) ≡ O v ( s ) + O v ( s ) (mod 1) . ECIDABILITY FOR STURMIAN WORDS 18
Thus ( s , s , s ) ∈ ⊕ v .Now suppose that ( s , s , s ) ∈ ⊕ v . Then by (3) and the definition of ⊕ α ( v ) Z ( s ) + α ( v ) Z ( s ) ≡ α ( v ) Z ( s ) (mod 1) . However, then α ( v )( Z ( s ) + Z ( s ) − Z ( s )) ≡ . Since α is irrational, we obtain Z ( s ) + Z ( s ) − Z ( s ) = 0. Thus ( s , s , s ) ∈ ⊕ fin v . Thus for each v ∈ R , we have(4) ⊕ v ∩ ( A fin v ) = ⊕ fin v . Let v ∈ R . We observe that the set O v ( A fin v ) is dense in O v ( A v ). Since addition iscontinuous, it follows from (4) that O v ( ⊕ fin v ) is dense in O v ( ⊕ v ). Since the graph of acontinuous function is closed, the topological closure of O v ( ⊕ fin v ) is O v ( ⊕ v ). Thus ⊕ is ω -regular by Corollary 1. (cid:3) Lemma 12.
Let v ∈ R , and let t , t , t ∈ A v be such that t ⊕ v t = t . Then O v ( t ) + O v ( t ) = O v ( t ) + 1 if v ≺ v t and t ≺ v t ; O v ( t ) − if t ≺ v v and t ≺ v t ; O v ( t ) otherwise.Proof. For ease of notation, let α = α ( v ), and set x i = O v ( t i ) for i = 1 , ,
3. By definitionof ⊕ v , we have that x , x , x ∈ I α ( v ) with x + x ≡ x (mod 1). Note that t i ≺ v t j ifand only if x i < x j .We first consider the case that 0 < x and x < x . Thus x + x > − α . Note that − α = 1 − α − < x + x − < (1 − α ) + (1 − α ) − − α < − α. Thus x + x − ∈ I α and x = x + x − x < x < x . Then x + x < − α , and therefore1 − α > x + x + 1 ≥ ( − α ) + ( − α ) + 1 = (1 − α ) − α > − α. Thus x + x + 1 ∈ I α and hence x = x + x + 1.Finally consider that 0 , x are ordered the same way as x , x . Since x + x ≡ x (mod 1), we know that | x − | and | x − x | differ by an integer k . If k >
0, wouldimply that one of these differences is at least 1, which is impossible within the interval I α . Therefore x − x − x and hence x = x + x . (cid:3) For i ∈ N , set i v := v ⊕ · · · ⊕ v | {z } i times ECIDABILITY FOR STURMIAN WORDS 19
Lemma 13.
The set F := { ( v, s ) ∈ A fin : Z v ( s ) α ( v ) < } is ω -regular, and for each ( v, s ) ∈ F O v ( s ) = ( α ( v ) Z v ( s ) if ( α ( v ) + 1) Z v ( s ) < ; α ( v ) Z v ( s ) − otherwise.Proof. By Lemma 5, we can first consider the case that α ( v ) > . In this situation, F v is just the set { v , v } , and hence obviously ω -regular.Now assume that α ( v ) < . Let w be the ≺ fin v -minimal element of A fin v with w ≺ v v . Wewill show that F v = { s ∈ A fin v : s (cid:22) fin v w } . Then ω -regularity of F follows then immediately.Let n ∈ N be maximal such that nα ( v ) <
1. It is enough to show that Z v ( w ) = n .By Lemma 9, O v ( v ) = α ( v ). Hence 1 α ( v ) , α ( v ) , . . . , ( n − α ( v ) ∈ I α ( v ) , but nα ( v ) > − α ( v ). Then for i = 1 , . . . , n − O v ( i v ) = iα ( v ) , O v ( n v ) = nα ( v ) − < . So i v (cid:23) v for i = 1 , . . . , n , but n v ≺ v . Thus n v = w and Z v ( w ) = n . (cid:3) Lemma 14.
Let v ∈ R and t ∈ A fin v . Then there is an s ∈ F v and t ′ ∈ A fin v such that t ′ (cid:22) v and t = t ′ ⊕ v s . In particular, A fin v = { t ∈ A fin v : t (cid:22) v v } ⊕ v F v . Proof.
Let n ∈ N be maximal such that nα <
1. Let t ∈ A fin v . We need to find s ∈ A fin v and u ∈ F v such that t = s ⊕ fin v v . We can easily reduce to the case that t ≻ v and Z v ( t ) > n .Let i ∈ { , . . . , n } be such that 0 ≥ O v ( t ) − iα > − α . Then let s ∈ A fin v be such that Z v ( s ) = Z v ( t ) − i . Note t = s ⊕ fin v i v . Thus we only need to show that s (cid:22) v .To see this, observe that by Lemma 13 O v ( s ) + αi ≡ O v ( s ) + O v ( i v ) ≡ O v ( t ) (mod 1) . Since O v ( t ) − iα ( v ) ∈ I α ( v ) , we know that O v ( s ) = O v ( t ) − iα ( v ) ≤
0. Therefore O v ( s ) (cid:22) v . (cid:3) The uniform ω -regularity of R α In this section, we turn to the question of the decidability of the logical first-ordertheory of R α . Recall that R α := ( R , <, + , Z , α Z ) for α ∈ R . The main result of thissection is the following: ECIDABILITY FOR STURMIAN WORDS 20
Theorem 2.
There is a uniform family of ω -regular structures ( D v ) v ∈ R such that foreach v ∈ R D v ≃ R α ( v ) . The proof of Theorem 2 is a uniform version of the argument given in [12] that also fixessome minor errors of the original proof. By Lemma 10 and Theorem 11, we already knowthat Z v : ( A fin v , ≺ fin v , ⊕ fin v ) → ( N , <, +)is an isomorphism for every v ∈ R . As our eventual goal also requires us to define theset α N , it turns out to be much more natural to instead use the isomorphism α ( v ) Z v : ( A fin v , ≺ fin v , ⊕ fin v ) → ( α ( v ) N , <, +) . Lemma 15.
There is a uniform family of ω -regular structures ( C a ) a ∈ R such that for each a ∈ R C a ≃ ([ − α ( a ) , ∞ ) , <, + , N , α ( a ) N ) . Proof.
Define B ⊆ A fin to be { ( v, s ) ∈ A fin : s (cid:22) v v } . Clearly, B is ω -regular. We nowdefine ≺ B and ⊕ B such that for each v ∈ R , the structure ( B v , ≺ Bv , ⊕ Bv ) is isomorphic to( N , <, +) under the map g v defined as g v ( s ) = α ( v ) Z v ( s ) − O v ( s ).We define ≺ B to be the restriction of ≺ fin to B . That is, for ( v, s ) , ( v, s ) ∈ B we have( v, s ) ≺ B ( v, s ) if and only if ( v, s ) ≺ fin ( v, s ) . It is immediate that ≺ B is ω -regular, since both B and ≺ fin are ω -regular.We define ⊕ B as follows:( v, s ) ⊕ B ( v, s ) = ( ( v, s ⊕ v s ) if s ⊕ fin v s (cid:22) v v ;( v, s ⊕ v s ⊕ v v ) otherwise.We now show that g v ( s ⊕ Bv s ) = g v ( s ) + g v ( s ) for every s , s ∈ B v .Name Definition A { ( v, w ) : v ∈ R, w is a v -Ostrowski representation } A fin { ( v, w ) : v ∈ R, w is a v -Ostrowski representation and eventually 0 } B { ( v, s ) ∈ A fin : s (cid:22) v v } C { ( v, s, t ) : ( v, s ) ∈ B ∧ ( v, t ) ∈ A } Table 1.
Definitions of sets used in the proof
ECIDABILITY FOR STURMIAN WORDS 21
Let ( v, s ) , ( v, s ) ∈ B . We first consider the case that s ⊕ v s (cid:22) v v . By Lemma 12, O v ( s ⊕ v s ) = O v ( s ) + O v ( s ). Thus g v ( s ⊕ Bv s ) = g v ( s ⊕ v s )= α ( v ) Z v ( s ⊕ v s ) − O v ( s ⊕ v s )= αZ v ( s ) + αZ v ( s ) − O v ( s ) − O v ( s )= g v ( s ) + g v ( s ) . Now suppose that s ⊕ v s ≻ v v . Since − α ( v ) ≤ O v ( s ) , O v ( s ) ≤
0, we get that1 − α ( v ) > O v ( s ) + O v ( s ) + α ( v ) ≥ − α ( v ) . Thus by Lemma 9, O v ( s ⊕ v s ⊕ v v ) = O v ( s ) + O v ( s ) + α ( v ) . We obtain g v ( s ⊕ Bv s ) = g v ( s ⊕ v s ⊕ v v )= αZ v ( s ⊕ v s ⊕ v v ) − O v ( s ⊕ v s ⊕ v v )= α ( v ) (cid:0) Z v ( s ) + Z v ( s ) (cid:1) + α ( v ) − O v ( s ) − O v ( s ) − α ( v )= g v ( s ) + g v ( s ) . Since s ≺ v s if and only if Z v ( s ) < Z v ( s ), we get that g v is an isomorphism between( B v , ≺ Bv , ⊕ Bv ) and ( N , <, +).Let C be defined by { ( v, s, t ) ∈ (Σ ω ) : ( v, s ) ∈ B ∧ ( v, t ) ∈ A } . Clearly C is ω -regular. Let T v : C v → [ − α ( v ) , ∞ ) ⊆ R map ( s, t ) g v ( s ) + O v ( t ).Note that T v is bijective for each v ∈ R , since every real number decomposes uniquelyinto a sum n + y , where n ∈ Z and y ∈ I v .We define an ordering ≺ Cv on C v lexicographically: ( s , t ) ≺ Cv ( s , t ) if either • s ≺ Bv s , or Map Domain Codomain α R Irr O v A v I α ( v ) Z v A finv N g v := α ( v ) Z v − O v B v N T v := g v + O v C v [ − α ( v ) , ∞ ) ⊆ R Table 2.
A list of the maps and their domains and codomains.
ECIDABILITY FOR STURMIAN WORDS 22 • s = s and t ≺ v t .The set { ( v, s , t , s , t ) : ( s , t ) , ( s , t ) ∈ C v ∧ ( s , t ) ≺ Cv ( s , t ) } is ω -regular. We can easily check that ( s , t ) ≺ Cv ( s , t ) if and only if T v ( s , t ) We just observe that ([ − α, ∞ ) , <, + , N , α N ) defines (in a matteruniform in α ) an isomorphic copy of R α . Now apply Lemma 15. (cid:3) Decidability results We are now ready to prove the results listed in the introduction. We first recall somenotation. Let L m be the signature of the first-order structure ( R , <, + , Z ), and let L m,a bethe extension of L m by a unary predicate. For α ∈ R > , let R α denote the L m,a -structure( R , <, + , Z , α Z ). For each L m,a -sentence ϕ , we set R ϕ := { v ∈ R : R α ( v ) | = ϕ } . Theorem 3. Let ϕ be an L m,a -sentence. Then R ϕ is ω -regular.Proof. By Theorem 2 there is a uniform family of ω -regular structures ( D v ) v ∈ R such thatsuch that for each v ∈ R D v ≃ R α ( v ) . Then R ϕ = { v ∈ R : D v | = ϕ } . This set is ω -regular by Fact 4. (cid:3) Let N = ( R ; ( R ϕ ) ϕ , ( X ) X ⊆ R n ω -regular ) be the relational structure on R with the relations R ϕ for every L -sentences ϕ and X ⊆ R n ω -regular. Because N is an ω -regular structure,we obtain the following decidability result. Corollary 2. The theory of N is decidable. Recall that Irr := (0 , \ Q . Definition 6. Let X ⊆ Irr n . Let X R be defined by X R := { ( v , . . . , v n ) ∈ R n : v ∼ v ∼ · · · ∼ v n ∧ ( α ( v ) , . . . , α ( v n )) ∈ X } We say X is recognizable modulo ∼ if X R is ω -regular. Lemma 16. The collection of sets recognizable modulo ∼ is closed under Boolean op-erations and coordinate projections.Proof. Let X, Y ⊆ Irr be recognizable modulo ∼ . It is clear that ( X ∩ Y ) R = X R ∩ Y R .Thus X ∩ Y is recognizable modulo ∼ . Let X c be Irr n \ X, the complement of X . Forease of notation, set E := { ( v , . . . , v n ) ∈ R n : v ∼ v ∼ · · · ∼ v n } ECIDABILITY FOR STURMIAN WORDS 24 Then( X c ) R = { ( v , . . . , v n ) ∈ R n : v ∼ v ∼ · · · ∼ v n ∧ ( α ( v ) , . . . , α ( v n )) / ∈ X } = E ∩ { ( v , . . . , v n ) ∈ R n : ( α ( v ) , . . . , α ( v n )) / ∈ X } = E ∩ { ( v , . . . , v n ) ∈ R n : ( α ( v ) , . . . , α ( v n )) / ∈ X ∨ ¬ ( v ∼ v ∼ · · · ∼ v n ) } = E ∩ ( R n \ X R ) . This set is ω -regular, and hence X c is recognizable modulo ∼ .For coordinate projections, it is enough to consider projections onto the first n − n > π be the coordinate projection onto first n − π ( X ) = { ( α , . . . , α n − ) ∈ R n − : ∃ α n ∈ R ( α , . . . , α n − , α n ) ∈ X } . Thus π ( X ) R is equal to { ( v , . . . , v n − ) ∈ R n − : v ∼ · · · ∼ v n − ∧ ∃ α n : ( α ( v ) , . . . , α ( v n − ) , α n ) ∈ X } Note that v α ( v ) is a surjection R ։ (0 , \ Q . Thus π ( X ) R is also equal to: { ( v , . . . , v n − ) ∈ R n − : v ∼ · · · ∼ v n − ∧ ∃ v n : ( α ( v ) , . . . , α ( v n )) ∈ X } . Unfortunately, this set is not necessarily equal to π ( X R ). There might be tuples( v , . . . , v n − ) such that no v n can be found, because it would require more bits in oneof its coefficients than v , . . . , v n − have for that coefficient. But π ( X R ) always contains some representation of α ( v ) , . . . , α ( v n − ) with the appropriate number of digits. We needonly ensure that removal of trailing zeroes does not affect membership in the language.Thus π ( X ) R is just the zero-closure of π ( X R ). Thus π ( X ) R is ω -regular by Lemma 2. (cid:3) Theorem 4. Let X , . . . , X n be recognizable modulo ∼ by B¨uchi automata A , . . . , A n ,and let Q be the structure ( Irr ; X , . . . , X n ) . Then the theory of Q is decidable.Proof. By Lemma 16 every set definable in Q is recognizable modulo ∼ . Moreover,for each definable set Y the automaton that recognizes Y modulo ∼ , can be computedfrom the automata A , . . . , A n . Let ψ be a sentence in the signature of Q . Without lossof generality, we can assume that ψ is of the form ∃ x χ ( x ) . Set Z := { a ∈ Irr n : Q | = χ (a) } . Observe that Q | = ψ if and only if Z is non-empty. Note for every a ∈ Irr n there are v , . . . , v n ∈ R such that v ∼ v ∼ · · · ∼ v n and ( α ( v ) , . . . , α ( v n )) = a . Thus Z isnon-empty if and only if the { ( v , . . . , v n ) ∈ R n : v ∼ v ∼ · · · ∼ v n ∧ ( α ( v ) , . . . , α ( v n )) ∈ Z } is non-empty. Thus to decide whether Q | = ψ , we first compute the automaton B thatrecognizes Z modulo ∼ , and then check whether the automaton accepts any word. (cid:3) ECIDABILITY FOR STURMIAN WORDS 25 We are now ready to prove Theorem C; that is decidability of the theory of the structure M = ( Irr , <, (M ϕ ) ϕ , (q) q ∈ Irr quad ) , where M ϕ is defined for each L m,a -formula as M ϕ := { α ∈ Irr : R α | = ϕ } . Proof of Theorem C. We just need to check that the relations we are adding are allrecognizable modulo ∼ . By Lemma 3 the ordering < is recognizable modulo ∼ . ByLemma 4, the singleton { q } is is recognizable modulo ∼ for every q ∈ Irr quad . Since M ϕ = α ( R ϕ ), recognizability of M ϕ modulo ∼ follows from Theorem 3. (cid:3) Of course, we can add to M a predicate for every subset of Irr n that is recognizablemodulo ∼ , and preserve the decidability of the theory. The reader can check thatexamples of subsets of Irr recognizable modulo ∼ are the set of all α ∈ Irr such thatthe terms in the continued fraction expansion of α are powers of 2, the set of all α ∈ Irr such that the terms in the continued fraction expansion of α are in (or are not in) somefixed finite set, and the set of all α ∈ Irr such that all even (or odd) terms in theircontinued fraction expansion are 1.7. Automatically Proving Theorems about Sturmian Words We have created an automatic theorem-prover based on the ideas and the decisionalgorithms outlined above, called Pecan [20]. We use Pecan to provide new proofs ofsome known results about characteristic Sturmian words.7.1. Classical theorems. We begin by giving automated proofs for several classicalresult result about Sturmian words. We refer the reader to [17] for more informationand traditional proofs of these results. Let us first recall the definition of palindromes.We denote by w R the reversal of a word w . We say a word w is a palindrome if w = w R .In the following, we assume that a ∈ R and i, j, k, n, m, p, s are a -Ostrowski representa-tions. This can be expressed in Pecan as Let a ∈ b c o _ s t a n d a r d.Let i ,j ,k ,n ,m ,p , s ∈ o s t r o w s k i( a ) . We write c a, ( i ) as $ C[i] in Pecan. Theorem 5. Characteristic Sturmian words are balanced and aperiodic.Proof. To show that a characteristic Sturmian word c α, is balanced, note that it issufficient to show that there is no palindrome w in c α, such that 0 w w c α, (see [17, Proposition 2.1.3]). We encode this in Pecan as follows. The pred-icate palindrome(a,i,n) is true when c a, [ i..i + n ] = c a, [ i..i + n ] R . The predicate factor_len(a,i,n,j) is true when c a, [ i..i + n ] = c a, [ j..j + n ]. ECIDABILITY FOR STURMIAN WORDS 26 Theorem ( " Balanced " , {∀ a . ¬ ( ∃ i , n . p a l i n d r o m e(a ,i , n ) ∧ ( ∃ j . f a c t o r _ l e n(a ,i ,n , j ) ∧ $ C [ j - 1] = 0 ∧ $ C [ j + n ] = 0) ∧ ( ∃ k . f a c t o r _ l e n(a ,i ,n , k ) ∧ $ C [ k - 1] = 1 ∧ $ C [ k + n ] = 1)) } ) . Pecan takes seconds to prove the theorem.Encoding the property that a word is eventually periodic is straightforward: e v e n t u a l l y _ p e r i o d i c (a , p ) : =p > 0 ∧ ∃ n . ∀ i . if i > n then $ C [ i ] = $ C [ i + p ] The resulting automaton has 4941 states and 35776 edges, and takes seconds tobuild. We then state the theorem in Pecan, which confirms the theorem is true. Theorem ( " A p e r i o d i c" , {∀ a . ∀ p . if p > 0 then ¬ e v e n t u a l l y _ p e r i o d i c (a , p ) } ) . (cid:3) A factor w of a word u right special if both w w u . Theorem 6. For each natural number n , c α, contains a unique right special factor oflength n , and this factor is c α, [1 ..n + 1] R .Proof. We first define right special factors, as above. Recall that factor_len(a,i,n,j) checks that c α, [ i..i + n ] = c α, [ j..j + n ]. r i g h t _ s p e c i a l _ f a c t o r (a ,i , n ) : =( ∃ j . f a c t o r _ l e n(a ,i ,n , j ) ∧ $ C [ j + n ] = 0) ∧ ( ∃ k . f a c t o r _ l e n(a ,i ,n , k ) ∧ $ C [ k + n ] = 1) We then define the first right special factor, which is the first occurrence (by in-dex) of the right special factor in the word c α, . This step is purely to reduce the costof checking the theorem: the right_special_factor automaton has 3375 states, but first_right_special_factor has only 112 (it also makes stating the theorem easier). f i r s t _ r i g h t _ s p e c i a l _ f a c t o r (a ,i , n ) : =s p e c i a l _ f a c t o r (a ,i , n ) ∧ ∀ j . if j > 0 ∧ f a c t o r _ l e n(a ,j ,n , i ) then i < = j We then check that each of these right special factors is equal to c α, [1 ..n + 1] R ,which also proves the uniqueness. The predicate reverse_factor(a,i,j,l) checks that c α, [ i..j ] = c α, [ k + 1 ..l + 1] R , where j − i = l − k . Theorem ( " The unique special factor of length n is C [1.. n +1]^ R " , {∀ a . ∀ i , n .if i > 0 ∧ f i r s t _ r i g h t _ s p e c i a l _ f a c t o r (a ,i , n ) thenr e v e r s e _ f a c t o r (a ,i , i +n , n ) ECIDABILITY FOR STURMIAN WORDS 27 } ) . (cid:3) Another characterization of Sturmian words due to Droubay and Pirillo [8, Theorem 5]is that a word is Sturmian if and only if it contains exactly one palindrome of length n if n is even, and exactly two palindromes of length n if n is odd. We prove the forwarddirection below. Theorem 7 ([8, Proposition 6]) . For every n ∈ N , c α, contains exactly one palindromeof length n if n is even, and exactly two palindromes of length n if n is odd.Proof. We begin by defining a predicate defining the location of the first occurrence ofeach length n palindrome in c α, . f i r s t _ p a l i n d r o m e (a , i , n ) : = p a l i n d r o m e(a , i , n ) ∧∀ j . if j > 0 ∧ f a c t o r _ l e n(a ,j ,n , i ) then i < = j The resulting automaton has 247 states and 1281 edges. The following states the theorem,and Pecan proves it in seconds. Theorem ( " " , {∀ a . ∀ n . (if even ( n ) ∧ n > 0 then ∃ i . ∀ k . f i r s t _ p a l i n d r o m e (a ,k , n ) iff i = k ) ∧ (if odd ( n ) then ∃ i , j . i < j ∧ ∀ k . f i r s t _ p a l i n d r o m e (a ,k , n ) iff ( i = k ∨ j = k )) } ) . (cid:3) Antisquares and more. Let w ∈ { , } ∗ . Then we denote by w the { , } -wordobtained by replacing each 1 in w by 0 and each 0 in w by 1.A word w ∈ { , } ∗ is an antisquare if w = vv for some v ∈ { , } ∗ . We define A O : (0 , \ Q → N ∪{∞} to map an irrational α to the maximum order of any antisquarein c α, if such a maximum exists, and to ∞ otherwise. We let A L : (0 , \ Q → N ∪ {∞} map α to the maximum length of any antisquare in c α, if such a maximum exists and ∞ otherwise. Note that A L ( α ) = 2 A O ( α ).A word w ∈ { , } ∗ is an antipalindrome if w = w R . We set A P : (0 , \ Q → N ∪{∞} tobe the map that takes an irrational α to the maximum length of any antipalindrome in c α, if such a maximum, and to ∞ otherwise. We will use Pecan to prove that A O ( α ) , A L ( α )and A P ( α ) are finite for every α . While the quantities A O ( α ), A P ( α ) and A L ( α ) can bearbitrarily large, we prove the new results that the length of the Ostrowski representa-tions of these quantities is bounded, independent of α . ECIDABILITY FOR STURMIAN WORDS 28 Let α ∈ (0 , 1) be irrational and N ∈ N . Let | N | α denote the length of the α -Ostrowskirepresentation of N , that is the index of the last nonzero digit of α -Ostrowski represen-tation of N , or 0 otherwise. Theorem 8. For every irrational α ∈ (0 , (i) | A O ( α ) | α ≤ (ii) | A P ( α ) | α ≤ (iii) | A L ( α ) | α ≤ (iv) A O ( α ) ≤ A P ( α ) ≤ A L ( α ) = 2 A O ( α ) .There are irrational numbers α, β ∈ (0 , such that A O ( α ) = A P ( α ) and A P ( β ) = A L ( β ) .Proof. Using Pecan, we create automata which compute A O , A P , and A L : A O ( α, n ) := has antisquare ( α, n ) ∧ ∀ m. has antisquare ( α, m ) = ⇒ m ≤ nA P ( α, n ) := has antipalindrome ( α, n ) ∧ ∀ m. has antipalindrome ( α, m ) = ⇒ m ≤ nA L ( α, n ) := has antisquare len ( α, n ) ∧ ∀ m. has antisquare len ( α, m ) = ⇒ m ≤ n We build automata recognizing α -Ostrowski representations of at most 4 and 6 nonzerodigits, called has 4 digits ( n ) and has 6 digits ( n ). Then we use Pecan to prove all theparts of the theorem by checking the following statement. Theorem ( " ( i ) , ( ii ) , ( iii ) , and ( iv ) " , {∀ a . h a s _ 4 _ d i g i t s(max antisquare( a )) ∧ h a s _ 4 _ d i g i t s( m a x _ a n t i p a l i n d r o m e ( a )) ∧ h a s _ 6 _ d i g i t s(max antisquare len( a )) ∧ max antisquare( a ) < = m a x _ a n t i p a l i n d r o m e ( a ) ∧ m a x _ a n t i p a l i n d r o m e ( a ) < = max antisquare len( a ) } ) . We also use Pecan to find examples of the equality: when α = [0; 3 , , A O ( α ) = A P ( α ) = 2, and when α = [0; 4 , , A P ( α ) = A L ( α ) = 2. (cid:3) Theorem 9. For every irrational α ∈ (0 , , all antisquares and antipalindromes in c α, are either of the form (01) ∗ or of the form (10) ∗ .Proof. We begin by creating a predicate called is all 01 stating that a subword c α, [ i..i + n ] is of the form (01) ∗ or (10) ∗ . We do this simply stating that c α, [ k ] = c α, [ k + 1] forall k with i ≤ k < i + n − is all 01(a ,i , n ) : = ∀ k . if i < = k ∧ k < i + n - 1 then $ C [ k ] = $ C [ k + 1] We can now directly state both parts of the; Pecan proves both in seconds. Theorem ( " All a n t i s q u a r e s are of the form (01)^* or (10)^* " , {∀ a . ∀ i , n . if antisquare(a ,i , n ) then is all 01(a ,i , n ) } ) . ECIDABILITY FOR STURMIAN WORDS 29 Theorem ( " All a n t i p a l i n d r o m e s are of the form (01)^* or (10)^* " , {∀ a . ∀ i , n . if antipalindrome(a ,i , n ) then is all 01(a ,i , n ) } ) . (cid:3) Least periods of factors of Sturmian words. We now use Pecan to give shortautomatic proofs a result about the least period of factors of characteristic Sturmianwords. A word w is a factor of a word u if there exist words v , v such that u = v wv .The semiconvergents p n,ℓ and q n,ℓ of a continued fraction [0; a , a , . . . ] are defined so that p n,ℓ q n,ℓ = ℓp n − + p n − ℓq n − + q n − for 1 ≤ ℓ < a n . Theorem 10. Let p be the least period of a factor of c α, . Then p is the denominator ofa semiconvergent of a ; that is p = q n,ℓ for some n and ℓ .Proof. We define when a number p is a least period of a factor of c α, as an automaton lp_occurs , as follows: l e a s t _ p e r i o d(a ,p ,i , j ) : = p = min { n : period (a ,n ,i , j ) } l p _ o c c u r s(a , p ) : = ∃ i , j . i > 0 ∧ j > 0 ∧ l e a s t _ p e r i o d(a ,p ,i , j ) It is easy to recognize a -Ostrowski representations of denominators of semiconvergents of a , because they are simply valid representations of the form [0 · · · b ] a , where b is somevalid digit. Theorem ( " " , { ∀ a , p . l p _ o c c u r s(a , p ) = > s e m i c o n v e r g e n t _ d e n o m ( p ) } ) . Pecan proves the theorem in seconds. (cid:3) A word w is called unbordered if the least period of w is | w | . We now are ready toreprove Lemma 8 in Currie and Saari [6]. This is originally due to de Luca and De Luca[7]. Theorem 11. The least period of c α, [ i..j ] is the length of the longest unbordered factorof c α, [ i..j ] .Proof. We have previously defined least periods, so we can easily define unbordered fac-tors. Similarly, it is straightforward to define the longest unbordered subwords of c α, : m a x _ u n b o r d e r e d _ s u b f a c t o r _ l e n (a ,i ,j , n ) : =n = max { m : ∃ k . i < = k ∧ k + n < = j ∧ l e a s t _ p e r i o d(a ,n ,k , k + n ) } Then the theorem we wish to prove is ECIDABILITY FOR STURMIAN WORDS 30 Theorem ( " " , { ∀ a ,i ,j , p . if i > 0 ∧ j > i ∧ p > 0 thenl e a s t _ p e r i o d(a ,p ,i , j ) ⇔ m a x _ u n b o r d e r e d _ s u b f a c t o r _ l e n (a ,i ,j , p ) } ) . Pecan confirms the theorem is true. (cid:3) Periods of the length- n prefix. In [10] Gabric, Rampersand and Shallit charac-terize all periods of the length- n prefix of a characteristic Sturmian word in terms of thelazy Ostrowski representation. We are able implement their argument in Pecan.Let α be a real number with continued fraction expansion [ a ; a , a , . . . ] and convergents p k /q k ∈ Q . We recall the definition of the lazy α -Ostrowski numeration system [9]. Fact 11. Let X ∈ N . The lazy α -Ostrowski representation of X is the unique word b N · · · b such that X = N X n =0 b n +1 q n where(1) ≤ b < a ;(2) ≤ b i ≤ a i for i > ;(3) if b i = 0 then b i − = a i for all i > ;(4) if b = 0 , then b = a − ; Theorem 12 ([10, Theorem 6]) . Let α be an irrational real number, and define Y n to bethe length n prefix of c α, . Define PER ( n ) to be the set of all periods of Y n . Then(1) The number of periods of Y n is equal to the sum of the digits in the lazy Ostrowskirepresentation of n .(2) Let the lazy Ostrowski representation of n be b · · · b N , and define A ( n ) = ( iq j + X j To define A ( n ), we first define several auxiliary automata and notions. Earlier, we definedaddition automata for the (greedy) Ostrowski numeration system, but we can also easilyhandle the lazy Ostrowski numeration system using an automaton recognizing ( ( a, x, y ) : x, y ∈ A fin a , x = x x · · · , y = y y · · · , ∞ X i =0 x i +1 q i = ∞ X i =0 y i +1 q i ) which we call ost_equiv(a,x,y) . The lazy_ostrowski(a,n) automaton checks whether n is a valid lazy a -Ostrowski representation. These automata allow us to convert betweenthe two systems.To define A ( n ), we break it up into smaller pieces; first, we wish to recognize the set B ( n ) = { iq j : 1 ≤ j ≤ b j +1 and 0 ≤ j ≤ N } . For each x ∈ ( | ∗ ) ω , denote by | x | fin the length of the longest prefix y of x such that x = yz where z ∈ ( ∗ ) ω , or ∞ if there is no such prefix. We then create the followingautomata: • as_long_as(x,y) recognizing the set { ( x, y ) : | x | fin ≥ | y | fin } . • has_1_digit(x) recognizing the set ( ∗ ) ∗ (( ∗ ) | ( | ∗ | ∗ ))( ∗ ) ω , i.e.,words of the form w w · · · such that there is at most one w i such that w i ∗ . • bounded_by(x,y) recognizing the set { ( x, y ) : x and y are aligned , x = x x · · · , y = y y · · · , ∀ i.x i ≤ lex y i } Then we can recognize the set B ( n ) from above by i > 0 ∧ h a s _ 1 _ d i g i t s( i ) ∧ a s _ l o n g _ a s(n , i ) ∧ b o u n d e d _ b y(i , n_l ) where n_l is the lazy a -Ostrowski representation of n .The last automaton we need to create is suffix_after(x,y,s) , recognizing the set { ( x, y, s ) : s = 0 | x | fin · y [ | x | fin .. ] } . We need this to be able to recognize the set of a -Ostrowski representations { m : 0 ≤ j ≤ N, m l = 0 j n l [ j..N ] , m l is the lazy a -Ostrowski representation of Z a ( m ) } where n l is the lazy a -Ostrowski representation of Z a ( n ).Finally, we can put everything together and define A ( n ), again indexed by the slope a , as: p ∈ $ A (a , n ) : = ∃ n_l , m_l . l a z y _ o s t r o w s k i(a , n_l ) ∧ o s t _ e q u i v(a ,n , n_l ) ∧∃ m . o s t _ e q u i v(a , m_l , m ) ∧∃ i . i > 0 ∧ h a s _ 1 _ d i g i t( i ) ∧ a s _ l o n g _ a s(n , i ) ∧ b o u n d e d _ b y(i , n_l ) ∧ s u f f i x _ a f t e r (i , n_l , m_l ) ∧ i + m = p Finally, we can state the theorem directly, which Pecan confirms is true. Theorem ( " 6 ( b ) " , { ∀ a . ∀ p , n . p ∈ $ Per (a , n ) ⇔ p ∈ $ A (a , n ) } ) . ECIDABILITY FOR STURMIAN WORDS 32 (cid:3) References 1. Jean-Paul Allouche and Jeffrey Shallit, Automatic sequences: Theory, applications, generalizations ,Cambridge University Press, 2003.2. Aseem Baranwal, Luke Schaeffer, and Jeffrey Shallit, Ostrowski-automatic sequences: Theory andapplications , Theor. Comput. Sci. (2021), 122–142.3. Aseem R. Baranwal and Jeffrey Shallit, Critical exponent of infinite balanced words via the Pellnumber system , Combinatorics on words, Lecture Notes in Comput. Sci., vol. 11682, Springer, Cham,2019, pp. 80–92. MR 40090624. V´eronique Bruy`ere, Georges Hansel, Christian Michaux, and Roger Villemaire, Logic and p -recognizable sets of integers , vol. 1, 1994, Journ´ees Montoises (Mons, 1992), pp. 191–238.MR 13189685. J. Richard B¨uchi, On a decision method in restricted second order arithmetic , Logic, Methodologyand Philosophy of Science (Proc. 1960 Internat. Congr.), Stanford Univ. Press, Stanford, Calif.,1962, pp. 1–11. MR 01836366. James D. Currie and Kalle Saari, Least periods of factors of infinite words , ITA (2009), 165–178.7. Aldo de Luca and Alessandro De Luca, Some characterizations of finite sturmian words , Theor.Comput. Sci. (2006), no. 1-2, 118–125.8. Xavier Droubay and Giuseppe Pirillo, Palindromes and Sturmian words , Theor. Comput. Sci. (1999), no. 1, 73 – 85.9. Chiara Epifanio, Christiane Frougny, Alessandra Gabriele, Filippo Mignosi, and Jeffrey Shallit, Sturmian graphs and integer representations over numeration systems , Discrete Appl. Math.10. Daniel Gabric, Narad Rampersad, and Jeffrey Shallit, An inequality for the number of periods in aword , arXiv:2005.11718 (2020).11. Daniel Goˇc, Dane Henshall, and Jeffrey Shallit, Automatic theorem-proving in combinatorics onwords , Internat. J. Found. Comput. Sci. (2013), no. 6, 781–798. MR 315896812. Philipp Hieronymi, Expansions of the ordered additive group of real numbers by two discrete sub-groups , J. Symb. Log. (2016), no. 3, 1007–1027.13. Philipp Hieronymi, Danny Nguyen, and Igor Pak, Presburger arithmetic with algebraic scalar mul-tiplications , arXiv:1805.03624 (2018).14. Philipp Hieronymi and Alonza Terry Jr, Ostrowski numeration systems, addition, and finite au-tomata , Notre Dame J. Form. Log. (2014), 215–232.15. Bakhadyr Khoussainov and Mia Minnes, Three lectures on automatic structures , Logic Colloquium2007, Lect. Notes Log., vol. 35, Assoc. Symbol. Logic, La Jolla, CA, 2010, pp. 132–176. MR 266823016. Bakhadyr Khoussainov and Anil Nerode, Automata theory and its applications , Birkhauser Boston,Inc., Secaucus, NJ, USA, 2001.17. M. Lothaire, Algebraic combinatorics on words. , vol. 90, Cambridge: Cambridge University Press,2002 (English).18. Hamoon Mousavi, Automatic Theorem Proving in Walnut , CoRR abs/1603.06017 (2016).19. Hamoon Mousavi, Luke Schaeffer, and Jeffrey Shallit, Decision algorithms for Fibonacci-automaticwords, I: Basic results , RAIRO Theor. Inform. Appl. (2016), no. 1, 39–66. MR 351815820. Reed Oei, Eric Ma, Christian Schulz, and Philipp Hieronymi, Pecan , available at https://github.com/ReedOei/Pecan , 2020.21. , Pecan: An Automated Theorem Prover for Automatic Sequences using B¨uchi automata ,arXiv:2102.01727 (2021).22. Alexander Ostrowski, Bemerkungen zur Theorie der Diophantischen Approximationen , Abh. Math.Semin. Univ. Hambg. ECIDABILITY FOR STURMIAN WORDS 33 23. Andrew M. Rockett and Peter Sz¨usz, Continued fractions , World Scientific Publishing Co., Inc.,River Edge, NJ, 1992. MR 118887824. Thoralf Skolem, ¨Uber einige Satzfunktionen in der Arithmetik , Skr. Norske Vidensk. Akad., Oslo,Math.-naturwiss. Kl. (1931), 1–28. Department of Mathematics, University of Illinois at Urbana-Champaign, 1409 WestGreen Street, Urbana, IL 61801, USA Email address : [email protected] URL : Department of Mathematics, University of Illinois at Urbana-Champaign, 1409 WestGreen Street, Urbana, IL 61801, USA Email address : [email protected] Department of Mathematics, University of Illinois at Urbana-Champaign, 1409 WestGreen Street, Urbana, IL 61801, USA Email address : [email protected] Institute for Quantum Computing, University of Waterloo, Waterloo, Ontario, N2L3G1, Canada Email address : [email protected] Department of Mathematics, University of Illinois at Urbana-Champaign, 1409 WestGreen Street, Urbana, IL 61801, USA Email address : [email protected] School of Computer Science, University of Waterloo, Waterloo, Ontario, N2L 3G1,Canada Email address : [email protected] URL ::