Ltcs–report Solving Language Equations and Disequations Using Looping Tree Automata with Colors Solving Language Equations and Disequations Using Looping Tree Automata with Colors

We extend previous results on the complexity of solving language equations with one-sided concatenation and all Boolean operations to the case where also disequations (i.e., negated equations) may occur. To show that solvability of systems of equations and disequations is still in ExpTime, we introduce a new type of automata working on infinite trees, which we call looping automata with colors. As applications of these results, we show new complexity results for disunification in the description logic FL 0 and for monadic set constraints with negation. We believe that looping automata with colors may also turn out to be useful in other applications.


Introduction
Equations with formal languages as constant parameters and unknowns are among the basic notions of formal language theory, first introduced by Ginsburg and Rice [8], who gave a characterization of the context-free languages by solutions of systems of equations of the resolved form X i = ϕ i (X 1 , . . ., X n ).For equations of the general form ϕ(X 1 , . . ., X n ) = ψ(X 1 , . . ., X n ) built using union and two-sided concatenation, testing their solvability is easily shown to be undecidable [14].The state-of-the-art in this area as of 2007 is presented in a survey by Kunc [10].More recent work shows that undecidability already holds for equations over a one-letter alphabet with concatenation as the only operation [9,11].In contrast, solvability of language equations with concatenation restricted to one-sided concatenation with constants can often be shown to be decidable by encoding the problem into monadic second-order logic on infinite trees (MSO) [15], but this usually does not yield optimal complexity results.
In logic for programming and artificial intelligence, language equations with onesided concatenation are, for instance, relevant in the context of monadic set constraints and unification in description logics (DLs).Unification in DLs has been proposed [4] as a novel inference service that can, for example, be used to detect redundancies in ontologies.As a simple example, assume that one knowledge engineer has defined the concept of "women having only daughters" by the concept term Woman ∀child.Woman.A second knowledge engineer might represent this notion in a somewhat more fine-grained way, e.g., by using the term Female Human in place of Woman.The concept terms Woman ∀child.Woman and Female Human ∀child.(FemaleHuman) are not equivalent, but they are meant to represent the same concept.The two terms can obviously be made equivalent by viewing the concept name Woman as a concept variable and replacing it in the first term by the concept term Female Human.Unification in DLs checks for the existence of such substitutions, and thus can be used to alert the knowledge engineers to potential redundancies in the ontology.In [4] it was shown that unification in the DL FL 0 can be reduced to finite solvability1 of language equations with one-sided concatenation and union, and that this problem is in turn ExpTime-complete.In [3] it was shown that the same complexity result holds for solvability, 2 and in [5] this result was extended to language equations with one-sided concatenation and all Boolean operations, and to other decision problems than just solvability.
Language equations with one-sided concatenation and all Boolean operations can also be regarded as a particular case of equations on sets of terms, known as set constraints, which received significant attention [13] in logic for programming since they can be used in program analysis.In fact, solvability of such language equations corresponds to solvability of monadic set constraints, where all function symbols are at most unary.In [1] it was already shown that solvability of monadic set constraints is an ExpTime-complete problem.
In the present paper, we extend the existing results for language equations with one-sided concatenation and all Boolean operations to the case of finite systems of language equations and disequations (i.e., negated equations).We will show that solvability and finite solvability of such systems are still in ExpTime.The motivation comes again from description logics and from set constraints.Set constraints with negation have been investigated in several papers [7,16,2], where it is shown that solvability in the general case is NExpTime-complete.The exact complexity of the monadic case has, to the best of our knowledge, not been determined yet.In description logics, it makes sense to consider not only unification, but also disunification problems in order to prevent certain unifiers.For example the concept term Woman ∀child.Woman also unifies with Male Human ∀child.(MaleHuman), which could, e.g., be prevented by stating that Woman should not become a subconcept of Male, i.e., that Woman Male must not be unified with Woman.
In Section 2, we formally define language equations and disequations with onesided concatenation and all Boolean operations, and show that their (finite) solvability can be reduced to the existence of certain runs of a corresponding looping tree automaton.In Section 3, we introduce looping tree automata with colors, which can express the condition on the runs formulated in the previous section, and then analyze the complexity of their emptiness problem.Finally, in Section 4 we use these results to determine the complexity of testing (finite) solvability of the systems of language (dis)equations introduced in Section 2, and then in turn apply this result to identify the complexity of solving disunification problems in FL 0 as well as monadic set constraints with negation.

Language (dis)equations with one-sided concatenation
In this section, we first introduce the language (dis)equations that we want to solve, and then we show how solvability can be reduced to a problem for looping automata working on infinite trees.

The problem definition
Given a finite alphabet Σ and finitely many variables X 1 , . . ., X n , the set of language expressions is defined by induction: • any variable X i is a language expression; • the empty word ε is a language expression; • a concatenation ϕa of a language expression ϕ with a symbol a ∈ Σ is a language expression;3 • if ϕ, ϕ are language expressions, then so are (ϕ ∪ ϕ ), (ϕ ∩ ϕ ) and (∼ϕ).
Given a mapping θ = {X 1 → L 1 , . . ., X n → L n } of the variables to languages L 1 , . . ., L n over Σ, its extension to language expressions is defined as We call such a mapping a substitution.
A language equation is of the form ϕ = ψ and a language disequation is of the form ϕ = ψ, where ϕ, ψ are language expressions.The substitution θ solves the equation We are interested in solvability of finite systems of language equations and disequations, where a substitution θ solves such a system iff it solves every (dis)equation in the system.Such a solution is called finite iff the languages L 1 = θ(X 1 ), . . ., L n = θ(X n ) are finite.
Using the fact that, for any sets M 1 , M 2 , we have we can transform a given finite system of language equations and disequations into an equivalent one (i.e., one with the same set of solutions) of the form In order to test such a system for (finite) solvability, we translate it into a looping tree automaton.

Translation into looping tree automata
Given a ranked alphabet Γ, where every symbol has a nonzero rank, infinite trees over Γ are defined in the usual way, that is, every node in the tree is labeled with an element f ∈ Γ and has as many successor nodes as is the rank of f .A looping tree automaton A = (Q, Γ, Q 0 , ∆) consists of a finite set of states Q, a ranked alphabet Γ, a set of initial states Q 0 ⊆ Q, and a transition function where k is the rank of f .A run r of A on a tree t labels the nodes of t with elements of Q, such that the root is labeled with q 0 ∈ Q 0 , and the labels respect the transition function, that is, if a node v has label t(v) in t and label r(v) in r, then the tuple (q 1 , . . ., q k ) labeling the successors of v in r must belong to ∆(q, t(v)).The tree t is accepted by A if there is a run of A on t.The language accepted by the looping tree automaton A is defined as It is well-known that the non-emptiness problem for looping tree automata, that is, the question whether, given such an automaton A, the accepted language L(A) is non-empty, is decidable in linear time [6].
When reducing a finite system of language (dis)equations of the form (1) to a looping tree automaton, we actually consider a very restricted case of looping tree automata.Assume that the alphabet used in the system is Σ = {a 1 , . . ., a m }.
Then we restrict our attention to a ranked alphabet Γ containing a single symbol γ of rank m.Thus, there is only one infinite tree, and the labeling of its nodes by γ can basically be ignored.Every node in this tree can be uniquely represented by a word w ∈ Σ * , where each symbol a i selects the ith successor of a node.Consequently, any run on this tree of a looping tree automaton with set of states Q can be represented as a mapping from Σ * to Q.
Given a finite system of language (dis)equations of the form (1), let Φ denote the set of all subexpressions of ϕ, ψ 1 , . . ., ψ k .We assume that ε, X 1 , . . ., X n ∈ Φ (otherwise, we simply add them).In [5] we have shown how to construct a looping tree automaton A with the set of states Q := 2 Φ , and with a 1-1-correspondence between runs of A and substitutions.To be more precise, given a run r : Lemma 2.1 ( [5]) The mapping of runs to substitutions introduced above is a bijection, and the mapping of substitutions to runs is its inverse.
How do runs that correspond to solutions look like?Given a substitution θ, the corresponding run r θ satisfies for all ξ ∈ Φ. Recall that our system is of the form (1) and that ϕ, ψ 1 , . . ., ψ k belong to Φ. Thus, θ solves the equation ϕ = ∅ iff ϕ / ∈ r θ (w) for all w ∈ Σ * , i.e., the run does not use any states containing ϕ. Consequently, if we remove from A all states containing ϕ, then we obtain an automaton whose runs are in a 1-1-correspondence with the solutions of ϕ = ∅.Let us call the resulting looping tree automaton A ϕ .Obviously, the size of A ϕ is exponential in the size of the input system of language (dis)equations, and this automaton can be constructed in exponential time.To decide solvability of the equation ϕ = ∅ it is enough to test whether A ϕ has a run, which can be done using the (linear-time) emptiness test for looping tree automata.
However, some of the runs of A ϕ may correspond to substitutions that do not solve the disequations.If θ solves the disequation ψ i = ∅, then there is a w ∈ Σ * such that w ∈ θ(ψ i ), which is equivalent to ψ i ∈ r θ (w).Lemma 2.2 A run r of A ϕ corresponds to a solution of the whole system (1) iff for every i, 1 ≤ i ≤ k, there is a word w ∈ Σ * such that ψ i ∈ r θ (w).
If we view the indices 1, . . ., k as colors and assign to each state q of A ϕ the color set κ(q) := {i | ψ i ∈ q}, then the condition in the lemma can be reformulated as follows: we are looking for runs in which each color occurs in the color set of at least one state.We will show in the next section how one can check whether a run satisfying such an additional "color condition" exists.
Finiteness of a solution can also easily be expressed by a condition on runs.In fact, since we have w ∈ θ(X i ) iff X i ∈ r θ (w), we need to look for runs in which the variables X i occur only finitely often.Let us call a state q of A ϕ a variable state if X i ∈ q for some i, 1 ≤ i ≤ n.Lemma 2.3 A run r of A ϕ corresponds to a finite solution of ϕ = ∅ iff it contains only finitely many variable states, i.e., the set {w ∈ Σ * | r(w) is a variable state} is finite.

Looping tree automata with colors
In this section, we first introduce a new type of automata that can express the "color condition" caused by disequations, and then analyze the complexity of the non-emptiness problem for these automata.Definition 3.1 A looping tree automaton with colors is of the form A = (Q, Γ, Q 0 , ∆, K, κ), where A = (Q, Γ, Q 0 , ∆) is a looping tree automaton, K is a finite set (of colors), and κ : Q → 2 K assigns to every state q a set of colors κ(q) ⊆ K.
A run of A = (Q, Γ, Q 0 , ∆, K, κ) on a tree t is a run of the underlying looping tree automaton (Q, Γ, Q 0 , ∆) on t.The set κ(r) of colors of the run r is defined as κ(r) := {ν ∈ K | there is a node v in t with ν ∈ κ(r(v))}.
The run r satisfies the color condition if K = κ(r).The tree t is accepted by the looping tree automaton with colors A if there is a run of A on t that satisfies the color condition.The language L(A) accepted by the looping tree automaton with colors A is the set of all trees accepted by A.

