SWI-prolog sCASP library and inf/2

I am trying to replicate the worked Event Calculus example from the paper:

Modeling and Verification of Timed Systems with the Event Calculus and s(CASP)
Sarat Chandra Varanasi, Brendan Hall, Joaquín Arias, Elmer Salazar, Fang Li, Kinjal Basu, Kevin Driscoll and Gopal Gupta (CEUR Workshop Proceedings (CEUR-WS.org)
https://ceur-ws.org/Vol-2970/gdepaper2.pdf

It is a nice worked example which seems to contain all necessary code. I have replicated the results using Ciao sCASP and am hoping to replicate it using the swi-prolog sCASP library (and web UI).

The sources contain the following clause (and similar) :

% conditions for controller to detect train is in gate area
happens(in, T) :-
    holdsAt(position(X1), T1),
    holdsAt(position(X2), T2),
    X1 #< 10,
    X2 #>= 10,
    sampling_window(W),
    T2 #< T1 + W,
    T2 #> T1,
    inf(T2, T).

As one would expect, I include:

:- use_module(library(scasp)).    

However when I run this I get errors:

?- ? holdsAt(passing, T).
ERROR: No permission to scasp procedure `nf_q:wait_linear/3'
ERROR: In:
ERROR:   [42] throw(error(permission_error(scasp,procedure,...),_1114))
ERROR:   [39] scasp_dyncall:predicate_calls(bv_q:inf(_1164,_1166,_1168,_1170),_1154) at /home/sam/.local/share/swi-prolog/pack/scasp/prolog/scasp/dyncall.pl:331
ERROR:   [38] findall_loop(_1194,scasp_dyncall:predicate_calls(...,_1212),_1198,[]) at /usr/lib/swi-prolog/boot/bags.pl:109
ERROR:   [37] cleanup_bag('$bags':findall_loop(_1248,...,_1252,[]),'$bags':'$destroy_findall_bag') at /usr/lib/swi-prolog/boot/bags.pl:106
ERROR:   [34] scasp_dyncall:predicate_callees_nc(bv_q:inf(_1302,_1304,_1306,_1308),_1292) at /home/sam/.local/share/swi-prolog/pack/scasp/prolog/scasp/dyncall.pl:325
ERROR:   [33] scasp_dyncall:predicate_callees(bv_q:inf(_1350,_1352,_1354,_1356),_1340) at /home/sam/.local/share/swi-prolog/pack/scasp/prolog/scasp/dyncall.pl:319
ERROR:   [32] scasp_dyncall:callee_closure([bv_q: ...,...|...],t(user: ...,true,<,t(...,true,<,...,...),t(...,true,>,...,...)),[bv_q: ...,...|...],_1392) at /home/sam/.local/share/swi-prolog/pack/scasp/prolog/scasp/dyncall.pl:263
ERROR:   [17] scasp_dyncall:callee_graph([user: ...,...],_1502) at /home/sam/.local/share/swi-prolog/pack/scasp/prolog/scasp/dyncall.pl:254
ERROR:   [15] scasp_dyncall:scasp_query_clauses(user:holdsAt(passing,_1564),_1552) at /home/sam/.local/share/swi-prolog/pack/scasp/prolog/scasp/dyncall.pl:193
ERROR:   [14] scasp_dyncall:scasp(user:holdsAt(passing,_1608),[]) at /home/sam/.local/share/swi-prolog/pack/scasp/prolog/scasp/dyncall.pl:123
ERROR:   [13] '<meta-call>'(scasp:(...;false)) <foreign>
ERROR:   [12] setup_call_cleanup(scasp:set_scasp_mode(unicode,false),scasp:(...;false),scasp:set_scasp_mode(false,false)) at /usr/lib/swi-prolog/boot/init.pl:680
ERROR:    [9] toplevel_call(user:user: ...) at /usr/lib/swi-prolog/boot/toplevel.pl:1173
ERROR: 
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
   Exception: (37) cleanup_bag('$bags':findall_loop(_930, scasp_dyncall:predicate_calls(bv_q:inf(_912, _914, _916, _918), _930), _938, []), '$bags':'$destroy_findall_bag') ? abort
% Execution Aborted

How can I bring the CLP(Q) inf/2 into use in the same way as #< and friends?

Many thanks,

Steve

Hey Steve,

That’s an interesting issue. Currently SWI-Prolog’s s(CASP) port doesn’t provide something like inf/2 for s(CASP) programs AFAICT. I think that’s quite reasonable though since inf/2 is not a CLP constraint–it’s an extra-logical solver predicate. To observe its non-logical properties, consider the following queries:

?- {A > 0}, inf(A,B), inf(A, B), {A > 1}.
B = 0,
{A>1}.

?- {A > 0}, inf(A,B), {A > 1}, inf(A, B).
false.

The operational nature of inf/2 is also conveyed in its documentation (emphasis added):

Computes the infimum of Expression within the current state of the constraint store and returns that infimum in Inf. This predicate does not change the constraint store.

So I’m wondering how inf/2 should be interpreted in the settings of s(CASP)…

Well, there were partial remains of library(clpq) inf/2 and sup/2. Steve and I managed to get them working through the whole conversion and checking process of sCASP.