Reasoning about Qualitative Relations Between Straight Lines

0 downloads 0 Views 292KB Size Report
portunity of designing the rods as straight lines and then establishing the qualitative relations ... condition “not parallel and not overlapping” is realized in slanting lines. The analysis ..... OUTPUT: Yes, if S is consistent, No otherwise. 1. For.
Reasoning about Qualitative Relations Between Straight Lines Matteo Cristani Dipartimento di Informatica, Universit`a di Verona C`a Vignal 2, strada Le Grazie, 15, I-37134 Verona (Italy) [email protected]

Abstract We present two calculi for reasoning about relations between straight lines. The first calculus allows reasoning about straight lines in two dimensions, the second one in three dimensions. We show that two-dimensional straight line reasoning is polynomially solvable, whilst three-dimensional straight line reasoning is NPcomplete. We then provide a complete classification of tractability for the three-dimensional case, based on the individuation of eight maximal tractable subclasses.

1

Introduction

Formalisms for representing and reasoning about qualitative spatial information have been largely addressed, both within AI, and in Geographical Information Systems investigations (Cohn, 1999). The effort has been devoted to developing efficient representations for reasoning about topological information (Bennett, 1998; Renz & Nebel, 1999; Renz, 1999; Jonsson & Drakengren, 1997). Some other aspects, such as orientation (Ligozat, 1998; Isli & Cohn, 1998), distance (Hern´andez, Clementini, & Di Felice, 1995) and qualitative morphology (Cristani, 1999) have also been investigated. In this paper we address a new topic in spatial reasoning: relations between Straight Lines. What is the practical interest in this particular topic? We argue that for at least two applications the straight lines are useful: Geographic Information Systems (GIS), in particular Urban GIS, and Computer Aided Design.

1

Example 1 Consider a GIS which is used as a Decision Support System for designing plans in Urban Development. We have a part of one city map and one architect, who is using the program, would like to ask a suggestion about the disposition of a set of intersecting streets. He wants to obtain a structure in which certain streets are necessarily parallel, whilst other ones are necessarily not. The GIS helps the architect, providing the possibility of specifying directional relations between the straight lines representing the streets. In Figure 1 a pictorial example is provided.  SCHEMA OF THE STREETS CITY MAP

BUILDINGS

Figure 1: A Urban GIS in which the straight lines representing streets are related each other in a qualitative way.

Example 2 A CAD System is used to design engines. An engineer, who is a user of the system, wants to query the Decision Support System (DSS) component of the CAD itself in order to establish whether a complex system of mechanically driven rods can be realized respecting qualitative constraints among the rods themselves. The DSS component offers to the user the opportunity of designing the rods as straight lines and then establishing the qualitative relations between these which implement the constraints among the rods. In Figure 2 a pictorial example is provided.  In the above examples we have objects which occupy an actual extended region, like rods or streets, which we treat as segments, and then again simplify the problem by analyzing only the relations between the straight lines which the segments belong to. It is possible, in principle, to develop a segment algebra, where we provide relations between directions and topological relations like the ones of RCC-8 or other specific ones, which can be 2

ENGINE 1 STICK 2: FIX

STICK 1: FIX

WIRES

MOBILE STICK 4

STICK 3: FIX ENGINE 3

ENGINE 2

Figure 2: A CAD system in which a system of rods is represented by straight lines. developed for segments. Such an algebra would be interesting, but since one of the main relational aspects involved in it, the directional one, has not yet been dealt with, we think it is worth representing the problem explicitly and analyzing the computational behavior of the obtained representation, which is the purpose of the present paper. Recently, Moratz et al. (Moratz, Renz, & Wolter, 2000) reached some results about Reasoning on Line Segments. The analysis they provide involves many topics, such that orientation, incidence, topology. They do not provide, conversely a specific analysis of the directional component of the segment relations (Renz, 2000). The problems we deal with are two: defining the structure of relation algebras able to represent the knowledge we have about two straight lines, and individuate the complexity of the problem of deciding the consistency of network of constraints labelled by relations taken from the set of unions of these relations. We analyze both the problems in two and in three dimensions. It is well known, from elementary geometry, that the directional relations between two straight lines in the plane are defined by the conditions of Parallelism and Overlapping. In two dimensions, two straight lines cannot be both not parallel and not overlapping. The same notions of parallelism and overlapping can be used in three dimensions space, and in that case the condition “not parallel and not overlapping” is realized in slanting lines. The analysis above is formalized within the paper, and gives rise to two algebras: one for reasoning about relations between straight lines in the plane, with three basic relations, called 2DSLA, and the other one for reasoning about relations between straight lines in three dimensions, with four basic relations, 3

called 3DSLA. The computational analysis performed on the two algebras shows that reasoning in 2DSLA is polynomially solvable on deterministic machines, while reasoning in 3DSLA is NP-complete. The 3DSLA algebra is then investigated to compute polynomially solvable subclasses, and we show that there exist eight subclasses of 3DSLA which can be solved in O(n2 ). These algebras are all maximal tractable, and we prove that they provide a complete classification of tractability in 3DSLA. The paper is organized as follows. Section 2 introduces terminology and basic definitions used in the rest of the paper; Section 3 describes the 2DSLA algebra, and Section 4 the 3DSLA algebra; Section 5 analyzes the tractability of subalgebras in the 3DSLA algebra; finally Section 6 takes some conclusions and sketches future work.

2

Terminology and definitions