Decidability of the emptiness problem
In order to show decidability of the non-emptiness problem for looping tree automata with colors, we reduce it to the non-emptiness problem for Büchi tree automata.A Büchi tree automaton A = (Q, Γ, Q 0 , ∆, F ) is a looping tree automaton that additionally is equipped with a set F of final states.A run r of this automaton on a tree t satisfies the Büchi acceptance condition if, on every infinite path through the tree, infinitely many nodes are labeled with final states.The tree t is accepted by the Büchi tree automaton A if there is a run of A on t that satisfies the Büchi acceptance condition.Again, the language L(A) accepted by the Büchi tree automaton A is the set of all trees accepted by A. It is well-known that the emptiness problem for Büchi tree automata is decidable in quadratic time [17].
Let A = (Q, Γ, Q 0 , ∆, K, κ) be a looping tree automaton with colors.The corresponding Büchi tree automaton ) is defined as follows: The automaton B A simulates A in the first components of its states.The second component guesses in which subtree the still required colors are to be found.The Büchi acceptance condition ensures that only runs where these guesses are correct are accepting runs.
Proof.First, assume that r is a run of A on t that satisfies the color condition, i.e., κ(r) = K.For each color ν ∈ K, select a node v ν of t such that ν ∈ κ(r(v ν )) and v ν has minimal distance from the root, i.e., no node u in t strictly above v ν satisfies ν ∈ κ(r(u)).We now construct a run of B A on t by adding to r the second components of the states of B A .Consider an arbitrary node v in t.We assign to this node the color set The mapping r from the nodes of t to the states of B A is defined as r (v) = (r(v), λ(v)).We claim that this mapping is a run of B A on t that satisfies the Büchi acceptance condition.
To show that r is indeed a run of B A , consider an arbitrary node v of t.Let v 1 , . . ., v k be the successor nodes of v.We must show that (( , and thus it is sufficient to show that Pairwise disjointness of the sets λ(v 1 ), . . ., λ(v k ) is an immediate consequence of the fact that we have chosen only one node v ν for each color ν, and such a node can belong only to one of the successor subtrees of v. To show that Thus, v ν lies below v, which shows that ν ∈ λ(v).Since v ν was chosen so that it has minimal distance from the root, ν ∈ κ(r(v)) is not possible.Thus, we have shown that shows that the first option is not possible.Consequently, v ν belongs to one of the subtrees below v, which yields ν ∈ λ(v i ) for some i, 1 ≤ i ≤ k.
To show that r satisfies the Büchi acceptance condition, consider the maximal distance of the color nodes v ν for ν ∈ K from the root.Since K is finite, this maximal distance is a well-defined natural number d.Any node v that has a larger distance from the root than d cannot be equal to or have below itself any of the color nodes.Consequently, λ(v) = ∅.This shows that, in any infinite path in t, infinitely many nodes are labeled by r with a state of B A whose second component is ∅.Since these are exactly the final states of B A , this shows that r satisfies the Büchi acceptance condition.Thus, we have shown that any tree accepted by A is also accepted by B A , i.e., L(A) ⊆ L(B A ).
To show that the inclusion in the other direction also holds, assume that r is a run of B A on t that satisfies the Büchi acceptance condition.Let r be the mapping from the nodes of t to Q that is obtained from r by disregarding the second components of states, i.e., if r (v) = (q, L) , then r(v) = q.Obviously, r is a run of A. It remains to show that it satisfies the color condition.Assume that there is a color ν ∈ K that does not occur in κ(r).We claim that this implies that there is an infinite path in t satisfying the following property: ( * ) for any node v in this path, the second component of r (v) contains ν.Since this would imply that r does not satisfy the Büchi acceptance condition, this then shows that such a color cannot exist, i.e., K = κ(r).
To show the existence of an infinite path satisfying property ( * ), it is sufficient to show the following: if v is a node in t such that the second component L of r (v) contains ν, then there is a successor node v i of v such that the second component The existence of such a successor node is an immediate consequence of the definition of the transition relation of B A and the fact that ν cannot be an element of κ(r(v)) since we have assumed ν ∈ κ(r).
As an immediate consequence of this proposition we have that the non-emptiness problem for looping tree automata with colors is decidable: given a looping tree automaton with colors A, we can construct B A , and then use the quadratic nonemptiness test for Büchi automata.Regarding the complexity of this decision procedure, we can observe that the size of B A is polynomial in the number of states of A, but exponential in the number of colors.
Theorem 3.3 The non-emptiness problem for looping tree automata with colors can be decided in time polynomial in the number of states, but exponential in the number of colors.
The non-emptiness for looping tree automata with colors can actually also be reduced to the one for looping tree automata without colors.This reduction will be described in Subsection 3.2.In contrast to the reduction to Büchi tree automata described above, this reduction is not language-preserving, but only emptiness-preserving.In fact, we will show in Subsection 3.3 that looping tree automata with colors are more expressive than looping tree automata.
Finally, in Subsection 3.4 we will determine the exact worst-case complexity of the emptiness problem for looping tree automata with colors w.r.t. the overall size of the input automaton.

Reduction to looping tree automata without colors
It is, actually, also possible to reduce the non-emptiness problem for looping tree automata with colors to the one for looping tree automata without colors.In this reduction, however, we do not get an automaton accepting the same tree language, but only one that behaves the same w.r.t. the emptiness problem.More precisely, we will show that we can transform the Büchi tree automaton B A constructed from the looping tree automaton with colors A into a looping tree automaton without colors Let A = (Q, Γ, Q 0 , ∆, K, κ) be a looping tree automaton with colors, and B A = (Q , Γ, Q 0 , ∆ , F ) the corresponding Büchi tree automaton, as introduced above.Recall that a transition ((q, L), f ) → ((q 1 , L 1 ), . . ., (q k , L k )) is called decreasing if |L| > |L i | holds for all i, 1 ≤ i ≤ k, and non-decreasing otherwise.Lemma 3.8 states that any non-decreasing transition satisfies the following two properties: We call a non-decreasing transition ((q, L), f ) → ((q 1 , L 1 ), . . ., Let N be the cardinality of Q.The looping tree automaton without colors C A is defined as this transition is decreasing or trivial n > 0, n i = n − 1, and n j = N for all j = i if this is a non-decreasing transition with Proof.First, assume that L(C A ) = ∅.Let r be a run of C A on some tree t.If we remove the third component of all states in this run, then we obviously obtain a run r of B A .It remains to show that this run satisfies the Büchi acceptance condition.Assume that there is an infinite path in t such that r does not assign states with empty second component to the nodes of this path from some point on.Then, less than |K| decreasing transitions and no trivial transitions can be applied in this path.Consequently, from some point on, only non-trivial nondecreasing transitions are applied in such a way that the successor node with the non-empty color set is always the one on the path.However, by the definition of ∆ , this is possible at most N times in a row, and not infinitely often.
Second, assume that L(B A ) = ∅.Let r be a run of B A on some tree t.Since the set of final states of B A is reproducing in the sense that successor states of Figure 1: Cutting out a slice between two repeated states.
a final state are also final, we know that every infinite path in r ends with an infinite sequence of final states.By König's Lemma, this implies that we have only finitely many occurrences of non-final states in r .We choose r and t such that the number of occurrences of non-final states is minimal, i.e., there is no tree t and run r of B A on t that contains fewer occurrences of non-final states.
If such a minimal run r on a tree t cannot be turned into a run of C A on t by adding appropriate numbers as third components of the states, then there is a path in r that contains a sequence of consecutive non-trivial non-decreasing transitions of length greater than N .Since the transitions are non-trivial, the states in this sequence are all non-final, and since it is longer than N , at least one of the states occurs twice.We can now modify t and r by cutting out the slice between these repeating states: if the first occurrence of this state is at node v and the second at node v , then we remove all nodes equal to or below v that are not equal to or below v , as illustrated in Figure 1.
It is easy to see that this yields a tree and a run on this tree that satisfies the Büchi acceptance condition.However, since this new run contains fewer occurrences of non-final states, this contradicts our choice of t and r .Consequently, r can be turned into a run of C A by adding appropriate numbers as third components of the states.
Together with Proposition 3.2, this lemma yields the following proposition.
Proposition 3.5 For every looping tree automata with colors A we can effectively construct a looping tree automaton without colors This construction can be carried out in time polynomial in the number of states of A, but exponential in the number of colors of A.

Expressiveness
We say that a class C 2 of tree automata is at least as expressive as another such class C 1 if every tree language that can be accepted by an automaton of class C 1 can also be accepted by an automaton of class C 2 .The class C 2 is more expressive than the class C 1 if additionally there is a tree language that can be accepted by an automaton of class C 2 , but not by one of class C 1 .
Theorem 3.6 Büchi tree automata are more expressive than looping tree automata with colors, and looping tree automata with colors are more expressive than looping tree automata.
Proof.Proposition 3.2 shows that Büchi tree automata are at least as expressive as looping tree automata with colors.Thus, to show the first statement of the theorem, it remains to exhibit a tree language that can be accepted by a Büchi tree automaton, but not by a looping tree automaton with colors.Let Γ := {a, b} where a, b are function symbols of arity 1, and define L ∞a := {t | t is an infinite tree over Γ containing a infinitely often}.
It is well-known (and easy to see) that L ∞a can be accepted by a Büchi tree automaton.Now assume that A = (Q, Γ, Q 0 , ∆, K, κ) is a looping tree automaton with colors that accepts L ∞a , and let n > |Q|.Consider the infinite tree t ∈ L ∞a whose only path starts with a, and where between two consecutive occurrences of a there are exactly n occurrences of b.Let r be a run of A that accepts t, i.e., satisfies the color condition.Thus, there is a node v in t such that all the colors in K have already been seen when the run reaches this node.Without loss of generality we can assume that v is labeled with a (otherwise, we just go to the next a).In the b-block of length n > |Q| after this a, r must label two different nodes with the same state from Q.But then we can modify t into t such that all nodes after v are labeled with b, and there is a run r of A on t that coincides with r up to the node v. Thus, r also satisfies the color condition, which shows that A accepts t ∈ L ∞a .This is a contradiction, which shows that a looping tree automaton with colors accepting L ∞a cannot exist.
Regarding the second statement, any looping tree automaton can be viewed as a looping tree automaton with colors where the color set is empty, which shows that looping tree automata with colors are at least as expressive as looping tree automata.Thus, it remains to exhibit a tree language that can be accepted by a looping tree automaton with colors, but not by a looping tree automaton without colors.Let Γ be as above, and define L ≥1a := {t | t is an infinite tree over Γ containing at least one a}.
The following looping tree automaton with colors A = (Q, Γ, Q 0 , ∆, K, κ) obviously accepts L ≥1a : • ∆(q a , a) := {q a , q b }, ∆(q b , b) := {q a , q b }, ∆(q a , b) := ∅ =: ∆(q b , a); • K := {a} and κ(q a ) := {a}, κ(q b ) := ∅.Now assume that A = (Q , Γ, Q 0 , ∆ ) is a looping tree automaton without colors that accepts L ≥1a , and let n > |Q |.Consider the tree t ∈ L ≥1a that starts with n nodes labeled with b, followed by a node labeled with a, and after that has only nodes labeled with b.Then there must be a run r of A on t .Since n > |Q |, there is a state of Q that occurs twice in r on the first n nodes.Consequently, if we modify t into t by replacing the only a by b, we obtain a tree t ∈ L ≥1a on which nevertheless there is a run of A .This is a contradiction, which shows that a looping tree automaton without colors accepting L ≥1a cannot exist.

The exact complexity of the emptiness problem
If we consider the complexity of the emptiness test described in Subsection 3.1 w.r.t. the overall size of the input automaton, then the test yields an ExpTime upper bound for the emptiness problem.In this section, we show that the problem is actually NP-complete.
Obviously, the size of A C is polynomial in the size of L and C.
A run r of A C on the unique infinite tree over Γ contains, for every i, 1 ≤ i ≤ n, either p i or ¬p i , i.e., it determines a propositional valuation.If this run satisfies the color condition, then every clause c belongs to κ(r), i.e., there is a literal that occurs in r (i.e., is true in the valuation determined by r) and that is contained in c.This shows that runs satisfying the color condition determine valuations that satisfy all clauses in C. Conversely, a propositional valuation determines a unique run r, by choosing for every i the literal that is true in this valuation.If the valuation satisfies C, then for each clause c one of its literals is true, and thus occurs in r.Consequently, each clause occurs in the color set κ(r), which shows that r satisfies the color condition.Therefore, the clause set C is satisfiable iff Since the satisfiability problem for sets of propositional clauses is NP-hard, this shows that the same is true for the non-emptiness problem for looping tree automata with colors.
Proposition 3.7 The non-emptiness problem for looping tree automata with colors is NP-hard.
To show that the non-emptiness problem for looping tree automata with colors is in NP we consider the Büchi tree automaton constructed in the previous subsection.But first, we eliminate all states in the given automaton that do not occur in any run: these states can be identified in polynomial time using the emptiness test for looping tree automata [6].The resulting automaton has the same set of runs on any tree, and thus also accepts the same language.
Let us now assume that all states of the looping tree automaton with colors A = (Q, Γ, Q 0 , ∆, K, κ) occur in some run, and that the set of colors K is nonempty. 4Let B A = (Q , Γ, Q 0 , ∆ , F ) be the Büchi automaton constructed from A in the previous section.Call a transition ((q, L), f ) → ((q 1 , L 1 ), . . ., (q k , L k )) Otherwise, the transition is called non-decreasing.The following lemma is an easy consequence of the definition of ∆ .
Lemma 3.8 If ((q, L), f ) → ((q 1 , L 1 ), . . ., (q k , L k )) is non-decreasing, then κ(q)∩ L = ∅ and there is an i, 1 ≤ i ≤ k, such that L i = L and L j = ∅ for all j = i.Now, assume that r is a run of B A satisfying the Büchi acceptance condition.This run starts with an initial state (q 0 , K) ∈ Q 0 = Q 0 × {K}.If the first transition that is applied is a non-decreasing transition, then there is exactly one successor node n 1 of the root to which r assigns a state with K = ∅ as second component, whereas all the other nodes are assigned states with empty second components (i.e., final states).If another non-decreasing transition is applied to n 1 , then there is exactly one successor node of n 1 to which r assigns a state with K = ∅ as second component, etc.Since r satisfies the Büchi acceptance condition, after a finite number of non-decreasing steps we reach a node v to which a decreasing transition is applied.Let this decreasing transition be of the form ((q, K), ) → ((q 1 , L 1 ), . . ., (q k , L k )) (where here and in the following, the alphabet symbol from Γ is irrelevant).Since the transition is decreasing, we have . ., v k be the successor nodes of v, and consider all v i such that L i = ∅.We can now apply the same analysis as for the root and K to the nodes v i and L i = ∅, i.e., we follow a chain of non-decreasing transitions that reproduce L i until we find the next decreasing transition.This can be done until all color sets are empty.Basically, this construction yields a finite tree of decreasing transitions satisfying certain easy to check properties (see Definition 3.9 below).Our NP-algorithm guesses such a tree and checks whether the required properties are satisfied.Before we can formally define the relevant properties of this tree, we need to introduce one more notation.
Let L ⊆ K be a non-empty set of colors and let q, q be states in Q.We say that q is directly L-reachable from q if there is a transition (q, ) → (q 1 , . . ., q k ) in ∆ such that q = q i for some i, 1 ≤ i ≤ k, and L ∩ κ(q) = ∅.Note that this implies that there is a non-decreasing transition ((q, L), ) → ((q 1 , L 1 ), . . ., (q k , L k )) with L i = L and L j = ∅ for j = i in the transition relation ∆ of B A .We say that q is L-reachable from q if there is a sequence of states p 0 , . . ., p ( ≥ 0) such that q = p 0 , q = p , and p i+1 is directly L-reachable from p i for all i, 0 ≤ i < .
Definition 3.9 Given a looping tree automaton with colors A and the corresponding Büchi tree automaton B A , a dt-tree for B A is a finite tree T whose nodes are decreasing transitions of B A such that the following properties are satisfied: • the root of T is of the form ((q, K), ) → ((q 1 , L 1 ), . . ., (q k , L k )) such that q is K-reachable from some initial state of A; • if ((q, L), ) → ((q 1 , L 1 ), . . ., (q k , L k )) is a node in T and i 1 , . . ., i are all the indices i with L i = ∅, then this node has successor nodes of the form ((q i j , L i j ), ) → • • • such that q i j is L i j -reachable from q i j for j = 1, . . ., .
Lemma 3.10 We have L(B A ) = ∅ iff there exists a dt-tree for B A .
Proof.For the "only if" direction, we have already sketched above how a run of B A satisfying the Büchi acceptance condition on some tree t can be used to construct a dt-tree for B A .
For the "if" direction, it also easy to see how a dt-tree T for B A can be turned into a run r T of B A satisfying the Büchi acceptance condition.If the root of T is of the form ((q, K), ) → ((q 1 , L 1 ), . . ., (q k , L k )), where q is K-reachable from the initial state q 0 of A, then the run r T labels the root with (q 0 , K).It uses the fact that q is K-reachable from q 0 to apply a sequence of non-decreasing transitions leading from the root to a node v labeled with (q, K).The nodes v branching off from this path from the root to v are labeled with states of the form (q , ∅).By our assumptions on A, q occurs in some run r q of A. This run can be used to generate the part of r T below the node v by using the part of r q below the node labeled by r q with q , and extending its states with the second component ∅.
Now, let us go back to the node v, which is labeled with (q, K) by r T .Its successor nodes are labeled according to the decreasing transition ((q, K), ) → ((q 1 , L 1 ), . . ., (q k , L k )).For the successors nodes of v labeled in this way, each state whose second component is ∅ can be treated as described above for the node v .Each state with a non-empty second component can be processed as described for the root above, etc.Since the leaves of T have empty color sets on their right-hand sides, it is easy to see that this way we actually construct a run r T satisfying the Büchi acceptance condition.
The lemma shows that it is enough to design an algorithm that checks for the existence of a dt-tree.For this to be possible in non-deterministic polynomial time, we need to know that the size of dt-trees is polynomial in the size of A. We can actually show the following linear bound in the number of colors.

Lemma 3.11
The number of nodes of a dt-tree is bounded by 2•|K|.
In a dt-tree, for every color there is exactly one transition removing it, and every removing transition removes at least one color.Consequently, a dt-tree can contain at most |K| removing transitions.Since decreasing transitions that are leaves in a dt-tree are necessarily removing, this also shows that the number of leaves of a dt-tree is bounded by |K|.
Any branching transition increases the number of leaves by at least one, which shows that a dt-tree can contain at most |K| − 1 branching transitions.Since every decreasing transition is either removing or branching, this completes the proof of the lemma.
Together with Lemma 3.10, this lemma yields the desired NP upper bound.
Proposition 3.12 The non-emptiness problem for looping tree automata with colors is in NP.
Proof.After modifying the input automaton (in polynomial time) so that all states are used in some run, the algorithm starts by guessing a decreasing transition ((q, K), ) → ((q 1 , L 1 ), . . ., (q k , L k )) and then checks (in polynomial time) whether q is K-reachable from some initial state.For every index i such that L i = ∅, the algorithm then guesses a decreasing transition ((q i , L i ), ) → . . .and checks whether q i is L i -reachable from q i , etc.The Lemma 3.11 ensures that overall only linearly many decreasing transitions need to be guessed.
Note that, though the algorithm checks whether L(B A ) = ∅, it never explicitly constructs the (exponentially large) Büchi automaton B A .
Given the NP-hardness result of Proposition 3.7, we thus have determined the exact worst-case complexity of the non-emptiness problem.
Theorem 3.13 The non-emptiness problem for looping tree automata with colors is NP-complete.

Applying the results
We will first show that the results obtained so far allow us to determine the exact complexity of (finite) solvability of finite systems of language (dis)equations with one-sided concatenation.
Proposition 4.1 For a given finite system of language (dis)equations of the form (1), solvability and finite solvability are decidable in ExpTime.
Proof.Let A φ = (Q, Γ, Q 0 , ∆) be the looping tree automaton constructed from the system (1) in Section 2.2, and define K := {1, . . ., k} and κ(q) := {i ∈ K | ψ i ∈ q} for all q ∈ Q.According to Lemma 2.2, the system (1) has a solution iff the looping tree automaton with colors A = (Q, Γ, Q 0 , ∆, K, κ) has a run satisfying the color condition, i.e., accepts a non-empty language.As shown in the previous section, from A we can construct a Büchi automaton B A such that L(A) = L(B A ) and the size of B A is polynomial in the number of states, but exponential in the number of colors of A. Since the number of states of A is exponential in the size of the system (1), but the number of colors is linear in that size, the size of B A is exponential in the size of the system (1).As the emptiness problem for Büchi automata can be solved in polynomial time, this yields the desired ExpTime upper bound for solvability.
For finite solvability, we also must take the condition formulated in Lemma 2.3 into account, i.e., we are looking for runs of B A such that states of B A whose first components are variable states of A occur only finitely often.This condition can easily be expressed by modifying the Büchi automaton B A , as described in a more general setting in the proof of the next lemma.Since the new Büchi automaton constructed in that proof is linear in the size of the original automaton, this yields the desired ExpTime upper bound for finite solvability.
there is a run of B on t that contains only finitely many states from P }.
Basically, this Büchi automaton guesses (by decreasing the second component of a state to 0) that from now on only states from Q \ P will be seen.In fact, once the second component is 0, it stays 0 in all successor states, and only states from Q \ P are paired with 0. Since F contains only states with second component 0, this enforces that on every path eventually only states with second component 0 (and thus first component in Q \ P ) occur.By König's lemma, this implies that a run of B satisfying the Büchi acceptance condition contains only finitely many states with second component 1, and thus only finitely many states whose first component belongs to P .
Since (finite) solvability of language equations that are simpler than the ones considered here are ExpTime-hard [4,3], we thus have determined the exact complexity of (finite) solvability of our systems of language (dis)equations.

Syntax
Semantics Table 1: Syntax and semantics of FL 0 -concept terms.
Theorem 4.3 The problems of deciding solvability and finite solvability of finite systems of language (dis)equations of the form (1) are ExpTime-complete.

Disunification in FL 0
Description logics (DLs) are a well-investigated family of logic-based knowledge representation formalisms.They can be used to represent the relevant concepts of an application domain using concept terms, which are built from concept names and role names using certain concept constructors.From a semantic point of view, concept names and concept terms represent sets of individuals, whereas roles represent binary relations between individuals.The expressive power of a given DL depends on what concept constructors are available.Here, we are concerned with the DL FL 0 .
Unification in FL 0 has been investigated in detail in [4].In particular, it is shown there that solvability of FL 0 -unification problems is an ExpTime-complete problem.The ExpTime upper bound is based on a reduction to finite solvability of a restricted form of language equations with one-sided concatenation.In this subsection, we use Theorem 4.3 to show that this upper bound also holds for FL 0 -disunification problems.But first, we introduce syntax and semantics of FL 0 .
Starting from the finite and disjoint sets N c of concept names and N r of role names, FL 0 -concept terms are built using the concept constructors conjunction (C D), value restriction (∀r.C), and the top concept ( ).For example, the concept term Woman ∀child.Woman.
describes the concept of "women having only daughters," using the concept name Woman and the role names child.
The semantics of concept terms is defined as in first-order predicate logic, using the notion of an interpretation.In order to define (dis)unification of concept terms, we first have to introduce the notions of concept patterns and substitutions operating on concept patterns.To this purpose, we need a finite set of concept variables N v (disjoint from N c ∪ N r ).FL 0 -concept patterns are FL 0 -concept terms defined over the set N c ∪ N v of concept names and the set N r of role names.For example, given A ∈ N c , X ∈ N v , and r ∈ N r , ∀r.A ∀r.∀r.X is an FL 0 -concept pattern.
A substitution σ is a mapping from N v into the set of all FL 0 -concept terms.This mapping is extended from variables to concept patterns in the obvious way: The first step towards transforming FL 0 -disunification problems into finite systems of language (dis)equations is to transform concept terms and patterns into an appropriate normal form.By using the equivalence ∀r.(C D) ≡ ∀r.C ∀r.D as a rewrite rule from left to right, any FL 0 -concept pattern can be transformed into an equivalent term that is either or a (non-empty) conjunction of patterns of the form ∀r 1 .• • • ∀r m .A for m ≥ 0 (not necessarily distinct) role names r 1 , . . ., r m ∈ N r and a concept name or concept variable A ∈ N c ∪ N v .We abbreviate ∀r 1 .• • • ∀r m .A by ∀r 1 . . .r m .A, where r 1 . . .r m is considered as a word over the alphabet of all role names N r .In addition, instead of ∀w 1 .A . . .∀w .A we write ∀L.A where L := {w 1 , . . ., w } is a finite set of words over N r .The term ∀∅.A is considered to be equivalent to .Using these abbreviations, any FL 0 -concept pattern C can be rewritten as for finite sets of words S A , S X (A ∈ N c , X ∈ N v ) over the alphabet N r .If C is a concept term, i.e., a pattern that does not contain concept variables, then we have S X = ∅ for all X ∈ N v .Recall that the term ∀∅.X is equivalent to , and can thus be removed from the conjunction.
Correctness of our (yet to be defined) reduction from disunification to solvability of language (dis)equations depends on the following (easily provable) characterization of (in)equivalence between FL 0 -concept terms: Next, let us analyze the application of a substitution to a concept pattern in terms of the normal form introduced above.
Lemma 4.6 Let C be a pattern with normal form as described in (2) and let σ be a substitution such that for all X ∈ N v .Then we have where S X S X,A stands for the concatenation of the language S X with the language S X,A .The only remaining problem is that the language (dis)equations E C 0 ,D 0 (A) and D C i ,D i (A) used in this lemma are actually not language equations with one-sided concatenation as introduced in Section 2, since concatenation of constants is performed from the left rather than from the right.However, this problem can easily be overcome by reversing all concatenations.For a finite language S, its mirror image S mir is obtained in the obvious way, by mirroring all words in it, where (a 1 . . .a n ) mir := a n . . .a 1 .Given the language equation The The following lemma is thus an immediate consequence of Lemma 4.8.
Lemma 4.9 The disunification problem {C 0 ≡ ?D 0 , C 1 ≡ ?D 1 , . . ., C k ≡ ?D k } has a solution iff for every A ∈ N c , there is a substitution θ A such that • θ A (X A ) is finite for all A ∈ N c and all variables X occurring in the problem; • θ A solves the language equation E C 0 ,D 0 (A) for all A ∈ N c ; • for every index i ∈ {1, . . ., k} there is a concept name A ∈ N c such that θ A solves the language disequation D C i ,D i (A).
In order to take care of the last condition of the lemma, we consider functions f : {1, . . ., k} → N c .Given such a function f , we define, for each A ∈ N c , the system of language (dis)equations DE f (A) as The following theorem is then an immediate consequence of Lemma 4.9.
Theorem 4.10 The disunification problem {C 0 ≡ ?D 0 , C 1 ≡ ?D 1 , . . ., C k ≡ ?D k } has a solution iff there is a function f : {1, . . ., k} → N c such that, for every concept names A ∈ N c , the system of language (dis)equations DE f (A) has a finite solution.
Since there are exponentially many functions f : {1, . . ., k} → N c and finite solvability of each system of language (dis)equations DE f (A) can be tested in exponential time by Theorem 4.3, this yields an overall exponential time complexity.ExpTime-hardness already holds for the special case of unification [4].

Monadic set constraints
Set constraints [1] are constraint systems in which the variables range over sets of terms.They can, for example, be used for program analysis.Here, we are concerned with set constraints with negation, as considered in [7,16,2].
As already mentioned in [3] and [5], there is a close connection between language equations with one-sided concatenation and monadic set constraints, i.e., set constraints where all function symbols are unary or nullary.For the case of set constraints without negation (i.e., where only inclusions between sets are allowed), it has been known for a long time [1] that the unrestricted case is NExpTime-complete and the monadic one (with at least two unary symbols and at least one nullary symbol) is ExpTime-complete.For the case of set constraints with negation (i.e., where inclusions and negated inclusions between sets are allowed), NExpTime-completeness for the unrestricted case has been shown by several authors [7,16,2], but to the best of our knowledge, the monadic case has not been investigated.In this subsection, we use Theorem 4.3 to show the ExpTime upper bound for the monadic case also holds with negation.But first, we need to introduce set constraints with negation.
Given a finite signature Ω, i.e., a finite set of function symbols with associated arities, the set T (Ω) of ground terms over Ω is defined in the usual way: every nullary function symbol a ∈ Ω belongs to T (Ω), and if f ∈ Ω is an n-ary function symbol (n ≥ 1) and t 1 , . . ., t n ∈ T (Ω), then f (t 1 , . . ., t n ) ∈ T (Ω).
Definition 4.12 Let X be a finite set of variables and Ω be a finite signature, which is disjoint from X .Set expressions over Ω and X are defined inductively: • Every variable X ∈ X and every nullary function symbol a ∈ Ω is a set expression.
If E, E are set expressions, then E ⊆ E is a positive set constraint and E ⊆ E is a negative set constraint.A finite system of set constraints with negation is a finite set of positive and negative set constraints.
The following lemma shows that the condition L S 1 ∪ . . .∪ L Sn ⊆ CΣ * can be expressed using language equations.As an easy consequence of these two lemmas we thus obtain that solvability of finite systems of monadic set constraints with negation can be reduced in polynomial time to solvability of finite systems of language (dis)equations.
Theorem 4.15 Let S be a finite system of monadic set constraints with negation, and assume that X is a variable that does not occur in X = {X 1 , . . ., X n }.Then S is solvable iff the finite system of language (dis)equations Since ExpTime-hardness already holds for monadic set constraints without negation [1], we have thus shown the following theorem.
Corollary 4.16 Solvability of monadic set constraints with negation is ExpTimecomplete.

Conclusion
We have shown that solvability and finite solvability of systems of language (dis)equations are ExpTime-complete, in contrast to their undecidability (Σ 0 2completeness) in the case of unrestricted concatenation [12].We have used these results to obtain new complexity results for solving monadic set constraints with negation, and for disunification problems in the DL FL 0 .As a tool, we have introduced looping tree automata with colors.Though the results of Section 3 show that a direct reduction to the emptiness problem for Büchi tree automata would be possible, using looping tree automata with colors as intermediate formalism makes the presentation much clearer and easier to comprehend.In addition, we believe that these automata may be of interest also for other applications in logic.
Given finite sets N c of concept names and N r of role names, an interpretation I = (∆ I , • I ) consists of a non-empty set ∆ I (the domain of I) and an interpretation function • I that maps each concept name A ∈ N c to a set A I ⊆ ∆ I and each role name r ∈ N r to a binary relation r I ⊆ ∆ I ×∆ I .The extension of • I to arbitrary concept terms is defined inductively, as shown in the second column of Table 1.The concept term D subsumes the concept term C (C D) iff C I ⊆ D I for all interpretations I. Two concept terms C, D are equivalent (C ≡ D) iff they subsume each other.We write C ≡ D to indicate that C, D are not equivalent.

Lemma 4 . 5 (
[4]) Let C, D be FL 0 -concept terms such thatC ≡ A∈Nc ∀S A .A and D ≡ A∈Nc ∀T A .A. Then C ≡ D iff S A = T A for all A ∈ N c , and thus C ≡ D iff S A = T A for some A ∈ N c .
mirror image D C,D (A) of the language disequation D C,D (A) is defined in the same way.Obviously, (finite) solutions of E C,D (A) can be transformed into (finite) solutions of E C,D (A) by mirroring the languages in these solutions, and vice versa.The same is true for the disequations D C,D (A) and D C,D (A).