I’ve playing around with sCASP again and don’t cease to be amazed at its beauty. Say we have this small program, just four facts:
:- use_module(library(scasp)).
bird(sam).
bird(tweety).
-bird(lion).
-bird(monkey).
Now look at the amazing queries we can do:
% okay, this one not so amazing
?- scasp(bird(X),[]).
X = sam ; % sam is a bird
X = tweety ; % tweety is a bird
false.
% maybe X is a bird?
?- scasp(not -bird(X),[]).
X ∉ [lion,monkey] ; % X may be a bird, if it is different from
% lion and monkey (wow!)
false.
% is there an X for which I am not sure whether it is a bird or not?
?- scasp((not -bird(X),not bird(X)),[]).
X ∉ [lion,monkey,sam,tweety] ; % if X is different from lion,monkey,
% sam or tweety then I am not sure
% whether it is a bird or not
% (wow squared!)
false.
% maybe X is not a bird?
?- scasp((not bird(X)),[]).
X ∉ [sam,tweety] ; % X might not be a bird, if X is different from
% sam or tweety (wow!)
false.
% do I know for sure that X is not a bird?
?- scasp((-bird(X)),[]).
X = lion ; % yes, lion is not a bird
X = monkey ; % yes, monkey is not a bird
false.
This ability to handle uncertain knowledge is quite a beauty.