2
votes

I am using Swi-Prolog Csharp DLL and CLP(FD). I have the following Prolog file :

:- use_module(library(clpfd)).

constr(V0,V1,V2,C0,C1,C2) :-
   ((V0 #= 1901) #\/ (V0 #= 1750)) #<==> C0,
   ((V1 #= 3) #\/ (5 #= V1)) #<==> C1,
   ((V2 #>= 1)) #<==> C2.

config(V1,V2) :- constr(1750,V1,V2,1,1,1).

V0,V1,V2 are my variables. C0,C1,C2 are my constraints reification variables. When calling config(V1,V2). , I want to get the V1 and V2 domain values such that all constraints are satisfied.

When using in SWI-Prolog interface, I get :

1 ?- config(V1,V2).
V1 in 3\/5,
V2 in 1..sup.

Now I am wondering how to get this result in the C# port of SWI-Prolog. Calling query.SolutionVariables[0]["V1"] or query.SolutionVariables[0]["V2"] give me intermediate variables.

For V1 I could use a labelling strategy (res(X,L) :- setof(X, indomain(X), L).), but that will not work for V2 as it corresponds to a non-finite domain.

So, in a nutshell, how can I get the non-finite domain info for a solution variable with C# Swipl DLL ?

Thanks in advance.

1
It has nothing to do with the C++ ffi. Rather, use copy_term/3 - false
Could you please show me how to use it ? - M.V.

1 Answers

2
votes
?- Goal_0 = config(V1,V2), Goal_0, copy_term(Goal_0, Goal_0, C_0s).
Goal_0 = config(V1, V2),
C_0s = [clpfd:(V1 in 3\/5), clpfd:(V2 in 1..sup)],
V1 in 3\/5,
V2 in 1..sup.

Thus, use copy_term/3 to get all the constraints attached. Then use the common term ffi.