• Nem Talált Eredményt

On the Order Type of Scattered Context-Free Orderings

N/A
N/A
Protected

Academic year: 2022

Ossza meg "On the Order Type of Scattered Context-Free Orderings"

Copied!
14
0
0

Teljes szövegt

(1)

J. Leroux and J.-F. Raskin (Eds.): Tenth International Symposium on Games, Automata, Logics, and Formal Verification (GandALF’19).

EPTCS 305, 2019, pp. 169–182, doi:10.4204/EPTCS.305.12

© Kitti Gelle & Szabolcs Iván This work is licensed under the Creative Commons Attribution License.

Kitti Gelle

University of Szeged, Hungary kgelle@inf.u-szeged.hu

Szabolcs Iván

University of Szeged, Hungary szabivan@inf.u-szeged.hu

We show that if a context-free grammar generates a language whose lexicographic ordering is well- ordered of type less thanω2, then its order type is effectively computable.

1 Introduction

If an alphabetΣis equipped by a linear order<, this order can be extended to the lexicographic ordering

< on Σ as u<v if and only if either u is a proper prefix of v or u=xay and v =xbz for some x,y,z∈Σand lettersa<b. So any languageL⊆Σcan be viewed as a linear ordering (L, <). Since {a,b}contains the dense ordering(aa+bb)aband every countable linear ordering can be embedded into any countably infinite dense ordering, every countable linear ordering is isomorphic to one of the form(L, <) for some language L⊆ {a,b}. A linear ordering (or an order type) is called regular or context-free if it is isomorphic to the linear ordering (or, is the order type) of some language of the appropriate type. It is known [2] that an ordinal is regular if and only if it is less thanωω and is context- free if and only if it is less thanωωω. Also, the Hausdorff rank [13] of any scattered regular (context-free, resp.) ordering is less thanω (ωω, resp) [10, 8].

It is known [9] that the order type of a well-ordered language generated by a prefix grammar (i.e. in which each nonterminal generates a prefix-free language) is computable, thus the isomorphism problem of context-free ordinals is decidable if the ordinals in question are given as the lexicograpic ordering of prefixgrammars. Also, the isomorphism problem of regular orderings is decidable as well [15, 3]. At the other hand, it is undecidable for a context-free grammar whether it generates a dense language, hence the isomorphism problem of context-free orderings in general is undecidable [7].

Algorithms that work for the well-ordered case can in many cases be “tweaked” somehow to make them work for the scattered case as well: e.g. it is decidable whether(L, <) is well-ordered or scat- tered [6] and the two algorithms are quite similar.

In this paper we continue to explore the boundary of decidability of the isomorphism problem of context-free orderings. We show that if the order type o(L) of a context-free language Lis known to have the formω×k+nfor some integerskandn, thenkandncan be effectively computed. The main building block for proving this is a decision procedure for solvingo(L(X))=? ω for each nonterminalX, and a recursive algorithm that terminates for languages of order type less thanω2.

2 Notation

Alinear ordering is a pair (Q, <), where Q is some set and the< is a transitive, antisymmetric and connex (that is, for eachx,yQexactly one ofx<y,y<xorx=yholds) binary relation onQ. The pair

*Ministry of Human Capacities, Hungary grant 20391-3/2018/FEKUSTRAT is acknowledged. Szabolcs Iván was supported by the János Bolyai Scholarship of the Hungarian Academy of Sciences. Kitti Gelle was supported by the ÚNKP-19-3-SZTE-86 New National Excellence Program of the Ministry of Human Capacities.

(2)

(Q, <)is also written simplyQif the ordering is clear from the context. A (necessarily injective) function h:Q1Q2, where(Q1, <1)and(Q2, <2)are some linear orderings, is called an(order) embeddingif for eachx,yQ1,x<1yimpliesh(x)<2h(y). Ifhis also surjective,his anisomorphism, in which case the two orderings areisomorphic. An isomorphism class is called anorder type. The order type of the linear orderingQis denoted byo(Q).

