You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected output: binding of ?x = 2. Produced output: no bindings (no valid solution found). This doesn't change if we switch the order of the predicate additions like this, however:
Try the following:
prolog->addPredicate("(apred ?x ?y)",
"(= ?x ?y)",
"(member ?x (0 2))");
prolog->addPredicate("(apred ?x ?y)",
"(= ?x ?y)",
"(member ?x (1 3))");
prolog->addPredicate("(apred ?x)",
"(apred ?x 2)");
solPrior = prolog->query("(apred ?x)", solPrior);
if(solPrior.valid())
std::cout << "BINDINGS " << solPrior.bindings().toString() << "\n";
}
Expected output: binding of ?x = 2. Produced output: no bindings (no valid solution found). This doesn't change if we switch the order of the predicate additions like this, however:
prolog->addPredicate("(apred ?x ?y)",
"(= ?x ?y)",
"(member ?x (1 3))");
prolog->addPredicate("(apred ?x ?y)",
"(= ?x ?y)",
"(member ?x (0 2))");
prolog->addPredicate("(apred ?x)",
"(apred ?x 2)");
so it's probably a recursion issue.
The next call (essentially, an unwrapping of the branch of apred that should work):
solPrior = prolog->query("(and (= ?x 2) (member ?x (0 2)))", solPrior);
if(solPrior.valid())
std::cout << "BINDINGS " << solPrior.bindings().toString() << "\n";
}
produces the expected binding of ?x = 2
The text was updated successfully, but these errors were encountered: