transitive-closure

Definition of a path/trail/walk

家住魔仙堡 提交于 2019-11-26 01:22:40
问题 Many predicates define some kind of an acyclic path built from edges defined via a binary relation, quite similarly to defining transitive closure. A generic definition is thus called for. Note that the notions defined in graph theory do not readily match what is commonly expected. Most notably, we are not interested in the edges\' names. Worse, also graph theory has changed a bit, introducing the notion of walk, noting Traditionally, a path referred to what is now usually known as an open

Definition of Reflexive Transitive Closure

我只是一个虾纸丫 提交于 2019-11-25 22:45:22
问题 Many predicates essentially use some form of transitive closure, only to discover that termination has to be addressed too. Why not solve this once and forever with closure0/3 : :- meta_predicate closure0(2,?,?). :- meta_predicate closure(2,?,?). :- meta_predicate closure0(2,?,?,+). % internal closure0(R_2, X0,X) :- closure0(R_2, X0,X, [X0]). closure(R_2, X0,X) :- call(R_2, X0,X1), closure0(R_2, X1,X, [X1,X0]). closure0(_R_2, X,X, _). closure0(R_2, X0,X, Xs) :- call(R_2, X0,X1), non_member(X1