<<

Monadic chain logic over iterations and applications to pushdown systems

Dietrich Kuske Markus Lohrey Institut fur¨ Informatik, Universitat¨ , Universitat¨ , FMI, Germany [email protected] [email protected]

Abstract was shown by Blumensath and Kreutzer [3]. The full iteration Afu differs from the local full iteration Logical properties of iterations of relational structures only in as far as it contains the prefix relation on A instead are studied and these decidability results are applied to the of the immediate successor relation son. Since this prefix model checking of a powerful extension of pushdown sys- relation is the transitive closure of son, there is an MSO- tems. It is shown that the monadic chain theory of the iter- interpretation of the full iteration in the local full iteration. ation of a structure A (in the sense of Shelah and Stupp) is As an immediate consequence from [25, 3], one obtains a decidable in case the first-order theory of the structure A is preservation theorem for MSO and its modulo counting ex- decidable. This result fails if Muchnik’s clone-predicate is tensions for this full iteration in place of the local full it- added. A model of pushdown automata, where the stack al- eration. Since one can express in first-order logic that an phabet is given by an arbitrary (possibly infinite) relational element of the full iteration (i.e., a word over the base struc- structure, is introduced. If the stack structure has a decid- ture) represents a path in the base structure, both parts of the able first-order theory with regular reachability predicates, preservation theorem fail for the full iteration and first-order then the same holds for the configuration graph of this push- logic (Propositions 3.4 and 3.5). down automaton. This result follows from our decidability To overcome this problem, Section 4 is devoted to the result for the monadic chain theory of the iteration. study of the basic iteration Aba where one omits Much- nik’s clone predicate but keeps the prefix order. For basic iterations, the preservation theorem for MSO was proved 1. Introduction by Stupp [22] (cf. [21]). Rabin’s seminal result on the de- cidability of the MSO-theory of the complete infinite bi- In this paper, we study iterations of relational structures, nary tree [18] is an immediate corollary of this preserva- their logical properties, and apply our results to the model tion theorem. For this basic iteration we are able to prove checking of a powerful extension of pushdown systems. the preservation theorem for first-order logic. In fact, we The local full iteration A of a relational base structure can show even more: If a structure has a decidable first- loc ch A with universe A consists of the set A of finite words order theory, then its basic iteration has a decidable MSO - ch over A. One of its relations is the immediate successor theory (Thm. 4.10). MSO is the fragment of MSO where relation son. The sons of a word w carry the relations of second-order quantification is restricted to chains (i.e., or- the base structure A. Furthermore, Muchnik’s unary clone dered subsets) with respect to the tree structure of the iter- ch predicate collects all words whose final two letters are iden- ation. MSO on trees was investigated in [23]. To reduce ch tical. Semenov [20] sketched a proof of what is now known the MSO -theory of the basic iteration to the first-order as Muchnik’s preservation theorem: The monadic second theory of the base structure, we proceed as follows: First, we show that quantification over chains can be restricted order (MSO for short) theory of the local full iteration Aloc can be reduced to the MSO-theory of the base structure A, to ultimately periodic chains of bounded offset and period ch and, if two base structures have the same MSO-theory, then length (Thm. 4.7). Truth of MSO -formulas with bounded the same holds for their iterations. Hence, if the MSO- quantification can be determined in a bounded prefix of the theory of a structure A is decidable, then also the MSO- basic iteration. Finally, this bounded prefix can be inter- preted in the base structure. Since all these bounds can be theory of the local full iteration Aloc is decidable. A full proof of this result was given by Walukiewicz in [25]. A computed effectively, our preservation theorem follows. first-order variant of Muchnik’s theorem for first-order logic Roughly speaking, the results from Section 3 and Sec- follows from [14]. For modulo counting extensions of MSO tion 4 show that, in order to have a first-order preservation and for guarded second order logic, a preservation theorem theorem for the iteration, we are not allowed to copy an in- finite amount of information between the levels of the tree the prefix relation on finite words and is its non-reflexive structure — this is in some sense the essence of the clone- part. For a subalphabet and a word u ∈ we de- predicate. Thus, the clone-predicate has an immense effect note with |u| the number of occurrences of symbols from on the expressive power of the basic iteration although it in u. In case is finite, REG() denotes the set of all looks quite innocent at first glance. It should be also noted regular languages over the alphabet . that the clone-predicate allows to define the unravelling of a graph G within the full iteration of G (cf. [6]). 2.1. Iterations In Section 5 we present an application of our decid- ch A ability result for MSO over basic iterations to pushdown Let A = (A, (R )R∈) be a relational structure over the systems. Pushdown systems were used to model the state finite relational signature . The basic iteration Aba of A is space of sequential programs with nested procedure calls, the structure see e.g. [9]. Model-checking problems for pushdown sys- tems were studied for various temporal logics (LTL, CTL, Aba = (A , , (R)R∈, ε) where modal -calculus) [1, 9, 13, 24]. When modeling recur- A R = {(ua , . . . , uan) | u ∈ A , (a , . . . , an) ∈ R }. sive sequential programs via pushdown systems, it is neces- 1 b 1 sary to abstract local variables (which have to be stored on Exampleb 2.1 Suppose the structure A has two elements a the stack) with an infinite range (like for instance integers) and b and two unary relations R1 = {a} and R2 = {b}. to some finite range, in order to obtain a finite pushdown Then R1 = {a, b} a and R2 = {a, b} b. Hence the basic alphabet. This abstraction may lead to so called spurious iteration Aba can be visualized as a complete binary tree counterexamples [8]. Here, we introduce pushdown sys- with unaryb predicates tellingb whether the current node is tems where the stack alphabet is the (possibly infinite) uni- the first or the second son of its father. In addition, the root verse of an arbitrary stack structure A. With any change ε is a constant of the structure A . of the control state, our pushdown model associates one of ba three basic operations: (i) replacing the topmost symbol of In the full iteration Afu of A, we have the additional the stack by another one according to some binary predi- unary clone predicate cl = {uaa | u ∈ A, a ∈ A}, i.e., cate of the stack structure, (ii) pushing or (iii) popping a symbol from some unary predicate of the stack structure. Afu = (A , , cl, (R)R∈, ε) . Such a pushdown system can model programs with nested procedure calls, where procedures use variables with an in- We will also consider a relaxationb of the full iteration finite domain. The configuration graph of such a pushdown where the prefix relation is replaced by the direct successor system is defined as for finite stack alphabets. We study relation son = {(u, ua) | a ∈ A , a ∈ A}, i.e., the logic FOREG for these configuration graphs. FOREG is the extension of first-order logic which allows to define Aloc = (A , son, cl, (R)R∈, ε) . new binary predicates by regular expressions over the bi- We refer to this iteration as local iteration. Note that A is nary predicates of the base structure A. Variants of FOREG b fu MSO-definable (but not first-order definable) in A . were studied in [15, 19, 26]. FOREG is a suitable lan- loc guage for the specification of reachability properties of re- 2.2. Logics active systems; its expressive power is between first-order logic and MSO. Based on our decidability result Thm. 4.10 we show that if FOREG is decidable for the base struc- Let be some signature. Atomic formulas are R x , . . . , x , x x , and x X where x , . . . , x are ture A of a pushdown system, then FOREG remains de- ( 1 n) 1 = 2 1 ∈ 1 n cidable for the configuration graph of the pushdown system individual variables, R ∈ is an n-are relational symbol, (Thm. 5.1). For this result, it is important that in our push- and X is a set variable. Monadic second-order formulas are down model procedure calls and returns cannot transfer an obtained from atomic formulas by conjunction, negation, and quantification ∃x and ∃X for x an individual and X a infinite amount of information to another call level. This re- flects our undecidability result Proposition 3.4 for the clone set variable. The satisfaction relation (A, a, C) |= ϕ(x, X) predicate. is defined as usual with the understanding that set variables range over subsets of A. A first-order formula is a monadic second-order formula without set variables. 2. Preliminaries Now let be a designated binary relation symbol in . A monadic second-order chain formula or MSOch-formula Let be a (not necessarily finite) alphabet. With + we is just a monadic second-order formula. For these MSOch- denote the set of all finite non-empty words over . Then formulas, we define a new satisfaction relation |=ch: it is de- = + ∪ {ε} with ε the empty word. With we denote fined as |= with the only difference that set variables range

