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:- expects_dialect(swi).   58
   59%
   60% Don't report export of private predicates from clpr
   61%
   62:- multifile
   63	user:portray_message/2.   64
   65:- dynamic
   66	user:portray_message/2.   67%
   68user:portray_message(warning,import(_,_,clpr,private)).
   69
   70:- load_files(
   71	[
   72	    'clpr/bb_r',
   73	    'clpr/bv_r',
   74	    'clpr/fourmotz_r',
   75	    'clpr/ineq_r',
   76	    'clpr/itf_r',
   77	    'clpr/nf_r',
   78	    'clpr/store_r',
   79	    'clpqr/class',
   80	    'clpqr/dump',
   81	    'clpqr/geler',
   82	    'clpqr/itf',
   83	    'clpqr/ordering',
   84	    'clpqr/project',
   85	    'clpqr/redund',
   86	    library(ugraphs)
   87	],
   88	[
   89	    if(not_loaded),
   90	    silent(true)
   91	]).   92
   93		 /*******************************
   94		 *	 TOPLEVEL PRINTING	*
   95		 *******************************/
   96
   97:- multifile
   98	prolog:message/3.   99
  100% prolog:message(query(YesNo)) --> !,
  101%	['~@'-[chr:print_all_stores]],
  102%         '$messages':prolog_message(query(YesNo)).
  103
  104prolog:message(query(YesNo,Bindings)) --> !,
  105	{dump_toplevel_bindings(Bindings,Constraints)},
  106	{dump_format(Constraints,Format)},
  107	Format,
  108        '$messages':prolog_message(query(YesNo,Bindings)).
  109
  110dump_toplevel_bindings(Bindings,Constraints) :-
  111	dump_vars_names(Bindings,[],Vars,Names),
  112	dump(Vars,Names,Constraints).
  113
  114dump_vars_names([],_,[],[]).
  115dump_vars_names([Name=Term|Rest],Seen,Vars,Names) :-
  116	(   var(Term),
  117	    (   get_attr(Term,itf,_)
  118	    ;   get_attr(Term,geler,_)
  119	    ),
  120	    \+ memberchk_eq(Term,Seen)
  121	->  Vars = [Term|RVars],
  122	    Names = [Name|RNames],
  123	    NSeen = [Term|Seen]
  124	;   Vars = RVars,
  125	    Names = RNames,
  126	    Seen = NSeen
  127	),
  128	dump_vars_names(Rest,NSeen,RVars,RNames).
  129
  130dump_format([],[]).
  131dump_format([X|Xs],['{~w}'-[X],nl|Rest]) :-
  132	dump_format(Xs,Rest).
  133
  134memberchk_eq(X,[Y|Ys]) :-
  135	(   X == Y
  136	->  true
  137	;   memberchk_eq(X,Ys)
  138	)