Algorithm Search⌘K

Modeladvanced

Rectangle algebra

Also called rectangle calculus.

The qualitative calculus of axis-parallel rectangles, with one Allen relation per axis. It has 169 base relations, 2^169 relations, and NP-complete consistency.

The rectangle algebra describes how two rectangles with sides parallel to the axes lie relative to each other, by giving one relation of Allen's interval algebra for their projections on the xx axis and one for their projections on the yy axis. "A is left of B and overlaps it vertically" is the base relation (b,o)(b, o). It is the standard qualitative constraint calculus for layouts, maps and documents, where objects are often summarised by their minimum bounding rectangles. This page treats it as a model: what a problem in it may say, what is counted, and what is known about its complexity.

The machine

The domain is the set of rectangles A=XA×YAA = X_A \times Y_A, where XA=(xA−,xA+)X_A = (x_A^-, x_A^+) and YA=(yA−,yA+)Y_A = (y_A^-, y_A^+) are intervals with xA−<xA+x_A^- < x_A^+ and yA−<yA+y_A^- < y_A^+. The base relations are the pairs (r,s)(r, s) of interval base relations, with

A(r,s)B  ⟺  XArXB and YAsYB.A \mathrel{(r, s)} B \iff X_A \mathrel{r} X_B \text{ and } Y_A \mathrel{s} Y_B.

There are 13×13=16913 \times 13 = 169 base relations, and they are jointly exhaustive and pairwise disjoint because the interval relations are. A relation is any set of base relations, so there are 21692^{169} relations. The identity is (eq,eq)(eq, eq). Converse and composition work axis by axis:

(r,s)⌣=(r⌣,s⌣),(r1,s1)⋄(r2,s2)=(r1⋄r2)×(s1⋄s2),(r, s)^{\smile} = (r^{\smile}, s^{\smile}), \qquad (r_1, s_1) \diamond (r_2, s_2) = (r_1 \diamond r_2) \times (s_1 \diamond s_2),

so the 169×169169 \times 169 composition table is read off the interval table and never stored. Composition is strong, because it is strong on each axis and the axes are independent.

A relation of the form R×SR \times S, with RR and SS interval relations, is a product relation; there are 81912+18191^2 + 1 of them, counting the empty relation. Most relations are not products: "A is left of B or above B" is ({b}×B)∪(B×{bi})(\{b\} \times \mathcal{B}) \cup (\mathcal{B} \times \{bi\}), a union that no product equals.

What it counts

An input is a qualitative constraint network on nn rectangles. The questions are the usual ones: consistency, a solution (rectangles with real or integer coordinates), and minimal labels. Cost is measured in nn. A label is a set of up to 169 base relations, so a word-RAM implementation stores it as 169 bits, or as a pair of 13-bit masks when it is a product.

Relation to other models

  • Interval algebra. Each axis is an interval network. A network whose labels are all products Rij×SijR_{ij} \times S_{ij} is consistent exactly when the xx network with labels RijR_{ij} and the yy network with labels SijS_{ij} are both consistent, since the two axes do not interact.
  • Block algebra. The same construction in kk dimensions has 13k13^k base relations (Balbiani, Condotta and Fariñas del Cerro 1999, 2002).
  • Cardinal directions. The cardinal direction calculus for points is the same product idea with the point algebra on each axis, 3×3=93 \times 3 = 9 base relations.
  • Topology. RCC8 describes contact and containment of arbitrary regions. For rectangles, each RCC8 relation is a union of rectangle relations; for example, two closed rectangles are disconnected exactly when their projections are in the interval relation bb or bibi on at least one axis.
  • Spatial indexes. An R-tree query such as "all boxes that intersect B" is a rectangle relation: the base relations whose projections intersect on both axes.

Known results in the model

problem result source
consistency, all 21692^{169} relations NP-complete by embedding the interval algebra
product relations R×SR \times S with RR, SS in a tractable interval class polynomial, axis by axis follows from the interval results
product relations with RR, SS ORD-Horn algebraic closure decides, O(n3)O(n^3) Nebel and Bürckert 1995 on each axis
strongly preconvex relations (not only products) algebraic closure decides Balbiani, Condotta and Fariñas del Cerro 1999
block algebra, kk dimensions analogous tractable subclasses Balbiani, Condotta and Fariñas del Cerro 2002

Hardness. Membership in NP: guess the order of the 2n2n endpoints on each axis, then check each label. Hardness: map an interval network NN with labels CijC_{ij} to the rectangle network with labels Cij×{eq}C_{ij} \times \{eq\}. All rectangles then have the same yy projection, and a solution of one network gives a solution of the other. So consistency is at least as hard as for intervals, which is NP-complete.

Products of ORD-Horn relations. If every label is Rij×SijR_{ij} \times S_{ij} with RijR_{ij}, SijS_{ij} in the ORD-Horn subclass, algebraic closure of the rectangle network keeps product labels, since intersection, converse and composition of products are products. If the closure has no empty label, then Rij⊆Rik⋄RkjR_{ij} \subseteq R_{ik} \diamond R_{kj} on each axis, so each axis network is closed, and by the Nebel-Bürckert theorem each is consistent. So closure decides these networks in O(n3)O(n^3) time.

Beyond products. Balbiani, Condotta and Fariñas del Cerro (1999) defined the strongly preconvex rectangle relations, a class that contains relations that are not products, and showed that algebraic closure decides consistency for it.

References

  1. Philippe Balbiani, Jean-François Condotta and Luis Fariñas del Cerro, A new tractable subclass of the rectangle algebra, Proceedings of IJCAI-99, Morgan Kaufmann, 1999, pages 442 to 447, the rectangle algebra as a product of two interval algebras, its consistency problem, and a tractable subclass beyond products of tractable interval relations
  2. Philippe Balbiani, Jean-François Condotta and Luis Fariñas del Cerro, A tractable subclass of the block algebra, constraint propagation and preconvex relations, EPIA 1999, Lecture Notes in Computer Science, Springer, 1999, pages 75 to 89 (the block algebra in n dimensions and its preconvex relations)
  3. Philippe Balbiani, Jean-François Condotta and Luis Fariñas del Cerro, Tractability results in the block algebra, Journal of Logic and Computation 12(5), 2002, pages 885 to 909 (tractable subclasses of the block algebra, where path consistency decides consistency)
  4. James F. Allen, Maintaining knowledge about temporal intervals, Communications of the ACM 26(11), 1983, pages 832 to 843 (the interval relations used on each axis)
  5. Frank Dylla and others, A survey of qualitative spatial and temporal calculi, algebraic and computational properties, ACM Computing Surveys 50(1), 2017, pages 1 to 39 (the rectangle and block algebras among the surveyed calculi)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/M531Q4/text.yaml