
eval_bool(Z) --> bool(X), "+", eval_bool(Y), {max(X,Y,Z)}.
eval_bool(Z) --> bool(X), "*", eval_bool(Y), {min(X,Y,Z)}.
eval_bool(X) --> bool(X).

bool(C) --> "-", bool(X),{neg(X,C)}.
bool(X) --> [C], {"0" =< C, C =< "1", X is C - "0"}.

max(X,Y,Y):- Y > X, !.
max(X,Y,X).

min(X,Y,X):- Y > X ,!.
min(X,Y,Y).

neg(0,1).
neg(1,0).

/*

| ?-  eval_bool(Z,"0*1+-0",[]).

Z = 0 ? ;

| ?-  eval_bool(Z,"1+-1",[]).

Z = 1 ? ;

no



*/
