Stepping aside from set theory for a moment - the transitive closure of a graph is another interesting problem/property. For a directed graph G = (V, E), the transitive closure of G is the graph (call it G') (V, E') such that an edge e is in E' if and only if there is a directed path from e_{v1} to e_{v2}. That is, the edge set of G' is all pairs of vertices in G where there is a path between the two vertices.

I don't suppose that was very enlightening, was it? Alright then, express the edge set of G as the relation Edge(A, B), where A and B are the endpoints of an edge. In datalog, one program that would find the relation describing all edges in the transitive closure of G would be:

- Closure(x,y)<--Edge(x,y)
- Closure(x,y)<--Closure(x,z), Edge(z,y)

I will state here, without backing it up (another node for another day, if it doesn't exist), that to find the transitive closure of a graph, the toolset you use needs to have some sort of iterative or recursive tool. This is why transitive closure can be found simply in datalog, but cannot be expressed at all in simple relational algebras (any of the first few described in relational algebra, for example). To find the transitive closure of a graph using relational algebra (using the same sort of relation as described above for datalog), you would need to add a while or fixpoint operator.