% -----------------------------------------------------------------------------
%  (C) Altran Praxis Limited
% -----------------------------------------------------------------------------
% 
%  The SPARK toolset is free software; you can redistribute it and/or modify it
%  under terms of the GNU General Public License as published by the Free
%  Software Foundation; either version 3, or (at your option) any later
%  version. The SPARK toolset is distributed in the hope that it will be
%  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
%  Public License for more details. You should have received a copy of the GNU
%  General Public License distributed with the SPARK toolset; see file
%  COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy of
%  the license.
% 
% =============================================================================


%-------------------------------------------------------------------------------
% RULE FAMILIES CONTAINED HEREIN :-
%
% inequals     : inequalities rules for integers and reals
% zero         : equality/non-equality to 0 with multiplication rules
%-------------------------------------------------------------------------------
% MODEL DECLARATIONS FOR THIS FILE :-
%
% rule_family inequals:
%         X < Y  requires [ X:ir, Y:ir ] &
%         X <= Y requires [ X:ir, Y:ir ] &
%         X > Y  requires [ X:ir, Y:ir ] &
%         X >= Y requires [ X:ir, Y:ir ] &
%         X <> Y requires [ X:ir, Y:ir ] &
%         X = Y  requires [ X:ir, Y:ir ].
%
% rule_family zero:
%         X = Y  requires [ X:ir,  Y:ir  ] &
%         X <> Y requires [ X:ir,  Y:ir  ] &
%         X or Y requires [ X:any, Y:any ].
%-------------------------------------------------------------------------------


/*** INEQUALS Rules ***/

/*** Addition or subtraction of a number from one side of an inequality ***/

inequals(1):    I-N<J may_be_deduced_from [ I<J, N>=0 ].
inequals(2):    I-N<J may_be_deduced_from [ I<=J, N>0 ].
inequals(3):    I-N<=J may_be_deduced_from [ I<=J, N>=0 ].

inequals(4):    J>I-N may_be_deduced_from [ I<J, N>=0 ].
inequals(5):    J>I-N may_be_deduced_from [ I<=J, N>0 ].
inequals(6):    J>=I-N may_be_deduced_from [ I<=J, N>=0 ].

inequals(7):    I+N>J may_be_deduced_from [ I>J, N>=0 ].
inequals(8):    I+N>J may_be_deduced_from [ I>=J, N>0 ].
inequals(9):    I+N>=J may_be_deduced_from [ I>=J, N>=0 ].

inequals(10):   N+I>J may_be_deduced_from [ I>J, N>=0 ].
inequals(11):   N+I>J may_be_deduced_from [ I>=J, N>0 ].
inequals(12):   N+I>=J may_be_deduced_from [ I>=J, N>=0 ].

inequals(13):   J<I+N may_be_deduced_from [ I>J, N>=0 ].
inequals(14):   J<I+N may_be_deduced_from [ I>=J, N>0 ].
inequals(15):   J<=I+N may_be_deduced_from [ I>=J, N>=0 ].

inequals(16):   J<N+I may_be_deduced_from [ I>J, N>=0 ].
inequals(17):   J<N+I may_be_deduced_from [ I>=J, N>0 ].
inequals(18):   J<=N+I may_be_deduced_from [ I>=J, N>=0 ].


/*** Addition and subtraction of a number on both sides of an inequality ***/

inequals(19):   I+N<J+N may_be_deduced_from [ I<J ].
inequals(20):   N+I<J+N may_be_deduced_from [ I<J ].
inequals(21):   I+N<N+J may_be_deduced_from [ I<J ].
inequals(22):   N+I<N+J may_be_deduced_from [ I<J ].

inequals(23):   I+N>J+N may_be_deduced_from [ I>J ].
inequals(24):   N+I>J+N may_be_deduced_from [ I>J ].
inequals(25):   I+N>N+J may_be_deduced_from [ I>J ].
inequals(26):   N+I>N+J may_be_deduced_from [ I>J ].

