View source with raw comments or as raw
    1/*  $Id$
    2
    3    Part of CLP(R) (Constraint Logic Programming over Reals)
    4
    5    Author:        Leslie De Koninck
    6    E-mail:        Leslie.DeKoninck@cs.kuleuven.be
    7    WWW:           http://www.swi-prolog.org
    8		   http://www.ai.univie.ac.at/cgi-bin/tr-online?number+95-09
    9    Copyright (C): 2004, K.U. Leuven and
   10		   1992-1995, Austrian Research Institute for
   11		              Artificial Intelligence (OFAI),
   12			      Vienna, Austria
   13
   14    This software is part of Leslie De Koninck's master thesis, supervised
   15    by Bart Demoen and daily advisor Tom Schrijvers.  It is based on CLP(Q,R)
   16    by Christian Holzbaur for SICStus Prolog and distributed under the
   17    license details below with permission from all mentioned authors.
   18
   19    This program is free software; you can redistribute it and/or
   20    modify it under the terms of the GNU General Public License
   21    as published by the Free Software Foundation; either version 2
   22    of the License, or (at your option) any later version.
   23
   24    This program is distributed in the hope that it will be useful,
   25    but WITHOUT ANY WARRANTY; without even the implied warranty of
   26    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   27    GNU General Public License for more details.
   28
   29    You should have received a copy of the GNU Lesser General Public
   30    License along with this library; if not, write to the Free Software
   31    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
   32
   33    As a special exception, if you link this library with other files,
   34    compiled with a Free Software compiler, to produce an executable, this
   35    library does not by itself cause the resulting executable to be covered
   36    by the GNU General Public License. This exception does not however
   37    invalidate any other reasons why the executable file might be covered by
   38    the GNU General Public License.
   39*/
   40
   41
   42
   43:- module(clpr,
   44	[
   45	    {}/1,
   46	    maximize/1,
   47	    minimize/1,
   48	    inf/2, inf/4, sup/2, sup/4,
   49	    bb_inf/3,
   50	    bb_inf/5,
   51	    ordering/1,
   52	    entailed/1,
   53	    clp_type/2,
   54	    dump/3
   55	]).   56:- license(gpl_swipl, 'CLP(R)').   57:- use_module(library(dialect)).   58:- expects_dialect(swi).   59
   60%
   61% Don't report export of private predicates from clpr
   62%
   63:- multifile
   64	user:portray_message/2.   65
   66:- dynamic
   67	user:portray_message/2.   68%
   69user:portray_message(warning,import(_,_,clpr,private)).
   70
   71:- use_module(clpr/bb_r).   72:- use_module(clpr/bv_r).   73:- use_module(clpr/fourmotz_r).   74:- use_module(clpr/ineq_r).   75:- use_module(clpr/itf_r).   76:- use_module(clpr/nf_r).   77:- use_module(clpr/store_r).   78:- use_module(clpqr/class).   79:- use_module(clpqr/dump).   80:- use_module(clpqr/geler).   81:- use_module(clpqr/itf).   82:- use_module(clpqr/project).   83:- use_module(clpqr/redund).   84:- use_module(library(ugraphs)).   85
   86
   87:- use_module(clpqr/ordering, [ordering/2]).
 ordering(+Spec) is det
Specify the preferred variable ordering of answer constraints. A variable that comes first in Spec is the one the answer constraint defines, i.e. the one on its left hand side. Spec is either a list of variables or a term A<B or A>B. As ordering/1 interns variables the solver does not know yet, it may be stated before or after the constraints it talks about.
   98ordering(Spec) :-
   99	ordering(clpr, Spec).
  100
  101		 /*******************************
  102		 *	       SANDBOX		*
  103		 *******************************/
  104
  105:- multifile
  106	sandbox:safe_primitive/1.  107
  108sandbox:safe_primitive(clpr:ordering(_)).
  109
  110		 /*******************************
  111		 *	 TOPLEVEL PRINTING	*
  112		 *******************************/
  113
  114:- multifile
  115	prolog:message/3.  116
  117% prolog:message(query(YesNo)) --> !,
  118%	['~@'-[chr:print_all_stores]],
  119%         '$messages':prolog_message(query(YesNo)).
  120
  121prolog:message(query(YesNo,Bindings)) --> !,
  122	{dump_toplevel_bindings(Bindings,Constraints)},
  123	{dump_format(Constraints,Format)},
  124	Format,
  125        '$messages':prolog_message(query(YesNo,Bindings)).
  126
  127dump_toplevel_bindings(Bindings,Constraints) :-
  128	dump_vars_names(Bindings,[],Vars,Names),
  129	dump(Vars,Names,Constraints).
  130
  131dump_vars_names([],_,[],[]).
  132dump_vars_names([Name=Term|Rest],Seen,Vars,Names) :-
  133	(   var(Term),
  134	    (   get_attr(Term,clpqr_itf,_)
  135	    ;   get_attr(Term,clpqr_geler,_)
  136	    ),
  137	    \+ memberchk_eq(Term,Seen)
  138	->  Vars = [Term|RVars],
  139	    Names = [Name|RNames],
  140	    NSeen = [Term|Seen]
  141	;   Vars = RVars,
  142	    Names = RNames,
  143	    Seen = NSeen
  144	),
  145	dump_vars_names(Rest,NSeen,RVars,RNames).
  146
  147dump_format([],[]).
  148dump_format([X|Xs],['{~w}'-[X],nl|Rest]) :-
  149	dump_format(Xs,Rest).
  150
  151memberchk_eq(X,[Y|Ys]) :-
  152	(   X == Y
  153	->  true
  154	;   memberchk_eq(X,Ys)
  155	)