---
title: Relation-set Following Operation
url: https://www.emergentmind.com/topics/relation-set-following-operation
type: topic
---

# Relation-set Following Operation

A relation-set following operation generalizes the “successor”/“next”/“image” concept from binary relations to complex query algebras, succinct representations, and higher-order data models. It provides a unifying formal lens connecting database subset selection and optimization, process-mining “directly-follows” queries, and set-image operations on compact binary relations. Modern research establishes that navigation, enumeration, and optimization over sets of relations (solution sets, ordered pairs, or labeled images) can be described and efficiently implemented using a mixture of extended relational algebra, succinct data structures, and carefully constructed ordering and limiting operators.

## 1. Formal Definitions and Core Constructs

Let $R \subseteq [1,\sigma] \times [1,n]$ be a binary relation. The classic *set following* or *image* operation, given $X \subseteq [1,\sigma]$, is
$$
R(X) = \{z \in [1,n] ~|~ \exists \alpha \in X : (\alpha, z) \in R \},
$$
and, symmetrically for $Y \subseteq [1,n]$, the preimage is $R^{-1}(Y) = \{\alpha \in [1,\sigma] ~|~ \exists z \in Y : (\alpha, z) \in R\}$ [1201.3602].

This primitive underpins more elaborate operations in higher-order relational algebra. In “Relational Algebras for Subset Selection and Optimisation,” solution sets are defined as
$$
U = \langle Base_U,\, Decision_U,\, \chi_U \rangle,
$$
with $\dom(U)=\{I_U\subseteq Base_U\times Decision_U ~|~ \pi_{Base_U}(I_U)=Base_U \wedge (Base_U\to Decision_U)\}$, and manipulations always proceed via the characteristic function $\chi_U$ [2509.06439].

A particularly important class is *directly follows* in event logs, where (in an event table Log with case identifier $c$ and time $t$):
$$
\langle df \rangle_{c,t}(Log) = \rho_{\downarrow}(Log) \bowtie_{\downarrow c = \uparrow c \wedge \downarrow t < \uparrow t} \rho_{\uparrow}(Log) -
  \pi_{As}\left[
    \left(
      \rho_{\downarrow}(Log) \bowtie_{\downarrow c = \uparrow c \wedge \downarrow t < \uparrow t} \rho_{\uparrow}(Log)
    \right)
    \bowtie_{\downarrow c = c \wedge \downarrow t < t < \uparrow t} Log
  \right],
$$
where $As$ collects disjoint renamed attributes [1706.08259].

## 2. Algebraic Laws and Expressiveness

All set-following and solution-set operators in these frameworks demonstrate closure under natural extensions of union, intersection, difference, join, selection, rename, and projection, provided these are “lifted” to work over relation sets. Notably, the characteristic-function $\chi$ composition encodes the classical Boolean algebraic properties (commutativity, associativity, distributivity) [2509.06439].

Ordering and limiting (“next”/“following”) extend the algebra to support navigation and search:
- $\tau_{sol}[\mu](U)$ transforms a (potentially exponential) solution set $U$ into a sequence ordered by objective $\mu$.
- $\lambda_{sol}[n](\tau_{sol}[\mu](U))$ yields the top-$n$ solutions — this sequence realizes “step”/“follow”/“successor” semantics, where $\lambda_{sol}[1]$ is “first,” $\lambda_{sol}[k]$ is the $k$-th, and so on [2509.06439].

For *directly-follows*, equivalence properties include:
- Selection/disjunction push-down:
  $$
  \langle df\rangle_{c,t}(\sigma_{a\theta x} Log) = \sigma_{\downarrow a\theta x \wedge \uparrow a\theta x} (\langle df\rangle_{c,t} (Log))
  $$
- Projection push-down and join commutation, enabling efficient query optimization, are similarly formalized [1706.08259].

## 3. Data Structures and Enumeration Algorithms

Succinct binary relation representations play a central role for efficient set-following. BinRel-Str, BinRel-WT (wavelet tree), BinRel-GWT (generalized wavelet tree), and BRWT (binary-relation wavelet tree) each offer tradeoffs in space and query time [1201.3602].

In BinRel-WT, storing a bitmap $B$ and a string $S$ (object-major order of labels), allows the operation $obj(L,x,y)=\{z \in [x,y] : \exists \alpha \in L, (\alpha,z) \in R\}$ in $O(|output| \cdot \log \sigma)$ time. Wavelet trees support enumeration via rank and select primitives at each node for logarithmic time per followed element.