In this section we introduce the basic notions of constraint processing for the convenience of readers not familiar with this approach. A deeper description of constraints as used in Artificial Intelligence can be found in Tsang’s book “Foundations of constraint satisfaction” (Tsang, 1993). Definition 1 Given a set D, a binary relations R ⊆ D × D, and two variables x1 and x2 over D, an expression x1 Rx2 , is said to be a (binary) constraint over D for x1 and x2 . For any set of variables V = {x1 , x2 , ..., xn , ...}, and any set of values W of a domain D, W = {d1 , d2 , ..., dn , ...}, the collection of pairs {(x1 , d1 ); (x2 , d2 ); ...; (xn , dn ); ...} is said to be an assignment for V . We assume that for any i we assign di to xi . When no confusion arises we refer to W as an assignment. For any constraint C = xi Rxj , an assignment {di , dj } is valid for C iff the pair hdi , dj i is V in R. A finite set of constraints C= {C1 , C2 , C3 , ..., Cn } is interpreted as ni=1 Ci .

Definition 2 A finite set of constraints C= {C1 , C2 , C3 , ..., Cn }, where for any 1 ≤ i ≤ n Ci = xji Ri xki , is consistent iff there exists an assignment for the variables {xj1 , xj2 , ..., xjn , xk1 , xk2 , ..., xkn } , which is valid for each constraint in A. Such an assignment is said to be a solution for C.

4

A finite set of constraints C, can be represented by a constraint network, which is a graph labeled on the vertices by the names of the variables involved in C, and on any edge e by the relations established in C between the variables associated to the vertices connected by e. We can extend the concept of consistency to constraints networks. Given a set D, and a subset R of binary relations over D (R⊆ 2D×D ), which is an algebra of relations, namely R is closed under union, intersection, composition and converse, the set of constraints A, which can be defined on R by a set of variables X = {x1 , x2 , ..., xn , ...} is said to be a constraint algebra. When no confusion arises we use the term constraint algebra also to refer the underlying algebra of relations. Generally, an algebra of relations as defined above is said to be a proper relation algebra, or sometimes a concrete relation algebra. In particular, when one of the relations is the identity, the algebra of relations is said to be integral. The algebras documented in the literature of constraints are often integral, and this is also the case for the new algebras we introduce in this paper. However, this is not necessary for allowing reasoning with constraints, and therefore we do not require it here, for coherence with the literature. Given a constraint algebra A, a subset S of A, which is closed under composition, converse and intersection, but not necessarily under union, is said to be a sub-algebra of R. The term sub-algebra, which is very common in the Artificial Intelligence literature, when referred to such subclasses (see, for instance, Nebel and Buerkhert (Nebel & B¨ urckert, 1995), and Jonsson and Drakengren (Jonsson & Drakengren, 1997)) is not intended in th usual sense in which the use of the prefix sub- is meant for. In general, a substructure X of Y is a subset of Y with the same structure of Y (like subgroups, for instance). This is generally not true for constraint sub-algebras. We use the term here again for coherence with the current literature. Given a constraint algebra A, a subset G of A is said to be a generator set for A iff each relation in A is in the closure of G with respect to union, composition, intersection and converse. If all the relations in a generator set B are mutually exclusive (namely the intersection of any pair of those is empty), and jointly exhaustive (namely their union forms the universal S relation on the domain D, b∈B b = D2 ) the generator set is said to be a base for A. Given a constraint algebra A, and a base B for A, a complete network S, (a complete graph is a graph such that each pair of vertices is connected by an edge), which is labeled on edges by relations in B, is called a scenario. Given a network of constraints T on a constraint algebra A, and a base B 5

for A, a solvable scenario whose solutions are solutions of T is said to be a consistent scenario for T . A network of constraints which has a consistent scenario is consistent. The problem of deciding whether a constraint network N , is consistent, is called consistency checking. Given an algebra A the consistency checking of networks labeled by relations in A is indicated as SAT(A). > will be used in the rest of the paper to indicate the universal relation in a constraint algebra, whilst ⊥ will denote the empty relation.

3

Two-dimensional straight lines: the 2DSLA algebra

2DSLA is a constraint algebra for representing the relations between two Straight Lines in two dimensions. In this section we discuss the structure of the algebra and present three distinct methods for computing a solution in polynomial time. In two dimensions two Straight Lines can be in three incidence relations. If they are distinct they can be either incident or properly parallel. A pictorial representation of the three basic relations of 2DSLA is presented in Figure 3.

EQ

PR

IN

Figure 3: The three basic relations of the 2DSLA Algebra. We name the three basic relations of 2DSLA, respectively EQ (coincide), PR (properly parallel) and IN (incident). Each of these relations is its own converse. An interpretation I of a set of constraints S on 2DSLA such that any involved variable is mapped to a two-dimensional straight line will be called a 2d-interpretation. If all the constraints in S are satisfied by substituting the elements of I for variables in S, then we call the interpretation a 2dsolution. A constraint set S which has a 2d-solution is said to be 2d-solvable. 6

A two-dimensional straight line can be represented by a linear equation as y =m·x+q where m and q are real numbers. Note that this representation excludes the vertical lines, which can be represented instead by equations like x = k. We will prove that vertical lines are not needed for finding solutions of 2DSLA constraint sets. Note that a pair m and q uniquely identifies a non-vertical straight line in the real plane. Suppose that we name two lines l1 and l2 . Moreover assume that m1 , m2 , q1 and q2 are the variables representing the angular coefficients and origin ordinates for the lines. The three conditions of the basic relations defined above can be expressed by the relations between the lines y = m1 · x + q1 and y = m2 · x + q2 as in EQl1 l2 PRl1 l2 INl1 l2

≡ ≡ ≡

(m1 = m2 ) ∧ (q1 = q2 ) (m1 = m2 ) ∧ (q1 6= q2 ) m1 6= m2 .