inequals(27):   I+N<>J+N may_be_deduced_from [ I<>J ].
inequals(28):   N+I<>J+N may_be_deduced_from [ I<>J ].
inequals(29):   I+N<>N+J may_be_deduced_from [ I<>J ].
inequals(30):   N+I<>N+J may_be_deduced_from [ I<>J ].

inequals(31):   I-N<J-N may_be_deduced_from [ I<J ].
inequals(32):   I-N>J-N may_be_deduced_from [ I>J ].
inequals(33):   I-N<>J-N may_be_deduced_from [ I<>J ].


/*** Multiplication on both sides of an inequality by a number ***/

inequals(34):   I*N<>J*N may_be_deduced_from [ I<>J, N<>0 ].
inequals(35):   I*N>J*N may_be_deduced_from [ I>J, N>0 ].
inequals(36):   I*N<J*N may_be_deduced_from [ I<J, N>0 ].
inequals(37):   I*N>J*N may_be_deduced_from [ I<J, N<0 ].
inequals(38):   I*N<J*N may_be_deduced_from [ I>J, N<0 ].
inequals(39):   I*N>=J*N may_be_deduced_from [ I>=J, N>=0 ].
inequals(40):   I*N<=J*N may_be_deduced_from [ I<=J, N>=0 ].
inequals(41):   I*N>=J*N may_be_deduced_from [ I<=J, N<=0 ].
inequals(42):   I*N<=J*N may_be_deduced_from [ I>=J, N<=0 ].


/*** Addition and subtraction of two inequalities ***/

inequals(43):   A+C>B+D may_be_deduced_from [ A>=B, C>D ].
inequals(44):   A+C>B+D may_be_deduced_from [ A>B, C>=D ].
inequals(45):   A+C>B+D may_be_deduced_from [ A>=D, C>B ].
inequals(46):   A+C>B+D may_be_deduced_from [ A>D, C>=B ].
inequals(47):   A-D>B-C may_be_deduced_from [ A>=B, C>D ].
inequals(48):   A-D>B-C may_be_deduced_from [ A>B, C>=D ].

inequals(49):   A+C<B+D may_be_deduced_from [ A<=B, C<D ].
inequals(50):   A+C<B+D may_be_deduced_from [ A<B, C<=D ].
inequals(51):   A+C<B+D may_be_deduced_from [ A<=D, C<B ].
inequals(52):   A+C<B+D may_be_deduced_from [ A<D, C<=B ].
inequals(53):   A-D<B-C may_be_deduced_from [ A<=B, C<D ].
inequals(54):   A-D<B-C may_be_deduced_from [ A<B, C<=D ].

inequals(55):   A+C<>B+D may_be_deduced_from [ A<>B, C=D ].
inequals(56):   A+C<>B+D may_be_deduced_from [ A=B, C<>D ].
inequals(57):   A+C<>B+D may_be_deduced_from [ A<>D, B=C ].
inequals(58):   A+C<>B+D may_be_deduced_from [ A=D, B<>C ].
inequals(59):   A-D<>B-C may_be_deduced_from [ A<>B, C=D ].
inequals(60):   A-D<>B-C may_be_deduced_from [ A=B, C<>D ].


/*** Addition and subtraction of a number on both sides of an inequality ***/

inequals(61):   I+N=J+N may_be_deduced_from [ I=J ].
inequals(62):   N+I=J+N may_be_deduced_from [ I=J ].
inequals(63):   I+N=N+J may_be_deduced_from [ I=J ].
inequals(64):   N+I=N+J may_be_deduced_from [ I=J ].

inequals(65):   I+N<=J+N may_be_deduced_from [ I<=J ].
inequals(66):   N+I<=J+N may_be_deduced_from [ I<=J ].
inequals(67):   I+N<=N+J may_be_deduced_from [ I<=J ].
inequals(68):   N+I<=N+J may_be_deduced_from [ I<=J ].

