Is there any easy way to translate a Prolog/ASP code into CLIPS?
Something like this one, but with CLIPS instead of Prover9: https://github.com/potassco/anthem/tree/master/examples
Is there any easy way to translate a Prolog/ASP code into CLIPS?
Something like this one, but with CLIPS instead of Prover9: https://github.com/potassco/anthem/tree/master/examples
You can translate some of ASP into forward chaining, when the forward chaining engine allows you non-deterministic choice actions. The result will be a disjunctive head logic program. Here is an example of a little ASP program:
:- p, q, r.
{p,r}.
{q} :- p.
{r} :- p.
You can then rewrite this into forward chaining rules. For brevity we have used our (;)/2 action in the head of the forward chaining rules:
fail <= posted(p), posted(q), posted(r).
post(p); post(r) <= posted(init).
post(q) <= posted(p).
post(r) <= posted(p).
Here is a tracing Prolog execution, the code will first try p, but the constraint p, q, r will prevent this answer set element as a solution:
Jekejeke Prolog 3, Development Environment 1.3.2
(c) 1985-2018, XLOG Technologies GmbH, Switzerland
?- post(init).
0 Call post(init) ?
1 Call post(p) ?
2 Call clause(q, true) ?
2 Fail clause(q, true) ?
2 Call post(q) ?
3 Call clause(p, true) ?
3 Exit clause(p, true) ?
3 Call clause(r, true) ?
3 Fail clause(r, true) ?
2 Exit post(q) ?
2 Call post(r) ?
3 Call clause(p, true) ?
3 Exit clause(p, true) ?
3 Call clause(q, true) ?
3 Exit clause(q, true) ?
3 Call fail ?
3 Fail fail ?
2 Fail post(r) ?
1 Fail post(p) ?
In the above clause/2 does check the bodies of the disjunctive head logic program. The Prolog interpreter will then backtrack to r as an answer set element:
1 Call post(r) ?
2 Call clause(p, true) ?
2 Fail clause(p, true) ?
1 Exit post(r) ?
0 Exit post(init) ?
Yes