Given a constraint set C, an interpretation of relations as above is henceforth called an equational interpretation of 2DSLA constraint sets. When we allow the variables to be interpreted also as equations of vertical lines like x = k, we will speak of generalized equational interpretations. A consequence of the above formalization is the composition table of 2DSLA, which appears in Table 1. The composition of EQ with any relation R in 2DSLA, and the composition of any relation R in 2DSLA with EQ obviously gives R. The four remaining compositions are defined in the next Theorem. Theorem 1 The following compositions can be computed: • PR ◦ PR = {EQ, PR} • PR ◦ IN = IN • IN ◦ PR = IN • IN ◦ IN = >

7

◦ EQ PR IN

EQ EQ PR IN

PR PR {EQ, PR} IN

IN IN IN >

Table 1: The composition table of the 2DSLA Algebra. Proof Based on the equational interpretation of a constraint set we can prove the compositions claimed above by showing that: • PR ◦ PR = {EQ, PR}. To prove this simply note that: – m1 = m2 ∧ q1 6= q2 ; – m2 = m3 ∧ q2 6= q3 . Thus we can conclude m1 = m3 , but nothing about the relation between q1 and q3 . The relation between x1 and x3 is thus {EQ, PR}. • PR ◦ IN = IN. To prove this simply note that: – m1 = m2 ∧ q1 6= q2 – m2 6= m3 Thus we can conclude m1 6= m3 . The relation between x1 and x3 is thus IN. Analogously we can prove that IN ◦ PR = IN. • IN ◦ IN = >. To prove this simply note that: – m1 6= m2 – m2 6= m3 Thus we cannot conclude anything about the relations between both the angular coefficients and the origin ordinates. The relation between x1 and x3 is thus >. This proves the claim for the cases in which the lines involved are not vertical. The cases in which one of the involved line is vertical can be proved analogously and their proof is left to the reader. 

8

P T T F F

Relation EQ PR IN -

O T F T F

Table 2: The correspondence between parallelism and overlapping conditions for 2DSLA basic relations. We can describe the three basic relations of 2DSLA, by means of the conditions of parallelism (a directional relation) and overlapping (namely the fact that the intersection is not empty, a topological relation). When these conditions are both true the lines coincide; when the first is true and the second is false we have the case of proper parallelism, and, when the first is false and the second is true proper intersection. Note that the case in which both the conditions are false is not possible in two dimensions. The expression P ∧ O holds for three dimensional slanting lines. The conditions of parallelism and overlapping can be expressed in form of a Horn theory, by introducing the description based on angular coefficients and origin ordinates. The parallelism condition is simply expressed by the relation m1 = m2 , whilst the overlapping condition can be expressed by the more complicated relation m1 6= m2 ∨ q1 = q2 . The basic relations of 2DSLA correspond to the conditional expressions, with respect to parallelism (P) and overlap (O), which appear in Table 2. We now exclude vertical lines without loss of generality, as stated in the following proposition. Proposition 1 If a 2DSLA constraint set is 2d-solvable, then it has a 2dsolution without vertical lines. Proof Suppose that a 2d-solution X of a 2DSLA constraint set S contains vertical lines. Any rigid transformation of the real plane transforms X in X 0 which is still a solution of S. Thus, a rotation of X is a solution of S. Suppose that α is the smallest (in absolute value) not null angle formed by a line in S and the ordinate axis. A rotation of α2 is, a solution of X not containing vertical lines.  When we interpret P and O respectively as m1 = m2 and m1 6= m2 ∨ q1 = q2 , a solution of the set of equations and inequations obtained by this implementation is named a sl-solution. A set of expressions with two letters

9

P and O, where each expression only contains two variables will be called a PO constraint set. For instance, the constraint set P x1 x2 ∧ Ox1 x2 ; ¬P x2 x3 ; ¬Ox1 x3 ∨ P x1 x3 is a PO constraint set. A consistent PO constraint set S is said to be 2d-PO consistent iff S is consistent and for any pairs of variables x and y in S the set S ∪ Pxy ∧ Oxy is inconsistent. We can now claim the following lemma, whose proof is a trivial consequence of the definitions of 2d-PO consistency and sl-solutions. Lemma 1 A 2d-PO consistent constraint set has a sl-solution. The main consequence of Lemma 1 is that we can define the 2D-k-Horn theory, with the operators P and O, as interpreted by m1 = m2 and m1 6= m2 ∨ q1 = q2 respectively. Consider, for instance, the relation {EQ, IN}. The Horn representation, by means of the P and O operators is, clearly, O. The relation {PR, IN}, instead, is implemented in the much more complex expression (P ∧ ¬O) ∨ (¬P ∧ O) which is equivalent to ¬((P ∧ O) ∨ (¬P ∧ ¬O)), which, since (¬P ∧ ¬O)) is not possible in two dimensions is equivalent to ¬(P ∧ O) = ¬P ∨ ¬O. We can define another Horn theory, only based on the = operator defined on real numbers. An expression a = b is a positive literal, whilst a 6= b is a negative one. This theory will henceforth called the minimal Horn theory. The relation {PR, IN}, for instance, is represented by (m1 = m2 ∧ q1 6= q2 ) ∨ (m1 6= m2 ∧ q1 = q2 ). We can thus claim the following theorem. Theorem 2 SAT(2DSLA) is polynomially solvable on deterministic machines. Proof Each of the eight relations of 2DSLA can be written in terms of the conditions of Table 3. The eight expressions in the second column of the above table are 2D-kHorn clauses, because they contain only one positive literal for each conjunct. Analogously the eight expressions in the third column are minimal Horn clauses. Therefore any set of these can be decided in O(n2 ), since they will be a number of n2 with respect to the number of variables of the constraint set, 10

Relation ⊥ EQ PR IN {EQ, PR} {EQ, IN} {PR, IN} >

