There is an error in the disjunction rule. Further the
permutation rule is a structural rule:
G, A, B, D |- C
---------------
G, B, A, D |- C
And you should code it, so that it doesn't loop. But now this can exactly happen. There is a simple trick, maybe you wanted to implement it, only swap in non-atoms to the fronts.
Here is a cleaned up version:
:- use_module(library(basic/lists)).
sc([neg(A)|L],R) :- !, sc(L,[A|R]).
sc(L,[neg(A)|R]) :- !, sc([A|L],R).
sc(L,[or(A,B)|R]) :- !, sc(L,[A,B|R]).
sc([or(A,B)|L],R) :- !, sc([A|L],R), sc([B|L],R).
sc([A|L],R) :- atom(A), select(B,L,H), compound(B), !, sc([B,A|H],R).
sc(L,[A|R]) :- atom(A), select(B,R,H), compound(B), !, sc(L,[B,A|H]).
sc(L,R) :- member(A,L), member(A,R), !.
And here are some runs:
Jekejeke Prolog 3, Runtime Library 1.3.5
(c) 1985-2019, XLOG Technologies GmbH, Switzerland
?- sc([],[neg(or(neg(p),neg(neg(p))))]).
No
?- sc([],[or(neg(p),neg(neg(p)))]).
Yes
Remarks: I have moved the identity rule to the end, so it will only hit atoms. I have placed cuts, which is justified by some inversion lemmas for classical logic. Might not work for other logics or when non-ground problems are posed.
{}button to format it properly. Do you know that[ (neg ((neg p)or neg (neg p)))]is a list of one element? - lurker