Reasoning about Qualitative Direction and Distance between Extended Objects using Answer Set Programming

by   Yusuf Izmirlioglu, et al.
Sabancı University

In this thesis, we introduce a novel formal framework to represent and reason about qualitative direction and distance relations between extended objects using Answer Set Programming (ASP). We take Cardinal Directional Calculus (CDC) as a starting point and extend CDC with new sorts of constraints which involve defaults, preferences and negation. We call this extended version as nCDC. Then we further extend nCDC by augmenting qualitative distance relation and name this extension as nCDC+. For CDC, nCDC, nCDC+, we introduce an ASP-based general framework to solve consistency checking problems, address composition and inversion of qualitative spatial relations, infer unknown or missing relations between objects, and find a suitable configuration of objects which fulfills a given inquiry.


Reasoning about Cardinal Directions between 3-Dimensional Extended Objects using Answer Set Programming

We propose a novel formal framework (called 3D-nCDC-ASP) to represent an...

Allen's Interval Algebra Makes the Difference

Allen's Interval Algebra constitutes a framework for reasoning about tem...

A Trajectory Calculus for Qualitative Spatial Reasoning Using Answer Set Programming

Spatial information is often expressed using qualitative terms such as n...

Reasoning about Cardinal Directions between Extended Objects: The Hardness Result

The cardinal direction calculus (CDC) proposed by Goyal and Egenhofer is...

Reasoning about Cardinal Directions between Extended Objects

Direction relations between extended spatial objects are important commo...

A Generalised Approach for Encoding and Reasoning with Qualitative Theories in Answer Set Programming

Qualitative reasoning involves expressing and deriving knowledge based o...

Qualitative shape representation based on the qualitative relative direction and distance calculus eOPRAm

This document serves as a brief technical report, detailing the processe...

1 Introduction

Spatial representation and reasoning is an essential component of geographical information systems, cognitive robotics, spatial databases, document interpretation and digital forensics. Many tasks in these areas, such as satellite image retrieval, navigation of a robot to a destination, describing the location of an object, constructing digital maps involve dealing with spatial properties of the objects and the environment.

In some domains (e.g., exploration of an unknown territory), qualitative models are more suitable for representing and reasoning about spatial relations because quantitative data may not always be available due to uncertainty or incomplete knowledge. In cognitive systems, spatial information obtained through perception might be coarse or imperfect. Even if quantitative data is available, in some circumstances agents may prefer to use qualitative terms for the sake of sociable and understandable communication. For instance, humans express orientation and distance in words like left, right, front, back, north, near. Naval, air and space navigation typicaly involve geographical directions such as south, east, northwest. Although qualitative terms have less resolution in geometry than their quantitative counterparts, it is easier for people to communicate using them. It is more eloquent to say “The library is in front of the theater, near the cafeteria” rather than “The library is at 38.6 latitude and 27.1 longitude. This explains why driving instructions in GPS system are conducted in daily language.

As an illustrative scenario (depicted in Figure 1), suppose that a robot is assisting a parent to find her missing child in a shopping mall that is not completely known to the robot nor to the parents. The robot has received some sightings of the child (e.g., “to the south of Store A”). This information will be useful if the robot can understand the relative location of the child described qualitatively, figure out where the child might be, based on such qualitative direction constraints, and describe qualitatively in which direction (e.g., “to the north”) the parents should search for their child.

Figure 1: Missing child scenario

In another scenario depicted in Figure 2, a human user requests a service robot to prepare the kitchen table. The commonsense knowledge for a well-set table can be described using statements such as “The plate is in the middle of the table”, “Spoon is on the right and very near to the plate”, “Desert is between napkin and salad”, “Salad is on the left and near to the plate”, “Salt is adjacent to the napkin which is near to the top border”, “The cup is on the right or back and very near to the bottle.” The human might express his preferences as well: “It is better if the juice is placed on the right side of the plate, not far and not very near to it”. To set up the table, the robot should possess representation of these qualitative direction and distance relations between objects in order to understand the human and infer the setting. It is also beneficial if the robot can utilize commonsense knowledge to enhance the arrangement, for example “by default the fork is placed next to the spoon”.

