View source with raw comments or as raw
    1/*
    2
    3    Part of CLP(Q) (Constraint Logic Programming over Rationals)
    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): 2006, K.U. Leuven and
   10		   1992-1995, Austrian Research Institute for
   11		              Artificial Intelligence (OFAI),
   12			      Vienna, Austria
   13
   14    This software is based on CLP(Q,R) by Christian Holzbaur for SICStus
   15    Prolog and distributed under the license details below with permission from
   16    all mentioned authors.
   17
   18    This program is free software; you can redistribute it and/or
   19    modify it under the terms of the GNU General Public License
   20    as published by the Free Software Foundation; either version 2
   21    of the License, or (at your option) any later version.
   22
   23    This program is distributed in the hope that it will be useful,
   24    but WITHOUT ANY WARRANTY; without even the implied warranty of
   25    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   26    GNU General Public License for more details.
   27
   28    You should have received a copy of the GNU Lesser General Public
   29    License along with this library; if not, write to the Free Software
   30    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
   31
   32    As a special exception, if you link this library with other files,
   33    compiled with a Free Software compiler, to produce an executable, this
   34    library does not by itself cause the resulting executable to be covered
   35    by the GNU General Public License. This exception does not however
   36    invalidate any other reasons why the executable file might be covered by
   37    the GNU General Public License.
   38*/
   39
   40:- module(clpq,
   41	  [ {}/1,
   42	    maximize/1,
   43	    minimize/1,
   44	    inf/2, inf/4, sup/2, sup/4,
   45	    bb_inf/3,
   46	    bb_inf/4,
   47	    ordering/1,
   48	    entailed/1,
   49	    clp_type/2,
   50	    dump/3%, projecting_assert/1
   51	  ]).   52:- license(gpl_swipl, 'CLP(Q)').   53:- use_module(library(dialect)).   54:- expects_dialect(swi).   55
   56%
   57% Don't report export of private predicates from clpq
   58%
   59:- multifile
   60	user:portray_message/2.   61
   62:- dynamic
   63	user:portray_message/2.   64%
   65user:portray_message(warning,import(_,_,clpq,private)).
   66
   67:- use_module([ clpq/bb_q,
   68		clpq/bv_q,
   69		clpq/fourmotz_q,
   70		clpq/ineq_q,
   71		clpq/itf_q,
   72		clpq/nf_q,
   73		clpq/store_q,
   74		clpqr/class,
   75		clpqr/dump,
   76		clpqr/geler,
   77		clpqr/itf,
   78		clpqr/ordering,
   79		clpqr/project,
   80		clpqr/redund,
   81		library(ugraphs)
   82	      ]).   83
   84		 /*******************************
   85		 *	 TOPLEVEL PRINTING	*
   86		 *******************************/
   87
   88:- multifile
   89	prolog:message/3.   90
   91prolog:message(query(YesNo,Bindings)) --> !,
   92	{dump_toplevel_bindings(Bindings,Constraints)},
   93	dump_format(Constraints),
   94        '$messages':prolog_message(query(YesNo,Bindings)).
   95
   96dump_toplevel_bindings(Bindings,Constraints) :-
   97	dump_vars_names(Bindings,[],Vars,Names),
   98	dump(Vars,Names,Constraints).
   99
  100dump_vars_names([],_,[],[]).
  101dump_vars_names([Name=Term|Rest],Seen,Vars,Names) :-
  102	(   var(Term),
  103	    (   get_attr(Term,clpqr_itf,_)
  104	    ;   get_attr(Term,clpqr_geler,_)
  105	    ),
  106	    \+ memberchk_eq(Term,Seen)
  107	->  Vars = [Term|RVars],
  108	    Names = [Name|RNames],
  109	    NSeen = [Term|Seen]
  110	;   Vars = RVars,
  111	    Names = RNames,
  112	    Seen = NSeen
  113	),
  114	dump_vars_names(Rest,NSeen,RVars,RNames).
  115
  116dump_format([]) --> [].
  117dump_format([X|Xs]) -->
  118	['{~w}'-[X], nl],
  119	dump_format(Xs).
  120
  121memberchk_eq(X,[Y|Ys]) :-
  122	(   X == Y
  123	->  true
  124	;   memberchk_eq(X,Ys)
  125	)