Clause F O∧P O∧P O∧P P O O∨P T

Minimal clause F m1 = m2 ∧q1 = q2 m1 = m2 ∧q1 6= q2 m1 6= m2 m1 = m 2 m1 6= m2 ∨q1 = q2 m1 6= m2 ∨q1 6= q2 T

Table 3: The eight relations of 2DSLA expressed by basic conditions. or equivalently, the number of vertices in the constraint network representing the constraint set, and the Horn clauses can be decided by Positive Unit Resolution algorithms, as for instance (Dowling & Gallier, 1984), which requires a linear time in the number of clauses.  Note that if we translate a 2DSLA constraint set S into its minimal Horn representation and solve the obtained set S 0 in the Point Algebra (Vilain, Kautz, & van Beek, 1990), by means of the Nebel and Buerkhert method (Nebel & B¨ urckert, 1995), then a solution of S 0 can be interpreted as a set of straight lines satisfying S. Let us show a short example of such a procedure. Example 3 Consider the set of constraints: C = {{EQ, IN}x1 x2 ; {PR}x2 x3 ; {PR, IN}x1 x3 } The implementation in its minimal Horn representation gives the set of constraints: C 0 = {(m1 = m2 ∧ q1 = q2 ) ∨ m1 6= m2 ; m2 = m3 ∧ q2 6= q3 ; (m1 = m3 ∧ q1 6= q3 ) ∨ m1 6= m3 The above constraint set has, for instance, the scenario m1 = m2 = m3 ∧ q1 = q2 6= q3 which can be solved by the assignment m1 = m2 = m3 = 0 ∧ q1 = q2 = 0 ∧ q3 = 1. The solution corresponds to the assignment of the horizontal axis to x 1 and x2 and for a line parallel to the horizontal axis at height 1 to x3 .  The development of a specific Horn theory leads to a method of computing the solution based on Positive Unit Resolution, as claimed in Theorem 2. 11

1 2 3 4 5 6 7 8

EQ EQ PR IN IN {EQ, PR} {EQ, PR} {EQ, PR}

EQn {EQ, PR}n ⊕ {EQ, IN} {EQ, PR}n ⊕ PR, IN} {EQ, IN} ⊕ {PR, IN} PR⊗IN {EQ, PR}n PRn PRn ⊗{EQ, PR}n

Table 4: The implicit ways of obtaining contradictions in 2DSLA. We evaluate also a technique of constraint-based consistency checking: the path- consistency method. A network of constraints T is said to be pathconsistent iff the label of any edge e, connecting x to y in T , is contained in the relation which a path connecting x and y in T composes to. Pathconsistency can be shown to be equivalent to three-consistency, namely to prove path-consistency of a network N , it is sufficient to prove that any subnetwork with no more than three vertices is globally consistency. In other terms to prove path-consistency of a network N we can show that for any triple of vertices x, y and z in N the relation on the edge connecting x to z is not empty and it is contained in the composition of the relation on the edge connecting x to y and the relation connecting y to z. Theorem 3 A path-consistent 2DSLA constraint network is consistent. Proof We show that any inconsistent 2DSLA constraint network N contains an inconsistent three-vertices subnetwork. In fact, if N |= ⊥xy then there exist a pair of relations r1 and r2 , such that r1 xy and r2 xy, where r1 ⊕r2 = ⊥. In Table 5 we list the relations r1 and r2 in 2DSLA satisfying r1 ⊕ r2 = ⊥. Moreover, the ways of writing implicitly the relations of 2DSLA are listed in Table 4.  Applicability of path-consistency is useful, since implementations of such technique is very common in Artificial Intelligence applications. However, the computational cost of the method is high, being O(n3 ), where n is the number of variables in the constraint set. Fortunately, we can prove that the consistency of a 2DSLA network can be decided in O(n2 ) also by a different constraint-based algorithms.

12

1 2 3 4 5 6

EQ EQ EQ PR PR IN

PR IN {PR, IN} IN {EQ, IN} {EQ, PR}

Table 5: The six possible contradictions of 2DSLA. (1) EQ

xi

x1

(2) EQ

{EQ,PR}

xn

x1

(3) {EQ,PR}

xi

(4) {EQ,PR} xn

{PR,IN}

PR

xi

x1 (7) PR x1

IN

{PR,IN}

xi

{EQ,PR} x1

z xi

xn

{EQ,IN}

(6)

(5)

{EQ,PR}

{EQ,IN}

x x1

xi

(8) PR

PR x1

xn

y

{EQ,PR} xn

xi

{EQ,PR} xn

Figure 4: The eight ways of representing a contradiction in 2DSLA. First of all note that the set of relations G2 = {{EQ, PR}, {EQ, IN}, {PR, IN}} generates all the relations in 2DSLA. Table 6 shows eight expressions for the relations in 2DSLA with the three generators of G2 . The implementation of a constraint set by the method proposed in Table 13

Relation ⊥ EQ PR IN {EQ, PR} {EQ, IN} {PR, IN} >

Expression {EQ, PR}⊕{EQ, IN}⊕{PR, IN} {EQ, PR} ⊕ {EQ, IN} {PR, IN} ⊕ {EQ, PR} {PR, IN} ⊕ {EQ, IN} {EQ, PR} {EQ, IN} {PR, IN} {EQ, IN} ⊗ {EQ, IN}