Figure 2: Kitchen table scenario

With these motivations, our objective in this thesis is to develop a general framework to represent constraints, commonsense knowledge, preferences about qualitative directions and distances, to check consistency of these information, and to infer unknown spatial relations. We propose to develop this framework using Answer Set Programming (ASP).

2 Related Literature

Beginning with the seminal work of Allen on Interval Algebra [2], a multitude of qualitative calculi have been proposed in the literature focusing on different aspects of space. Some of these formalisms focus on topology (DIR9 [15], RCC8 [10]), direction (cone and projection based [17], LR [28], Double-cross [18], Dipole [35], SV [26], OPRA [33], Rectangle Algebra [3, 4], Cardinal Directional Calculus [21, 42]), distance [47, 32, 16, 22], size [17], and shape [13, 20, 45, 39, 12]. An overview of qualitative spatial and temporal calculus can be found in recent surveys [11, 8, 14].

As for direction, point objects [17, 33, 26], line segments and ternary relations [18, 34], and extended regions on the plane [4, 21] have been examined. These formalisms are designed for point objects; in this thesis we consider extended objects.

Rectangle Algebra [4] and Cardinal Directional Calculus [21, 42, 43] are widely used for reasoning about directions between extended objects on the plane. Rectangle Algebra (RA) is an extension of Allen’s Interval Algebra into 2-dimension. Objects are rectangles whose sides are parallel to axes of reference frame. An RA relation is identified by a pair of interval relation between sides of rectangles in horizontal and vertical axis. In Direction Relation Matrix  [21], the space is divided into 9 tiles and the direction of the target object is represented by its intersection with the tiles in a 3x3 matrix. A more formal model was adapted by Skiadopoulos and Koubarakis [42, 43] in a manner that lower dimensional parts (points and lines) do not alter directional relations. Its new form is named Cardinal Directional Calculus (CDC). In this thesis, our studies regarding directions is based on CDC. Consistency checking in CDC and its computational complexity have been investigated in subsequent research [29, 30, 31, 40, 42, 43, 46]. Polynomial time complexity fragments of the problem have been identified [29, 31, 40, 46] and algorithms have been presented for them. Although consistency checking problem is proven to be NP-complete in general [29, 30, 31, 43], no solution method exists for these intractable problems in the literature.

There are also calculi that integrate different aspects such as topology and orientation [24], orientation and distance [9, 34, 37, 38], topology and size [19], topology, size and distance [6]. These formalisms consider solely point objects for describing combined spatial relations. We aim to construct a formal framework for reasoning about directions and distance for extended planar objects in the thesis. We consider qualitative distance which includes symbolic relations with adjustable granularity.

In the literature, qualitative direction and distance are combined to define a qualitative position. Symbolic binary distance relation is augmented into cone-based cardinal directions with granularity  [9]. This model with four cone-based cardinal directions (north, south, east, west) and four interval-based distance relations has been further investigated [23].

As for other formalisms that combine direction with distance, in one study [47] LR calculus is enriched with a comparative distance relation. Orientation of a point is identified with respect to the directed line segment across the two reference objects and denoted by . In [32]

, the same LR calculus is augmented with an interval-based qualitative distance relation of arbitrary granularity. They encode qualitative spatial constraints in Prolog with CLP (Constraint Logic Programming). This model is also extended into 3D space 


In TPCC calculus [34], LR relations are made finer by further subdividing the 2-D space into four cones. To measure the distance, they draw a circle whose radius is the line segment across reference objects . Inside of the circle is designated as near and outside of it as far. In another model [37, 36], the planar space is partitioned into angular segments that are called distance orientation interval (DOI). In these calculi, a DOI is specified by four metric parameters and correspond to a qualitative position.

Another approach [38] for describing qualitative position suggests adding symbolic distance relations into calculus. The distance relation can be asymmetric hence the distance relation is specified by a pair of relations. The distance concept is similar to interval-based system [9] except that the borders of the intervals also constitute a separate distance relation.

