% An arithmetic component in an expert system
% Cut without undercutting

rlset reals;


{}


aci := ex({x,y},0<x and y<0 and x*r-x*tt+tt=x*q-x*s+s and x*b-x*d+d=y*a-y*c+c)$



aciqf := rlqe aci;


aciqf := 

(s - tt = 0 and q - r - s + tt = 0 and c - d = 0 and b - d = 0 and a - c = 0) or

                                                                          2
 (s - tt = 0 and q - r - s + tt = 0 and b - d <> 0 and b*c - b*d - c*d + d  > 0

 and a - c <> 0 and a*b - a*d - b*c + c*d > 0) or (s - tt = 0

 and q - r - s + tt = 0 and a - c <> 0

                                                               2
 and (a*b - a*d - b*c + c*d < 0 or (b - d = 0 and a*c - a*d - c  + c*d > 0))) or

                                                     2              2
 (q - r - s + tt <> 0 and q*s - q*tt - r*s + r*tt - s  + 2*s*tt - tt  < 0

 and b*s - b*tt + c*q - c*r - c*s + c*tt - d*q + d*r = 0 and a - c = 0) or (

                                                   2              2
q - r - s + tt <> 0 and q*s - q*tt - r*s + r*tt - s  + 2*s*tt - tt  < 0

                                                                   2
 and a - c <> 0 and a*b*q*s - a*b*q*tt - a*b*r*s + a*b*r*tt - a*b*s

                      2        2                                             2
 + 2*a*b*s*tt - a*b*tt  + a*c*q  - 2*a*c*q*r - 2*a*c*q*s + 2*a*c*q*tt + a*c*r

                                 2                      2        2
 + 2*a*c*r*s - 2*a*c*r*tt + a*c*s  - 2*a*c*s*tt + a*c*tt  - a*d*q  + 2*a*d*q*r

                             2
 + a*d*q*s - a*d*q*tt - a*d*r  - a*d*r*s + a*d*r*tt - b*c*q*s + b*c*q*tt

                             2                      2    2  2      2
 + b*c*r*s - b*c*r*tt + b*c*s  - 2*b*c*s*tt + b*c*tt  - c *q  + 2*c *q*r

      2          2         2  2      2          2         2  2      2
 + 2*c *q*s - 2*c *q*tt - c *r  - 2*c *r*s + 2*c *r*tt - c *s  + 2*c *s*tt

    2   2        2                                         2
 - c *tt  + c*d*q  - 2*c*d*q*r - c*d*q*s + c*d*q*tt + c*d*r  + c*d*r*s

 - c*d*r*tt > 0) or (b - d <> 0

 and b*s - b*tt + c*q - c*r - c*s + c*tt - d*q + d*r = 0

                        2
 and b*c - b*d - c*d + d  > 0 and a - c = 0)


end;

Tested on alfred running Linux 4.4.38.1.amd64-smp x86_64 CSL
Time (counter 1): 80 ms  plus GC time: 30 ms
1: real 0.37
user 0.24
sys 0.04
