I am trying to solve ax^2+bx+c>0 type inequality question using prolog.
Can i use this coding for solving the problem. two
:-use_module(library(fd)).
compute(L=R, X) :-
term_variables(L, [X]),
L #= R.
I am trying to solve ax^2+bx+c>0 type inequality question using prolog.
Can i use this coding for solving the problem. two
:-use_module(library(fd)).
compute(L=R, X) :-
term_variables(L, [X]),
L #= R.
First library(clpfd)
(not fd
) is - as far as I know - a finite domain solver. So you need to provide the finite domains.
Secondly, you provide an equality constraint, you should provide an inequality constraint.
Example:
:- use_module(library(clpfd)).
compute(L>R,X,Low,High) :-
term_variables(L, [X]),
X in Low..High,
L #> R,
label([X]).
Or when no domains are given:
compute(L>R,X) :-
term_variables(L,[X]),
L #> R.
And then instantiate:
?- compute(5*X*X-2*X+7>0,X).
2*X#=_G1114,
_G1128*X#=_G1126,
5*X#=_G1128,
_G1152+_G1114#=_G1126,
_G1152 in -6..sup,
_G1152+7#=_G1174,
_G1174 in 1..sup.