Inequality solving using Prolog

267 views Asked by At

I am working on solving inequality problems using prolog.I have found a code and it solves ax+b>=0 type equations.

The code I have used is as follows.

:-use_module(library(clpr)).
dec_inc(left,right):-
      copy_term(left-right,Copyleft-Copyright).
      tell_cs(Copyleft).
      max(Copyright,right,Leq).
      tell_cs(Leq).

max([],[],[]).
max([E=<_|Ps],[_=<P1|P1s],[K=<P1|Ls]):-
      sup(E,K),
      max(Ps,P1s,Ls).

tell_cs([]).  
tell_cs([C|Cs]):-
      {C},
      tell_cs(Cs).

for example

  1. when we give {2*X+2>=5}. it gives the correct answer. {X>=1.5}.

    2.But if I enter fraction like {(X+3)/(3*X+1)>=1}. it gives {1- (3+X)/ (1+3.0*X)=<0.0}.

How can I solve this type of inequality questions to find the final answer.(questions which include fractions).
Please help me.
If there is any learning material I can refer please let me know.

1

There are 1 answers

1
CapelliC On

library(clpr) documentation advises that it deals with non linear constraints only passively, so you're out of luck. You need a more sophisticated algebra system.