For example, the class of all linear orderings contain all the finite linear orderings and the orderings of the integers (Z), the positive integers (N) and the negative integers (N) whose order type is denoted ζ,ω and−ωrespectively. Order types of the finite sets are denoted by their cardinality, and[n]denotes {1, . . . ,n}for eachn≥0, ordered in the standard way.

The ordered sum∑x∈QQx, whereQis some linear ordering and for eachxQ,Qxis a linear ordering, is defined as the ordering with domain{(x,q):xQ,qQx}and ordering relation(x,q)<(y,p)if and only if eitherx<y, orx=yandq<pin the respectiveQx. If eachQxhas the same order typeo1andQ has order typeo2, then the above sum has order typeo1×o2. IfQ= [2], then the sum is usally written as Q1+Q2.

If(Q, <)is a linear ordering andQQ, we also write(Q, <)for the subordering of(Q, <), that is, to ease notation we also use<for the restriction of<toQ.

A linear ordering (Q, <)is calleddense if it has at least two elements and for eachx,yQwhere x<ythere exists azQsuch thatx<z<y. A linear ordering isscatteredif no dense ordering can be embedded into it. It is well-known that every scattered sum of scattered linear orderings is scattered, and any finite union of scattered linear orderings is scattered. A linear ordering is called awell-orderingif it has no subordering of type−ω. Clearly, any well-ordering is scattered. Since isomorphism preserves well-orderedness or scatteredness, we can call an order type well-ordered or scattered as well, or say that an order type embeds into another. The well-ordered order types are calledordinals. For any setΩof ordinals,(Ω, <)is well-ordered by the relationo1<o2 ⇔ “o1can be embedded injectively intoo2but not vice versa”. The principle of well-founded induction can be formulated as follows. AssumePis a property of ordinals such that for any ordinalo, ifPholds for all ordinals smaller thano, thenPholds foro. ThenPholds for all the ordinals.

For standard notions and useful facts about linear orderings see e.g. [13] or [14].

Hausdorff classified the countable scattered linear orderings with respect to their rank. We will use the definition of the Hausdorff rank from [8], which slightly differs from the original one (in whichH0

contains only the empty ordering and the singletons, and the classesHα are not required to be closed under finite sum, see e.g. [13]). For each countable ordinalα, we define the classHαof countable linear orderings as follows. H0 consists of all finite linear orderings, and whenα >0 is a countable ordinal, thenHα is the least class of linear orderings closed under finite ordered sum and isomorphism which contains all linear orderings of the form∑i∈ZQi, where eachQi is inHβi for someβi<α.

By Hausdorff’s theorem, a countable linear orderQis scattered if and only if it belongs toHα for some countable ordinalα. Therank r(Q)of a countable scattered linear ordering is the least ordinal α withQHα.

As an example, ω,ζ,−ω and ω+ζ or any finite sum of the form ∑

i∈[n]

oi withoi∈ {ω,−ω,1}for eachi∈[n]each have rank 1 while(ω+ζ)×ωhas rank 2.

LetΣbe an alphabet (a finite nonempty set) and letΣ+, resp) stand for the set of all (all nonempty, resp) finite words overΣ, ε for the empty word, |u|for the length of the word u,u·vor simply uvfor the concatenation ofuandv. Alanguageis an arbitrary subsetLofΣ. We assume that each alphabet is equipped by some (total) linear order. Two (strict) partial orderings, the strict ordering<sand the prefix ordering<pare defined overΣas follows:

(3)

u<svif and only ifu=u1au2andv=u1bv2for some wordsu1,u2,v2∈Σand lettersa<b,

u<pvif and only ifv=uwfor some nonempty wordw∈Σ.

The union of these partial orderings is the lexicographical ordering<=<s∪<p. We call the language L well-ordered or scattered, if (L, <) has the appropriate property and we define the rank r(L) of a scattered languageLasr(L, <). The order typeo(L)of a languageLis the order type of(L, <). For example, ifa<b, theno

{akb:k≥0}

=−ω ando

{(bb)ka:k≥0}

=ω.

Whenρis a relation over words (like<or<s), we writeKρLifuρvfor each worduKandvL.

