The transitive closure of a relation
R
is the least transitive relation containing R
.
This is sometimes written as Rtr
.
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).
Doets, Kees. From Logic to Logic Programming. MIT Press, 1994.
Copyright © 2014 Barry Watson. All rights reserved.