I have implemented several chain rules in a way that the last rule obtain the desired result depending on the result of the previous ones.
rule1(X,Y) :-
pred1(X,Z),
pred1(Y,Z).
rule2(Z,T) :-
rule1(X,Y),
pred2(Z,X),
pred2(T,Y).
I need to obtain every fact that has been inferred for each one of the rules. I'm doing this from Java using the jpl library.
String stringFileQuery = "rule1(X,Y)";
System.out.println(stringFileQuery + " "
+ (Query.hasSolution(stringFileQuery) ? "succeeded" : "failed"));
Query fileQuery = new Query(stringFileQuery);
System.out.println("all solutions of " + stringFileQuery);
while (fileQuery.hasMoreSolutions()) {
Map<String, Term> s10 = fileQuery.nextSolution();
System.out.println("First -> " + s10.get("X") + ", Second ->" + 10.get("Y"));
}
How can I obtain all these facts, even in Prolog? In the real program, I have more that two rules.