inequals(69):   I+N>=J+N may_be_deduced_from [ I>=J ].
inequals(70):   N+I>=J+N may_be_deduced_from [ I>=J ].
inequals(71):   I+N>=N+J may_be_deduced_from [ I>=J ].
inequals(72):   N+I>=N+J may_be_deduced_from [ I>=J ].

inequals(73):   I-N=J-N may_be_deduced_from [ I=J ].
inequals(74):   I-N<=J-N may_be_deduced_from [ I<=J ].
inequals(75):   I-N>=J-N may_be_deduced_from [ I>=J ].


/*** Multiplication on both sides of an inequality by a number ***/

inequals(76):   I*N=J*N may_be_deduced_from [ I=J ].


/*** Addition and subtraction of two inequalities ***/

inequals(77):   A+C>=B+D may_be_deduced_from [ A>=B, C>=D ].
inequals(78):   A+C>=B+D may_be_deduced_from [ A>=D, C>=B ].
inequals(79):   A-D>=B-C may_be_deduced_from [ A>=B, C>=D ].

inequals(80):   A+C<=B+D may_be_deduced_from [ A<=B, C<=D ].
inequals(81):   A+C<=B+D may_be_deduced_from [ A<=D, C<=B ].
inequals(82):   A-D<=B-C may_be_deduced_from [ A<=B, C<=D ].

inequals(83):   A+C=B+D may_be_deduced_from [ A=B, C=D ].
inequals(84):   A+C=B+D may_be_deduced_from [ A=D, B=C ].
inequals(85):   A-D=B-C may_be_deduced_from [ A=B, C=D ].


/* Rule numbering gap: 86-103 are in INTINEQS; retained for compatibility */


/*** Additional rules for inequalities with multiplication ***/

inequals(104):  X=Y     may_be_deduced_from [ X*N=Y*N, N<>0 ].

inequals(105):  X<>Y    may_be_deduced_from [ X*N<>Y*N, N<>0 ].

inequals(106):  X<=Y    may_be_deduced_from [ X*N<=Y*N, N>0 ].
inequals(107):  X<=Y    may_be_deduced_from [ X*N>=Y*N, N<0 ].

inequals(108):  X>=Y    may_be_deduced_from [ X*N>=Y*N, N>0 ].
inequals(109):  X>=Y    may_be_deduced_from [ X*N<=Y*N, N<0 ].

inequals(110):  X<Y     may_be_deduced_from [ X*N<Y*N, N>0 ].
inequals(111):  X<Y     may_be_deduced_from [ X*N>Y*N, N<0 ].

inequals(112):  X>Y     may_be_deduced_from [ X*N>Y*N, N>0 ].
inequals(113):  X>Y     may_be_deduced_from [ X*N<Y*N, N<0 ].

inequals(114):  X*Y<=0  may_be_deduced_from [ X>=0, Y<=0 ].
inequals(115):  X*Y<=0  may_be_deduced_from [ X<=0, Y>=0 ].

inequals(116):  X*Y>=0  may_be_deduced_from [ X>=0, Y>=0 ].
inequals(117):  X*Y>=0  may_be_deduced_from [ X<=0, Y<=0 ].

inequals(118):  X*Y<0   may_be_deduced_from [ X>0, Y<0 ].
inequals(119):  X*Y<0   may_be_deduced_from [ X<0, Y>0 ].

inequals(120):  X*Y>0   may_be_deduced_from [ X>0, Y>0 ].
inequals(121):  X*Y>0   may_be_deduced_from [ X<0, Y<0 ].


/*** Rules for equality and non-equality to zero involving multiplication ***/

zero(1):        X * Y = 0  may_be_deduced_from [ X = 0 ].
zero(2):        X * Y = 0  may_be_deduced_from [ Y = 0 ].
zero(3):        X=0 or Y=0 may_be_deduced_from [ X*Y=0 ].
zero(4):        X * Y <> 0 may_be_deduced_from [ X<>0, Y<>0 ].
zero(5):        X <> 0     may_be_deduced_from [ X * Y <> 0 ].
zero(6):        Y <> 0     may_be_deduced_from [ X * Y <> 0 ].