Table 6: Eight expressions for the relations of 2DSLA as generated by the generator set G 2 . 6 is named henceforth an ΩG2 implementation. Given a constraint set S, the set of constraints in G2 obtained by this implementation is ΩG2 (S). Note that the composition of relations in G2 always gives >, except for {EQ, PR} ⊗ {EQ, PR} = {EQ, PR}. When a constraint set entails the contradiction, we certainly have a structure {EQ, PR}n ⊕ {EQ, IN} ⊕ {PR, IN}. A structure like the one defined above is henceforth called a G2-contradiction network. The following lemma can be proved by looking at the representations in Table 6 and observing that in each case, when we have one of the six contradictions of Table5, we also have a G2-contradiction network. Lemma 2 Any contradictory 2DSLA contradiction network.

constraint network contains a G2-

Thanks to Lemma 2 we can now develop an algorithm for deciding consistency of a 2DSLA constraint set which simply looks for cycles in the constraint network marked by {EQ, P R} to check whether they are interrupted by {PR, IN } and {EQ, IN}. We name this algorithm G2 -consistency, and present it in Figure 5. We can thus claim the following theorem. Theorem 4 Algorithm G2 -consistency correctly decides the consistency of a 2DSLA constraint set S in O(n2 ) time, where n is the number of variables in S. Proof Correctness of the algorithm immediately follows from Lemma 2. The complexity can be derived by the known cost of cycle detection in directed graphs, which is indeed O(n2 ) time where n is the number of vertices in the 14

ALGORITHM G2 -consistency INPUT: A 2DSLA constraint network S. OUTPUT: Yes, if S is consistent, No otherwise. 1. 2. 3. 4.

For

any cycle c in S containing the vertices x and y If the edge between x and y is labelled by {PR, IN} and by {EQ, IN} then return inconsistency return consistency. Figure 5: The G2 -consistency algorithm.

graph.

4



Three-dimensional straight lines: the 3DSLA algebra

In three dimensions the incidence relations between two straight lines are four. A pictorial representation of the four basic relations of 3DSLA is presented in figure 6. We name the four basic relations of 3DSLA, respectively EQ, PR, IN and SL (slanting). Each of these relations is its own converse. To provide the composition table we can formalize the computation by means of a analytical geometry model of the three-dimensional lines. In general, a straight line in three dimensions is represented by the intersection of two planes as in below:  a1 x + b 1 y + c 1 z = d 1 a2 x + b 2 y + c 2 z = d 2 We also introduce a restriction, which corresponds to the restriction we introduced in Section 3 for two-dimensional straight lines. Consider two straight lines on the planes y = 0 and x = 0 (the planes xz and yz respectively), of equations z = mx + q and z = ny + r. 15

EQ

PR

IN

SL

Figure 6: The four basic relations of the Straight Line Algebra in three dimensions. If we consider a plane p1 which is normal to xz and passes through z = mx+ q, and a plane p2 which is normal to yz and passes through z = ny + r, we note that the intersection of the two planes is a generic non-vertical straight line. In other terms, for any non-vertical straight line l, the pair of the two-dimensional straight lines to which l projects on the planes xz and yz, defined by the four parameters m, q, n, r is a non-ambiguous representation of l. The cases we do not represent: • the vertical lines, namely the lines which are on planes normal to the xy plane which cannot be represented by the two-projections model; • the horizontal lines, namely the lines on planes parallel to the plane xy which we explicitly exclude. We can prove that, with respect to the problem of establishing consistency of a network of constraints, the exclusion of vertical and horizontal lines can be done without loss of generality. We exclude horizontal lines for three reasons: • a horizontal line which is parallel to one of the planes xz and yz is degenerated, since one of the projections is a point; 16

• a horizontal line which is neither parallel to the plane xz nor to yz is represented by two horizontal lines at the same quote, independently of its actual direction; • if we randomly choose two horizontal lines on the two projection planes, we are not sure to have a line represented if we do not make it sure that the lines have the same quote, namely the same equation z = k where k is a constant real. An interpretation I of a set of constraints S on 3DSLA so that any involved variable represents a three-dimensional straight line is a 3d-solution, iff all the constraints in S are satisfied by substituting the elements of I for variables in S. Any constraint set which has a 3d-solution is said to be 3d-solvable. Proposition 2 If a 3DSLA constraint set is 3d-solvable, then it has a 3dsolution without vertical and horizontal lines. Proof Suppose that a 3d-solution X of a 3DSLA constraint set S contains both vertical and horizontal lines. Any rigid motion of X is still a solution of S. Thus, a rotation along the plane xy of X is a solution of S. Analogously, a rotation along the plane yz of X is a solution of S. We can always provide a pair of these rotations of X so that the rotated lines are all not vertical and not horizontal.  We can prove the claim of Theorem 5. The proof is analogous to the proof of Theorem 1 and is therefore omitted for the sake of conciseness. Theorem 5 The compositions below can be computed: • PR ◦ PR = {EQ, PR} • PR ◦ IN = {IN, SL} • PR ◦ SL = {IN, SL} • IN ◦ IN = > • IN ◦ SL = {PR, IN, SL} • SL ◦ SL = >

17

◦ EQ

EQ EQ

PR IN SL

PR IN SL

PR PR {EQ, PR} {IN, SL} {IN, SL}

IN IN {IN, SL} > {IN, SL}

SL SL {IN, SL} {PR, IN, SL} >

