Newsgroups: comp.constraints
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!fas-news.harvard.edu!newspump.wustl.edu!news.starnet.net!wupost!howland.reston.ans.net!Germany.EU.net!Munich.Germany.EU.net!ecrc!acrab60!thom
From: thom@ecrc.de (Thom Fruehwirth)
Subject: Re: Solving a conjunction of X <= Y clauses
Message-ID: <D2Anqx.BEK@ecrc.de>
Sender: news@ecrc.de
Reply-To: thom@ecrc.de
Organization: European Computer-Industry Research Centre GmbH.
References: <D25DLK.Jwo@ips.cs.tu-bs.de>
Date: Thu, 12 Jan 1995 13:20:56 GMT
Lines: 44

Andreas Zeller (zeller@ips.cs.tu-bs.de) wrote on Mon, 9 Jan 1995 16:53:43 GMT:

 I am looking for an efficient algorithm to solve the following problem.

 Let n denote numerical constants, and x, y variables.  Let T be a
 boolean conjunction of constraints where each constraint has one of
 the forms

  1.  x OP n   with OP in { <, <=, =, >=, >, <> }
  2.  x OP y   with OP in { <, <=, =, >=, >, <> }

 The problem is to find out whether T is satisfiable (i.e. there exists
 a variable assignment such that all constraints are satisfied), or
 not.  

Such algorithms are easily implemented with constraint handling rules (CHRs),
a special purpose language to write constraint systems. CHRs are available
as a library of the constraint logic programming platform ECLiPSe. The
library includes about 20 constraint solvers, one of it solves your problems
of type 1 and type 2 over the reals and rationals. By adding some rules, 
the solver can be extended to work for integers or finite numerical domains.

You just have to encode the axioms of the corresponding theory.
You start with something like:

	reflexivity @ X=<X <=> true.
	symmetry @ X=<Y,Y=<X <=> X=Y.
	transitivity @ X=<Y,Y=<Z ==> X=<Z.

	check_numbers @ N=<M <=> number(N),number(M) | check_leq(N,M).

Solving A=<B,1=<A,B=<1 leads to the following sequence of rule applications:

 1=<A,A=<B propagates 1=<B by transitivity.
 1=<B,B=<1 simplifies to B=1 by symmetry.
 B=<A,A=<B simplifies to A=B by symmetry.

Resulting in A=1,B=1.

thom

PS: If you are interested I can run some examples for you.


