This page provides an implementation of a cost functions comparator as described in the following paper

Elvira Albert, Puri Arenas, Samir Genaim, and Germán Puebla. A Practical Comparator of Cost Functions and its Applications. [.pdf]

Use the links to navigate to the relevant information

Download

Download the file ub_checker.pl. It requires SWI-Prolog, but should work in any other Prolog system that provides a CLP(Q) library.

Usage

First load the checker into Prolog
?- use_module(ub_checker).
%  library(clpq) compiled into clpq 0.08 sec, 2,541 clauses
% ub_checker compiled into ub_checker 0.08 sec, 2,677 clauses
true.
Then, the main predicate used to compare two cost functions is ub_compare(+Exp1,+Exp2,+Phi,+Options,-Result) where

The options available are:

Syntax

A cost function e adheres to the following following syntax

 e :== n | nat(l) | e+e | e*e | log(a,nat(l)+1) | pow(a,nat(l)) | pow(nat(l),a) | max([e1,...,en]) | min([e1,...,en])

where n and a are non-negative integers such that n > 0 and a >= 2. The expression nat(l) stands for max(l,0) such that l is a linear expression that adheres to the following syntax

 l :== n | n*X | l+l

where n is an integer value and X is a Prolog variable (a sequence of letters, numbers or underscore such that it starts with an upper-case letter). A linear constraint c should adhere to the following syntax

 c :== l >= l | l =< l | l == l

Note that max can be use only when comparing upper bounds, and min only when comparing lower bounds. Mixing these expressions is not allowed.

Examples

?- compare_ubs(3*log(2,nat(A)+1),10*nat(B),[A>=4,B>=0,A+1==2],[],Res)
Res = yes

?- compare_ubs(max([nat(A),nat(B)]),nat(C),[C>=A,C>=B],[],Res)
Res = yes

?- compare_ubs(pow(nat(A),2),nat(B)*nat(C),[C>=A,B>=A,A>=0,B>=0,C>=0],[pow_norm_scheme=split],Res)
Res = yes

?- compare_ubs(min([nat(A),nat(B)]),nat(C),[C>=A,B>=2*C],[],Res)
Res = yes