Table 7: The composition table of the 3DSLA algebra. The composition table of 3DSLA appears in Table 7. The last case of Table 2 introduced in Section 3 corresponds to the conditional expression defining SL. The sixteen relation of 3DSLA correspond to the conditional expressions of Table 8 with respect to parallelism and overlapping. We can claim an analogous result of Lemma 1, whose proof is trivial and left to the reader. Lemma 3 Any consistent set of 3DSLA constraints has a 3d-solution. We introduce a particular subalgebra of 3DSLA, I, formed by the closure by union of the relations EQ, {PR, IN} and SL. The eight relations of I are thus EQ, {PR, IN}, SL {EQ, PR, IN}, {PR, IN, SL}, {EQ, SL}, ⊥ and >. Note that the composition in I is the same as the composition in the subalgebra of RCC-5 J formed by the closure by union of EQ, {PP, PP−1 } and {PO, DR}. The implementation of a constraint network N on I into the subalgebra of RCC-5 J is indicated by f(N ). We can prove the following technical lemma. Lemma 4 If a I network N has a 3d-solution, then f(N ) has a solution formed by space regions. Proof Suppose that we have found a solution of N without vertical and horizontal lines. Each element (line) of the solution can be considered as a 4-tuple of values (m, q, n, r). Now, consider that the case of slanting lines here is represented by projections with intersections at different quotes and by couples where two projections are parallel and two projections intersect. It is easy to show that when N is consistent we can provide a solution in which all the intersecting projections have different origin ordinates. In particular we can accommodate a solution where for any m1 ≤ m2 we also have q1 ≤ q2 , and for any n1 ≤ n2 we also have r1 ≤ r2 . Moreover, by a simple of the lines in one solution we obtain a solution in which any projection is such that q1 ≤ q2 iff r1 ≤ r2 . 18

Relation ⊥ EQ

Condition F P ∧O

PR IN SL {EQ, PR} {EQ, IN} {EQ, SL} {PR, IN} {PR, SL} {IN, SL} {EQ, PR, IN} {EQ, PR, SL} {EQ, IN, SL} {PR, IN, SL}

P ∧O P ∧O P ∧O P O P ∨O ∧ P ∨O P ∨O ∧ P ∨O O P P ∨O P ∨O P ∨O P ∨O T

>

Table 8: The sixteen relations of the 3DSLA algebra and their expressions by means of the conditions of parallelism and overlap. Let us call s(l) the union of the regions represented by the rectangle included between (0, 0), (m, 0), (m, q) and (0, q) on the plane xz and the rectangle included between (0, 0), (n, 0), (n, r) and (0, r) on the plane yz where m and q are the angular coefficient and the origin ordinate of the projection of l on xz, and n and r are the angular coefficient and the origin ordinate of the projection of l on yz. In Figure 7 we show an example. We immediately verify that: • when l1 and l2 in the solution of N are in EQ relation, then s(l1 ) and s(l2 ) are in EQ relation; • when l1 and l2 in the solution of N are in PR or in IN relation, then s(l1 ) and s(l2 ) are in {PP, PP−1 } relation; • when l1 and l2 in the solution of N are in SL relation, then s(l1 ) and s(l2 ) are in PO relation. 19

z=mx+q

(n,r) (m,q)

z=ny+r

Figure 7: A three dimensional line projected on the planes xz and yz, and represented as a space region. This shows that for any solution of N there exists one solution of f(N ).  The applicability of path-consistency to 2DSLA cannot be inherited by 3DSLA. However, we can prove the following lemma. Lemma 5 The 3DSLA path-consistent scenarios are consistent. Proof The closure by composition, intersection and converse B, of the set of basic relations in 3DSLA is formed by the relations listed in Table 9, and admit the representations in second column, which we assume, without loss of generality, to be the normal representation form of the corresponding relation. The set of relations used to obtain such a representation is indicated by G 3 , and clearly, G 3 = {PR; IN; SL}. The contradictions in B are PR ⊕ IN, PR ⊕ SL, and IN ⊕ SL. Correspondingly, the contradictions in G 3 are PRk ⊕ (IN ⊗ SL) ⊕ IN ⊗ PR−k , PRk ⊕ (IN ⊗ SL) ⊕ SL ⊗ PR−k , and IN ⊕ SL. 20

Relation ⊥ EQ

Representation IN ⊕ SL (PR ⊗ PR) ⊕ (IN ⊗ SL)

PR IN SL {EQ, PR} {IN, SL} {PR, IN, SL}

PR IN SL PR ⊗ PR PR ⊗ IN IN ⊗ SL IN ⊗ IN

>

Table 9: The closure by composition, intersection and converse of the basic relations in 3DSLA. The first two types of contradiction can be reduced to 3-consistency problems by reducing general cycles to 3-cycles, which is certainly possible, because the involved variables are three. The third contradiction involves only two variables. Thus, all this contradictions can be detected by path-consistency, since they all are formed by structures with no more than three vertices, which are all tested for consistency in path-consistency algorithms, or can be reduced to three vertices contradictory structures by the computation of pathconsistency.  Theorem 6 SAT(3DSLA) is NP-complete Proof The isomorphism between an intractable subalgebra of RCC-8 and a subalgebra of 3DSLA shows that SAT(3DSLA) is NP-hard, iff we can prove that that any satisfiable constraint network T on the subalgebra formed by ⊥, EQ, {PR, IN}, SL, {EQ, SL}, {EQ, PR, IN}, {PR, IN, SL}, > has a solution formed by space regions in the real plane satisfying the relations of N corresponding to the relations of 3DSLA as in the implementation defined above. This is proved in Lemma 4. Lemma 5 proves that path-consistency can be applied to 3DSLA scenarios for consistency checking. If we thus apply backtracking to a 3DSLA network, we prove that SAT(3DSLA) is in NP. This proves the claim. 

21

5

Tractable subclasses of 3DSLA