Answer Set Programming, thanks to its efficient solvers for computationally hard problems, have been applied to qualitative spatial reasoning [5, 7, 27]. These approaches are based on path consistency and don’t involve nonmonotonicity. As shown in [31, 43], local algorithms such as path consistency or k-consistency are not sufficient to decide consistency of a CDC network. Encoding of a constraint network in IA and RCC8 has been developed [7]. Their formulation can represent disjunctive constraints but not defaults. Likewise ASP has been utilized to check path consistency of a network in Trajectory Calculus [5]. Unknown relations are nondeterminitically generated and path consistency is tested with a composition table. In another study, ASP programs for checking consistency of basic and disjunctive constraint networks in any qualitative calculus are presented [27]. Specialized programs for IA and RCC8 are also provided.

Consistency problems that involve topology (part, whole, contact relations) and orientation (left, right, perpendicular, colinear relations) have been solved using ASP Modulo Theories (ASPMT) in [44]. The benefit of ASPMT is that it permits formulas in first order logic and equations including real numbers. The authors consider point, line segment, circle and polygon as spatial entities. Constraint networks in Interval Algebra, Rectangle Algebra, LR, RCC8 can be encoded in their setting. Spatial constraints are written in terms of polynomial inequalities in ASPMT and then transformed into SAT Modulo Theories for the SMT solver. For consistency checking in CDC, objects can be instantiated at any shape and size; consequently this approach is not complete for solving the CDC consistency checking problem in this thesis. Moreover their formulation does not allow for disjunctive, nonmonotonic constraints or preferences.

3 Our Approach

We use Cardinal Directional Calculus introduced by Skiadopoulos and Koubarakis [21, 42] to define relative direction of objects with respect to each other. In CDC, direction between objects are denoted by binary relations. Objects are extended regions on a plane and they can be simple, connected or disconnected as shown in Figure 3(i). The minimum bounding rectangle of the reference object along the axes (Figure 3(ii)) divides the plane into nine regions (called tiles): north (N), south (S), east (E), west (W), northeast (NE), northwest (NW), southeast (SE), southwest (SW), on (O) as in Figure 3(iii). These nine atomic (single-tile) relations and their combinations constitute the set of basic relations. (e.g. see Figure 3(iv)) CDC also allows for disjunction of these basic relations.

(i) (ii)

(iii) (iv)
Figure 3: (i) Regions , , , are connected, where is disconnected. (ii) A region and its bounding box. (iii) Reference tiles. (iv) Sample relations (orientation of with respect to ): , , .

Using these binary relations, relative directions of extended objects can be described in CDC as a set of constraints. In our studies, we formalize CDC using ASP and further extend it with a new form of constraints: Default CDC constraints. They can be used to express default assumptions like “The food truck is normally to the south of the movie theater”.

We define qualitative distance relations with adjustable granularity . To examplify, for granularity , the set of basic distance relations are

One of the central problems in CDC and qualitative spatial reasoning literature is the consistency checking of a constraint network. The input of the consistency checking problem are a set of spatial variables (objects), the domain of objects, a constraint network and the set of CDC relations. The domain can be the set of connected regions or the set of possibly disconnected regions in . Then, the consistency checking problem asks for whether there exists an instantiation of objects in the domain which satisfy all constraints in the network. If such an instantiation exists, the output is Yes, otherwise it is No.

Based on our representation of direction and distance constraints in ASP, we propose a novel method to check consistency of a network of constraints. Note that consistency checking problem is defined over continuous domain. We discretize consistency checking problem in CDC, prove its equivalence with the continuous version, and introduce a solution using ASP. We also establish soundness and completeness of our ASP-based solution. Namely, the ASP program has an answer set if and only if the given network of constraints is consistent.

Our ASP formulation is elaboration tolerant in the sense that a few rules are added to the main ASP program in order to incorporate disjunctive, default, soft, negative constraints, or to ensure that the generated regions are connected.