An ω-word over Σ is an ω-sequence a1a2. . . of letters ai ∈Σ. The set of all ω-words over Σis denoted Σω. The orderings < and <p are extended to ω-words. An ω-word w is called regular if w=uvω =uvvvv. . .for some finite wordsu∈Σand v∈Σ+. Whenwis a (finite orω-) word overΣ andL⊆Σis a language, thenL<wstands for the language{u∈L:u<w}. Notions likeL≥w,L<sware also used as well, with the analogous semantics.

Acontext-free grammaris a tupleG= (N,Σ,P,S), whereNis the alphabet of thenonterminal sym- bols,Σis the alphabet ofterminal symbols(orletters) which is disjoint fromN,SNis thestart symbol andPis a finite set ofproductionsof the formA→α, whereAN andα is asentential form, that is,

α =X1X2. . .Xk for somek≥0 and X1, . . . ,XkN∪Σ. The derivation relations ⇒, ⇒, ⇒ and ⇒

are defined as usual (where the subscriptℓstands for “leftmost”). Thelanguage generated bya gram- mar Gis defined as L(G) ={u∈Σ |Su}. Languages generated by some context-free grammar are called context-free languages. For any set ∆ of sentential forms, the language generated by∆ is L(∆) ={u∈Σ|α ⇒ufor someα ∈∆}. As a shorthand, we defineo(∆)aso(L(∆)). A languageLis prefix(or prefix-free) if there are no wordsu,vLwithu<pv. A context-free grammarG= (N,Σ,P,S) is called aprefixgrammar ifL(A)is a prefix language for eachAN. WhenX,Y∈N∪Σare symbols of a grammarG, we writeY XifXuY vfor some wordsuandv;XY ifX Y andY X both hold; andYX ifY X but notX Y. A production of the formXX1. . .XnwithXiX for each i∈[n]is called anescaping production.

A regular language over Σis one which can be built up from the singleton languages {a}, a∈Σ and the empty language /0 with finitely many applications of taking (finite) union, concatenationKL= {uv:uK,vL} and iteration K={u1. . .un:n≥0,uiK}. For standard notions on regular and context-free languages the reader is referred to any standard textbook, such as [11].

Linear orderings which are isomorphic to the lexicographic ordering of some context-free (regular, resp.) language are calledcontext-free (regular, resp.) orderings.

3 If o(L) < ω

2

, then o(L) is computable

In this section we consider a context-free grammar G= (N,Σ,P,S) which contains no left recursive nonterminals, and generates a(n infinite) scattered language such that for eachXN,X is usable and L(X)is an infinite language of nonempty words, moreover, each nonterminal but possiblySis recursive and there is no left recursive nonterminal (that is,X+uX vimpliesu6=ε). Any context-free grammar can effectively be transformed into such a form, see e.g. [9].

The section is broken into two parts: the first subsection contains some technical decidability lemmas, while the second one contains the main result that if we know thato(L)2for a well-ordered context- free languageL(so that the Hausdorff-rank ofLis at most one), theno(L)is effectively computable. This computability is already known for so-called ordinal grammars which generate a well-ordered language such that for each nonterminalX,L(X)is a prefix language [9]. However, this is a serious restriction and

(4)

makes many proofs easier since ifKis a prefix language, theno(KL) =o(L)×o(K)for any languageL.

This does not hold for arbitrary languages since e.g.o(a) =ω,o(b) =1 ando(ab) =−ω,o(aa) =ω, o((ac)) =ω ando((ac)(b+ab)) =ω+ (−ω)so a more careful case analysis is required. The reader is advised to skip the first subsection at first read – the proofs of the second part extensively refer to the lemmas of the first part.

3.1 Some technical lemmas

For anω-wordw, letPref(w)⊆Σstand for the set of the finite prefixes ofw. For eachu=a1. . .ak∈Σ

andv=b1. . .bt ∈Σ+letMu,v denote the automaton (without specified final states) depicted in Figure 1.

qε

start qa1 · · · qu qub1 · · · quv

q<s

q>s

Q<p

a1 a2 ak b1 b2 bt−1

bt σ<a1

σ<a2 σ<b1 σ<b2 σ<bt

