Cyclic relation in Datalog using SMTLib for z3
问题 I would like to express this problem in the SMTLib Format and evaluate it using Z3. edge("som1","som3"). edge("som2","som4"). edge("som4","som1"). edge("som3","som4"). path(x,y) :- edge(x,y). % x and y are strings path(x,z) :- edge(x,y), path(y,z). :- path(x,y), path(y,x). %cyclic path. My question is how to write the rule (or query) which detect the existence of a cycle in the relation path (this rule in basic datalog : :- path(x,y), path(y,x) ). 回答1: The tutorial Levent Erkok pointed out