4 Goal and Current Status of the Research

The objective of this thesis is to develop a generic formal framework to represent and reason about qualitative spatial relations. In the first step, we have studied directional relations and taken Cardinal Directional Calculus as a starting point. We have formulated CDC consistency checking problem in ASP. Then we have extended CDC with new sorts of constraints which involve defaults, preferences, negation using ASP [25]. We call this extended version of CDC as nonmonotonic CDC (nCDC).

Currently, we are working on a further extension of nCDC with qualitative distance relation. We name this extension as nCDC+. Preferences, disjunctive and default constraints can also be expressed in nCDC+.

For CDC, nCDC, nCDC+, we aim to introduce a general framework to solve consistency checking problems, address composition and inversion of qualitative spatial relations, infer unknown or missing relations between objects, and find a suitable configuration of objects which fulfills the given spatial constraints in the inquiry.

We have illustrated benefits of our methods for reasoning over nCDC constraints in [25] with the example scenarios mentioned in the introduction. We have evaluated efficiency of our approach for consistency checking in nCDC with experiments on benchmark instances. For this purpose, a variety of problem instances over differents domain have been prepared. For every instance, grounding time, total computation time and program size have been recorded. Observed values are compared across input parameters and the domain. We plan to perform these applications and experiments for nCDC+ as well.

5 Future Work