Algorithmically, enumeration is realized by an outer loop incrementing through $j=1,2,...$, each time calling $REL\_OBJ\_SELECT(\alpha,\beta,x,j)$ (see Section 3 of [1201.3602]) to retrieve the $j$-th image.

For higher-order solution sets, enumeration is algebraized via repeated application of ordering and limiting; practically, one executes an ORDER BY and increments an OFFSET (in e.g. SQL) or evaluates LIMIT $k$ for successive $k$ [2509.06439].

## 4. Application Domains

Relation-set following is operational in several settings:
- **In-database Process Mining**: Directly-follows is foundational for constructing directly-follows graphs used in process discovery, e.g. by Inductive Miner. Native operators (e.g. DIRECTLYFOLLOWS in H2) permit scalable in-database mining, with process discovery queries and immediate construction of frequency tables optimized in $O(|E|\log |E|)$ time [1806.01657][1706.08259].
- **Subset Selection and Optimization in Databases**: Solution-set following underpins practical prescriptive analytics (e.g., batch selection, assignment, scheduling optimizations) by producing and stepping through candidate relation instances [2509.06439].
- **Compact Indexes and Succinct Data Structures**: The set-image operation, and its enumeration, is crucial for text indexing, labeled graphs, and information retrieval over relational data, where only the set of followed objects (or labels) is required efficiently [1201.3602].

## 5. Compilation and Implementation Strategies

Relational algebraic set-sequence navigation does not require explicit successor operators as primitives. Instead, the canonical approach (articulated in [2509.06439]) is:
1. Construct a solution set (via $\omega_{sol}$ or binary relation representation);
2. Apply objective-based sorting ($\tau_{sol}$) to produce a sorted sequence;
3. Extract the next/desired solution via a limit/offset operator ($\lambda_{sol}$).

For standard RDBMSs, this model is compiled via a homomorphism $\Phi$ to ordinary relational constructs:
- Attributes are flattened ($Decision_U$-replica per $Base$-row);
- Constraints become Boolean predicates in WHERE;
- ORDER BY plus LIMIT/OFFSET or window/row_number yields enumerated navigation (e.g., “next solution”) [2509.06439].

Native implementations of set-following (e.g., for directly-follows) leverage tuple sorting and per-case scans, outperforming nested SQL approaches by avoiding $O(N^3)$ blowup and enabling interactive scalability on multi-million-event logs [1806.01657][1706.08259].

## 6. Comparative Performance and Theoretical Properties

Space and time guarantees for the principal representations and operations are summarized below:

| Model        | Space                          | Per-Image Time     | Notes                                          |
|--------------|-------------------------------|--------------------|------------------------------------------------|
| BinRel-WT    | $t\lceil\log \sigma\rceil + o(t+\sigma+n)$ | $O(\log \sigma)$ (per element) | General set image $obj(L,x,y)$                 |
| BinRel-GWT   | $tH_0(S)+o(tH_0(S))+O(t+n)$   | $O(\frac{\log \sigma}{\log \log n})$ | Larger fan-out; optimal for large $\sigma$     |
| Solution-set order+limit | -               | Output-sensitive    | Couples with relational optimizer [2509.06439]  |
| Directly-follows (native) | -              | $O(N\log N)$ abstraction | Linear retrieval ($O(1)$), $O(|A|^2)$ output   |

Native database implementations that exploit selection/projection pushdown and streaming produce significant performance improvements and avoid memory/disk bottlenecks common to nested-query or non-native approaches [1806.01657][1706.08259].

## 7. Theoretical and Practical Significance

The relation-set following operation unifies the expression and navigation of both simple relation images and the distinctly higher-order problem of stepping through ordered sets of solutions to combinatorial database queries. Its formalization in higher-order relational algebra ($RA_{sol}$) and succinct data structures provides strong closure and expressivity properties, as well as tractable enumeration and optimization for both theoretical analysis and real-world applications. Efficient implementations, both at the index and relational-engine level, are essential for scalable analytics, complex event pattern discovery, and prescriptive query answering in modern data-intensive systems [2509.06439][1706.08259][1806.01657][1201.3602].

Source: https://www.emergentmind.com/topics/relation-set-following-operation