σ>a1

σ>a2 σ>b1

σ>b2

σ>bt

σ

σ

Figure 1: The automatonMu,v

Proposition 1. For any words u∈Σ and v∈Σ+, the languages Pref(uvω),{w∈Σ:w<suvω}and {w∈Σ:uvω<sw}are regular.

Proof. Letu=a1. . .ak andv=b1. . .bt for the integersk≥0,t>0 and letters ai,bj and consider the automatonMu,vgiven in Figure 1. Then, by settingq<s (q>s, respectively) for the unique accepting state we recognize{w∈Σ:w<suvω}({w∈Σ:uvω <sw}, resp.), and by settingQ<pas the set of final states we recognizePref(uvω).

Lemma 1. For each sentential formαwith L(α)being infinite, we can generate a sequence w0,w1, . . .∈ L(α)and a regular word w∈Σω satisfying one of the following cases:

i) w1<sw2<s. . .and w= W

i≥0wi ii) w1>sw2>s. . .and w= V

i≥0wi

iii) w1<pw2<p. . .and w= W

i≥0wi

Proof. By the pumping lemma of context-free languages, asL(α)is infinite, one can generate a word uL(α)and a partitionu=u1u2u3u4u5such that|u2u4| ≥1 and for eachn≥0, the wordu1un2u3un4u5is inL(α).

Based on the relative order of the five subwords we consider the following cases:

(5)

1. There exists ann0such thatu3un40 <su2u3un40

Let us define the sequence aswn=u1un20+nu3un40+nu5. Let us fixnand letmdenotem=n0+n.

Here we get that wn<swn+1 if and only ifu3um4u5<su2u3um+14 u5, which is true since u3un40 <s u2u3un40impliesu3un40x<su2u3un40yfor anyx,y∈Σ, thus in particular forx=un4u5andy=un+14 u5

as well.

Hence the type of the sequence is of i) and the supremum isw= W

i≥0wi =u1uω2. (Observe that u26=εas that could not satisfyu3un40 <su2u3un40).

2. There exists ann0such thatu2u3un40 <su3un40

Again, u2 cannot be the empty word. Similarly to the first case, let us define the sequence as wn=u1un20+nu3un40+nu5and fixnand letmdenotem=n0+n.

Here we get thatwn+1<swnif and only ifu2u3um+14 u5<su3um4u5, which is true sinceu2u3un40 <s u3un40 impliesu2u3un40x<su3un40yfor anyx,y∈Σ, thus in particular forx=un+14 u5andy=un4u5

as well. So we get that the type of the sequence is ii) (with order type of−ω) and the infimum is w= V

i≥0wi=u1uω2.

3. For eachnit holds thatu3un4pu2u3un4andu46=ε In this caseu3uω4 =u2u3uω4.

Let us fixN=l

|u2|

|u4|

m

+1 and the sequence aswn=u1uN+n2 u3uN+n4 u5. Furthermore, letx∈Σ be the unique word withu3uN4x=u2u3uN4. That is,xis the unique suffix ofuN4 of length|u2|. Hence, for anynNwe also haveu3un4x=u2u3un4for the samex(as we know thatu3un4pu2u3un4, their length differ by|u2|, and the latter word ends withuN4).

We have three subcases:

(a) It holds thatu3uN4u5<su2u3uN+14 u5

First observe that asu2u3uN+14 u5=u3uN4xu4u5, the assumption of the subcase yields u5<s

xu4u5. Then for eachmN we have u3um4u5<su3um4xu4u5=u2u3um4u4u5 =u2u3um+14 u5, implyingu1um2u3um4u5<su1um+12 u3um+14 u5. So the sequence is of type i) and its supremum is eitheru1uω2 (ifu2is nonempty) oru1u3uω4 (otherwise).

(b) It holds thatu2u3uN+14 u5<su3uN4u5

First sinceu2u3uN+14 u5 can be written asu3uN4xu4u5, the assumption of the subcase yields xu4u5 <su5. Then for each mN we have u3um4xu4u5 =u2u3um4u4u5 =u2u3um+14 u5 <s u3um4u5, so we get a sequence of words such thatu1um+12 u3um+14 u5<su1um2u3um4u5. Hence, the sequence is of type ii) with the infimum of eitheru1uω2 (if u2 is nonempty) or u1u3uω4 (otherwise).

