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%, projecting_assert/1
   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/ordering).   83:- use_module(clpqr/project).   84:- use_module(clpqr/redund).   85:- use_module(library(ugraphs)).   86
   87
   88		 /*******************************
   89		 *	 TOPLEVEL PRINTING	*
   90		 *******************************/
   91
   92:- multifile
   93	prolog:message/3.   94
   95% prolog:message(query(YesNo)) --> !,
   96%	['~@'-[chr:print_all_stores]],
   97%         '$messages':prolog_message(query(YesNo)).
   98
   99prolog:message(query(YesNo,Bindings)) --> !,
  100	{dump_toplevel_bindings(Bindings,Constraints)},
  101	{dump_format(Constraints,Format)},
  102	Format,
  103        '$messages':prolog_message(query(YesNo,Bindings)).
  104
  105dump_toplevel_bindings(Bindings,Constraints) :-
  106	dump_vars_names(Bindings,[],Vars,Names),
  107	dump(Vars,Names,Constraints).
  108
  109dump_vars_names([],_,[],[]).
  110dump_vars_names([Name=Term|Rest],Seen,Vars,Names) :-
  111	(   var(Term),
  112	    (   get_attr(Term,itf,_)
  113	    ;   get_attr(Term,geler,_)
  114	    ),
  115	    \+ memberchk_eq(Term,Seen)
  116	->  Vars = [Term|RVars],
  117	    Names = [Name|RNames],
  118	    NSeen = [Term|Seen]
  119	;   Vars = RVars,
  120	    Names = RNames,
  121	    Seen = NSeen
  122	),
  123	dump_vars_names(Rest,NSeen,RVars,RNames).
  124
  125dump_format([],[]).
  126dump_format([X|Xs],['{~w}'-[X],nl|Rest]) :-
  127	dump_format(Xs,Rest).
  128
  129memberchk_eq(X,[Y|Ys]) :-
  130	(   X == Y
  131	->  true
  132	;   memberchk_eq(X,Ys)
  133	)