From: Edward S. <esc...@ce...> - 2016-02-24 21:35:32
|
Hi all, Thanks again for the help so far. I removed clpfd from our program, and that particular issue went away. Unfortunately, we have another one. Here's a snippet of the problem: certainInstanceCallsMethod(Constructor, Method) :- someStuff(Constructor, Method), writeln('ok'), writeln(Constructor), writeln(Method). certainInstanceCallsMethod(Constructor, Method) :- writeln('hey'), writeln(Method), certainConstructor(Constructor), writeln('hey2'), writeln(Constructor), certainVFTableEntry(VFTable, _, Method), writeln('here we go'), writeln(Method), % And the method is in that virtual function table. certainVFTableWrite(_, Constructor, _, VFTable), writeln('done!'). certainInstanceCallsMethodSet(Constructor, Set) :- certainConstructor(Constructor), setof(Method, certainInstanceCallsMethod(Constructor, Method), Set). Here is the problematic output: ok method(101) method(101) ok method(101) method(102) ok method(101) method(103) hey _164154 hey2 method(101) C = method(101), S = [method(101),method(102),method(103)] ? ; here we go method(104) done! false. So the first rule is used to prove certainInstanceCallsMethod(method(101), method(101)), certainInstanceCallsMethod(method(101), method(102)), and certainInstanceCallsMethod(method(101), method(103)). The second rule begins evaluating, but stops when it reaches certainVFTableEntry. AFTER I hit semicolon some type of backtracking occurs and the second rule finishes, proving certainInstanceCallsMethod(method(101), method(104)). If I execute the query again, all four methods are included in the resulting set. It's possible and even likely that certainVFTableEntry is recursing and calling certainInstanceCallsMethod again; this is why we are using tabling. Assuming I have rid my program of all coroutining, is this a bug, or is it some type of expected behavior? In particular, why does the backtracking happen outside of the setof()? Thanks again, Ed |