(Recalling some) Definitions:
- Fix a finite collection of finite sets: $A_1,\ldots,A_k$. Then relationship $R\subseteq A_1 \times A_2 \times \ldots\times A_k$. (Remark: $A_i$'s need not be distinct.)
- A rule (or transition) $\sigma: R^m \to A_1 \times A_2 \times \ldots\times A_k$.
Examples:
Consider the ancestor relationship $R = \{(x,y)\mid x \text{ is an ancestor of } y\}$. Then the rule $\sigma: R^2 \to A \times A$ is given by $\sigma((x,y),(y,z)) = (x,z)$ represents the transitive rule that if $x \text{ is an ancestor of } y$ and $y \text{ is an ancestor of } z$ then $x \text{ is an ancestor of } z$.
Consider the 3-cycles relationship $R = \{ (x, y, z) \mid x\rightarrow y \rightarrow z \rightarrow x \text{ is a directed cycle of a Graph}\}$. Then the rule $\sigma: R \to R$ given by $\sigma((x,y,z)) = (y, z, x)$ represents the cyclic order symmetry relation.
Question-1: Given $\sigma$ and $R$, what is an efficient algorithm to compute the transitive closure of $\sigma$ with respect to $R$?
(Remark: Some naive/ obvious approaches I thought of so far:
(Brute force: ) Loop through all $e\in R^m$,check if $e$ satisfies conditions of $\sigma$, if yes then add $\sigma(e)$ to $R$. Repeat until no more new elements can be added. $O(|R|^m)$.
For example-1 with a binary relationship and transitive rule, I know about Floyd-Marshall Algorithm. $O(|A|^3)$. There are 3 independent variables $x, y, z\in A$. Looping through them would be $O(|A|^3)$. But surely Floyd-Marshall is more superior than brute force looping over $x, y, z\in A$.
Using the independent variable trick one gets $O(|A|^p)$, where $p$ is number of independent variables. At this stage we need to check if all conditions satisfy or not. So in the most general case this is a $\mathrm{SAT}$ problem and hence probably no hopes of doing better. However I would love to know more about if anything more is known than what I am thinking about naively.)
Question-2: Is there a software package that already implements this? (I prefer Python, but any language should be fine).