Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursion+backtracking doesn't work #44

Open
mpomarlan opened this issue Oct 21, 2016 · 2 comments
Open

Recursion+backtracking doesn't work #44

mpomarlan opened this issue Oct 21, 2016 · 2 comments
Assignees
Labels

Comments

@mpomarlan
Copy link
Collaborator

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

@mpomarlan
Copy link
Collaborator Author

Now that I think about it, this is not as critical as it looks. I'll rewrite the forward planner in C++ so we can side-step this.

@fairlight1337
Copy link
Owner

Hm, that's odd. Okay, I'll have a closer look once I find some spare time this weekend (or on Monday, whatever happens first).

Thanks for figuring out the issue. This should actually work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants