Search code examples
mathprologlogicconstraint-programmingeclipse-clp

Using trigonometric functions in eclipse clp


I'm new to eclipse CLP and I want to implement a predicate that gets all the angles equivalent to a specific sinusoidal function, something like

:- lib(ic).
solve(L) :-
L = [X,Y,Z],
L::[-180..180],
cos(X) #= sin(Y) + sin(Z),
labeling(L).

I know that this scheme probably works for integral values of the variables; so I need an alternative solution that also uses CLP.


Solution

  • Ok I figured it out,

    :-lib(ic).
    solve(V):-
    V = [X,Y,Z],
    V::[0 .. 180],
    cos(X*pi/180) $= sin(Y*pi/180) + sin(Z*pi/180),
    labeling(V).
    

    N.B: the cos and sin predicates work with radians