(c) It holds thatu3uN4u5<pu2u3uN+14 u5

In this case for eachmNwe haveu3um4u5<pu2u3um+14 u5, so we get an ascending prefix chain. Hence the order type of this sequence of iii) isω with the supremum of eitheru1uω2 (ifu2is nonempty) oru1u3uω4 (otherwise).

4. It holds thatu3<pu2u3andu4=ε Note thatu2cannot be empty in this case.

We have three subcases:

(a) It holds thatu3u5<su2u3u5

(6)

In this case for each n≤0 we have u1un2u3u5 <su1un+12 u3u5 iff u3u5 <su2u3u5 which is the assumption of this subcase. So we get that the sequence type is i) and the supremum is w=u1uω2.

(b) It holds thatu2u3u5<su3u5

Here, similarly to the previous case for each n≤0 we have u1un+12 u3u5 <su1un2u3u5 iff u2u3u5<su3u5, which is implied by the assumption. Hence we have an infinite descending chain with the sequence type of ii) and infimumw=u1uω2.

(c) It holds thatu3u5<pu2u3u5

In the last case sinceu3u5<pu2u3u5, for eachn≤0 we haveu1un2u3u5<pu1un+12 u3u5which is a prefix chain with sequence type of iii) and supremumw=u1uω2.

Observe that it is also decidable which (sub)case applies: first we check for the condition of Case 4 (which is clearly decidable). Then, if that condition does not hold, we check whetheru3uω4 =u2u3uω4 holds. As equality of regular words is decidable, this can be done, and if they are the same, then we again have three sub-conditions concerning finite words. Otherwise, ifu3uω4 6=u2u3uω4, then either u3uω4 <s u2u3uω4, that is,u3un40 <su2u3un40 for somen0, oru2u3uω4 <su3uω4, in which caseu2u3un40 <su3un40 for some n0. But since we know that one of these two cases has to hold, we only have to iterate through all the integersnand compareu3un4 withu2u3un4 and eventually there will be annfor which these two become comparable by<s. (A more efficient algorithm also exists, e.g. by analyzing the direct product automatonMu3,u4×Mu2u3,u4.)

We recall the following characterizations of those context-free grammars generating a scattered (or well-ordered) language from [1]:

Theorem 1 ([1]). Assume G = (N,Σ,P,S) is a context-free grammar such that each nonterminal is usable,ε-free and there are no left-recursive nonterminals. Then

• L(G)is scattered if and only if for each recursive nonterminal X there exists a word uX ∈Σ+such that whenever X+uXα for some u∈Σ,α ∈(N∪Σ), then uu+X.

• If L(G)is scattered and XX are recursive nonterminals, then there exists a word uX,X<puX such that whenever X+uXαfor some u∈Σ,α ∈(N∪Σ), then uuXuX,X.

• L(G)is well-ordered if and only if it is scattered and for each recursive nonterminal X , L(X)<uωX. Moreover, for each X,Xthe words uX and uX,X are effectively computable and it is decidable whether L(X)is scattered, or well-ordered.

Proposition 2. If L(X)is well-ordered for the recursive nonterminal X , thenWL(X) =uωX.

Proof. By Theorem 1,L(X)<uωX. SinceXis recursive and all the nonterminals are usable, there exists some derivation of the formXuX vfor some wordsu,v∈Σand sou=umX for somem>0. SinceX is usable, there exists some wordwL(X)and so for eachn>0, the wordum·nX wvnis inL(X)and is still upperbounded byuωX. As the supremum of these words isuωX, we got the claimed result.

We call an infinite languageL⊆Σaprefix chainif for eachu,vL, eitherupvorvpu, that is, Lis totally ordered by the prefix relation, or equivalently,L⊆Pref(w)for someω-wordw. Clearly, any languageLis either a prefix chain or contains two wordsu,vwithu<sv. Note that ifLis a prefix chain, theno(L) =ω.