Our agenda for future work consists of the following items:

  • Experimental evaluation for nCDC+ : We plan to create benchmark instances with nCDC+ networks that include directional, distance constraints, run experiments and evaluate the results with respect to computation time.

  • Applications of nCDC+: We plan to revise example scenarios in the introduction for nCDC+ and apply our ASP-based methods to solve them.


  • [1]
  • [2] James F. Allen (1983): Maintaining Knowledge about Temporal Intervals. Commun. ACM 26(11), pp. 832–843, doi:
  • [3] Philippe Balbiani, Jean-François Condotta & Luis Fariñas del Cerro (1998): A model for reasoning about bidemsional temporal relations. In: Proceedings of the Sixth International Conference on Principles of Knowledge Representation and Reasoning, Morgan Kaufmann Publishers Inc., pp. 124–130.
  • [4] Philippe Balbiani, Jean-François Condotta & Luis Fariñas del Cerro (1999): A New Tractable Subclass of the Rectangle Algebra. In: Proc. of IJCAI, pp. 442–447.
  • [5] George Baryannis, Ilias Tachmazidis, Sotiris Batsakis, Grigoris Antoniou, Mario Alviano, Timos Sellis & Pei-Wei Tsai (2018): A Trajectory Calculus for Qualitative Spatial Reasoning Using Answer Set Programming. Theory and Practice of Logic Programming 18(3-4), pp. 355–371, doi:
  • [6] David Brageul & Hans W Guesgen (2007): A Model for Qualitative Spatial Reasoning Combining Topology, Orientation and Distance. In: FLAIRS Conference, pp. 653–658.
  • [7] Christopher Brenton, Wolfgang Faber & Sotiris Batsakis (2016): Answer Set Programming for Qualitative Spatio-Temporal Reasoning: Methods and Experiments. In: OASIcs-OpenAccess Series in Informatics, 52, Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik.
  • [8] Juan Chen, Anthony G Cohn, Dayou Liu, Shengsheng Wang, Jihong Ouyang & Qiangyuan Yu (2015): A survey of qualitative spatial representations.

    The Knowledge Engineering Review

    30(1), pp. 106–136, doi:
  • [9] Eliseo Clementini, Paolino Di Felice & Daniel Hernández (1997): Qualitative representation of positional information. Artificial intelligence 95(2), pp. 317–356, doi:
  • [10] Anthony G Cohn, Brandon Bennett, John Gooday & Nicholas Mark Gotts (1997): Qualitative spatial representation and reasoning with the region connection calculus. GeoInformatica 1(3), pp. 275–316, doi:
  • [11] Anthony G Cohn & Jochen Renz (2008): Qualitative Spatial Representation and Reasoning. Handbook of Knowledge Representation, p. 551, doi:
  • [12] Christopher H Dorr & Reinhard Moratz (2014): Qualitative shape representation based on the qualitative relative direction and distance calculus eOPRAm. arXiv preprint arXiv:1412.6649.
  • [13] Vincent Dugat, Pierre Gambarotto & Yannick Larvor (1999): Qualitative theory of shape and orientation. In: Proc. of the 16th Int. Joint Conference on Artificial Intelligence (IJCAI’99), Stockolm, Sweden, pp. 45–53.
  • [14] Frank Dylla, Jae Hee Lee, Till Mossakowski, Thomas Schneider, André Van Delden, Jasper Van De Ven & Diedrich Wolter (2017): A survey of qualitative spatial and temporal calculi: algebraic and computational properties. ACM Computing Surveys (CSUR) 50(1), p. 7, doi:
  • [15] Max J Egenhofer & John Herring (1990): Categorizing binary topological relations between regions, lines, and points in geographic databases. The 9(94-1), p. 76.
  • [16] Zoe Falomir, Lledó Museros, Vicent Castelló & Luis Gonzalez-Abril (2013): Qualitative distances and qualitative image descriptions for representing indoor scenes in robotics. Pattern Recognition Letters 34(7), pp. 731–743, doi:
  • [17] A. U. Frank (1991): Qualitative Spatial Reasoning about Cardinal Directions. In: Proc. of Auto-Carto 10.
  • [18] Christian Freksa (1992): Using orientation information for qualitative spatial reasoning, pp. 162–178. Springer Berlin Heidelberg.
  • [19] Alfonso Gerevini & Jochen Renz (2002): Combining topological and size information for spatial reasoning. Artificial Intelligence 137(1-2), pp. 1–42, doi:
  • [20] Björn Gottfried (2005): Global feature schemes for qualitative shape descriptions. IJCAI-05 WS on spatial and temporal reasoning.
  • [21] R Goyal & Max J Egenhofer (1997): The direction-relation matrix: A representation for directions relations between extended spatial objects. The annual assembly and the summer retreat of University Consortium for Geographic Information Systems Science 3, pp. 95–102.
  • [22] Hans W Guesgen (2002): Reasoning about distance based on fuzzy sets. Applied Intelligence 17(3), pp. 265–270, doi:
  • [23] Jung-Hong Hong, Max Egenhofer & Andrew U Frank (1995): On the robustness of qualitative distance-and direction-reasoning. In: Autocarto Conference, pp. 301–310.
  • [24] Lothar Hotz, Pascal Rost & Stephanie von Riegen: Combining Qualitative Spatial Reasoning and Ontological Reasoning for Supporting Robot Tasks.
  • [25] Yusuf Izmirlioglu & Esra Erdem (2018): Qualitative Reasoning About Cardinal Directions Using Answer Set Programming. In: Proc. of AAAI.
  • [26] Jae Hee Lee, Jochen Renz & Diedrich Wolter (2013): StarVars - Effective Reasoning about Relative Directions. In: Proc. of IJCAI, pp. 976–982.
  • [27] Jason Jingshi Li (2012): Qualitative spatial and temporal reasoning with answer set programming. In: Tools with Artificial Intelligence (ICTAI), 2012 IEEE 24th International Conference on, 1, IEEE, pp. 603–609, doi:
  • [28] Gérard F Ligozat (1993): Qualitative triangulation for spatial reasoning. In: European Conference on Spatial Information Theory, Springer, pp. 54–68.
  • [29] Weiming Liu (2013): Qualitative constraint satisfaction problems: algorithms, computational complexity, and extended framework. Ph.D. thesis, University of Technology, Sydney.
  • [30] Weiming Liu & Sanjiang Li (2011): Reasoning about cardinal directions between extended objects: The NP-hardness result. Artificial Intelligence 175(18), pp. 2155–2169, doi:
  • [31] Weiming Liu, Xiaotong Zhang, Sanjiang Li & Mingsheng Ying (2010): Reasoning about cardinal directions between extended objects. Artificial Intelligence 174(12-13), pp. 951–983, doi:
  • [32] M Teresa Escrig Monferrer & Francisco Toledo Lobo (1996): Enhancing qualitative relative orientation with qualitative distance for robot path planning. In: Tools with Artificial Intelligence, 1996., Proceedings Eighth IEEE International Conference on, IEEE, pp. 174–182.
  • [33] Reinhard Moratz, Frank Dylla & Lutz Frommberger (2005): A relative orientation algebra with adjustable granularity. In: Proceedings of the Workshop on Agents in Real-Time and Dynamic Environments (IJCAI 05), 21, p. 22.
  • [34] Reinhard Moratz, Bernhard Nebel & Christian Freksa (2002): Qualitative spatial reasoning about relative position. In: International Conference on Spatial Cognition, Springer, pp. 385–400.
  • [35] Reinhard Moratz, Jochen Renz & Diedrich Wolter (2000): Qualitative spatial reasoning about line segments. In: ECAI, pp. 234–238.
  • [36] Reinhard Moratz & Jan Oliver Wallgrün: Spatial Reasoning about Relative Orientation and Distance for Robot Exploration. In: Spatial Information Theory. Foundations of Geographic Information Science, doi:
  • [37] Reinhard Moratz & Jan Oliver Wallgrün (2003): Spatial reasoning about relative orientation and distance for robot exploration. In: International Conference on Spatial Information Theory, Springer, pp. 61–74.
  • [38] Reinhard Moratz & Jan Oliver Wallgrün (2012): Spatial reasoning with augmented points: Extending cardinal directions with local distances. Journal of Spatial Information Science 2012(5), pp. 1–30.
  • [39] Lledó Museros & M Teresa Escrig (2004): A qualitative theory for shape representation and matching for design. In: Proceedings of the 16th European Conference on Artificial Intelligence, IOS Press, pp. 858–862.
  • [40] Isabel Navarrete, Antonio Morales & Guido Sciavicco (2007): Consistency Checking of Basic Cardinal Constraints over Connected Regions. In: Proc. of IJCAI, pp. 495–500. Available at
  • [41] Julio Pacheco, Mª Teresa Escrig & Francisco Toledo (2002): Qualitative spatial reasoning on three-dimensional orientation point objects. In: Proccedings of the QR2002. 16th International WorkShop on Qualitative Reasoning. Editors: Nuria Agell and.
  • [42] Spiros Skiadopoulos & Manolis Koubarakis (2004): Composing cardinal direction relations. Artificial Intelligence 152(2), pp. 143–171, doi:
  • [43] Spiros Skiadopoulos & Manolis Koubarakis (2005): On the consistency of cardinal direction constraints. Artificial Intelligence 163(1), pp. 91–135, doi:
  • [44] Przemyslaw Andrzej Walega, Mehul Bhatt & Carl P. L. Schultz (2015): ASPMT(QS): Non-Monotonic Spatial Reasoning with Answer Set Programming Modulo Theories. In: Proc. of LPNMR, pp. 488–501.
  • [45] Nico Van de Weghe, Guy De Tré, Bart Kuijpers & Philippe De Maeyer (2005): The double-cross and the generalization concept as a basis for representing and comparing shapes of polylines. In: OTM Confederated International Conferences” On the Move to Meaningful Internet Systems”, Springer, pp. 1087–1096.
  • [46] Xiaotong Zhang, Weiming Liu, Sanjiang Li & Mingsheng Ying (2008): Reasoning with Cardinal Directions: An Efficient Algorithm. In: Proceedings of the Twenty-Third AAAI Conference on Artificial Intelligence, AAAI 2008, Chicago, Illinois, USA, July 13-17, 2008, pp. 387–392.
  • [47] Kai Zimmermann & Christian Freksa (1996): Qualitative spatial reasoning using orientation, distance, and path knowledge. Applied intelligence 6(1), pp. 49–58, doi: