I’m using: SWI-Prolog version 9.0.4
In this very helpful thread I was pointed towards Event Calculus and sCASP as a potential tool for modeling system behavior in some other software. I’ve read the BEC paper, installed sCASP, and gotten the BEC code from here. Reading the papers, this appears to be exactly what I need, but I’m having trouble getting it to work
My first issue is loading the code! (This is no longer an issue, please skip this part!) I’m using Emacs. I’ve put the BEC code from the above link into a directory. I have my own source file next to it. At the top of my file I’ve got:
:- use_module(library(scasp)).
consult[bec_theory].
If I then consult
my own source file, I get a broken situation that starts with “Syntax error: Operator expected”, and I’m unable to query anything using sCASP’s query operators. I’ve also tried #include 'bec_theory'
instead of consult
, and also tried the modified version of bec_theory.pl here, with the .<.
operators replaced with #<
.
So far the only thing that works is to start by consulting the modified bec_theory.pl file, then going to my own source file and consulting that as well. Obviously it would be great if I could just consult a single file and get going!
My own code is currently a dumb hello-wold-type setup, just to demonstrate it works. Eventually I’m hoping to model complex processing of multiple data streams that interact with each other in confusing ways, but for now I’m starting with this:
happens(data_upload, 2).
initiallyN(data_in_db).
initiates(data_upload, data_in_db, T).
Then I’d like the system to tell me that data_in_db
is false at T < 2 and true at T >= 2. The first query goes okay:
? holdsAt(data_in_db, 1).
Warning: scasp_predicate `'user:terminates'/3' does not exist
Warning: scasp_predicate `'user:trajectory'/4' does not exist
Warning: scasp_predicate `'user:initiallyP'/1' does not exist
Warning: scasp_predicate `'user:releases'/3' does not exist
false.
But then:
? holdsAt(data_in_db, 3).
Warning: scasp_predicate `'user:terminates'/3' does not exist
Warning: scasp_predicate `'user:trajectory'/4' does not exist
Warning: scasp_predicate `'user:initiallyP'/1' does not exist
Warning: scasp_predicate `'user:releases'/3' does not exist
% s(CASP) model
{ not initiallyN(_A), not initiates(_I,data_in_db,_J),
initiallyN(data_in_db), not initiates(_K,_,_),
not happens(data_upload,_B), not initiates(_L,data_in_db,_M),
not happens(data_upload,_C), not initiates(data_upload,_N,_),
not happens(data_upload,_D), initiates(data_upload,data_in_db,_B),
happens(data_upload,2), initiates(data_upload,data_in_db,_C),
not ¬ holdsAt(_,_E), initiates(data_upload,data_in_db,_D),
not ¬ holdsAt(_A,_F), initiates(data_upload,data_in_db,2),
not ¬ holdsAt(data_in_db,_G), startedIn(0,data_in_db,_G),
¬ holdsAt(data_in_db,_H), not startedIn(0,data_in_db,_H),
holdsAt(data_in_db,3), not stoppedIn(2,data_in_db,3)
},
{_O>0, _=_E-_O, _P>0, _=_E-_P, _Q>0, _=_E-_Q, _R>=0, ... = ..., ... =< ...},
{_S>0, _=_F-_S, _T>0, _=_F-_T, _U>0, _=_F-_U, _V>=0, ... = ..., ... > ...},
_A ∉ [data_in_db],
{_W>0, _=2-_X-_W, _Y>0, _=2-_X-_Y, _Z>0, _= ... - ... - _Z, _A1>=0, ... = ..., ..., ...},
{_B1>0, _=_H-_B1, _C1>0, _=_H-_C1, _D1>0, _=_H-_D1, _E1>0, ... = ..., ..., ...},
_I ∉ [data_upload],
_K ∉ [data_upload],
_N ∉ [data_in_db],
_C ∉ [2],
_L ∉ [data_upload]
Running holdsAt(data_in_db, T)
, in expectations of getting something like T #>= 2
, results in output like the above.
Obviously I’ve got something very basically wrong here, but I hope I’m just a few misconceptions away from being able make this work. Thanks in advance for any assistance!