最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Prolog, could not derive which predicate may be called - Stack Overflow

programmeradmin0浏览0评论

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?

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?

Share edited Mar 6 at 8:32 false 10.2k13 gold badges109 silver badges216 bronze badges asked Mar 5 at 17:14 СтаниславСтанислав 34 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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.

发布评论

评论列表(0)

  1. 暂无评论