Ask DCG Prolog for an answer
I have a DCG written in a prologue that tries to translate a string into a simple boolean proposition.
Current rules: + means OR, * means AND, - means NOT
g(or(X,Y)) -->
f(X),
"+",
g(Y).
g(X) -->
f(X).
f(and(X,Y)) -->
e(X),
"*",
f(Y).
f(X) -->
e(X).
e(not(X)) -->
"-",
d(X).
e(X) -->
d(X).
d(X)-->
"(",
g(X),
")".
d(a)-->
"a".
d(b)-->
"b".
However I am having problems with errors Out of local trace
.
This code should be correct, but how can I ask Prolog to give and(not(or(a,b)),or(b,not(a)))
as an answer to-(a+b) * (b + -a)
+3
source to share