2 over chains (i.e., sets whose elements are mutually compa- Proof. Let M be a Turing machine that accepts a non- rable) in (A, ). Note that if ϕ is a first-order formula, then recursive set L (we assume that M accepts with empty A |= ϕ if and only if A |=ch ϕ. tape). Let be the set of tape symbols and states Let A and B be two -structures. Then we write of M. Then consider the following structure A = MSO A m B if, for any MSO-formula ϕ of quantifier depth (A, E, (Ea)a∈) where A is the set of configurations of M at most m, we have A |= ϕ ⇐⇒ B |= ϕ. This relation and, for any configurations c1, c2 and any a ∈ , we have is an equivalence relation. If we only consider first-order formulas (MSOch-formulas, resp.) ϕ of quantifier depth at (c1, c2) ∈ E if and only if c2 can be obtained from c1 FO ch by one step of the Turing machine. most m, then we write A m B (A m B, resp.).

(c1, c2) ∈ Ea if and only if c2 = c1a. 3. The theory of the full iteration The first-order theory of A is decidable since A is auto- matic [12]. There is a formula with one free variable We first deal with MSO-theories. Muchnik’s theorem x such that (A, c) |= if and only if c is a configura- sharpens an earlier result of Stupp. Its full proof can be tion with empty tape. Furthermore, from a state q and found in [25] (cf. also [2]).1 an input word w, we can write a first-order formula ϕqw with one free variable x such that, for any configuration c, Theorem 3.1 Let be some finite relational signa- (A, c) |= ϕqw if and only if c = qw. ture. There exists a computable function red : Now consider the full iteration of A. The formulas and , , such that, for any - MSO( cl son) → MSO( ) ϕqw are obtained by restricting the quantification to siblings structure A, we have A |= red(ϕ) if and only if A |= ϕ. loc of the free variable x. Furthermore, let w be some binput wdord and let q0 be the initial state of M. Then w is ac- One infers immediately: cepted if and only if there exists a sequence of configura- tions u = c0c1 . . . cn ∈ A such that the following hold in Corollary 3.2 If the MSO-theory of a structure A is de- the full iteration of A: (i) the minimal nonempty prefix c0 of u satisfies ϕ[q w, (ii) u satisfies , and (iii) for all proper cidable, then the MSO-theory of its local iteration Aloc is 0 decidable as well. and non-empty prefixes v of u, we have b ∃v0, v00 : v l v0 u ∧ v l v00 ∧ cl(v00) ∧ E(v00, v0), To derive another corollary, let m ∈ N be arbitrary. Then, there is a finite set of MSO-formulas such that any where x l y is shorthand for x y ∧ ∀z(x b z y → MSO-sentence of quantifier depth at most m is logically x = z). Since the language of the Turing machine M is equivalent to some sentence from . Let n be an upper non-recursive, this proves that the first-order theory of the bound for the quantifier depth of red(ϕ) for ϕ ∈ . This full iteration of A is undecidable. tu observation yields:

Hence, Corollary 3.2 and therefore Thm. 3.1 with the full Corollary 3.3 For any m ∈ N, there exists n ∈ N such iteration taking the place of the local iteration and first-order that, for any two -structures A and B with A MSO B, we n logic replacing MSO do not hold. A similar problem arises have A MSO B . loc m loc with respect to Corollary 3.3.

Note that the MSO-theories of the local and the full it- Proposition 3.5 For every n ∈ N there exist structures A eration can be reduced onto each other. Hence Muchnik’s n and B such that A FO B but (A ) 6FO (B ) . Thm. 3.1 and Corollaries 3.2 and 3.3 hold for the full iter- n n n n n fu 6 n fu ation Afu in place of the local iteration Aloc equally well. Surprisingly, this is not the case for first-order logic as we Proof. For n ∈ N, let An denote the structure An = show next. (Z, succ, 0, 2n+1) that consists of a copy of the integers with successor relation and two constants a and b. Note n+1 Proposition 3.4 There exists a structure A with a decid- that in An there is a path of length 2 from a to b. We n+1 will also consider the structure Bn = (Z, succ, 2 , 0) that able first-order theory such that the full iteration Afu has an undecidable first-order theory. differs from An only in the values of the constants (that are exchanged). Then the structures An and Bn cannot be dis- 1Thm. 3.1 and its two corollaries also hold for counting extensions of tinguished by any first-order sentence of quantifier rank at FO MSO and for guarded second-order logic [3]. most n, i.e., An n Bn.

3 Now consider the following sentence ϕ in the language 4.1. Preliminaries of the full iteration of An and Bn: For i, ` ∈ N, let i,` be the extension of the signature ∃x ∈ a ∃z ∈ b : x z ∧ (, ) by i individual and ` chain constants. We write i y l y0 z ∧ y l y00∧ for i,0. From ` and m, one can effectively compute a fi- ∀y : x y z → ∃y0∃y00 b b cl(y00) ∧ E(y00, y0) nite upper bound Ni(`, m) for the number of equivalence ch ½ ¾ classes of m on the class of all i,`-structures, see [10]. For u ∈ A, let t be the structure (uA, v, (R) , u) To show that An satisfies ϕ, take x =b 0 and z = u R∈ 0 1 2 . . . 2n+1. Since the last letters of these words are a over the signature 1, where (i) the relation v is the re- and b, resp., they belong to a and b, resp. Any word y with striction of to uA and (ii) R is the restriction of R to + x y z has the form 0 1 . . . i for some 0 i < 2n+1. uA (the restriction to uA could contain tuples of the Then y0 = y (i+1) and y00 = y i ensureb that ϕ indeed holds. form (u, u, . . . , u) which are excluded from R). Forbany b u, v ∈ A , the mapping f : tu → tv with f(ux) = vx is an On the other hand, Bn does not satisfy ϕ: Suppose it 0 isomorphism – this is the reason to consider R and not the would, i.e., there are x = x a and z = xa1a2 . . . akb satisfying the second line of the formula ϕ. Then restriction of R to uA . Similarly, the 2-structure tu,v = uA vA+, , R , u, v is defined for u, v A with a a1 a2 . . . ak b is a path in B from a to b - but such a path ( \ v ( )R∈ ) ∈ does not exist. Since ϕ has quantifier rank 6, we obtain u v. Here, agbain, R is the restriction of R to uA+ \ vA+. FO (An)fu 66 (Bn)fu. tu b In Proposition 3.4 and 3.5, the interplay between the Example 2.1 (continued). In the case of Example 2.1, tu prefix relation and the clone-predicate is crucial. If just is just the subtree rooted at the node u. On the other hand, one of these two relations is present, a first-order version tu,v is obtained from tu by deleting all descendents of v of Muchnik’s theorem and its corollaries holds. For the and marking the node v as a constant. Thus, we can think clone-predicate, this follows from a more general result on of tu,v as a tree with a marked leaf. These special trees are so called factorized unfoldings from our earlier paper [14] fundamental in the work of Gurevich and Shelah [11] and in (see Theorem 3.6 below). For the prefix relation, we prove Thomas’ study of the monadic second-order chain theory of the result in this paper (Theorem 4.10 and Corollary 4.11). the complete binary tree [23]. The following constructions generalize those from [11, 23] to the more general context Theorem 3.6 ([14]) Let be a finite relational signature. of basic iterations as considered here. Let be some finite relational signature. There exists In the following, fix some ` ∈ N. We then define the op- a computable function red : FO(, cl, son) → FO() erations of product and infinite product of i,`-structures: If such that, for any -structure A, we have A |= red(ϕ) A is a 2,`-structure with second individual constant v and B if and only if Aloc |= ϕ. a disjoint i,`-structure with first individual constant u, then their product A B is a i,`-structure. It is obtained from the If the first-order theory of a structure A is decidable, union of A and B by identifying v and u and erasing it from then the first-order theory of its local iteration Aloc is the list of constants. In other words, the individual constants decidable as well. in A B are the first constant from A and all but the first constant from B. Furthermore, the chains from A and B are N N For any m ∈ , there exists n ∈ such that, for any united. Now let be disjoint -structures with individ- FO An 2,` two -structures A and B with A n B, we have ual constants u and v for n N. Then the infinite product FO n n ∈ Aloc m Bloc. n∈N An is a 1,`-structure. It is obtained from the union of the structures An by identifying vn and un+1 for any ch 4. The MSO -theory of the basic iteration Qn ∈ N. The only individual constant of this infinite product is u0. If An = An+1 for all n ∈ N, then we write simply ω In this section, we will show that statements analogous A0 for the infinite product of the structures An. Standard to Muchnik’s Thm. 3.1 and Corollaries 3.2 and 3.3 hold for applications of Ehrenfeucht-Fra¨ısse-g´ ames (cf. [7]) yield: basic iterations and first-order logic. In doing so, it turns out N 0 Proposition 4.1 Let m, ` ∈ , An, An be 2,`-structures ch 0 that we can even consider the MSO -theory of the basic for n ∈ N and let B, B be some i,`-structures such that iteration. Let us fix a base structure A, R over ch 0 N ch 0 A = ( ( )R∈) An m An for n ∈ and B m B . Then a signature . In the rest of Section 4, we write ch 0 0 ch 0 A0 B m A0 B and An m An. t = A . (1) n∈N n∈N ba Y Y

4 4.2. Ultimately periodic chains and their combina- (a) |u1| exceeds the offset of all the chains C1, C2, . . . , C`, torics (b) for any 1 i ` and for any n 1, the period length of C divides |u | |u |, and For a word u ∈ A∞ = A ∪ Aω, let ↓u A denote i n+1 n ch the set of finite prefixes of u, and ⇓u = ↓u \ {u}. Similarly, (c) for any 1 i < j, we have (tu1,u2 , C, C) m 1 ↓C = {↓u | u ∈ C} for C A . Finally, u C = {v ∈ (tui,uj , C, C). A uv C for u A and C A. | ∈ } ∈ This implies A chainS C A is ultimately periodic if it can be written as E ∪ uvF with E, F A finite and u, v ∈ A. If (t, C, C) = (tε,u1 , C, C) (tun,un+1 , C, C) E ⇓u and F ⇓v, it is ultimately |v|-periodic with offset n>0 Y |u|. Since v = ε is possible, finite chains are ultimately ch ω m (tε,u1 , C, C) (tu1,u2 , C, C) 0-periodic. Furthermore, if C is ultimately p-periodic with + offset q, then it is also ultimately xp-periodic with offset q+ Now let v ∈ A with u1v = u2 and consider E = C ∩↓u1, y for any x, y ∈ N with x 1. 1 1 F = u1 (C ∩ ↓u2) = u1 C ∩ ↓v, and D = E ∪ u1v F . In the following, we will consider the structure t from Because of (a) and (b) we can continue as follows: (1) together with ` + 1 chains C1, . . . , C`, C. To make ω the presentation more concise, write C for the `-tuple = (tε,u1 , C, E) (tu1,u2 , C, F ) (C1, . . . , C`). We will also meet structures tu and tu,v to- = (t , C, D) (t n n+1 , C, D) gether with the restriction of C, C to their domain. Again ε,u1 u1v ,u1v n0 for simplicity, we write, e.g., (tu, C) for (tu, C ∩ uA ). Y = (t, C, D).

ω ω 4.3. Shortening ultimately periodic chains Since E ↓u1v and F ↓v , the set D is linearly or- dered and therefore ultimately periodic. tu Suppose we are in the realm of Example 2.1 and let Ci A be regular and let ui ∈ A . Then, as a corollary from Rabin’s tree theorem, for any C A, there exists a regular 4.3.2. Ultimately periodic chains with small offset set D A that satisfies the same MSO-formulas of quan- Lemma 4.3 Let m > 0, C A be an ultimately p - tifier depth m in the structure (t, C , . . . , C , u , . . . , u ) as i i 1 ` 1 n periodic chain with offset q for 1 i ` and let C does. In this section, we want to prove a similar result for i C A be an ultimately p-periodic chain with offset q > basic iterations. For this, “regular set” is replaced by “ulti- max(q , . . . , q ) + lcm(p , . . . , p ) (N (` + 1, m) + 2). mately periodic chain”. In addition, we want to bound the 1 ` 1 ` 1 Then there exists an ultimately p-periodic chain D with off- offset and the period of the chain D. set q lcm(p , . . . , p ) such that (t, C, C) ch (t, C, D). We start showing that some ultimately periodic chain D 1 ` m exists that can take the role of C (Proposition 4.2). Propo- sition 4.6 will allow to bound the period of D (thereby pos- Proof. Let C = E ∪ uv F with E ⇓u, F ⇓v, |u| = q and |v| = p. Then we can write u = u0xyz sibly enlarging the offset). Finally, Lemma 4.3 bounds the 0 size of the offset (without changing the period). Finally, such that |u | = max(q1, . . . , q`), |x|, |y| > 0 are mul- ch Thm. 4.7 shows that we succeeded in our attempt to find an tiples of lcm(p1, . . . , p`), z 6= ε, and (tu0x, C, C) m equivalent ultimately periodic chain D of small period and (tu0xy, C, C). offset. When deleting in the structure (t, C, C) all nodes 0 + 0 from u xA \ u xyA , we end up with (tε,u0x, C, C) 0 (tu0xy, C, C). Since u is long enough and the lengths of x 4.3.1. Existence of ultimately periodic chains and y are multiples of lcm(p1, . . . , p`), the structures (t, C) and (t 0 , C) (t 0 , C) are isomorphic. Hence there is a Proposition 4.2 Let m ∈ N, C1, . . . , C` A be ul- ε,u x u xy timately periodic chains and let C A be any chain. chain D A such that Then there exists an ultimately periodic chain D such that (t, C, C) = (tε,u0x, C, C) (tu0x, C, C) (t, C, C) ch (t, C, D). m ch m (tε,u0x, C, C) (tu0xy, C, C) Proof. Assume C not to be ultimately periodic (and there- = (t, C, D). ω fore infinite) and let ∈ A with C ↓. By Ramsey’s This chain has the same period as C, but the offset is re- theorem (see [16] for this application), there is a strictly in- duced by |y| lcm(p1, . . . , p`). tu creasing sequence u1 u2 u3 of non-empty prefixes of such that, A similar proof yields the following lemma.

5 0 0 Lemma 4.4 Let m > 0, Ci A be an ultimately pi- with D = (C ∩ ⇓u) ∪ uD . Since the period length of D 0 0 periodic chain with offset qi for 1 i k and let ui ∈ A equals p , the chain D is ultimately p -periodic. tu be words with |ui| = qi for k < i ` and let u ∈ A with |u| max(q1, . . . , q`) + lcm(p1, . . . , pk) (N1(` + Proposition 4.6 Let m ∈ N, Ci A be an ultimately pi- 1, m) + 2). Then there exists a word v ∈ A with |v| ch periodic chain with offset qi for 1 i ` and let C A |u| lcm(p1, . . . , pk) and (t, C, u, u) (t, C, u, v). m be an ultimately p-periodic chain. Then there exists an 0 ch ultimately p -periodic chain D such that (t, C, C) m 4.3.3. Ultimately periodic chains with small period 0 (t, C, D) and p 2 lcm(p1, . . . , p`) (N2(` + 1, m) + 2). Lemma 4.5 Let m ∈ N, Ci A be an ultimately pi- 0 periodic chain with offset qi for 1 i ` and let C A Proof. Set p0 = p 2 lcm(p1, . . . , p`) (N2(` + 1, m) + be an ultimately p-periodic chain with offset q. Suppose 2). This allows to apply Lemma 4.5 iteratively. The re- 0 furthermore p > 2 lcm(p1, . . . , p`)(N2(` + 1, m) + 2) is a sult is a sequence of ultimately pi-periodic chains with 0 0 0 0 multiple of lcm(p1, . . . , p`). Then there exists an ultimately p0 > p1 > pn. This process terminates once pn 0 0 p -periodic chain D A such that p < p is a multiple of 2 lcm(p1, . . . , p`) (N2(` + 1, m) + 2). tu ch lcm(p1, . . . , p`) and (t, C, C) m (t, C, D). Now we can finally prove that any chain C can be re- Proof. It is sufficient to consider an infinite chain C. In placed by an ultimately periodic chain D of small period ch this case, one first shows the existence of u, w ∈ A, v ∈ and offset without changing the MSO -properties: + w and F, F1, . . . , F` A such that the following hold: Theorem 4.7 Let m ∈ N, Ci A be ultimately pi- |w| = lcm(p1, . . . , p`) and p = |v| periodic chains with offset qi for 1 i ` and let C A 0 1 0 be a chain. Then there exists an ultimately p -periodic chain ∅ 6= F ⇓v and v F = u C =: C 0 D with offset q max(q1, . . . , q`) + lcm(p1, . . . , p`) 1 0 0 ∅ 6= Fi ⇓w and w Fi = u Ci =: Ci for 1 i ` (N1(` + 1, m) + 2) and p 2 lcm(p1, . . . , p`) (N2(` + ch 1, m) + 2) such that (t, C, C) m (t, C, D). The word v can be factorized as x1x2x3 such that x1, x2 ∈ + w , x3 ∈ w , and Proof. By Prop. 4.2, we can assume C to be ulti- 0 0 ch 0 0 (tx1,vx1 , C , C ) m (tx1x2,vx1 , C , C ). mately periodic. Prop. 4.6 allows to bound its pe- riod by 2 lcm(p , . . . , p ) (N (` + 1, m) + 2). Al- For n > 0, we have vnx = x (x x x )n. One can show 1 ` 2 1 1 2 3 1 though this increases the offset, an iterative application of that Lemma 4.3 shortens the offset again to a value of at most 0 0 0 0 n n+1 (tx1,vx1 , C , C ) = (tv x1,v x1 , C , C ) and max(q1, . . . , q`) + lcm(p1, . . . , p`) (N1(` + 1, m) + 2) 0 0 0 0 n n+1 without increasing the period. tu (tx1x2,vx1 , C , C ) = (tv x1x2,v x1 , C , C ). Hence we have ch 0 0 0 0 0 0 4.4. Bounded MSO -theory n n+1 (t, C , C ) = (tε,vx1 , C , C ) (tv x1,v x1 , C , C ) n>0 Y For an MSOch-formula and q, p ∈ N let ∃C (q, p) : (t , C0, C0) (t , C0, C0)ω = ε,vx1 x1,vx1 stand for “there exists an ultimately p0-periodic chain C ch 0 0 0 0 ω 0 m (tε,vx1 , C , C ) (tx1x2,vx1 , C , C ) with offset at most q and p p such that holds”. Simi- 0 0 0 0 larly, ∃x q : means “there exists a word x of length at = (t , C , C ) (t n n+1 , C , C ) ε,vx1 v x1x2,v x1 most q such that holds”. The formulas ∀C (q, p) : n>0 0 0 Y and ∀x q : should be understood similarly. A bounded t, C , D ch = ( ) MSO -sentence is an expression of the form 0 for some |x3x1|-periodic chain D . 0 Q C q , p Q C q , p Then p := |x3x1| is a multiple of lcm(p1, . . . , p`). Fur- 1 1 ( 1 1) ` ` ( ` `) 0 0 thermore Q1x1 r1 Qkxk rk : (t, C, C) = (tε,u, C, C) (tu, C, C) where is a Boolean combination of atomic formulas and 0 0 0 = (tε,u, C, C) (t, C , C ) Qi, Qj ∈ {∃, ∀}. Standard techniques allow to shift set quantifiers to the front in a prenex normalform formula (at ch (t , C, C) (t, C0, D0) m ε,u the expense of additional quantifiers). Hence Thm. 4.7 and = (t, C, D) Lemma 4.4 imply:

6 Proposition 4.8 From an MSOch-sentence ϕ, one can ef- (possibly infinite) universe of an arbitrary base structure G. fectively compute a bounded MSOch-sentence such that, Push- and pop operations are triggered via the relations of ch for any structure A, we have Aba |= ϕ if and only if the base structure G and a finite set of control states, but are ch Aba |= . independent from the topmost stack symbol. The configu- ration graph of such a pushdown system is defined as for Remark 4.9 If we restrict set quantification in MSOch- finite stack alphabets. We study the logic FOREG for these sentences further to ultimately periodic chains, we obtain configuration graphs. FOREG is the extension of first-order a new satisfaction relation |=period (that only makes sense logic which allows to define new binary predicates by regu- for iterations). The above proposition implies in particu- lar expressions over the binary predicates of the base struc- lar that this seemingly new satisfaction relation equals |=ch. ture A. Based on our decidability result Corollary 4.11 we This consequence parallels Rabin’s result [17] where he re- show that if FOREG is decidable for the base structure G of stricts set quantifications to run over regular sets. a pushdown system, then FOREG remains decidable for the configuration graph of the pushdown system (Thm. 5.1). 4.5. Reduction of the MSOch-theory to the first- order theory 5.1. The logic FOREG

ch Theorem 4.10 From an MSO -sentence ϕ, one can effec- Let be a finite alphabet of labels and let G = tively compute a first-order sentence ϕ0 such that, for any (A, (E)∈, R1, . . . , Rm) be a relational structure, where structure A, we have A |=ch ϕ if and only if A |= ϕ0. ba E A A is a binary relation and R1, . . . , Rm are ad- ditional non-binary relations. For a word w = 1 n N n w Proof. Let A be some structure. For n ∈ let A = with i ∈ we define the binary relation →G = E1 n n ε (A , , (R) ∈ , eq) where (i) A is the set of words R En . We have →G = idA and →G = E for ∈ . in A of length at most n and (ii) (u, v) ∈ eq if and only For a regular language L we define reachL = 0 0 0 w if there existb a ∈ A and u , v ∈ A with u = u a and →G. An FOREG-formula over the structure G ch w∈L v = v0a. Now let ϕ be a bounded MSO -sentence with is simply a first-order formula over the extended structure N S first-order kernel and let n ∈ be the maximal number (A, (reachL)L∈REG(), R1, . . . , Rm). appearing in the bounds in ϕ. Note that does not relate the chains Ci directly, but only indirectly via the individual 5.2. Pushdown systems over infinite stack alphabets variables xj. This allows to write a first-order formula in n ch the language of A such that Aba |= ϕ if and only if n A pushdown system S = (Q, G, ) over a stack structure A |= . Here, the predicate eq is necessary in order to G is given by the following data: express the periodicity of a chain. n Note that the first-order theory of A can be reduced G is a relational structure of the form to that of A. There is even such a reduction that works G = (A, (eq)∈1 , (push)∈2 , (pop )∈3 , ⊥), uniformly in n and A. Hence the proof is complete. tu where 1, 2, 3 are finite and mutually disjoint alphabets (let = 1 ∪ 2 ∪ 3 in the following), Since Thm. 4.10 parallels Muchnik’s Theorem 3.1, we eq A A, push , pop A, and ⊥ ∈ A. can derive similar corollaries: Q is a finite set of states such that Q ∩ A = ∅. Corollary 4.11 Let be some finite relational signature. : → Q Q If the first-order theory of a -structure A is decidable, ch then the MSO -theory of its basic iteration Aba is With S we associate the configuration graph C(S) = decidable as well. + (A Q, (E)∈), where: N N For any m ∈ , there exists n ∈ such that, for any E = {(wap, wbq) | w ∈ A, (a, b) ∈ eq , () = FO two -structures A and B with A n B, we have (p, q)} for ∈ ch 1 Aba m Bba. + E = {(wp, waq) | w ∈ A , a ∈ push, () = 5. FOREG over pushdown systems (p, q)} for ∈ 2 + E = {(wap, wq) | w ∈ A , a ∈ pop , () = In this section we apply our decidability result for (p, q)} for ∈ 3 MSOch over basic iterations to pushdown systems. We in- troduce pushdown systems where the stack alphabet is the The following theorem is the main result of this section:

7 (=) Theorem 5.1 Let G be a stack structure with decidable |w| = |u| = |v|. Thus, (uap, ubq) ∈ reach, for some FOREG-theory. Then the configuration graph C(S) has a (and hence all) u ∈ A if and only if (ap, bq) ∈ reach, . decidable FOREG-theory. Lemma 5.2 For c, d ∈ A+Q and , ∈ we have The rest of this section is devoted to the proof of this the- (c, d) ∈ reach, if and only if there exist m, n orem. The idea is to define, using the logic FOREG, a suit- 0, m, . . . , 0, 0, . . . , n ∈ , and configurations + able structure A in the stack structure G. Since we assume cm, . . . , c0, d0, . . . , dn ∈ A Q such that: that the FOREG-theory of G is decidable, it follows that the c = c, d = d, = , = first-order theory of A is decidable. Thus, by Corollary 4.11 m n m n the MSOch-theory of the basic iteration A is decidable. () ba (ci, ci1) ∈ reachi,i1 for 1 i m To obtain Thm. 5.1, we give an MSOch-interpretation of (c , d ) ∈ reach(=) the configuration graph C(S) in Aba. 0 0 0,0 For a finite automaton T and states and of T , let (+) (dj , dj ) ∈ reach for 1 j n L(T, , ) be the set of words that label some path from 1 j1,j to in T . Fix regular languages L1, . . . , Lk . Then there ex- Proof. The if-direction is obvious. For the other direction ists a finite automaton T = (, , ) with state set such take for c0 (resp. d0) the leftmost (resp. rightmost) occur- that every language Li is a union of languages of the form rence of a configuration of minimal height along a path in L(T, , ) for certain states , ∈ . For , ∈ let C(S) from the configuration c to the configuration d. tu

+ + For all p, q ∈ Q and , ∈ define a binary predicate reach, = {(up, vq) ∈ A Q A Q | w ∃w ∈ L(T, , ) : up →C(S) vq}. H(p, , q, ) = {(a, b) ∈ A A | (ap, bq) ∈ reach, }.

Thus, reach, = reachL for L = L(T, , ). We will Lemma 5.3 The relation H(p, , q, ) is effectively show that the first-order theory of the structure FOREG-definable over the stack structure G.

+ B = (A Q, (reach, ),∈) (2) Proof. We will construct effectively a finite automa- ton B with state set Q and alphabet 1 such that is decidable. Since the decision procedure for the first-order u (ap, bq) ∈ reach, if and only if a →G b for some theory of B will be uniform in the automaton T , this proves u ∈ L(B, (p, ), (q, )), which proves the lemma. For this, Thm. 5.1. we will construct a finite sequence of automata Bi (i 0) Let , ∈ , p, q ∈ Q, u ∈ A+, and a ∈ A. We write with state set Q and alphabet 1, which converges to (up, uaq) ∈ reach(+) if and only if there exist ∈ and , 2 the automaton B. The finite state automaton B0 contains x the transition (p, ) → (q, ) if and only if () = (p, q) x ∈ such that x ∈ L(T, , ), up →C(S) uaq, |y|2 |y|3 for every prefix y of x, and |x|2 = |x|3 . Thus, and →T for some ∈ 1. Now assume that Bi is (+) already constructed and assume that (up, uaq) belongs to the relation reach, if there exists a path from up to uaq in the configuration graph C(S) whose 0 label belongs to L(T, , ) such that all the configurations in T there are transitions →T , ( ∈ 2) and 0 along this path except the very first one up are of the form →T ( ∈ 3), uvr for some v ∈ A+, and r ∈ Q. Note that (up, uaq) ∈ () = (p, p0), () = (q0, q), and (+) (+) + reach, implies (vp, vaq) ∈ reach, for all v ∈ A . () there exist a ∈ push , b ∈ pop , and u ∈ Symmetrically, we write (uap, uq) ∈ reach, if and only 0 0 0 0 u if there exist ∈ 3 and x ∈ such that x ∈ L(T, , ), L(Bi, (p , ), (q , )) such that a →G b. x uap → uq, |y| |y| for every prefix y of x, and C(S) 2 3 Note that the last point is decidable, since the FOREG- |x| = |x| . Finally, for , ∈ , p, q ∈ Q, u, v ∈ A+ 2 3 theory of G is decidable. In this situation we add the ε- we write (up, vq) ∈ reach(=) if and only if there exists w ∈ ε , transition (p, ) → (q, ) to Bi and call the resulting au- w L(T, , ) such that up →C(S) vq, |y|2 |y|3 for every tomaton Bi+1. We repeat this process as long as we will prefix y of w, and |w|2 = |w|3 . Thus, (up, vq) belongs add new ε-transitions. Note that in each step the state set (+) to the relation reach, if there exists a path from up to is not changed. Let B be the resulting automaton. It is not u vq in the configuration graph C(S) whose label belongs to difficult to prove (ap, bq) ∈ reach, if and only if a →G b, L(T, , ) such that all the configurations along this path for some u ∈ L(B, (p, ), (q, )), which proves the lemma. are of the form wr for some r ∈ Q and w ∈ A+ with tu

8 Define for all p, q ∈ Q and , ∈ unary predicates bj ∈ U(qj1, j1, qj , j ) for 1 j n. D(p, , q, ), U(p, , q, ) A as follows: These definitions and Lemma 5.5 imply: a ∈ D(p, , q, ) ⇔ Lemma 5.6 We have (up, vq) ∈ reach, if and only if (a, b) ∈ H(p, , p0, 0) ∧ there exist u0, v0 ∈ A+, p0, q0 ∈ Q, 0, 0 ∈ such that: ∃b ∈ pop : 0 0 0 0 () = (p , q) ∧ →T 0 0 0 p ∈Q, ∈, ½ ¾ (u, u ) ∈ D(p, , p , ) _∈3 0 0 0 0 0 0 a ∈ U(p, , q, ) ⇔ (u , v ) ∈ {(xa, xb) | x ∈ A , (a, b) ∈ H(p , , q , )} (v0, v) ∈ U(q0, 0, q, ) (b, a) ∈ H(p0, 0, q, ) ∧ ∃b ∈ push : p, p0 0 Now, let us consider the structure p0∈Q,0∈, ( ( ) = ( ) ∧ →T ) _∈2 A = (A ∪ Q, (q)q∈Q,(D(p, , q, ))p,q∈Q,,∈, By Lemma 5.3, the unary predicates D(p, , q, ) and (H(p, , q, ))p,q∈Q,,∈, U(p, , q, ) are FOREG-definable in the stack structure G. (U(p, , q, )) ). The next lemma follows directly from the definition of the p,q∈Q,,∈ predicates D(p, , q, ), H(p, , q, ), and U(p, , q, ). Since each of its relations is FOREG-definable in the stack structure G, and G has a decidable FOREG-theory, A has Lemma 5.4 We have: a decidable first-order theory. Thus, by Thm. 4.10, D(p, , q, ) = {a ∈ A | ∃u ∈ A+ : (uap, uq) ∈ reach()} , Aba = ((A ∪ Q) , , (q)q∈Q, U(p, , q, ) = {a ∈ A | ∃u ∈ A+ : (up, uaq) ∈ reach(+)} \ , (D(p, , q, ))p,q∈Q,,∈, b \ Note that in Lemma 5.4, one might replace the quantifier (H(p, , q, ))p,q∈Q,,∈, ∃u ∈ A+ by ∀u ∈ A+. Lemma 5.2 and Lemma 5.4 imply: \ (U(p, , q, ))p,q∈Q,,∈) Lemma 5.5 We have (up, vq) ∈ reach if and only if , has a decidable MSOch-theory. We finally show that the there exist m, n 0, w ∈ A, a ∈ A, p ∈ Q, ∈ i i i structure B from (2), for which we have to show decid- (0 i m), and b ∈ A, q ∈ Q, ∈ (0 j m) j j j ability of the first-order theory, is MSOch-interpretable in such that: + Aba, which proves Thm. 5.1. Clearly, the universe A Q = m, = n, p = pm, q = qn, of B is first-order definable in Aba using the prefix re- lation and the unary relations q = (A ∪ Q)q for u wa a , v wb b , = 0 m = 0 n q ∈ Q. In order to define the relations reach, of B it suffices by Lemma 5.6 to define the binary relations a ∈ D(p , , p , ) for all 1 i m, b i i i i 1 i 1 D(p, , q, ), U(p, , q, ), {(xa, xb) | x ∈ A, (a, b) ∈ + + ch (a0, b0) ∈ H(p0, 0, q0, 0), H(p, , q, )} A A in A using MSO . The relation {(xa, xb) | x ∈ A, (a, b) ∈ H(p, , q, )} can be defined b ∈ U(q , , q , ) for all 1 j n j j1 j1 j j as H(p,\, q, ) ∩ A+ A+; note that A+ is first-order de- finable in A using the prefix relation and the relations q Define the binary relations D(p, , q, ) , U(p, , q, ) ch + + for q ∈ Q. Finally, the MSO -definitions of D(p, , q, ) A A as follows: (u, v) ∈ D(p, , q, ) if and only if there exist m 0, and U(p, , q, ) follow Buchi’¨ s technique for expressingb the existence of a successful run of an automaton on a finite a , . . . , am ∈ A, p , . . . , pm ∈ Q, , . . . , m ∈ with 1 0 0 word in MSO. This completes the proof of Thm. 5.1. u = va1 am, 6. Open problems p = pm, q = p0, = m, = 0, and

ch ai ∈ D(pi, i, pi1, i1) for 1 i m. We have shown that the MSO -theory (i.e., the frag- ment of the full MSO-theory where set quantification is re- (u, v) ∈ U(p, , q, ) if and only if there exist n 0, stricted to chains) of the basic iteration Aba of a structure b1, . . . , bn ∈ A, q0, . . . , qn ∈ Q, 0, . . . , n ∈ with A can be reduced to the first-order theory of A. Using this result, we have shown that the FOREG-theory of the con- v = ub1 bn, figuration graph C(S) of a pushdown system S over an infi- p = q0, q = qn, = 0, = n, and nite stack structure A can be reduced to the FOREG-theory

9 of A. We plan to investigate whether similar preservation [13] O. Kupferman and M. Y. Vardi. An automata-theoretic theorems can be shown also for temporal logics like CTL, approach to reasoning about infinite-state systems. In CTL, or the modal -calculus. Another interesting candi- CAV 2000, LNCS 1855, pages 36–52. Springer, 2000. date for investigations of this kind is TC2 [26], i.e., first- order logic extended by the transitive closure operator for [14] D. Kuske and M. Lohrey. Logical aspects of Cayley- binary relations. graphs: The monoid case. Int. J. Algebra Comput., 16(2):307–340, 2006. References [15] F. Neven and T. Schwentick. Expressive and effi- cient pattern languages for tree-structured data. In [1] R. Alur, M. Benedikt, K. Etessami, P. Godefroid, PODS’00, pages 145–156. ACM Press, 2000. T. W. Reps, and M. Yannakakis. Analysis of recur- [16] D. Perrin and J.-E. Pin. Infinite Words. Automata, sive state machines. ACM Trans. Program. Lang. Syst, semigroups, logic and games. Pure and Applied Math- 27(4):786–818, 2005. ematics vol. 141. Elsevier, 2004. [2] D. Berwanger and A. Blumensath. The monadic the- [17] M. Rabin. Automata on infinite objects and Church’s ory of tree-like structures. In Automata, logics, and problem. American Mathematical Society, Provi- infinite games, LNCS 2500, pages 285–301. Springer, dence, R.I., 1972. Conference Board of the Mathe- 2002. matical Sciences Regional Conference Series in Math- [3] A. Blumensath and S. Kreutzer. An extension of ematics, No. 13. muchnik’s theorem. J. Log. Comput., 15:59–64, 2005. [18] M. O. Rabin. Decidability of second-order theories [4] A. Carayol and S. Wohrle.¨ The Caucal hierarchy of in- and automata on infinite trees. Trans. Am. Math. Soc., finite graphs in terms of logic and higher-order push- 141:1–35, 1969. down automata. In FSTTCS 2003, LNCS 2914, pages [19] T. Schwentick. On diving in trees. In MFCS’00, 112–123. Springer, 2003. LNCS 1893, pages 660–669. Springer, 2000. [5] D. Caucal. On the transition graphs of Turing ma- chines. Theor. Comput. Sci., 296(2):195–223, 2003. [20] A. L. Semenov. Decidability of monadic theories. In MFCS’84, LNCS 176, pages 162–175. Springer, [6] B. Courcelle and I. Walukiewicz. Monadic second- 1984. order logic, graph coverings and unfoldings of tran- sition systems. Ann. Pure Appl. Logic, 92(1):35–62, [21] S. Shelah. The monadic theory of order. Ann. Math. 1998. (2), 102:379–419, 1975. [7] H.-D. Ebbinghaus and J. Flum. Finite Model Theory. [22] J. Stupp. The lattice-model is recursive in the original Springer, 1991. model. The Hebrew University, Jerusalem, 1975. [8] J. Esparza, S. Kiefer, and S. Schwoon. Abstraction re- [23] W. Thomas. On chain logic, path logic, and first-order finement with Craig interpolation and symbolic push- logic over infinite trees. In LICS’87, pages 245–256. down systems. In TACAS 06, LNCS 3920, pages 489– IEEE Computer Society Press, 1987. 503. Springer, 2006. [24] I. Walukiewicz. Pushdown processes: Games and [9] J. Esparza, A. Kucera, and S. Schwoon. Model check- model-checking. Inf. Comput., 164(2):234–263, 2001. ing LTL with regular valuations for pushdown sys- [25] I. Walukiewicz. Monadic second-order logic on tree- tems. Inf. Comput., 186(2):355–376, 2003. like structures. Theor. Comput. Sci., 275(1–2):311– [10] Y. Gurevich. Monadic second-order theories. In 346, 2002. J. Barwise and S. Feferman, editors, Model-Theoretic [26] S. Wohrle¨ and W. Thomas. Model checking syn- Logics, pages 479–506. Springer, 1985. chronized products of infinite transition systems. In [11] Y. Gurevich and S. Shelah. Rabin’s uniformization LICS’04, pages 2–11. IEEE Computer Society Press, problem. J. of Symb. Logic, 48:1105–1119, 1983. 2004. [12] B. Khoussainov and A. Nerode. Automatic presenta- tions of structures. In Logic and Computational Com- plexity, LNCS 960, pages 367–392. Springer, 1995.

10