Lemma 2. It is decidable for each nonterminal X whether L(X)is a prefix chain.

(7)

Proof. By Lemma 1 we can effectively generate an infinite sequence w0,w1, . . ., either ascending or descending, belonging toL(X)along with its limit, which is of the formuvω for some u∈Σ,v∈Σ+. Now if the sequence is either a>s-chain or a<s-chain, thenL(X)cannot be a prefix chain.

Otherwise, the sequence itself is a prefix chain and its limit isuvω, hence the whole language L(X) is a prefix chain if and only ifL(X)⊆Pref(uvω)which can be effectively decided sincePref(uvω)is a regular language.

Lemma 3. If L is a context-free language with o(L) =ω, thenWL is a computable regular word.

Proof. Applying Lemma 1 we can generate a (necessarily increasing) sequencew0<w1< . . .of words belonging toLalong with their supremumuvω. Since the order type ofLis alsoω, its supremum has to coincide byuvω.

Lemma 4. Let X be a nonterminal such that L(X)is not a prefix chain andα be a sentential form with L(α)being infinite. Then o(Xα)is an infinite order type different fromω.

Proof. SinceL(X)is not a prefix chain and is infinite, there existsu,vL(X)withu<sv. ThenuL(α)<s

vyfor any memberyofL(α), hence each suchvyhas infinitely many lower bounds inL(Xα), thuso(Xα) cannot beω.

The last lemma of the subsection is a bit technical:

Lemma 5. If L1⊆Pref(uvω)is a context-free prefix chain with order typeω for some words u∈Σand v∈Σ+and L2⊆Σis a context-free language with order typeω, then it is decidable whether there exists some w1L1, u∈Σand a∈Σwith w1u<puvω, w1ua<suvω and ua<pWL2.

Proof. Let us writeu=a1. . .akandv=b1. . .bt and consider the automatonMu,v of Figure 1. For each stateqofMu,v, letLu,v(q)stand for the (regular) language{w∈Σ:qε·w=q}.

LetQ1Q<p be the set of those states qfor whichL1Lu,v(q)is nonempty. Since eachLu,v(q)is regular,Q1is computable, moreover,qQ1if and only ifqε·w=qfor somewL1.

Now by Lemma 3 we can compute the regular wordu2vω2 =WL2 and consider the direct product automatonM=Mu,v×Mu2,v2 where inMu2,v2 we use the primed versionqof each stateq.

We claim that there exists wordsw1,u and a letterasatisfying the conditions of the lemma if and only if a state of the form(q<s,q)is reachable from a state(p,qε)inMfor someqQ<p and pQ1.

