% BEGIN LICENSE BLOCK
% Version: CMPL 1.1
%
% The contents of this file are subject to the Cisco-style Mozilla Public
% License Version 1.1 (the "License"); you may not use this file except
% in compliance with the License.  You may obtain a copy of the License
% at www.eclipse-clp.org/license.
% 
% Software distributed under the License is distributed on an "AS IS"
% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
% the License for the specific language governing rights and limitations
% under the License. 
% 
% The Original Code is  The ECLiPSe Constraint Logic Programming System. 
% The Initial Developer of the Original Code is  Cisco Systems, Inc. 
% Portions created by the Initial Developer are
% Copyright (C) 1991-2006 Cisco Systems, Inc.  All Rights Reserved.
% 
% Contributor(s): Thom Fruehwirth, ECRC. 
% 
% END LICENSE BLOCK

% gauss.chr ================================================================
% constraint handling rules for naive gaussian elimination
% thom fruehwirth 910610,911213,920124,930602,931223
% complete for equalities, leaves equalities implicit, slow
% may loop if variables of the equations are unified 


handler gauss.

:- local (=:=)/2.

operator(100,xfx,equals).

constraints (=:=)/2, (equals)/2.

normalize @ 
A =:= B <=> 
	normalize(A,B,Poly,Const), 
	Poly equals Const.   	

eliminate @ 
[X*Coeff1|P1] equals C1 \ P equals C2 <=> delete(X*Coeff2,P,P2) | 
	is_div(Coeff2,Coeff1,C), 
	mult_const(eq0(C1,P1),C,eq0(C1C,P1C)),	
        add_eq0(eq0(C2,P2),eq0(C1C,P1C),eq0(C3,P3)),
	P3 equals C3.


:- ['math-utilities'].	% load auxiliary file


/*
:-      3 * X + 2 * Y - 4 * (3 + Z) =:= 2 * (X - 3) + (Y + Z) * 7 ,      
        2 * (X + Y + Z) =:= 3 * (X - Y - Z) , 
        5 * (X + Y) - 7 * X - Z =:= (2 + 1 + X) * 6.
Z = Z
Y = Y
X = X
Constraints:
(6) -11 * Z_g1647 =:= 11
(10) -7.0 * X_g1711 =:= 12
(11) 2.72727275 * Y_g1679 =:= 1.79220796

:-      3 * X + 2 * Y - 4 * (3 + Z) =:= 2 * (X - 3) + (Y + Z) * 7 ,      
        2 * (X + Y + Z) =:= 3 * (X - Y - Z).   
Z = Z
Y = Y
X = X
Constraints:
(5) -0.545454502 * X_g1651 + 2.72727275 * Y_g1619 =:= 2.72727275
(6) -11 * Z_g1587 =:= 11
*/

/* end of file gauss.chr ------------------------------------------------*/