The negative result on complexity of reasoning in 3DSLA can be partly compensated by the fact that from Table 8 we derive large classes of Horn clauses. The simplest way of obtaining these classes and thereafter derive tractability, is to classify the sixteen relations based on the choice of P and O truth for driving Horn clauses construction. As in Section 3, we can develop here a 3D-k-Horn theory based on a different interpretation of the operators P and O. Consider two lines l 1 and l2 . The projections of l1 and l2 will be assumed to be not vertical or horizontal. This can be done without loss of generality thanks to Proposition 2. The parameters of l1 will be indicated by m1 , q1 , n1 , r1 , whilst the parameters of l2 will be indicated by m2 , q2 , n2 , r2 . The parallelism condition is simply: the projections on xz are parallel and so do the projections on yz. Therefore, this condition can be expressed by m1 = m2 ∧ n1 = n2 . The overlapping condition, instead, can be defined as either the lines coincide, or the projections intersect at the same quote. Having the same quote is an expression which can be defined as follows. If we compute the intersection of z = m1 x + q1 with z = m2 x + q2 , we obtain q1 − q 2 m2 − m 1

x= and z = m1 ·

q1 − q 2 + q1 , m2 − m 1

whilst the intersection of z = n1 y + r1 with z = n2 y + r2 is y= and z = n1 ·

r1 − r 2 n2 − n 1 r1 − r 2 + r1 . n2 − n 1

Therefore, the condition having the same quote is

(−m1 · q2 · n2 + m2 · q1 · n2 + m1 · q2 · n1 − m2 · q1 · n1 ) = (−n1 · r2 · m2 + n2 · r1 · m2 + n1 · r2 · m1 − n2 · r1 · m1 ).

22

which becomes m1 · n2 · (−q2 + r1 ) + m2 · n2 · (q1 − r1 ) + m1 · n1 · (q2 − r2 ) + m2 · n1 · (−q1 + r2 ) The overlapping condition is expressed thus by m1 = m 2 ∧ n 1 = n 2 ∧ q1 = q 2 ∧ r1 = r 2 for the coincidence condition, and by m1 6= m2 ∧ n1 6= n2 ∧ m1 ·

r1 − r 2 q1 − q 2 + q1 = n1 · + r1 m2 − m 1 n2 − n 1

for the condition of intersecting at the same quote. This representation is not expressible in the minimal Horn theory, since the constraint sets obtained from it cannot be expressed by equalities and inequalities of variables. These sets cannot be solved by Point Algebra methods, since the condition of having the intersections of the projections at the same quote cannot be expressed in form of distance constraints. However, the kind of equations we have to solve in this case are simply third degree homogeneous equations, that, as proved in nonlinear programming can be solved in O(n3 ) with n number of variables. Summarizing, the relation of parallelism between three-dimensional straight lines can be easily expressed in minimal Horn theory whilst the relation of overlapping requires a third degree equation in order to be expressed. However we know that sets of linear and third degree homogeneous equations define a set of relations that can be solved altogether in polynomial time. This means that the computation of the relation of parallelism and of the relation of overlapping are polynomial problems. Conclusively, a Horn-theory based on P and O is utilizable. The possible Horn theories we can develop based on the primitives of parallelism and overlapping are four. P P P P

and and and and

O O O O

are are are are

positive positive positive positive

literals literals literals literals

(H{P,O} ); (H{P,O} ); (H{P,O} ); (H{P,O} );

which exhibit the Horn clauses as in Table 10. Note that the basic relations of 3DSLA are 3D-k-Horn, for any choice we make of positive literals. The four classes of the classification of Horn clauses are tractable, provided that they are closed, by Positive Unit Resolution (Dowling & Gallier, 1984). Closure is trivial with respect to intersection and converse, while it follows from the table for composition as well. We can therefore claim the following theorem. 23

Relation ⊥ EQ PR IN SL EQ, PR EQ, IN EQ, SL PR, IN PR, SL IN, SL EQ, PR, IN EQ, PR, SL EQ, IN, SL PR, IN, SL >

H{P,O} • • • • • • • • • • • • • •

H{P,O} • • • • • • • • • • • • • •

H{P,O} • • • • • • • • • • • • • •

H{P,O} • • • • • • • • • • • • • •

Table 10: The four classes of Horn clauses of the 3DSLA algebra. Theorem 7 SAT(H{P,O} ), SAT(H{P,O} ), SAT(H{P,O} ) and SAT(H{P,O} ) are polynomially solvable on deterministic machines. The four classes of the classification are not so far the only classes for which tractability can be proved. By using the standard method of individuation of classes as originally proposed by Jonsson and Drakengren (Jonsson & Drakengren, 1997) and also used by Cristani (Cristani, 1999) we introduce here the classes formed by all the relations which contain a symmetric relation. Usually we have got one algebra of that type, but here, since the basic relations are all symmetric, we have got four of those, presented in Table 11. The four classes above are trivially closed, since each relation r of the base is such that r ◦ r ⊇ r. Moreover, given a network of constraints labelled by relations taken from one of the algebras C EQ , C P R , C IN and C SL , the network clearly exhibits a scenario, obtained by labelling each edge of the network by the basic relation on which the subalgebra is built. This scenario provides a solution, since in the three-dimensional geometric space R3 , there 24

Relation ⊥ EQ PR IN SL EQ, PR EQ, IN EQ, SL PR, IN PR, SL IN, SL EQ, PR, IN EQ, PR, SL EQ, IN, SL PR, IN, SL >

C EQ • •

CP R •

C IN •

C SL •

• • • • •

• •

• •

• • • • • •

• • • •

• • • • •

• • • • • • •

