I'm trying to run the program but I get an error:
Sandbox restriction! Could not derive which predicate may be called from call(C) expression1(A,B) combined_expression(A,B,C) solve
expression1(C, J) :-
(C, \+J);
(\+C, J).
expression2(J, D) :-
(J, \+D);
(\+J, D).
expression3(D, C, J) :-
(
D,
\+ C,
\+ J
);
(
\+ D,
(C ; J)
).
values([true, false]).
combined_expression(C, J, D) :-
write('C = '), write(C), write(', '),
write('J = '), write(J), write(', '),
write('D = '), writeln(D),
expression1(C, J),
expression2(J, D),
expression3(C, J, D).
solve:-
values(Values),
member(A, Values),
member(B, Values),
member(C, Values),
combined_expression(A, B, C).
How can this be fixed?
You haven't said, but that error message looks like it is from SWISH - a restricted shared web environment. As a security protection to stop people attacking it, SWISH will only run code that it can make sure is not an attack. By putting a term into C
and executing it with (C, \+J)
SWISH cannot be sure the code is safe for it, and will not run it.
You can download SWI Prolog and install it locally, and run any code you want.