Index

Transitive Closure

The transitive closure of a relation R is the least transitive relation containing R. This is sometimes written as Rtr.

Example

In the following Prolog code connected/2 is the transitive closure of path/2.

	
path(a,b).
path(b,c).
path(c,d).
path(d,e).
path(d,f).

connected(X, Y) :-
	path(X,Y).
connected(X, Y) :-
	connected(X, Z),
	connected(Z, Y).
	
      

References

Doets, Kees. From Logic to Logic Programming. MIT Press, 1994.

Index