Table 11: The four subsets of 3DSLA formed by all the relations containing one of the basic relation in each class, plus the empty relation. exists an infinite number of parallel, incident and slanting straight lines. Consequently, we can claim the following theorem. Theorem 8 SAT(C EQ ), SAT(C P R ), SAT(C IN ) and SAT(C SL ) are polynomially solvable on deterministic machines. If we look at the Table 10 and 11 we note that the pair of the relations {EQ, SL} and {PR, IN} never appears in the eight tractable subsets we individuated above. We can prove the following lemma. Lemma 6 Any subalgebra of 3DSLA which is not contained in one class among H{P,O} , H{P,O} , H{P,O} , H{P,O} , C EQ , C P R , C IN and C SL contains both {EQ, SL} and {PR, IN}. Proof (Machine-assisted) We tested the presence of {EQ, SL} and {PR, IN} in any subset of 3DSLA 4 among all the 22 = 65536 which result to be both closed and not contained 25

in one class among H{P,O} , H{P,O} , H{P,O} , H{P,O} , C EQ , C P R , C IN or C SL by a LISP program TRANSITIVE-CLOSURE which can be found in the On-line Appendix of the paper (Cristani, 1999).  Based on Lemma 6 we can thus claim the following theorem. Theorem 9 The eight classes H{P,O} , H{P,O} , H{P,O} , H{P,O} , C EQ , C P R , C IN and C SL are all the maximal tractable subclasses of 3DSLA.

6

Conclusions and further work

We presented two calculi for reasoning about relations between straight lines. The first calculus allows reasoning about straight lines in the real plane, the second one in a three-dimensional space. We showed that two-dimensional straight line reasoning is polynomially solvable, while three-dimensional straight line reasoning is NP-complete. We then provided a complete classification of tractability for three-dimensional straight line reasoning, based on the individuation of eight maximal tractable subclasses. These subclasses are four Horn classes and four classes centered on a symmetric relation (as a matter of fact, for this algebra on the basic relations). The applicability of the results we discussed in this paper all depend on the use of spatial reasoning in context where the usefulness of lines is known. Certainly Urban Geographic Information Systems and Computer Assisted Design are applications to which straight lines are relevant, but also Surveying Engineering, Satellite Territorial Control, and others may be important. We want to note her one more important aspect of the motivating examples, and note a generally unevaluated perspective, in theoretical investigations about tractability and representability: the impact of the investigation in the semantic of calculi. In such calculi one of the “unknown” dimension is the meaning that subclasses have with respect to applications. If we know a semantically relevant subclass we can establish, among what is natural (as for example, pointizable relations in Allen’s calculus) and what is tractable. Therefore the establishment of tractability boundary is important also as an evaluation tool, for expressive or simple languages which can be individuated for practical purposes. Further developments of the investigation are mainly three: 1. Extension to reasoning with semi-intervals (Freksa, 1992) in two and also in three-dimensional spaces; 26

2. Extension to reasoning with oriented lines and combinations of this with qualitative orientation issues (Cohn, 1999); 3. Combination of the two straight line algebras with RCC. We also will enterprise a deep investigation of the structure of segment algebraic framework as conceived by Moratz et al. (Moratz et al., 2000), to compare the approaches and study differences and analogy.

Acknowledgments I would like to thanks Jochen Renz who very kindly discussed with me this topic. His hints have been useful in writing the paper.

References Bennett, B. (1998). Determining consistency of topological relations. Constraints, 3 (2&3), 213–225. Cohn, A. (1999). Qualitative spatial representations. In Proc. IJCAI99 Workshop Adaptive Spatial Representations of Dynamic Environments. Cristani, M. (1999). The Complexity of Reasoning about Spatial Congruence. Journal of Artificial Intelligence Research, 11, 361–390. Dowling, W., & Gallier, J. (1984). Linear time algorithms for testing the satifiability of propositional horn formula. Journal of Logic Programming, 3, 267–284. Freksa, C. (1992). Temporal reasoning based on semi-intervals. Artificial Intelligence, 54, 199–227. Hern´andez, D., Clementini, E., & Di Felice, P. (1995). Qualitative distances. In Frank, A. U., & Kuhn, W. (Eds.), Spatial Information Theory: A Theoretical Basis for GIS, Lecture Notes in Computer Science No. 988, pp. 45–58 Semmering, Austria. COSIT’95, Springer-Verlag. Isli, A., & Cohn, A. G. (1998). An algebra for cyclic ordering of 2d orientations. In Proceedings of the 15th American Conference on Artificial Intelligence (AAAI-98), pp. 643–649 Madison, WI. AAAI/MIT Press.

27

Jonsson, P., & Drakengren, T. (1997). A Complete Classification of Tractability in the Spatial Theory RCC-5. Journal of Artificial Intelligence Research, 6, 211–221. Research Note. Ligozat, G. (1998). Reasoning about cardinal directions. Journal of Visual Languages and Computing, 9, 23–44. Moratz, R., Renz, J., & Wolter, D. (2000). Qualitative spatial reasoning about line segments. In Proceedings of the 14th European Conference on Artificial Intelligence (ECAI’00) Berlin,Germany. to appear. Nebel, B., & B¨ urckert, H. J. (1995). Reasoning about temporal relations: A maximal tractable subclass of Allen’s interval algebra. Journal of the ACM, 42 (1), 43–66. Renz, J. (1999). Maximal Tractable Fragments of the Region Connection Calculus: A Complete Analysis. In Proccedings of the 17th International Conference on Artificial Intelligence (IJCAI 99). Renz, J. (2000). Personal communication.. Renz, J., & Nebel, B. (1999). On the complexity of qualitative spatial reasoning: A maximal tractable fragment of the Region Connection Calculus. Artificial Intelligence, 108 (1-2), 69–123. Tsang, E. (1993). Foundations of Constraint Satisfaction. Academic Press, London, UK. Vilain, M., Kautz, H., & van Beek, P. (1990). Constraint Propagation Algorithms for Temporal Reasoning: a revised Report. In Readings in Qualitative Reasoning about Physical Systems, pp. 373–381. Morgan Kaufmann, San Mateo, CA, USA.

28