Indeed: assume (p,qεw= (q<s,q) for such states: let us choose p,q and w so that |w|is the shortest possible. SincepQ1andq<s ∈/Q1,w=uafor some wordu∈Σanda∈Σ. Then,qε·uQ<p, since bothq<s andq>sare trap states inMu2,v2. Sincewis a shortest possible word andq<s,q>s are trap states inMu,v, we get that p·uQ<p. Since pQ1, there is some wordw1L1withqε·w1=p.

Thus, this choice ofw1,uandasatisfies the conditions of the lemma.

And similarly, givenw1L1,u∈Σanda∈Σsatisfying the conditions we can define p=qε·w1, q=qε·ua.

3.2 The main decision procedures

In this part we flesh out the “top-level” results leading to the aforementioned computability result: that the order type of well-ordered context-free languages with Hausdorff-rank at most 1 is computable.

The main building block is the result that it is decidable for any context-free language Lwhether o(L) =ω holds.

(8)

Lemma 6. Ifα=X1X2is a sentential form and for each1≤i≤2we know whether o(Xi) =ωholds or not, then it is also effectively computable whether o(α)isω.

Proof. Clearly, ifo(X1)oro(X2)is some infinite order type different fromω, theno(α)is also such an order type and we can stop. Also, ifX1∈Σ, then o(α) =o(X2) and we are done. We can also decide whetherL(X1X2)is well-ordered and if not, it cannot beω and we can stop.

So we can assume thatX1Nand thusL(X1)is infinite and hence o(X1) =ω by assumption. Let L1,L2andLrespectively stand forL(X1),L(X2)andL(X1X2).

IfX2∈Σ, then we have several subcases:

1. If there exists a worduL1and some lettera<X2withuabeing a prefix of infinitely many words inL1, thenuX2 is strictly larger than each of these wordsv, and sovX2<suX2as well, thuso(L) cannot beωbut some other infinite order type (asuX2Lis preceded by infinitely many members ofL).

2. Otherwise, letuL1. It suffices to show that there are only finitely many elements inLwhich are smaller thanuX2. AssumevX2Lis so thatvX2<puX2 thenv<pu as well, and asuhas only finitely many proper prefixes, we have that there can only be a finite number of such wordsv. Now ifvX2<suX2, then eitherv<u(that’s again a finite number of possibilities, aso(L1) =ωimplies that any worduL1has only a finite number of lower bounds inL1) oru<v. Thus, in this case (asvX2<suX2rules out the possibility ofu<sv) it has to hold thatu<pvandv=uaxfor some a<X2. There are only finitely many possible choices for such lettersa<X2and by assumption (see the condition of the previous subcase), for each such letter,uacan be a prefix of only finitely many wordsvL1.

Thus,uX2 is larger than only a finite number of members ofLfor eachuL1, ando(L) =ω in this case.

We still have to show that it is decidable which of the two cases holds. Observe that ifuais a prefix of infinitely many words inL1 for some worduL1 and letter a<X2, then no wordwL1can satisfy ua<swas then the order type ofL1could not beω. Thus,ua<pWL1in this case for some worduL1

and lettera<X2. On the other hand, ifua<pWL1for some worduL1and lettera<X2, then for any wL1withua<wwe cannot haveua<swsince in that caseua<sW

L1would hold sincew<WL1. Hence, wheneverua<wfor some wordwL1, thenuais a prefix ofw. Since the order type ofL1is assumed to beω, anduais a prefix ofWL1, there has to be an infinite number of such wordsw.

Thus, if X2 ∈Σ, then o(L) is not ω if and only ifua<p W

L1 for some uL1 and a<X2. This condition is decidable: WL1is a computable regular wordu1vω1 by Lemma 3 and we only have to check whether the language L1a∩Pref(u1vω1) is nonempty for some letter a<X2 and the latter is a regular language by Proposition 1.

IfX2N, and thuso(X2) =ω, then we again have several cases:

3. If there exist wordsu,vL1withu<sv, then by Lemma 4 we geto(L)is some infinite order type different thanω.

4. Otherwise,L1is an infinite prefix chain, that is,L1⊆Pref(uvω)for some wordsu∈Σ,v∈Σ+. We have several subcases.

(a) Assume WL1 <WL. Since both are ω-words, we have<s here. Thus there exists some w=w1w2L,w1L1,w2L2withWL1<sw. SinceL1is an infinite prefix chain, there exists somew1L1,w1<pW

L1and|w1|>|w|, yieldingw1<sw. Sow1L2<sw, thuswL has an infinite number of lower bounds inLando(L)6=ωin this subcase.

(9)

(b) Assume there exists some w1L1 such thatw1·WL2<WL1. Again, both beingω-words this has to be a<srelation. This means that there exists somew1L1withw1·WL2<sw1 and sow1·L2<sw1yfor any memberyofL2, thus again,o(L)6=ω in this case.

(c) Assume none of the previous conditions hold: WLW

L1(henceWL1L2=WL1=uvω as well) and for eachw1L1we haveWL1w1·WL2.

We claim that in this case o(L) =ω if and only if for each w1L1 and w<p uvω with w1<pwthere exist only finitely many wordsw2L2such thatw1w2<sw.

For one direction, assume the latter condition holds. It suffices to show that for eachw<puvω there exist only finitely many many wordsw1L1,w2L2with w1w2<w, since (as the supremum of these words isWL1L2=uvω) this yields that each prefix ofo(L)is finite, thus o(L) =ω. So letw1w2<w. Sincew1L1 andL2⊆Pref(uvω), and w<puvω, we either havew1<pworwpw1. The latter would contradict tow1w2<w, hence we havew1<pw.

Thus, there are only finitely many options for choosing such a wordw1L1. Clearly, for each fixedw1L1 there are only finitely many options for choosing wordsw2 withw1w2<pw and by the condition there are only finitely many wordsw2L2 withw1w2<sw, hence in total, there are only finitely many words inL1L2precedingw, showingo(L) =ω.

For the other direction, assume the latter condition doesnot hold. Then there exists some w1L1,w<puvω withw1<pwsuch thatw1w2<swfor infinitely many wordsw2L2. In this case we can writew2=w2axandw=w1w2byuniquely for some lettersa<band words w2,x,y. Since there are only finitely many options for the fixed wordswandw1to choosew2, banda, for some paira<bof letters and wordw2withw1w2bpwthere are infinitely many wordsw2L2such thatw2apw2. LetL2L2denote the (infinite) set of these words and letw1L1be some word inL1with|w1| ≥ |w1w2b|. SinceL1is an infinite prefix chain, such a wordw1 exists andw1w2bpw1, thusw1L2<sw1, and sow1L2<sw1yfor an arbitrary memberyofL2, and sow1yis preceded by infinitely many words inL, yieldingo(L)6=ω.

We still have to show that the condition of Subcase (c) is decidable. We claim that the condition doesnothold if and only if there exists somew1L1and wordsu∈Σ,a∈Σwithw1u<puvω, w1ua<suvω and ua<pWL2. Indeed, ifw1,u,aare such objects, then there is a unique letter b∈Σwithw1ub<puvω. Now we can choosew=w1ubas the conditionua<pW

L2implies the existence of infinitely many wordsw2Lwithuapw2. The other direction is already treated in the proof of Subcase (c).

The condition in this form is decidable due to Lemma 5.

As we covered all the possible scenarios, and in each case we got decidability, we proved the lemma.

Corollary 1. Assumeα=X1. . .Xnis some sentential form where for each Xiwe know whether o(Xi) =ω holds. Then we can decide whether o(α) =ω holds.

Proof. We can assume thatα∈/Σ(otherwiseo(α) =1 and we can stop). Using the standard construc- tion of introducing fresh nonterminalsY1, . . .Yn−1 and productionsY1X1Y2,Y2X2Y3,. . . ,Yn−1Xn−1Xnwe can successively decide forYn−1,Yn−2, . . . ,Y1whethero(Yi) =ω; if for any of them we have thato(Yi)is some other infinite order type, then so iso(Y1) =o(α), otherwiseo(α) =ω.

Theorem 2. It is decidable for each recursive nonterminal X whether o(X) =ω holds.

Proof. By our assumptions ofG, L(X) is infinite. In the first step, we decide whether L(X) is well- ordered. If not, theno(X)is clearly notω and we can stop.

Ábra

Figure 1: The automaton M u,v

Hivatkozások

KAPCSOLÓDÓ DOKUMENTUMOK

33 ◦ Model dependent (simple) correctness is de0ned by means of parsing the visual sentences generated by a model transformation by using the graph grammar of the 35 target language..

In this paper we presented our tool called 4D Ariadne, which is a static debugger based on static analysis and data dependen- cies of Object Oriented programs written in

It is proved that the problem of deciding if a regular expression denotes a star-free language is PSPACE-complete.. The paper also includes a new proof of the PSPACE-completeness

In my dissertation, I endeavoured to map the Hungarian corporate language education scene in order to explore what characterises the context of on-site language

Muller context-free languages (MCFLs) are languages of countable words, that is, labeled countable linear orders, generated by Muller context-free grammars.. Equivalently, they are

Moreover, we define the least fixed point semantics of a context-free jungle grammar in any nondeterministic algebra, viewing the grammar as a system of equations, and we prove

We manipulated two variables between-subjects, Affix Type (prefixes or suffixes) and Stress Location (local root vowel or nonlocal root vowel), for a total of

It is shown that the following five classes of weighted languages are the same: (i) the class of weighted languages generated by plain weighted context-free grammars, (ii) the class