Merge branch 'master' of yap.dcc.fc.up.pt:yap-6
This commit is contained in:
commit
e2201f57e1
16
configure.in
16
configure.in
@ -1239,25 +1239,27 @@ if test ! "$yap_cv_cplint" = "no"
|
|||||||
LDFLAGS=${LDFLAGS}" `echo $GLIBS | awk '{print $1}'` -L$prefix/lib/"
|
LDFLAGS=${LDFLAGS}" `echo $GLIBS | awk '{print $1}'` -L$prefix/lib/"
|
||||||
if test ! "$yap_cv_cplint" = "yes"
|
if test ! "$yap_cv_cplint" = "yes"
|
||||||
then
|
then
|
||||||
LDFLAGS+=" -L${yap_cv_cplint}/lib"
|
CPLINT_LDFLAGS+=" -L${yap_cv_cplint}/cudd -L${yap_cv_cplint}/mtr -L${yap_cv_cplint}/st -L${yap_cv_cplint}/util -L${yap_cv_cplint}/epd "
|
||||||
CPLINT_LDFLAGS+=" -L${yap_cv_cplint}/lib"
|
|
||||||
CPLINT_CFLAGS+=" -I${yap_cv_cplint}/include"
|
CPLINT_CFLAGS+=" -I${yap_cv_cplint}/include"
|
||||||
|
CPLINT_LIBS="-lcudd -lmtr -lst -lutil -lepd -lm "$CPLINT_LIBS
|
||||||
fi
|
fi
|
||||||
AC_SEARCH_LIBS([g_hash_table_new], [glib-2.0], [CPLINT_LIBS="-lglib-2.0 "], [AC_MSG_ERROR([This package needs glib >=2.0.], [1])], [])
|
#AC_SEARCH_LIBS([g_hash_table_new], [glib-2.0], [], [AC_MSG_ERROR([This package needs glib >=2.0.], [1])], [])
|
||||||
AC_SEARCH_LIBS([array_do_alloc], [glu], [CPLINT_LIBS="-lglu "$CPLINT_LIBS], [AC_MSG_ERROR([This package needs glu.], [1])], [])
|
#AC_SEARCH_LIBS([Cudd_Init], [cudd], [], [AC_MSG_ERROR([This package needs CUDD.], [1])], [-lcudd -lmtr -lst -lutil -lepd -lm])
|
||||||
AC_SEARCH_LIBS([Cudd_Init], [cu], [CPLINT_LIBS="-lcu "$CPLINT_LIBS], [AC_MSG_ERROR([This package needs glu.], [1])], [-lglu -lm])
|
#AC_SEARCH_LIBS([pow], [m], [], [AC_MSG_ERROR([This package needs m.], [1])], [-lm])
|
||||||
AC_SEARCH_LIBS([pow], [m], [CPLINT_LIBS="-lm "$CPLINT_LIBS], [AC_MSG_ERROR([This package needs m.], [1])], [-lglu -lm])
|
|
||||||
ENABLE_CPLINT=""
|
ENABLE_CPLINT=""
|
||||||
if test "$target_os" = "cygwin" -o "$target_os" = "mingw32"
|
if test "$target_os" = "cygwin" -o "$target_os" = "mingw32"
|
||||||
then
|
then
|
||||||
CPLINT_SHLIB_LD="gcc -shared ../yap.dll"
|
CPLINT_SHLIB_LD="gcc -shared ../../yap.dll"
|
||||||
|
SHLIB_SUFFIX="dll"
|
||||||
else
|
else
|
||||||
CPLINT_SHLIB_LD=$SHLIB_LD
|
CPLINT_SHLIB_LD=$SHLIB_LD
|
||||||
|
SHLIB_SUFFIX="so"
|
||||||
fi
|
fi
|
||||||
AC_SUBST(CPLINT_LIBS)
|
AC_SUBST(CPLINT_LIBS)
|
||||||
AC_SUBST(CPLINT_CFLAGS)
|
AC_SUBST(CPLINT_CFLAGS)
|
||||||
AC_SUBST(CPLINT_LDFLAGS)
|
AC_SUBST(CPLINT_LDFLAGS)
|
||||||
AC_SUBST(CPLINT_SHLIB_LD)
|
AC_SUBST(CPLINT_SHLIB_LD)
|
||||||
|
AC_SUBST(SHLIB_SUFFIX)
|
||||||
else
|
else
|
||||||
ENABLE_CPLINT="@#"
|
ENABLE_CPLINT="@#"
|
||||||
fi
|
fi
|
||||||
|
@ -1,32 +1,26 @@
|
|||||||
This directory contains the code of the LPAD anc CP-logic interpreter cplint
|
This directory contains the code of the LPAD anc CP-logic interpreter cplint
|
||||||
|
|
||||||
COMPILATION:
|
COMPILATION:
|
||||||
This package requires GLU (a subpackage of VIS) and GLIB version 1.2.
|
This package requires CUDD and GLIB version 1.2.
|
||||||
You can download GLU from http://vlsi.colorado.edu/~vis/getting_VIS_2.1.html
|
You can download CUDD from http://vlsi.colorado.edu/~fabio/CUDD/
|
||||||
You can download GLIB from http://www.gtk.org/. This is a standard Linux package
|
You can download GLIB from http://www.gtk.org/. This is a standard Linux package
|
||||||
so it is easy to install using the package management software of your Linux
|
so it is easy to install using the package management software of your Linux
|
||||||
distribution
|
distribution
|
||||||
|
|
||||||
INSTALLATION:
|
INSTALLATION:
|
||||||
Install glu:
|
Compile CUDD:
|
||||||
1) downlad glu-2.1.tar.gz
|
1) downlad cudd-2.4.2.tar.gz
|
||||||
2) decompress it
|
2) decompress it
|
||||||
3) cd glu-2.1
|
3) cd cudd-2.4.2
|
||||||
3) mkdir arch
|
4) check makefile options
|
||||||
4) cd arch
|
5) make
|
||||||
5) ../configure
|
|
||||||
6) make
|
|
||||||
7) su
|
|
||||||
8) make install
|
|
||||||
This will install glu into /usr/local, if you want to install to a different DIR
|
|
||||||
use ../configure --prefix DIR
|
|
||||||
|
|
||||||
Installation of cplint:
|
Installation of cplint:
|
||||||
When compiling Yap, use
|
When compiling Yap, use
|
||||||
configure --enable-cplint
|
configure --enable-cplint=DIR
|
||||||
Under Windows, you have to use cygwin (glu does not compile under MinGW), so
|
Under Windows, you have to use cygwin (CUDD does not compile under MinGW), so
|
||||||
configure --enable-cplint --enable-cygwin
|
configure --enable-cplint --enable-cygwin=DIR
|
||||||
If you installed glu in DIR, use --enable-cplint=DIR
|
where DIR is the directory where you compiled CUDD
|
||||||
|
|
||||||
|
|
||||||
FEEDBACK:
|
FEEDBACK:
|
||||||
|
@ -10,9 +10,7 @@ for the relative license.
|
|||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "cuddInt.h"
|
#include "cuddInt.h"
|
||||||
#include "array.h"
|
|
||||||
#include "mtr.h"
|
#include "mtr.h"
|
||||||
#include "avl.h"
|
|
||||||
#include "YapInterface.h"
|
#include "YapInterface.h"
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
@ -21,16 +19,35 @@ typedef struct
|
|||||||
int var,value;
|
int var,value;
|
||||||
} factor;
|
} factor;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int nFact;
|
||||||
|
factor * factors;
|
||||||
|
} term;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int nTerms;
|
||||||
|
term * terms;
|
||||||
|
} expr;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int nVal,nBit;
|
int nVal,nBit;
|
||||||
array_t * probabilities;
|
double * probabilities;
|
||||||
array_t * booleanVars;
|
DdNode * * booleanVars;
|
||||||
} variable;
|
} variable;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int nVar;
|
||||||
|
int nBVar;
|
||||||
|
variable * varar;
|
||||||
|
int * bVar2mVar;
|
||||||
|
} variables;
|
||||||
|
|
||||||
void createVars(array_t * vars, YAP_Term t,DdManager * mgr, array_t * bVar2mVar,int create_dot, char inames[1000][20]);
|
variables createVars(YAP_Term t,DdManager * mgr, int create_dot, char inames[1000][20]);
|
||||||
void createExpression(array_t * expression, YAP_Term t);
|
expr createExpression(YAP_Term t);
|
||||||
void init_my_predicates(void);
|
void init_my_predicates(void);
|
||||||
int compare(char *a, char *b);
|
int compare(char *a, char *b);
|
||||||
gint my_equal(gconstpointer v,gconstpointer v2);
|
gint my_equal(gconstpointer v,gconstpointer v2);
|
||||||
@ -39,11 +56,11 @@ void dealloc(gpointer key,gpointer value,gpointer user_data);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
DdNode * retFunction(DdManager * mgr, array_t * expression,array_t * v);
|
DdNode * retFunction(DdManager * mgr, expr expression,variables v);
|
||||||
DdNode * retTerm(DdManager * mgr,array_t *factors,array_t * v);
|
DdNode * retTerm(DdManager * mgr,term t,variables v);
|
||||||
DdNode * retFactor(DdManager * mgr, factor f, array_t * v);
|
DdNode * retFactor(DdManager * mgr, factor f, variables v);
|
||||||
|
|
||||||
double Prob(DdNode *node, array_t * vars,array_t * bVar2mVar, GHashTable * nodes);
|
double Prob(DdNode *node, variables vars,GHashTable * nodes);
|
||||||
|
|
||||||
double ProbBool(DdNode *node, int bits, int nBit,int posBVar,variable v,
|
double ProbBool(DdNode *node, int bits, int nBit,int posBVar,variable v,
|
||||||
array_t * vars,array_t * bVar2mVar, GHashTable * nodes);
|
variables vars,GHashTable * nodes);
|
||||||
|
@ -19,20 +19,20 @@ int correctPosition(int index,variable v, DdNode * node,int posBVar);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
DdNode * retFunction(DdManager * mgr,array_t *expression, array_t *v)
|
DdNode * retFunction(DdManager * mgr,expr expression, variables v)
|
||||||
/* given an expression term1+term2+...+termn, returns the BDD that implements that function */
|
/* given an expression term1+term2+...+termn, returns the BDD that implements that function */
|
||||||
{
|
{
|
||||||
array_t * term;
|
term term1;
|
||||||
DdNode * tNode, * tmp, *tmp1;
|
DdNode * tNode, * tmp, *tmp1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i=0;
|
i=0;
|
||||||
tNode=Cudd_ReadLogicZero(mgr);
|
tNode=Cudd_ReadLogicZero(mgr);
|
||||||
Cudd_Ref(tNode);
|
Cudd_Ref(tNode);
|
||||||
while(i<array_n(expression))
|
while(i<expression.nTerms)
|
||||||
{
|
{
|
||||||
term=array_fetch(array_t * ,expression,i);
|
term1=expression.terms[i];
|
||||||
tmp=retTerm(mgr,term,v);
|
tmp=retTerm(mgr,term1,v);
|
||||||
Cudd_Ref(tmp);
|
Cudd_Ref(tmp);
|
||||||
tmp1=Cudd_bddOr(mgr,tNode,tmp);
|
tmp1=Cudd_bddOr(mgr,tNode,tmp);
|
||||||
Cudd_Ref(tmp1);
|
Cudd_Ref(tmp1);
|
||||||
@ -43,7 +43,7 @@ DdNode * retFunction(DdManager * mgr,array_t *expression, array_t *v)
|
|||||||
return tNode;
|
return tNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
DdNode * retTerm(DdManager * mgr,array_t *term, array_t * v)
|
DdNode * retTerm(DdManager * mgr,term t, variables v)
|
||||||
/* given a term V1=v1 and V2=v2 ... Vn=vn, returns the BDD that implements that function */
|
/* given a term V1=v1 and V2=v2 ... Vn=vn, returns the BDD that implements that function */
|
||||||
{
|
{
|
||||||
factor f;
|
factor f;
|
||||||
@ -53,9 +53,9 @@ DdNode * retTerm(DdManager * mgr,array_t *term, array_t * v)
|
|||||||
i=0;
|
i=0;
|
||||||
fNode=Cudd_ReadOne(mgr);
|
fNode=Cudd_ReadOne(mgr);
|
||||||
Cudd_Ref(fNode);
|
Cudd_Ref(fNode);
|
||||||
while (i<array_n(term))
|
while (i<t.nFact)
|
||||||
{
|
{
|
||||||
f=array_fetch(factor, term, i);
|
f=t.factors[i];
|
||||||
tmp=retFactor(mgr,f,v);
|
tmp=retFactor(mgr,f,v);
|
||||||
Cudd_Ref(tmp);
|
Cudd_Ref(tmp);
|
||||||
tmp1= Cudd_bddAnd(mgr,fNode,tmp);
|
tmp1= Cudd_bddAnd(mgr,fNode,tmp);
|
||||||
@ -67,7 +67,7 @@ DdNode * retTerm(DdManager * mgr,array_t *term, array_t * v)
|
|||||||
return fNode;
|
return fNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
DdNode * retFactor(DdManager * mgr, factor f, array_t * vars)
|
DdNode * retFactor(DdManager * mgr, factor f, variables vars)
|
||||||
/* given a factor V=v, returns the BDD that implements that function */
|
/* given a factor V=v, returns the BDD that implements that function */
|
||||||
{
|
{
|
||||||
int varIndex;
|
int varIndex;
|
||||||
@ -76,19 +76,19 @@ DdNode * retFactor(DdManager * mgr, factor f, array_t * vars)
|
|||||||
int bit;
|
int bit;
|
||||||
variable v;
|
variable v;
|
||||||
DdNode * node, *booleanVar, * tmp;
|
DdNode * node, *booleanVar, * tmp;
|
||||||
array_t * booleanVars;
|
DdNode ** booleanVars;
|
||||||
|
|
||||||
|
|
||||||
varIndex=f.var;
|
varIndex=f.var;
|
||||||
value=f.value;
|
value=f.value;
|
||||||
v=array_fetch(variable, vars, varIndex);
|
v=vars.varar[varIndex];
|
||||||
booleanVars=v.booleanVars;
|
booleanVars=v.booleanVars;
|
||||||
i=v.nBit-1;
|
i=v.nBit-1;
|
||||||
node=Cudd_ReadOne(mgr);
|
node=Cudd_ReadOne(mgr);
|
||||||
Cudd_Ref(node);
|
Cudd_Ref(node);
|
||||||
/* booelan var with index 0 in v.booleanVars is the most significant */
|
/* booelan var with index 0 in v.booleanVars is the most significant */
|
||||||
do {
|
do {
|
||||||
booleanVar=array_fetch(DdNode *,booleanVars,i);
|
booleanVar=booleanVars[i];
|
||||||
bit=value & 01;
|
bit=value & 01;
|
||||||
if (bit)
|
if (bit)
|
||||||
{
|
{
|
||||||
@ -111,7 +111,7 @@ DdNode * retFactor(DdManager * mgr, factor f, array_t * vars)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
double Prob(DdNode *node, array_t * vars,array_t * bVar2mVar, GHashTable * nodes)
|
double Prob(DdNode *node, variables vars, GHashTable * nodes)
|
||||||
/* compute the probability of the expression rooted at node
|
/* compute the probability of the expression rooted at node
|
||||||
nodes is used to store nodes for which the probability has alread been computed
|
nodes is used to store nodes for which the probability has alread been computed
|
||||||
so that it is not recomputed
|
so that it is not recomputed
|
||||||
@ -141,10 +141,10 @@ so that it is not recomputed
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mVarIndex=array_fetch(int,bVar2mVar,index);
|
mVarIndex=vars.bVar2mVar[index];
|
||||||
v=array_fetch(variable,vars,mVarIndex);
|
v=vars.varar[mVarIndex];
|
||||||
nBit=v.nBit;
|
nBit=v.nBit;
|
||||||
res=ProbBool(node,0,nBit,0,v,vars,bVar2mVar,nodes);
|
res=ProbBool(node,0,nBit,0,v,vars,nodes);
|
||||||
key=(DdNode **)malloc(sizeof(DdNode *));
|
key=(DdNode **)malloc(sizeof(DdNode *));
|
||||||
*key=node;
|
*key=node;
|
||||||
rp=(double *)malloc(sizeof(double));
|
rp=(double *)malloc(sizeof(double));
|
||||||
@ -156,22 +156,22 @@ so that it is not recomputed
|
|||||||
}
|
}
|
||||||
|
|
||||||
double ProbBool(DdNode *node, int bits, int nBit,int posBVar,variable v,
|
double ProbBool(DdNode *node, int bits, int nBit,int posBVar,variable v,
|
||||||
array_t * vars,array_t * bVar2mVar, GHashTable * nodes)
|
variables vars, GHashTable * nodes)
|
||||||
/* explores a group of binary variables making up the multivalued variable v */
|
/* explores a group of binary variables making up the multivalued variable v */
|
||||||
{
|
{
|
||||||
DdNode *T,*F;
|
DdNode *T,*F;
|
||||||
double p,res;
|
double p,res;
|
||||||
array_t * probs;
|
double * probs;
|
||||||
|
|
||||||
probs=v.probabilities;
|
probs=v.probabilities;
|
||||||
if (nBit==0)
|
if (nBit==0)
|
||||||
{
|
{
|
||||||
if (bits>=array_n(probs))
|
if (bits>=v.nVal)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p=array_fetch(double,probs,bits);
|
p=probs[bits];
|
||||||
res=p*Prob(node,vars,bVar2mVar,nodes);
|
res=p*Prob(node,vars,nodes);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,16 +183,16 @@ array_t * vars,array_t * bVar2mVar, GHashTable * nodes)
|
|||||||
F = node->type.kids.E;
|
F = node->type.kids.E;
|
||||||
bits=bits<<1;
|
bits=bits<<1;
|
||||||
|
|
||||||
res=ProbBool(T,bits+1,nBit-1,posBVar+1,v,vars,bVar2mVar,nodes)+
|
res=ProbBool(T,bits+1,nBit-1,posBVar+1,v,vars,nodes)+
|
||||||
ProbBool(F,bits,nBit-1,posBVar+1,v,vars,bVar2mVar,nodes);
|
ProbBool(F,bits,nBit-1,posBVar+1,v,vars,nodes);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
bits=bits<<1;
|
bits=bits<<1;
|
||||||
res=ProbBool(node,bits+1,nBit-1,posBVar+1,v,vars,bVar2mVar,nodes)+
|
res=ProbBool(node,bits+1,nBit-1,posBVar+1,v,vars,nodes)+
|
||||||
ProbBool(node,bits,nBit-1,posBVar+1,v,vars,bVar2mVar,nodes);
|
ProbBool(node,bits,nBit-1,posBVar+1,v,vars,nodes);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,6 +204,6 @@ currently explored by ProbBool */
|
|||||||
{
|
{
|
||||||
DdNode * bvar;
|
DdNode * bvar;
|
||||||
|
|
||||||
bvar=array_fetch(DdNode *,v.booleanVars,posBVar);
|
bvar=v.booleanVars[posBVar];
|
||||||
return bvar->index==index;
|
return bvar->index==index;
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ FILE *open_file (char *filename, const char *mode);
|
|||||||
void reverse(char s[]);
|
void reverse(char s[]);
|
||||||
static int compute_prob(void);
|
static int compute_prob(void);
|
||||||
|
|
||||||
void createVars(array_t * vars, YAP_Term t,DdManager * mgr, array_t * bVar2mVar,int create_dot, char inames[1000][20])
|
variables createVars(YAP_Term t,DdManager * mgr, int create_dot, char inames[1000][20])
|
||||||
/* adds the boolean variables to the BDD and returns
|
/* adds the boolean variables to the BDD and returns
|
||||||
an array_t containing them (array_t is defined in the util library of glu)
|
the array vars containing them
|
||||||
returns also the names of the variables to be used to save the ADD in dot format
|
returns also the names of the variables to be used to save the ADD in dot format
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
@ -35,10 +35,17 @@ returns also the names of the variables to be used to save the ADD in dot format
|
|||||||
variable v;
|
variable v;
|
||||||
char numberVar[10],numberBit[10];
|
char numberVar[10],numberBit[10];
|
||||||
double p;
|
double p;
|
||||||
b=0;
|
variables vars;
|
||||||
|
|
||||||
|
vars.varar= (variable *) malloc(0* sizeof(variable));
|
||||||
|
vars.bVar2mVar=(int *) malloc(0* sizeof(int));
|
||||||
|
|
||||||
|
b=0;
|
||||||
|
vars.nVar=0;
|
||||||
|
varIndex=0;
|
||||||
while(YAP_IsPairTerm(t))
|
while(YAP_IsPairTerm(t))
|
||||||
{
|
{
|
||||||
|
|
||||||
varTerm=YAP_HeadOfTerm(t);
|
varTerm=YAP_HeadOfTerm(t);
|
||||||
varIndex=YAP_IntOfTerm(YAP_HeadOfTerm(varTerm));
|
varIndex=YAP_IntOfTerm(YAP_HeadOfTerm(varTerm));
|
||||||
|
|
||||||
@ -48,10 +55,18 @@ returns also the names of the variables to be used to save the ADD in dot format
|
|||||||
probTerm=YAP_HeadOfTerm(varTerm);
|
probTerm=YAP_HeadOfTerm(varTerm);
|
||||||
v.nVal=nVal;
|
v.nVal=nVal;
|
||||||
v.nBit=(int)ceil(log(nVal)/log(2));
|
v.nBit=(int)ceil(log(nVal)/log(2));
|
||||||
v.probabilities=array_alloc(double,0);
|
v.probabilities=(double *) malloc(nVal* sizeof(double));
|
||||||
v.booleanVars=array_alloc(DdNode *,0);
|
v.booleanVars=(DdNode * *) malloc(v.nBit* sizeof(DdNode *));
|
||||||
for (i=0;i<nVal;i++)
|
for (i=0;i<nVal;i++)
|
||||||
{
|
{
|
||||||
|
p=YAP_FloatOfTerm(YAP_HeadOfTerm(probTerm));
|
||||||
|
v.probabilities[i]=p;
|
||||||
|
probTerm=YAP_TailOfTerm(probTerm);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0;i<v.nBit;i++)
|
||||||
|
{
|
||||||
|
|
||||||
if (create_dot)
|
if (create_dot)
|
||||||
{
|
{
|
||||||
strcpy(inames[b+i],"X");
|
strcpy(inames[b+i],"X");
|
||||||
@ -61,20 +76,24 @@ returns also the names of the variables to be used to save the ADD in dot format
|
|||||||
sprintf(numberBit,"%d",i);
|
sprintf(numberBit,"%d",i);
|
||||||
strcat(inames[b+i],numberBit);
|
strcat(inames[b+i],numberBit);
|
||||||
}
|
}
|
||||||
p=YAP_FloatOfTerm(YAP_HeadOfTerm(probTerm));
|
v.booleanVars[i]=Cudd_bddIthVar(mgr,b+i);
|
||||||
array_insert(double,v.probabilities,i,p);
|
vars.bVar2mVar=(int *)realloc(vars.bVar2mVar,(b+i+1)*sizeof(int));
|
||||||
probTerm=YAP_TailOfTerm(probTerm);
|
vars.bVar2mVar[b+i]=varIndex;
|
||||||
array_insert(DdNode *,v.booleanVars,i,Cudd_bddIthVar(mgr,b+i));
|
|
||||||
array_insert(int,bVar2mVar,b+i,varIndex);
|
|
||||||
}
|
}
|
||||||
Cudd_MakeTreeNode(mgr,b,nVal,MTR_FIXED);
|
Cudd_MakeTreeNode(mgr,b,v.nBit,MTR_FIXED);
|
||||||
b=b+nVal;
|
b=b+v.nBit;
|
||||||
array_insert(variable,vars,varIndex,v);
|
vars.varar=(variable *) realloc(vars.varar,(varIndex+1)* sizeof(variable));
|
||||||
|
vars.varar[varIndex]=v;
|
||||||
t=YAP_TailOfTerm(t);
|
t=YAP_TailOfTerm(t);
|
||||||
}
|
}
|
||||||
|
vars.nVar=varIndex+1;
|
||||||
|
vars.nBVar=b;
|
||||||
|
|
||||||
|
|
||||||
|
return vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
void createExpression(array_t * expression, YAP_Term t)
|
expr createExpression(YAP_Term t)
|
||||||
/* returns the expression as an array_t of terms (cubes) starting from the prolog lists of terms
|
/* returns the expression as an array_t of terms (cubes) starting from the prolog lists of terms
|
||||||
each term is an array_t of factors obtained from a prolog list of factors
|
each term is an array_t of factors obtained from a prolog list of factors
|
||||||
each factor is a couple (index of variable, index of value) obtained from a prolog list containing
|
each factor is a couple (index of variable, index of value) obtained from a prolog list containing
|
||||||
@ -84,12 +103,13 @@ two integers
|
|||||||
YAP_Term termTerm,factorTerm;
|
YAP_Term termTerm,factorTerm;
|
||||||
factor f;
|
factor f;
|
||||||
int i,j;
|
int i,j;
|
||||||
array_t * term;
|
term term1;
|
||||||
|
expr expression;
|
||||||
|
expression.terms=(term *)malloc(0 *sizeof(term));
|
||||||
i=0;
|
i=0;
|
||||||
while(YAP_IsPairTerm(t))
|
while(YAP_IsPairTerm(t))
|
||||||
{
|
{
|
||||||
term=array_alloc(factor,0);
|
term1.factors=(factor *)malloc(0 *sizeof(factor));
|
||||||
termTerm=YAP_HeadOfTerm(t);
|
termTerm=YAP_HeadOfTerm(t);
|
||||||
j=0;
|
j=0;
|
||||||
while(YAP_IsPairTerm(termTerm))
|
while(YAP_IsPairTerm(termTerm))
|
||||||
@ -97,14 +117,19 @@ two integers
|
|||||||
factorTerm=YAP_HeadOfTerm(termTerm);
|
factorTerm=YAP_HeadOfTerm(termTerm);
|
||||||
f.var=YAP_IntOfTerm(YAP_HeadOfTerm(factorTerm));
|
f.var=YAP_IntOfTerm(YAP_HeadOfTerm(factorTerm));
|
||||||
f.value=YAP_IntOfTerm(YAP_HeadOfTerm(YAP_TailOfTerm(factorTerm)));
|
f.value=YAP_IntOfTerm(YAP_HeadOfTerm(YAP_TailOfTerm(factorTerm)));
|
||||||
array_insert(factor,term,j,f);
|
term1.factors=(factor *)realloc(term1.factors,(j+1)* sizeof(factor));
|
||||||
|
term1.factors[j]=f;
|
||||||
termTerm=YAP_TailOfTerm(termTerm);
|
termTerm=YAP_TailOfTerm(termTerm);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
array_insert(array_t *,expression,i,term);
|
term1.nFact=j;
|
||||||
|
expression.terms=(term *)realloc(expression.terms,(i+1)* sizeof(term));
|
||||||
|
expression.terms[i]=term1;
|
||||||
t=YAP_TailOfTerm(t);
|
t=YAP_TailOfTerm(t);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
expression.nTerms=i;
|
||||||
|
return(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int compute_prob(void)
|
static int compute_prob(void)
|
||||||
@ -112,28 +137,28 @@ static int compute_prob(void)
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
YAP_Term out,arg1,arg2,arg3,arg4;
|
YAP_Term out,arg1,arg2,arg3,arg4;
|
||||||
array_t * variables,* expression, * bVar2mVar;
|
variables vars;
|
||||||
|
expr expression;
|
||||||
DdNode * function, * add;
|
DdNode * function, * add;
|
||||||
DdManager * mgr;
|
DdManager * mgr;
|
||||||
int nBVar,i,j,intBits,create_dot;
|
int nBVar,i,j,intBits,create_dot;
|
||||||
FILE * file;
|
FILE * file;
|
||||||
DdNode * array[1];
|
DdNode * array[1];
|
||||||
|
double prob;
|
||||||
char * onames[1];
|
char * onames[1];
|
||||||
char inames[1000][20];
|
char inames[1000][20];
|
||||||
char * names[1000];
|
char * names[1000];
|
||||||
GHashTable * nodes; /* hash table that associates nodes with their probability if already
|
GHashTable * nodes; /* hash table that associates nodes with their probability if already
|
||||||
computed, it is defined in glib */
|
computed, it is defined in glib */
|
||||||
//Cudd_ReorderingType order;
|
|
||||||
arg1=YAP_ARG1;
|
arg1=YAP_ARG1;
|
||||||
arg2=YAP_ARG2;
|
arg2=YAP_ARG2;
|
||||||
arg3=YAP_ARG3;
|
arg3=YAP_ARG3;
|
||||||
arg4=YAP_ARG4;
|
arg4=YAP_ARG4;
|
||||||
|
|
||||||
mgr=Cudd_Init(0,0,CUDD_UNIQUE_SLOTS,CUDD_CACHE_SLOTS,0);
|
mgr=Cudd_Init(0,0,CUDD_UNIQUE_SLOTS,CUDD_CACHE_SLOTS,0);
|
||||||
variables=array_alloc(variable,0);
|
|
||||||
bVar2mVar=array_alloc(int,0);
|
|
||||||
create_dot=YAP_IntOfTerm(arg4);
|
create_dot=YAP_IntOfTerm(arg4);
|
||||||
createVars(variables,arg1,mgr,bVar2mVar,create_dot,inames);
|
vars=createVars(arg1,mgr,create_dot,inames);
|
||||||
|
|
||||||
//Cudd_PrintInfo(mgr,stderr);
|
//Cudd_PrintInfo(mgr,stderr);
|
||||||
|
|
||||||
/* automatic variable reordering, default method CUDD_REORDER_SIFT used */
|
/* automatic variable reordering, default method CUDD_REORDER_SIFT used */
|
||||||
@ -148,10 +173,10 @@ static int compute_prob(void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
expression=array_alloc(array_t *,0);
|
expression=createExpression(arg2);
|
||||||
createExpression(expression,arg2);
|
|
||||||
|
function=retFunction(mgr,expression,vars);
|
||||||
|
|
||||||
function=retFunction(mgr,expression,variables);
|
|
||||||
/* the BDD build by retFunction is converted to an ADD (algebraic decision diagram)
|
/* the BDD build by retFunction is converted to an ADD (algebraic decision diagram)
|
||||||
because it is easier to interpret and to print */
|
because it is easier to interpret and to print */
|
||||||
add=Cudd_BddToAdd(mgr,function);
|
add=Cudd_BddToAdd(mgr,function);
|
||||||
@ -160,7 +185,7 @@ static int compute_prob(void)
|
|||||||
if (create_dot)
|
if (create_dot)
|
||||||
/* if specified by the user, a dot file for the BDD is written to cpl.dot */
|
/* if specified by the user, a dot file for the BDD is written to cpl.dot */
|
||||||
{
|
{
|
||||||
nBVar=array_n(bVar2mVar);
|
nBVar=vars.nBVar;
|
||||||
for(i=0;i<nBVar;i++)
|
for(i=0;i<nBVar;i++)
|
||||||
names[i]=inames[i];
|
names[i]=inames[i];
|
||||||
array[0]=add;
|
array[0]=add;
|
||||||
@ -179,13 +204,23 @@ static int compute_prob(void)
|
|||||||
{
|
{
|
||||||
dividend=(dividend<<1)+1;
|
dividend=(dividend<<1)+1;
|
||||||
}
|
}
|
||||||
out=YAP_MkFloatTerm(Prob(add,variables,bVar2mVar,nodes));
|
prob=Prob(add,vars,nodes);
|
||||||
|
out=YAP_MkFloatTerm(prob);
|
||||||
g_hash_table_foreach (nodes,dealloc,NULL);
|
g_hash_table_foreach (nodes,dealloc,NULL);
|
||||||
g_hash_table_destroy(nodes);
|
g_hash_table_destroy(nodes);
|
||||||
Cudd_Quit(mgr);
|
Cudd_Quit(mgr);
|
||||||
array_free(variables);
|
for(i=0;i<vars.nVar;i++)
|
||||||
array_free(bVar2mVar);
|
{
|
||||||
array_free(expression);
|
free(vars.varar[i].probabilities);
|
||||||
|
free(vars.varar[i].booleanVars);
|
||||||
|
}
|
||||||
|
free(vars.varar);
|
||||||
|
free(vars.bVar2mVar);
|
||||||
|
for(i=0;i<expression.nTerms;i++)
|
||||||
|
{
|
||||||
|
free(expression.terms[i].factors);
|
||||||
|
}
|
||||||
|
free(expression.terms);
|
||||||
return(YAP_Unify(out,arg3));
|
return(YAP_Unify(out,arg3));
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
.cmtt-10{font-family: monospace;}
|
.cmtt-10{font-family: monospace;}
|
||||||
.cmti-10{ font-style: italic;}
|
.cmti-10{ font-style: italic;}
|
||||||
p.noindent { text-indent: 0em }
|
p.noindent { text-indent: 0em }
|
||||||
|
td p.noindent { text-indent: 0em; margin-top:0em; }
|
||||||
p.nopar { text-indent: 0em; }
|
p.nopar { text-indent: 0em; }
|
||||||
p.indent{ text-indent: 1.5em }
|
p.indent{ text-indent: 1.5em }
|
||||||
@media print {div.crosslinks {visibility:hidden;}}
|
@media print {div.crosslinks {visibility:hidden;}}
|
||||||
@ -20,6 +21,9 @@ td center { margin-top:0em; margin-bottom:0em; }
|
|||||||
.Canvas { position:relative; }
|
.Canvas { position:relative; }
|
||||||
img.math{vertical-align:middle;}
|
img.math{vertical-align:middle;}
|
||||||
li p.indent { text-indent: 0em }
|
li p.indent { text-indent: 0em }
|
||||||
|
li p:first-child{ margin-top:0em; }
|
||||||
|
li p:last-child, li div:last-child { margin-bottom:0.5em; }
|
||||||
|
li p~ul:last-child, li p~ol:last-child{ margin-bottom:0.5em; }
|
||||||
.enumerate1 {list-style-type:decimal;}
|
.enumerate1 {list-style-type:decimal;}
|
||||||
.enumerate2 {list-style-type:lower-alpha;}
|
.enumerate2 {list-style-type:lower-alpha;}
|
||||||
.enumerate3 {list-style-type:lower-roman;}
|
.enumerate3 {list-style-type:lower-roman;}
|
||||||
@ -32,11 +36,11 @@ div.obeylines-v p { margin-top:0; margin-bottom:0; }
|
|||||||
td.displaylines {text-align:center; white-space:nowrap;}
|
td.displaylines {text-align:center; white-space:nowrap;}
|
||||||
.centerline {text-align:center;}
|
.centerline {text-align:center;}
|
||||||
.rightline {text-align:right;}
|
.rightline {text-align:right;}
|
||||||
div.verbatim {font-family: monospace; white-space: nowrap; }
|
div.verbatim {font-family: monospace; white-space: nowrap; text-align:left; clear:both; }
|
||||||
table.verbatim {width:100%;}
|
|
||||||
.fbox {padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
|
.fbox {padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
|
||||||
|
div.fbox {display:table}
|
||||||
div.center div.fbox {text-align:center; clear:both; padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
|
div.center div.fbox {text-align:center; clear:both; padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
|
||||||
table.minipage{width:100%;}
|
div.minipage{width:100%;}
|
||||||
div.center, div.center div.center {text-align: center; margin-left:1em; margin-right:1em;}
|
div.center, div.center div.center {text-align: center; margin-left:1em; margin-right:1em;}
|
||||||
div.center div {text-align: left;}
|
div.center div {text-align: left;}
|
||||||
div.flushright, div.flushright div.flushright {text-align: right;}
|
div.flushright, div.flushright div.flushright {text-align: right;}
|
||||||
@ -53,6 +57,8 @@ span.footnote-mark sup.textsuperscript, span.footnote-mark a sup.textsuperscript
|
|||||||
div.tabular, div.center div.tabular {text-align: center; margin-top:0.5em; margin-bottom:0.5em; }
|
div.tabular, div.center div.tabular {text-align: center; margin-top:0.5em; margin-bottom:0.5em; }
|
||||||
table.tabular td p{margin-top:0em;}
|
table.tabular td p{margin-top:0em;}
|
||||||
table.tabular {margin-left: auto; margin-right: auto;}
|
table.tabular {margin-left: auto; margin-right: auto;}
|
||||||
|
td p:first-child{ margin-top:0em; }
|
||||||
|
td p:last-child{ margin-bottom:0em; }
|
||||||
div.td00{ margin-left:0pt; margin-right:0pt; }
|
div.td00{ margin-left:0pt; margin-right:0pt; }
|
||||||
div.td01{ margin-left:0pt; margin-right:5pt; }
|
div.td01{ margin-left:0pt; margin-right:5pt; }
|
||||||
div.td10{ margin-left:5pt; margin-right:0pt; }
|
div.td10{ margin-left:5pt; margin-right:0pt; }
|
||||||
@ -70,8 +76,9 @@ span.TEX span.E{ position:relative;top:0.5ex;left:-0.0417em;}
|
|||||||
a span.TEX span.E {text-decoration: none; }
|
a span.TEX span.E {text-decoration: none; }
|
||||||
span.LATEX span.A{ position:relative; top:-0.5ex; left:-0.4em; font-size:85%;}
|
span.LATEX span.A{ position:relative; top:-0.5ex; left:-0.4em; font-size:85%;}
|
||||||
span.LATEX span.TEX{ position:relative; left: -0.4em; }
|
span.LATEX span.TEX{ position:relative; left: -0.4em; }
|
||||||
div.float img, div.float .caption {text-align:center;}
|
div.float, div.figure {margin-left: auto; margin-right: auto;}
|
||||||
div.figure img, div.figure .caption {text-align:center;}
|
div.float img {text-align:center;}
|
||||||
|
div.figure img {text-align:center;}
|
||||||
.marginpar {width:20%; float:right; text-align:left; margin-left:auto; margin-top:0.5em; font-size:85%; text-decoration:underline;}
|
.marginpar {width:20%; float:right; text-align:left; margin-left:auto; margin-top:0.5em; font-size:85%; text-decoration:underline;}
|
||||||
.marginpar p{margin-top:0.4em; margin-bottom:0.4em;}
|
.marginpar p{margin-top:0.4em; margin-bottom:0.4em;}
|
||||||
table.equation {width:100%;}
|
table.equation {width:100%;}
|
||||||
@ -88,10 +95,12 @@ table.pmatrix {width:100%;}
|
|||||||
span.pmatrix img{vertical-align:middle;}
|
span.pmatrix img{vertical-align:middle;}
|
||||||
div.pmatrix {text-align:center;}
|
div.pmatrix {text-align:center;}
|
||||||
table.pmatrix {width:100%;}
|
table.pmatrix {width:100%;}
|
||||||
|
span.bar-css {text-decoration:overline;}
|
||||||
img.cdots{vertical-align:middle;}
|
img.cdots{vertical-align:middle;}
|
||||||
.partToc a, .partToc, .likepartToc a, .likepartToc {line-height: 200%; font-weight:bold; font-size:110%;}
|
.partToc a, .partToc, .likepartToc a, .likepartToc {line-height: 200%; font-weight:bold; font-size:110%;}
|
||||||
.caption td.id{font-weight: bold; white-space: nowrap; }
|
.index-item, .index-subitem, .index-subsubitem {display:block}
|
||||||
table.caption {text-align:center;}
|
div.caption {text-indent:-2em; margin-left:3em; margin-right:1em; text-align:left;}
|
||||||
|
div.caption span.id{font-weight: bold; white-space: nowrap; }
|
||||||
h1.partHead{text-align: center}
|
h1.partHead{text-align: center}
|
||||||
p.bibitem { text-indent: -2em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; }
|
p.bibitem { text-indent: -2em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; }
|
||||||
p.bibitem-p { text-indent: 0em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; }
|
p.bibitem-p { text-indent: 0em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; }
|
||||||
@ -107,7 +116,7 @@ div.thanks{text-align:left; margin-left:10%; font-size:85%; font-style:italic; }
|
|||||||
div.author{white-space: nowrap;}
|
div.author{white-space: nowrap;}
|
||||||
.quotation {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; }
|
.quotation {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; }
|
||||||
.abstract p {margin-left:5%; margin-right:5%;}
|
.abstract p {margin-left:5%; margin-right:5%;}
|
||||||
table.abstract {width:100%;}
|
div.abstract {width:100%;}
|
||||||
.figure img.graphics {margin-left:10%;}
|
.figure img.graphics {margin-left:10%;}
|
||||||
/* end css.sty */
|
/* end css.sty */
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html >
|
<html >
|
||||||
<head><title>cplint Version beta2.0 Manual</title>
|
<head><title>cplint Version 2.0 Manual</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
|
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
|
||||||
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
|
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
|
||||||
<!-- html -->
|
<!-- html -->
|
||||||
<meta name="src" content="manual.tex">
|
<meta name="src" content="manual.tex">
|
||||||
<meta name="date" content="2008-06-19 23:25:00">
|
<meta name="date" content="2010-07-27 17:55:00">
|
||||||
<link rel="stylesheet" type="text/css" href="manual.css">
|
<link rel="stylesheet" type="text/css" href="manual.css">
|
||||||
</head><body
|
</head><body
|
||||||
>
|
>
|
||||||
@ -15,28 +15,27 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h2 class="titleHead">cplint Version beta2.0 Manual</h2>
|
<h2 class="titleHead">cplint Version 2.0 Manual</h2>
|
||||||
<div class="author" ><span
|
<div class="author" ><span
|
||||||
class="cmr-12">Fabrizio Riguzzi</span>
|
class="cmr-12">Fabrizio Riguzzi</span>
|
||||||
<br /><span
|
<br /><span
|
||||||
class="cmr-12">fabrizio.riguzzi@unife.it</span></div>
|
class="cmr-12">fabrizio.riguzzi@unife.it</span></div><br />
|
||||||
<br />
|
|
||||||
<div class="date" ><span
|
<div class="date" ><span
|
||||||
class="cmr-12">June 19, 2008</span></div>
|
class="cmr-12">July 27, 2010</span></div>
|
||||||
</div>
|
</div>
|
||||||
<h3 class="sectionHead"><span class="titlemark">1 </span> <a
|
<h3 class="sectionHead"><span class="titlemark">1 </span> <a
|
||||||
id="x1-10001"></a>Introduction</h3>
|
id="x1-10001"></a>Introduction</h3>
|
||||||
<!--l. 30--><p class="noindent"><span
|
<!--l. 31--><p class="noindent" ><span
|
||||||
class="cmtt-10">cplint </span>is a suite of programs for reasoning with LPADs <span class="cite">[<a
|
class="cmtt-10">cplint </span>is a suite of programs for reasoning with LPADs <span class="cite">[<a
|
||||||
href="#XVenVer03-TR">11</a>, <a
|
href="#XVenVer03-TR">11</a>, <a
|
||||||
href="#XVenVer04-ICLP04-IC">12</a>]</span> and CP-logic
|
href="#XVenVer04-ICLP04-IC">12</a>]</span> and CP-logic
|
||||||
programs <span class="cite">[<a
|
programs <span class="cite">[<a
|
||||||
href="#XVenDenBru-JELIA06">10</a>, <a
|
href="#XVenDenBru-JELIA06">10</a>, <a
|
||||||
href="#XCP-logic-unp">13</a>]</span>.
|
href="#XCP-logic-unp">13</a>]</span>.
|
||||||
<!--l. 32--><p class="indent"> It consists of three Prolog modules for answering queries using goal-oriented
|
<!--l. 33--><p class="indent" > It consists of three Prolog modules for answering queries using goal-oriented
|
||||||
procedures plus three Prolog modules for answering queries using the definition of the
|
procedures plus three Prolog modules for answering queries using the definition of the
|
||||||
semantics of LPADs and CP-logic.
|
semantics of LPADs and CP-logic.
|
||||||
<!--l. 36--><p class="indent"> The modules for answering queries using using goal-oriented procedures are
|
<!--l. 37--><p class="indent" > The modules for answering queries using using goal-oriented procedures are
|
||||||
<span
|
<span
|
||||||
class="cmtt-10">lpadsld.pl</span>, <span
|
class="cmtt-10">lpadsld.pl</span>, <span
|
||||||
class="cmtt-10">lpad.pl </span>and <span
|
class="cmtt-10">lpad.pl </span>and <span
|
||||||
@ -49,11 +48,11 @@ href="#XRig-AIIA07-IC">7</a>]</span> and <span class="cite">[<a
|
|||||||
href="#XRig-RCRA07-IC">8</a>]</span>. It is based on SLDNF resolution and
|
href="#XRig-RCRA07-IC">8</a>]</span>. It is based on SLDNF resolution and
|
||||||
is an adaptation of the interpreter for ProbLog <span class="cite">[<a
|
is an adaptation of the interpreter for ProbLog <span class="cite">[<a
|
||||||
href="#XDBLP:conf/ijcai/RaedtKT07">4</a>]</span>.
|
href="#XDBLP:conf/ijcai/RaedtKT07">4</a>]</span>.
|
||||||
<!--l. 42--><p class="noindent">It was proved correct <span class="cite">[<a
|
<!--l. 43--><p class="noindent" >It was proved correct <span class="cite">[<a
|
||||||
href="#XRig-RCRA07-IC">8</a>]</span> with respect to the semantics of LPADs for range
|
href="#XRig-RCRA07-IC">8</a>]</span> with respect to the semantics of LPADs for range
|
||||||
restricted acyclic programs <span class="cite">[<a
|
restricted acyclic programs <span class="cite">[<a
|
||||||
href="#XDBLP:journals/ngc/AptB91">1</a>]</span> without function symbols.
|
href="#XDBLP:journals/ngc/AptB91">1</a>]</span> without function symbols.
|
||||||
<!--l. 44--><p class="noindent">It is also able to deal with extensions of LPADs and CP-logic: the clause
|
<!--l. 45--><p class="noindent" >It is also able to deal with extensions of LPADs and CP-logic: the clause
|
||||||
bodies can contain <span
|
bodies can contain <span
|
||||||
class="cmtt-10">setof </span>and <span
|
class="cmtt-10">setof </span>and <span
|
||||||
class="cmtt-10">bagof</span>, the probabilities in the head may
|
class="cmtt-10">bagof</span>, the probabilities in the head may
|
||||||
@ -84,7 +83,7 @@ href="#XDBLP:journals/jacm/ChenW96">3</a>]</span>. As a consequence, it works fo
|
|||||||
class="cmtt-10">cpl.pl</span>: computes the probability of a query using a top-down procedure
|
class="cmtt-10">cpl.pl</span>: computes the probability of a query using a top-down procedure
|
||||||
based on SLG resolution and moreover checks that the CP-logic program
|
based on SLG resolution and moreover checks that the CP-logic program
|
||||||
is valid, i.e., that it has at least an execution model.</li></ul>
|
is valid, i.e., that it has at least an execution model.</li></ul>
|
||||||
<!--l. 50--><p class="indent"> The modules for answering queries using the definition of the semantics of LPADs
|
<!--l. 51--><p class="indent" > The modules for answering queries using the definition of the semantics of LPADs
|
||||||
and CP-logic are <span
|
and CP-logic are <span
|
||||||
class="cmtt-10">semlpadsld.pl</span>, <span
|
class="cmtt-10">semlpadsld.pl</span>, <span
|
||||||
class="cmtt-10">semlpad.pl </span>and <span
|
class="cmtt-10">semlpad.pl </span>and <span
|
||||||
@ -117,102 +116,73 @@ class="cmmi-10">P</span>, i.e.,
|
|||||||
and temporal precedence. It uses the definition of the semantics given in
|
and temporal precedence. It uses the definition of the semantics given in
|
||||||
<span class="cite">[<a
|
<span class="cite">[<a
|
||||||
href="#XCP-logic-unp">13</a>]</span>.</li></ul>
|
href="#XCP-logic-unp">13</a>]</span>.</li></ul>
|
||||||
<!--l. 59--><p class="noindent">
|
<!--l. 60--><p class="noindent" >
|
||||||
<h3 class="sectionHead"><span class="titlemark">2 </span> <a
|
<h3 class="sectionHead"><span class="titlemark">2 </span> <a
|
||||||
id="x1-20002"></a>Installation</h3>
|
id="x1-20002"></a>Installation</h3>
|
||||||
<!--l. 60--><p class="noindent"><span
|
<!--l. 61--><p class="noindent" ><span
|
||||||
class="cmtt-10">cplint </span>is distributed in source code in the CVS version of Yap. It
|
class="cmtt-10">cplint </span>is distributed in source code in the git version of Yap. It
|
||||||
includes Prolog and C files. Download it by following the instruction in <a
|
includes Prolog and C files. Download it by following the instruction in <a
|
||||||
href="http://www.ncc.up.pt/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}vsc/Yap/downloads.html" >
|
href="http://www.ncc.up.pt/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}vsc/Yap/downloads.html" >
|
||||||
http://www.ncc.up.pt/<span
|
http://www.ncc.up.pt/ vsc/Yap/downloads.html </a>.
|
||||||
class="cmsy-10">~</span>vsc/Yap/downloads.html </a>.
|
<!--l. 63--><p class="indent" > <span
|
||||||
<!--l. 62--><p class="indent"> <span
|
class="cmtt-10">cplint </span>requires cudd and glib-2.0. You can download cudd from <a
|
||||||
class="cmtt-10">cplint </span>requires glu (a subpackage of vis) and glib-2.0. You can download glu
|
href="http://vlsi.colorado.edu/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}fabio/CUDD/" >
|
||||||
from <a
|
http://vlsi.colorado.edu/ fabio/CUDD/ </a>. You can download glib-2.0 (version <span
|
||||||
href="http://vlsi.colorado.edu/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}vis/getting_VIS_2.1.html" > http://vlsi.colorado.edu/<span
|
|
||||||
class="cmsy-10">~</span>vis/getting_VIS_2.1.html </a> You can download
|
|
||||||
glib-2.0 (version <span
|
|
||||||
class="cmsy-10">≥ </span>2<span
|
class="cmsy-10">≥ </span>2<span
|
||||||
class="cmmi-10">.</span>0) from <a
|
class="cmmi-10">.</span>0)
|
||||||
href="http://www.gtk.org/" > http://www.gtk.org/ </a>. This is a standard GNU package
|
from <a
|
||||||
so it is easy to install it using the package management software of your Linux or
|
href="http://www.gtk.org/" > http://www.gtk.org/ </a>. This is a standard GNU package so it is easy to
|
||||||
Cygwin distribution.
|
install it using the package management software of your Linux or Cygwin
|
||||||
<!--l. 68--><p class="indent"> Install glu:
|
distribution.
|
||||||
|
<!--l. 69--><p class="indent" > Compile cudd:
|
||||||
<ol class="enumerate1" >
|
<ol class="enumerate1" >
|
||||||
<li class="enumerate"><a
|
<li
|
||||||
id="x1-2002x1"></a>downlad <span
|
class="enumerate" id="x1-2002x1">downlad <span
|
||||||
class="cmtt-10">glu-2.1.tar.gz</span>
|
class="cmtt-10">cudd-2.4.2.tar.gz</span>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
<li class="enumerate"><a
|
<li
|
||||||
id="x1-2004x2"></a>decompress it
|
class="enumerate" id="x1-2004x2">decompress it
|
||||||
</li>
|
</li>
|
||||||
<li class="enumerate"><a
|
<li
|
||||||
id="x1-2006x3"></a><span
|
class="enumerate" id="x1-2006x3"><span
|
||||||
class="cmtt-10">cd glu-2.1</span>
|
class="cmtt-10">cd cudd-2.4.2</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="enumerate"><a
|
<li
|
||||||
id="x1-2008x4"></a><span
|
class="enumerate" id="x1-2008x4">check makefile options
|
||||||
class="cmtt-10">mkdir arch</span>
|
|
||||||
</li>
|
</li>
|
||||||
<li class="enumerate"><a
|
<li
|
||||||
id="x1-2010x5"></a><span
|
class="enumerate" id="x1-2010x5"><span
|
||||||
class="cmtt-10">cd arch</span>
|
class="cmtt-10">make</span></li></ol>
|
||||||
</li>
|
<!--l. 78--><p class="indent" > Install Yap together with <span
|
||||||
<li class="enumerate"><a
|
|
||||||
id="x1-2012x6"></a><span
|
|
||||||
class="cmtt-10">../configure</span>
|
|
||||||
</li>
|
|
||||||
<li class="enumerate"><a
|
|
||||||
id="x1-2014x7"></a><span
|
|
||||||
class="cmtt-10">make</span>
|
|
||||||
</li>
|
|
||||||
<li class="enumerate"><a
|
|
||||||
id="x1-2016x8"></a><span
|
|
||||||
class="cmtt-10">su</span>
|
|
||||||
</li>
|
|
||||||
<li class="enumerate"><a
|
|
||||||
id="x1-2018x9"></a><span
|
|
||||||
class="cmtt-10">make install</span></li></ol>
|
|
||||||
<!--l. 80--><p class="noindent">This will install glu into <span
|
|
||||||
class="cmtt-10">/usr/local</span>, if you want to install to a different <span
|
|
||||||
class="cmtt-10">DIR </span>use
|
|
||||||
<span
|
|
||||||
class="cmtt-10">../configure --prefix DIR</span>
|
|
||||||
<!--l. 83--><p class="indent"> Install Yap together with <span
|
|
||||||
class="cmtt-10">cplint</span>: when compiling Yap following the instuction of
|
class="cmtt-10">cplint</span>: when compiling Yap following the instuction of
|
||||||
the <span
|
the <span
|
||||||
class="cmtt-10">INSTALL </span>file in the root of the Yap folder, use
|
class="cmtt-10">INSTALL </span>file in the root of the Yap folder, use
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-1">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
configure --enable-cplint=DIR
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
configure --enable-cplint
|
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 82--><p class="nopar" > Under Windows, you have to use Cygwin (glu does not compile under MinGW),
|
||||||
<!--l. 87--><p class="nopar"> Under Windows, you have to use Cygwin (glu does not compile under MinGW),
|
so<br
|
||||||
so
|
class="newline" />
|
||||||
<br class="newline" />
|
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-2">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
configure --enable-cplint=DIR --enable-cygwin
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
configure --enable-cplint --enable-cygwin
|
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 86--><p class="nopar" > where <span
|
||||||
<!--l. 91--><p class="nopar"> If you installed glu in <span
|
class="cmtt-10">DIR </span>is the path to the directory <span
|
||||||
class="cmtt-10">DIR</span>, use <span
|
class="cmtt-10">cudd-2.4.2 </span>(including <span
|
||||||
class="cmtt-10">--enable-cplint=DIR</span>
|
class="cmtt-10">cudd-2.4.2</span>).
|
||||||
<!--l. 94--><p class="indent"> After having performed <span
|
<!--l. 89--><p class="indent" > After having performed <span
|
||||||
class="cmtt-10">make install </span>you can do <span
|
class="cmtt-10">make install </span>you can do <span
|
||||||
class="cmtt-10">make installcheck </span>that will
|
class="cmtt-10">make installcheck </span>that will
|
||||||
execute a suite of tests of the various programs. If no error is reported you have a
|
execute a suite of tests of the various programs. If no error is reported you have a
|
||||||
working installation of <span
|
working installation of <span
|
||||||
class="cmtt-10">cplint</span>.
|
class="cmtt-10">cplint</span>.
|
||||||
<!--l. 97--><p class="noindent">
|
<!--l. 92--><p class="noindent" >
|
||||||
<h3 class="sectionHead"><span class="titlemark">3 </span> <a
|
<h3 class="sectionHead"><span class="titlemark">3 </span> <a
|
||||||
id="x1-30003"></a>Syntax</h3>
|
id="x1-30003"></a>Syntax</h3>
|
||||||
<!--l. 99--><p class="noindent">Disjunction in the head is represented with a semicolon and atoms in the head are
|
<!--l. 94--><p class="noindent" >Disjunction in the head is represented with a semicolon and atoms in the head are
|
||||||
separated from probabilities by a colon. For the rest, the usual syntax of Prolog is
|
separated from probabilities by a colon. For the rest, the usual syntax of Prolog is
|
||||||
used. For example, the CP-logic clause
|
used. For example, the CP-logic clause
|
||||||
<center class="math-display" >
|
<center class="math-display" >
|
||||||
@ -220,49 +190,35 @@ used. For example, the CP-logic clause
|
|||||||
src="manual0x.png" alt="h1 : p1 ∨...∨ hn : pn ← b1,...,bm,¬c1,...,¬cl " class="math-display" ></center> is
|
src="manual0x.png" alt="h1 : p1 ∨...∨ hn : pn ← b1,...,bm,¬c1,...,¬cl " class="math-display" ></center> is
|
||||||
represented by
|
represented by
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-3">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
h1:p1 ; ... ; hn:pn :- b1,...,bm,\+ c1,....,\+ cl
|
h1:p1 ; ... ; hn:pn :- b1,...,bm,\+ c1,....,\+ cl
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 100--><p class="nopar" > No parentheses are necessary. The <span
|
||||||
<!--l. 105--><p class="nopar"> No parentheses are necessary. The <span
|
|
||||||
class="cmtt-10">pi </span>are numeric expressions. It is up to the user to
|
class="cmtt-10">pi </span>are numeric expressions. It is up to the user to
|
||||||
ensure that the numeric expressions are legal, i.e. that they sum up to less than
|
ensure that the numeric expressions are legal, i.e. that they sum up to less than
|
||||||
one.
|
one.
|
||||||
<!--l. 108--><p class="indent"> If the clause has an empty body, it can be represented like this
|
<!--l. 103--><p class="indent" > If the clause has an empty body, it can be represented like this
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-4">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
h1:p1 ; ... ;hn:pn.
|
h1:p1 ; ... ;hn:pn.
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 106--><p class="nopar" > If the clause has a single head with probability 1, the annotation can be omitted and
|
||||||
<!--l. 111--><p class="nopar"> If the clause has a single head with probability 1, the annotation can be omitted and
|
|
||||||
the clause takes the form of a normal prolog clause, i.e.
|
the clause takes the form of a normal prolog clause, i.e.
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-5">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
h1:- b1,...,bm,\+ c1,...,\+ cl.
|
h1:- b1,...,bm,\+ c1,...,\+ cl.
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 110--><p class="nopar" > stands for
|
||||||
<!--l. 115--><p class="nopar"> stands for
|
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-6">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
h1:1 :- b1,...,bm,\+ c1,...,\+ cl.
|
h1:1 :- b1,...,bm,\+ c1,...,\+ cl.
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 114--><p class="nopar" >
|
||||||
<!--l. 119--><p class="nopar">
|
<!--l. 116--><p class="indent" > The coin example of <span class="cite">[<a
|
||||||
<!--l. 121--><p class="indent"> The coin example of <span class="cite">[<a
|
|
||||||
href="#XVenVer04-ICLP04-IC">12</a>]</span> is represented as (see file <span
|
href="#XVenVer04-ICLP04-IC">12</a>]</span> is represented as (see file <span
|
||||||
class="cmtt-10">coin.cpl</span>)
|
class="cmtt-10">coin.cpl</span>)
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-7">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
heads(Coin):1/2 ; tails(Coin):1/2:-
|
heads(Coin):1/2 ; tails(Coin):1/2:-
|
||||||
 <br />     toss(Coin),\+biased(Coin).
|
 <br />     toss(Coin),\+biased(Coin).
|
||||||
 <br />
|
 <br />
|
||||||
@ -273,16 +229,15 @@ heads(Coin):1/2 ; tails(Coin):1/2:-
|
|||||||
 <br />
|
 <br />
|
||||||
 <br />toss(coin).
|
 <br />toss(coin).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 127--><p class="nopar" > The first clause states that if we toss a coin that is not biased it has equal
|
||||||
<!--l. 132--><p class="nopar"> The first clause states that if we toss a coin that is not biased it has equal
|
|
||||||
probability of landing heads and tails. The second states that if the coin is biased it
|
probability of landing heads and tails. The second states that if the coin is biased it
|
||||||
has a slightly higher probability of landing heads. The third states that the coin is
|
has a slightly higher probability of landing heads. The third states that the coin is
|
||||||
fair with probability 0.9 and biased with probability 0.1 and the last clause states
|
fair with probability 0.9 and biased with probability 0.1 and the last clause states
|
||||||
that we toss a coin with certainty.
|
that we toss a coin with certainty.
|
||||||
<!--l. 137--><p class="noindent">
|
<!--l. 132--><p class="noindent" >
|
||||||
<h3 class="sectionHead"><span class="titlemark">4 </span> <a
|
<h3 class="sectionHead"><span class="titlemark">4 </span> <a
|
||||||
id="x1-40004"></a>Commands</h3>
|
id="x1-40004"></a>Commands</h3>
|
||||||
<!--l. 138--><p class="noindent">All six modules accept the same commands for reading in files and answering queries.
|
<!--l. 133--><p class="noindent" >All six modules accept the same commands for reading in files and answering queries.
|
||||||
The LPAD or CP-logic program must be stored in a text file with extension <span
|
The LPAD or CP-logic program must be stored in a text file with extension <span
|
||||||
class="cmtt-10">.cpl</span>.
|
class="cmtt-10">.cpl</span>.
|
||||||
Suppose you have stored the example above in file <span
|
Suppose you have stored the example above in file <span
|
||||||
@ -291,32 +246,23 @@ queries from this program, you have to run Yap, load one of the modules (such as
|
|||||||
example <span
|
example <span
|
||||||
class="cmtt-10">lpad.pl</span>) by issuing the command
|
class="cmtt-10">lpad.pl</span>) by issuing the command
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-8">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
use_module(library(lpad)).
|
use_module(library(lpad)).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 139--><p class="nopar" > at the command prompt. Then you must parse the source file <span
|
||||||
<!--l. 144--><p class="nopar"> at the command prompt. Then you must parse the source file <span
|
|
||||||
class="cmtt-10">coin.cpl </span>with the
|
class="cmtt-10">coin.cpl </span>with the
|
||||||
command
|
command
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-9">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
p(coin).
|
p(coin).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 144--><p class="nopar" > if <span
|
||||||
<!--l. 149--><p class="nopar"> if <span
|
|
||||||
class="cmtt-10">coin.cpl </span>is in the current directory, or
|
class="cmtt-10">coin.cpl </span>is in the current directory, or
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-10">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
p(’path_to_coin/coin’).
|
p(’path_to_coin/coin’).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 148--><p class="nopar" > if <span
|
||||||
<!--l. 153--><p class="nopar"> if <span
|
|
||||||
class="cmtt-10">coin.cpl </span>is in a different directory. At this point you can pose query to the
|
class="cmtt-10">coin.cpl </span>is in a different directory. At this point you can pose query to the
|
||||||
program by using the predicate <span
|
program by using the predicate <span
|
||||||
class="cmtt-10">s/2 </span>(for solve) that takes as its first argument a
|
class="cmtt-10">s/2 </span>(for solve) that takes as its first argument a
|
||||||
@ -325,13 +271,10 @@ as its second argument. For example, the probability of the conjunction
|
|||||||
<span
|
<span
|
||||||
class="cmtt-10">head(coin),biased(coin) </span>can be asked with the query
|
class="cmtt-10">head(coin),biased(coin) </span>can be asked with the query
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-11">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
s([head(coin),biased(coin)],P).
|
s([head(coin),biased(coin)],P).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 153--><p class="nopar" > For computing the probability of a conjunction given another conjunction you can
|
||||||
<!--l. 158--><p class="nopar"> For computing the probability of a conjunction given another conjunction you can
|
|
||||||
use the predicate <span
|
use the predicate <span
|
||||||
class="cmtt-10">sc/3 </span>(for solve conditional) that take takes as input the query
|
class="cmtt-10">sc/3 </span>(for solve conditional) that take takes as input the query
|
||||||
conjunction as its first argument, the evidence conjunction as its second argument
|
conjunction as its first argument, the evidence conjunction as its second argument
|
||||||
@ -341,25 +284,22 @@ class="cmtt-10">heads(coin) </span>given the evidence <span
|
|||||||
class="cmtt-10">biased(coin) </span>can be asked with the
|
class="cmtt-10">biased(coin) </span>can be asked with the
|
||||||
query
|
query
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-12">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
sc([heads(coin)],[biased(coin)],P).
|
sc([heads(coin)],[biased(coin)],P).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 158--><p class="nopar" > After having parsed a program, in order to read in a new program you must restart
|
||||||
<!--l. 163--><p class="nopar"> After having parsed a program, in order to read in a new program you must restart
|
|
||||||
Yap when using <span
|
Yap when using <span
|
||||||
class="cmtt-10">semlpadsld.pl </span>and <span
|
class="cmtt-10">semlpadsld.pl </span>and <span
|
||||||
class="cmtt-10">semlpad.pl</span>. With the other modules, you can
|
class="cmtt-10">semlpad.pl</span>. With the other modules, you can
|
||||||
directly parse a new program.
|
directly parse a new program.
|
||||||
<!--l. 167--><p class="indent"> When using <span
|
<!--l. 162--><p class="indent" > When using <span
|
||||||
class="cmtt-10">lpad.pl</span>, the system can print the message “Uunsound program” in
|
class="cmtt-10">lpad.pl</span>, the system can print the message “Uunsound program” in
|
||||||
the case in which an instance with a three valued well founded model is found.
|
the case in which an instance with a three valued well founded model is found.
|
||||||
Moreover, it can print the message “It requires the choice of a head atom from a non
|
Moreover, it can print the message “It requires the choice of a head atom from a non
|
||||||
ground head”: in this case, in order to answer the query, all the groundings of the
|
ground head”: in this case, in order to answer the query, all the groundings of the
|
||||||
culprit clause must be generated, which may be impossible for programs with
|
culprit clause must be generated, which may be impossible for programs with
|
||||||
function symbols.
|
function symbols.
|
||||||
<!--l. 169--><p class="indent"> When using <span
|
<!--l. 164--><p class="indent" > When using <span
|
||||||
class="cmtt-10">semcpl.pl</span>, you can print the execution process by using the
|
class="cmtt-10">semcpl.pl</span>, you can print the execution process by using the
|
||||||
command <span
|
command <span
|
||||||
class="cmtt-10">print. </span>after <span
|
class="cmtt-10">print. </span>after <span
|
||||||
@ -372,31 +312,25 @@ class="cmtt-10">context </span>is a list of atoms that are true in the context.
|
|||||||
<span
|
<span
|
||||||
class="cmtt-10">semcpl.pl </span>can print “Invalid program” in the case in which no execution process
|
class="cmtt-10">semcpl.pl </span>can print “Invalid program” in the case in which no execution process
|
||||||
exists.
|
exists.
|
||||||
<!--l. 174--><p class="indent"> When using <span
|
<!--l. 169--><p class="indent" > When using <span
|
||||||
class="cmtt-10">cpl.pl </span>you can print a partial execution model including all the
|
class="cmtt-10">cpl.pl </span>you can print a partial execution model including all the
|
||||||
clauses involved in the query issued with <span
|
clauses involved in the query issued with <span
|
||||||
class="cmtt-10">print. cpl.pl </span>can print the messages
|
class="cmtt-10">print. cpl.pl </span>can print the messages
|
||||||
“Uunsound program”, “It requires the choice of a head atom from a non ground
|
“Uunsound program”, “It requires the choice of a head atom from a non ground
|
||||||
head” and “Invalid program”.
|
head” and “Invalid program”.
|
||||||
<!--l. 177--><p class="indent"> The modules make use of a number of parameters in order to control their
|
<!--l. 172--><p class="indent" > The modules make use of a number of parameters in order to control their
|
||||||
behavior. They that can be set with the command
|
behavior. They that can be set with the command
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-13">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
set(parameter,value).
|
set(parameter,value).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 175--><p class="nopar" > from the Yap prompt after having loaded the module. The current value can be read
|
||||||
<!--l. 180--><p class="nopar"> from the Yap prompt after having loaded the module. The current value can be read
|
|
||||||
with
|
with
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-14">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
setting(parameter,Value).
|
setting(parameter,Value).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 180--><p class="nopar" > from the Yap prompt. The available parameters are:
|
||||||
<!--l. 185--><p class="nopar"> from the Yap prompt. The available parameters are:
|
|
||||||
<ul class="itemize1">
|
<ul class="itemize1">
|
||||||
<li class="itemize"><span class="obeylines-h"><span class="verb"><span
|
<li class="itemize"><span class="obeylines-h"><span class="verb"><span
|
||||||
class="cmtt-10">epsilon_parsing</span></span></span> (valid for all six modules): if (1 - the sum of the
|
class="cmtt-10">epsilon_parsing</span></span></span> (valid for all six modules): if (1 - the sum of the
|
||||||
@ -418,13 +352,10 @@ class="cmtt-10">m </span>is the number of the binary variable. The correspondenc
|
|||||||
between variables and clauses can be evinced from the message printed on the
|
between variables and clauses can be evinced from the message printed on the
|
||||||
screen, such as
|
screen, such as
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-15">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
Variables: [(2,[X=2,X1=1]),(2,[X=1,X1=0]),(1,[])]
|
Variables: [(2,[X=2,X1=1]),(2,[X=1,X1=0]),(1,[])]
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 194--><p class="nopar" > where the first element of each couple is the clause number of the input file
|
||||||
<!--l. 199--><p class="nopar"> where the first element of each couple is the clause number of the input file
|
|
||||||
(starting from 1). In the example above variable <span
|
(starting from 1). In the example above variable <span
|
||||||
class="cmtt-10">X0 </span>corresponds to clause <span
|
class="cmtt-10">X0 </span>corresponds to clause <span
|
||||||
class="cmtt-10">2</span>
|
class="cmtt-10">2</span>
|
||||||
@ -441,13 +372,10 @@ class="cmtt-10">graphviz </span>(<a
|
|||||||
href="www.graphviz.org" > www.graphviz.org </a>)
|
href="www.graphviz.org" > www.graphviz.org </a>)
|
||||||
using the command
|
using the command
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-16">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
dotty cpl.dot &
|
dotty cpl.dot &
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 203--><p class="nopar" >
|
||||||
<!--l. 208--><p class="nopar">
|
|
||||||
</li>
|
</li>
|
||||||
<li class="itemize"><span class="obeylines-h"><span class="verb"><span
|
<li class="itemize"><span class="obeylines-h"><span class="verb"><span
|
||||||
class="cmtt-10">ground_body</span></span></span> (valid for <span
|
class="cmtt-10">ground_body</span></span></span> (valid for <span
|
||||||
@ -460,27 +388,24 @@ class="cmtt-10">false</span>, ground
|
|||||||
constant. In the case where the body contains variables not in the
|
constant. In the case where the body contains variables not in the
|
||||||
head, setting it to false means that the body represents an existential
|
head, setting it to false means that the body represents an existential
|
||||||
event.</li></ul>
|
event.</li></ul>
|
||||||
<!--l. 212--><p class="noindent">
|
<!--l. 207--><p class="noindent" >
|
||||||
<h3 class="sectionHead"><span class="titlemark">5 </span> <a
|
<h3 class="sectionHead"><span class="titlemark">5 </span> <a
|
||||||
id="x1-50005"></a>Semantic Modules</h3>
|
id="x1-50005"></a>Semantic Modules</h3>
|
||||||
<!--l. 213--><p class="noindent">The three semantic modules need to produce a grounding of the program in order to
|
<!--l. 208--><p class="noindent" >The three semantic modules need to produce a grounding of the program in order to
|
||||||
compute the semantics. They require an extra file with extension <span
|
compute the semantics. They require an extra file with extension <span
|
||||||
class="cmtt-10">.uni </span>(for universe)
|
class="cmtt-10">.uni </span>(for universe)
|
||||||
in the same directory where the <span
|
in the same directory where the <span
|
||||||
class="cmtt-10">.cpl </span>file is.
|
class="cmtt-10">.cpl </span>file is.
|
||||||
<!--l. 216--><p class="indent"> There are two ways to specify how to ground a program. The first consists in
|
<!--l. 211--><p class="indent" > There are two ways to specify how to ground a program. The first consists in
|
||||||
providing the list of constants to which each variable can be instantiated. For
|
providing the list of constants to which each variable can be instantiated. For
|
||||||
example, in our case the current directory will contain a file <span
|
example, in our case the current directory will contain a file <span
|
||||||
class="cmtt-10">coin.uni </span>that is a
|
class="cmtt-10">coin.uni </span>that is a
|
||||||
Prolog file containing facts of the form
|
Prolog file containing facts of the form
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-17">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
universe(var_list,const_list).
|
universe(var_list,const_list).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 214--><p class="nopar" > where <span class="obeylines-h"><span class="verb"><span
|
||||||
<!--l. 219--><p class="nopar"> where <span class="obeylines-h"><span class="verb"><span
|
|
||||||
class="cmtt-10">var_list</span></span></span> is a list of variables names (each must be included in single quotes)
|
class="cmtt-10">var_list</span></span></span> is a list of variables names (each must be included in single quotes)
|
||||||
and <span class="obeylines-h"><span class="verb"><span
|
and <span class="obeylines-h"><span class="verb"><span
|
||||||
class="cmtt-10">const_list</span></span></span> is a list of constants. The semantic modules generate the grounding
|
class="cmtt-10">const_list</span></span></span> is a list of constants. The semantic modules generate the grounding
|
||||||
@ -490,29 +415,23 @@ class="cmtt-10">var_list</span></span></span> with the constants of
|
|||||||
class="cmtt-10">const_list</span></span></span>. Note that the variables are identified by name, so a variable with
|
class="cmtt-10">const_list</span></span></span>. Note that the variables are identified by name, so a variable with
|
||||||
the same name in two different clauses will be instantiated with the same
|
the same name in two different clauses will be instantiated with the same
|
||||||
constants.
|
constants.
|
||||||
<!--l. 222--><p class="indent"> The other way to specify how to ground a program consists in using mode and
|
<!--l. 217--><p class="indent" > The other way to specify how to ground a program consists in using mode and
|
||||||
type information. For each predicate, the file <span
|
type information. For each predicate, the file <span
|
||||||
class="cmtt-10">.uni </span>must contain a fact of the
|
class="cmtt-10">.uni </span>must contain a fact of the
|
||||||
form
|
form
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-18">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
mode(predicate(t1,...,tn)).
|
mode(predicate(t1,...,tn)).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 220--><p class="nopar" > that specifies the number and types of each argument of the predicate. Then, the list
|
||||||
<!--l. 225--><p class="nopar"> that specifies the number and types of each argument of the predicate. Then, the list
|
|
||||||
of constants that are in the domain of each type <span
|
of constants that are in the domain of each type <span
|
||||||
class="cmtt-10">ti </span>must be specified with a fact of
|
class="cmtt-10">ti </span>must be specified with a fact of
|
||||||
the form
|
the form
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-19">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
type(ti,list_of_constants).
|
type(ti,list_of_constants).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 225--><p class="nopar" > The file <span
|
||||||
<!--l. 230--><p class="nopar"> The file <span
|
|
||||||
class="cmtt-10">.uni </span>can contain both universe and mode declaration, the ones to be used
|
class="cmtt-10">.uni </span>can contain both universe and mode declaration, the ones to be used
|
||||||
depend on the value of the parameter <span
|
depend on the value of the parameter <span
|
||||||
class="cmtt-10">grounding</span>: with value <span
|
class="cmtt-10">grounding</span>: with value <span
|
||||||
@ -520,20 +439,18 @@ class="cmtt-10">variables</span>, the
|
|||||||
universe declarations are used, with value <span
|
universe declarations are used, with value <span
|
||||||
class="cmtt-10">modes </span>the mode declarations are
|
class="cmtt-10">modes </span>the mode declarations are
|
||||||
used.
|
used.
|
||||||
<!--l. 233--><p class="indent"> With <span
|
<!--l. 228--><p class="indent" > With <span
|
||||||
class="cmtt-10">semcpl.pl </span>only mode declarations can be used.
|
class="cmtt-10">semcpl.pl </span>only mode declarations can be used.
|
||||||
<!--l. 237--><p class="noindent">
|
<!--l. 232--><p class="noindent" >
|
||||||
<h3 class="sectionHead"><span class="titlemark">6 </span> <a
|
<h3 class="sectionHead"><span class="titlemark">6 </span> <a
|
||||||
id="x1-60006"></a>Extensions</h3>
|
id="x1-60006"></a>Extensions</h3>
|
||||||
<!--l. 238--><p class="noindent">In this section we will present the extensions to the syntax of LPADs and CP-logic
|
<!--l. 233--><p class="noindent" >In this section we will present the extensions to the syntax of LPADs and CP-logic
|
||||||
programs that <span
|
programs that <span
|
||||||
class="cmtt-10">cplint </span>can handle.
|
class="cmtt-10">cplint </span>can handle.
|
||||||
<!--l. 240--><p class="indent"> The first is the use of some standard Prolog predicates. The bodies can contain
|
<!--l. 235--><p class="indent" > The first is the use of some standard Prolog predicates. The bodies can contain
|
||||||
the built-in predicates:
|
the built-in predicates:
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-20">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
is/2
|
is/2
|
||||||
 <br />>/2
|
 <br />>/2
|
||||||
 <br /></2
|
 <br /></2
|
||||||
@ -549,55 +466,43 @@ is/2
|
|||||||
 <br />\==/2
|
 <br />\==/2
|
||||||
 <br />length/2
|
 <br />length/2
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 252--><p class="nopar" > The bodies can also contain the following library predicates:
|
||||||
<!--l. 257--><p class="nopar"> The bodies can also contain the following library predicates:
|
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-21">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
member/2
|
member/2
|
||||||
 <br />max_list/2
|
 <br />max_list/2
|
||||||
 <br />min_list/2
|
 <br />min_list/2
|
||||||
 <br />nth0/3
|
 <br />nth0/3
|
||||||
 <br />nth/3
|
 <br />nth/3
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 261--><p class="nopar" > plus the predicate
|
||||||
<!--l. 266--><p class="nopar"> plus the predicate
|
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-22">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
average/2
|
average/2
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 265--><p class="nopar" > that, given a list of numbers, computes its arithmetic mean.
|
||||||
<!--l. 270--><p class="nopar"> that, given a list of numbers, computes its arithmetic mean.
|
<!--l. 268--><p class="indent" > When using <span
|
||||||
<!--l. 273--><p class="indent"> When using <span
|
|
||||||
class="cmtt-10">lpadsld.pl</span>, the bodies can contain the predicates <span
|
class="cmtt-10">lpadsld.pl</span>, the bodies can contain the predicates <span
|
||||||
class="cmtt-10">setof/3 </span>and
|
class="cmtt-10">setof/3 </span>and
|
||||||
<span
|
<span
|
||||||
class="cmtt-10">bagof/3 </span>with the same meaning as in Prolog. Existential quantifiers are allowed in
|
class="cmtt-10">bagof/3 </span>with the same meaning as in Prolog. Existential quantifiers are allowed in
|
||||||
both, so for example the query
|
both, so for example the query
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-23">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
setof(Z, (term(X,Y))^foo(X,Y,Z), L).
|
setof(Z, (term(X,Y))^foo(X,Y,Z), L).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 271--><p class="nopar" > returns all the instantiations of <span
|
||||||
<!--l. 276--><p class="nopar"> returns all the instantiations of <span
|
|
||||||
class="cmtt-10">Z </span>such that there exists an instantiation of <span
|
class="cmtt-10">Z </span>such that there exists an instantiation of <span
|
||||||
class="cmtt-10">X </span>and <span
|
class="cmtt-10">X </span>and <span
|
||||||
class="cmtt-10">Y</span>
|
class="cmtt-10">Y</span>
|
||||||
for which <span
|
for which <span
|
||||||
class="cmtt-10">foo(X,Y,Z) </span>is true.
|
class="cmtt-10">foo(X,Y,Z) </span>is true.
|
||||||
<!--l. 279--><p class="indent"> An example of the use of <span
|
<!--l. 274--><p class="indent" > An example of the use of <span
|
||||||
class="cmtt-10">setof </span>and <span
|
class="cmtt-10">setof </span>and <span
|
||||||
class="cmtt-10">bagof </span>is in the file <span
|
class="cmtt-10">bagof </span>is in the file <span
|
||||||
class="cmtt-10">female.cpl</span>:
|
class="cmtt-10">female.cpl</span>:
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-24">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
male(C):M/P ; female(C):F/P:-
|
male(C):M/P ; female(C):F/P:-
|
||||||
 <br />    person(C),
|
 <br />    person(C),
|
||||||
 <br />    setof(Male,known_male(Male),LM),
|
 <br />    setof(Male,known_male(Male),LM),
|
||||||
@ -618,25 +523,22 @@ male(C):M/P ; female(C):F/P:-
|
|||||||
 <br />
|
 <br />
|
||||||
 <br />known_male(e).
|
 <br />known_male(e).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 295--><p class="nopar" > The disjunctive rule expresses the probability of a person of unknown sex of being
|
||||||
<!--l. 300--><p class="nopar"> The disjunctive rule expresses the probability of a person of unknown sex of being
|
|
||||||
male or female depending on the number of males and females that are known. This
|
male or female depending on the number of males and females that are known. This
|
||||||
is an example of the use of expressions in the probabilities in the head that depend
|
is an example of the use of expressions in the probabilities in the head that depend
|
||||||
on variables in the body. The probabilities are well defined because they always sum
|
on variables in the body. The probabilities are well defined because they always sum
|
||||||
to 1 (unless <span
|
to 1 (unless <span
|
||||||
class="cmtt-10">P </span>is 0).
|
class="cmtt-10">P </span>is 0).
|
||||||
<!--l. 304--><p class="indent"> Another use of <span
|
<!--l. 299--><p class="indent" > Another use of <span
|
||||||
class="cmtt-10">setof </span>and <span
|
class="cmtt-10">setof </span>and <span
|
||||||
class="cmtt-10">bagof </span>is to have an attribute depend on an
|
class="cmtt-10">bagof </span>is to have an attribute depend on an
|
||||||
aggregate function of another attribute, similarly to what is done in PRM and
|
aggregate function of another attribute, similarly to what is done in PRM and
|
||||||
CLP(BN).
|
CLP(BN).
|
||||||
<!--l. 306--><p class="indent"> So, in the classical school example (available in <span
|
<!--l. 301--><p class="indent" > So, in the classical school example (available in <span
|
||||||
class="cmtt-10">student.cpl</span>) you can find the
|
class="cmtt-10">student.cpl</span>) you can find the
|
||||||
following clauses:
|
following clauses:
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-25">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
student_rank(S,h):0.6 ; student_rank(S,l):0.4:-
|
student_rank(S,h):0.6 ; student_rank(S,l):0.4:-
|
||||||
 <br />    bagof(G,R^(registr_stu(R,S),registr_gr(R,G)),L),
|
 <br />    bagof(G,R^(registr_stu(R,S),registr_gr(R,G)),L),
|
||||||
 <br />    average(L,Av),Av>1.5.
|
 <br />    average(L,Av),Av>1.5.
|
||||||
@ -645,8 +547,7 @@ student_rank(S,h):0.6 ; student_rank(S,l):0.4:-
|
|||||||
 <br />    bagof(G,R^(registr_stu(R,S),registr_gr(R,G)),L),
|
 <br />    bagof(G,R^(registr_stu(R,S),registr_gr(R,G)),L),
|
||||||
 <br />    average(L,Av),Av =< 1.5.
|
 <br />    average(L,Av),Av =< 1.5.
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 311--><p class="nopar" > where <span class="obeylines-h"><span class="verb"><span
|
||||||
<!--l. 316--><p class="nopar"> where <span class="obeylines-h"><span class="verb"><span
|
|
||||||
class="cmtt-10">registr_stu(R,S)</span></span></span> expresses that registration <span
|
class="cmtt-10">registr_stu(R,S)</span></span></span> expresses that registration <span
|
||||||
class="cmtt-10">R </span>refers to student <span
|
class="cmtt-10">R </span>refers to student <span
|
||||||
class="cmtt-10">S </span>and
|
class="cmtt-10">S </span>and
|
||||||
@ -656,7 +557,7 @@ class="cmtt-10">R </span>reports grade <span
|
|||||||
class="cmtt-10">G </span>which is a natural
|
class="cmtt-10">G </span>which is a natural
|
||||||
number. The two clauses express a dependency of the rank of the student from the
|
number. The two clauses express a dependency of the rank of the student from the
|
||||||
average of her grades.
|
average of her grades.
|
||||||
<!--l. 319--><p class="indent"> Another extension can be used with <span
|
<!--l. 314--><p class="indent" > Another extension can be used with <span
|
||||||
class="cmtt-10">lpadsld.pl </span>in order to be able to represent
|
class="cmtt-10">lpadsld.pl </span>in order to be able to represent
|
||||||
reference uncertainty of PRMs. Reference uncertainty means that the link structure
|
reference uncertainty of PRMs. Reference uncertainty means that the link structure
|
||||||
of a relational model is not fixed but is uncertain: this is represented by having the
|
of a relational model is not fixed but is uncertain: this is represented by having the
|
||||||
@ -668,31 +569,25 @@ selected uniformly from certain sets, the following clauses can be used (see fil
|
|||||||
<span class="obeylines-h"><span class="verb"><span
|
<span class="obeylines-h"><span class="verb"><span
|
||||||
class="cmtt-10">paper_ref_simple.cpl</span></span></span>):
|
class="cmtt-10">paper_ref_simple.cpl</span></span></span>):
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-26">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
uniform(cites_cited(C,P),P,L):-
|
uniform(cites_cited(C,P),P,L):-
|
||||||
 <br />    bagof(Pap,paper_topic(Pap,theory),L).
|
 <br />    bagof(Pap,paper_topic(Pap,theory),L).
|
||||||
 <br />
|
 <br />
|
||||||
 <br />uniform(cites_citing(C,P),P,L):-
|
 <br />uniform(cites_citing(C,P),P,L):-
|
||||||
 <br />    bagof(Pap,paper_topic(Pap,ai),L).
|
 <br />    bagof(Pap,paper_topic(Pap,ai),L).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 321--><p class="nopar" > The first clauses states that the paper <span
|
||||||
<!--l. 326--><p class="nopar"> The first clauses states that the paper <span
|
|
||||||
class="cmtt-10">P </span>cited in a citation <span
|
class="cmtt-10">P </span>cited in a citation <span
|
||||||
class="cmtt-10">C </span>is selected
|
class="cmtt-10">C </span>is selected
|
||||||
uniformly from the set of all papers with topic theory. The second clauses
|
uniformly from the set of all papers with topic theory. The second clauses
|
||||||
expresses that the citing paper is selected uniformly from the papers with topic
|
expresses that the citing paper is selected uniformly from the papers with topic
|
||||||
ai.
|
ai.
|
||||||
<!--l. 331--><p class="indent"> These clauses make use of the predicate
|
<!--l. 326--><p class="indent" > These clauses make use of the predicate
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-27">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
uniform(Atom,Variable,List)
|
uniform(Atom,Variable,List)
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 329--><p class="nopar" > in the head, where <span
|
||||||
<!--l. 334--><p class="nopar"> in the head, where <span
|
|
||||||
class="cmtt-10">Atom </span>must contain <span
|
class="cmtt-10">Atom </span>must contain <span
|
||||||
class="cmtt-10">Variable</span>. The meaning is the following:
|
class="cmtt-10">Variable</span>. The meaning is the following:
|
||||||
the set of all the atoms obtained by instantiating <span
|
the set of all the atoms obtained by instantiating <span
|
||||||
@ -705,12 +600,10 @@ class="cmmi-10">∕N </span>where <span
|
|||||||
class="cmmi-10">N </span>is the length of
|
class="cmmi-10">N </span>is the length of
|
||||||
<span
|
<span
|
||||||
class="cmtt-10">List</span>.
|
class="cmtt-10">List</span>.
|
||||||
<!--l. 338--><p class="indent"> A more elaborate example is present in file <span class="obeylines-h"><span class="verb"><span
|
<!--l. 333--><p class="indent" > A more elaborate example is present in file <span class="obeylines-h"><span class="verb"><span
|
||||||
class="cmtt-10">paper_ref.cpl</span></span></span>:
|
class="cmtt-10">paper_ref.cpl</span></span></span>:
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-28">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
uniform(cites_citing(C,P),P,L):-
|
uniform(cites_citing(C,P),P,L):-
|
||||||
 <br />    setof(Pap,paper(Pap),L).
|
 <br />    setof(Pap,paper(Pap),L).
|
||||||
 <br />
|
 <br />
|
||||||
@ -723,22 +616,19 @@ uniform(cites_citing(C,P),P,L):-
|
|||||||
 <br />uniform(cites_cited(C,P),P,L):-
|
 <br />uniform(cites_cited(C,P),P,L):-
|
||||||
 <br />    cites_cited_group(C,T),bagof(Pap,paper_topic(Pap,T),L).
|
 <br />    cites_cited_group(C,T),bagof(Pap,paper_topic(Pap,T),L).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 346--><p class="nopar" > where the cited paper depends on the topic of the citing paper. In particular, if the
|
||||||
<!--l. 351--><p class="nopar"> where the cited paper depends on the topic of the citing paper. In particular, if the
|
|
||||||
topic is theory, the cited paper is selected uniformly from the papers about theory
|
topic is theory, the cited paper is selected uniformly from the papers about theory
|
||||||
with probability 0.9 and from the papers about ai with probability 0.1. if
|
with probability 0.9 and from the papers about ai with probability 0.1. if
|
||||||
the topic is ai, the cited paper is selected uniformly from the papers about
|
the topic is ai, the cited paper is selected uniformly from the papers about
|
||||||
theory with probability 0.01 and from the papers about ai with probability
|
theory with probability 0.01 and from the papers about ai with probability
|
||||||
0.99.
|
0.99.
|
||||||
<!--l. 354--><p class="indent"> PRMs take into account as well existence uncertainty, where the existence of
|
<!--l. 349--><p class="indent" > PRMs take into account as well existence uncertainty, where the existence of
|
||||||
instances is also probabilistic. For example, in the paper domain, the total number of
|
instances is also probabilistic. For example, in the paper domain, the total number of
|
||||||
citations may be unknown and a citation between any two paper may have a
|
citations may be unknown and a citation between any two paper may have a
|
||||||
probability of existing. For example, a citation between two paper may be more
|
probability of existing. For example, a citation between two paper may be more
|
||||||
probable if they are about the same topic:
|
probable if they are about the same topic:
|
||||||
|
|
||||||
<table
|
<div class="verbatim" id="verbatim-29">
|
||||||
class="verbatim"><tr class="verbatim"><td
|
|
||||||
class="verbatim"><div class="verbatim">
|
|
||||||
cites(X,Y):0.005 :-
|
cites(X,Y):0.005 :-
|
||||||
 <br />    paper_topic(X,theory),paper_topic(Y,theory).
|
 <br />    paper_topic(X,theory),paper_topic(Y,theory).
|
||||||
 <br />
|
 <br />
|
||||||
@ -751,8 +641,7 @@ cites(X,Y):0.005 :-
|
|||||||
 <br />cites(X,Y):0.008 :-
|
 <br />cites(X,Y):0.008 :-
|
||||||
 <br />    paper_topic(X,ai),paper_topic(Y,ai).
|
 <br />    paper_topic(X,ai),paper_topic(Y,ai).
|
||||||
</div>
|
</div>
|
||||||
</td></tr></table>
|
<!--l. 362--><p class="nopar" > This is an example where the probabilities in the head do not sum up to one so the
|
||||||
<!--l. 367--><p class="nopar"> This is an example where the probabilities in the head do not sum up to one so the
|
|
||||||
null event is automatically added to the head. The first clause states that, if the topic
|
null event is automatically added to the head. The first clause states that, if the topic
|
||||||
of a paper <span
|
of a paper <span
|
||||||
class="cmtt-10">X </span>is theory and of paper <span
|
class="cmtt-10">X </span>is theory and of paper <span
|
||||||
@ -761,10 +650,10 @@ there is a citation from <span
|
|||||||
class="cmtt-10">X </span>to <span
|
class="cmtt-10">X </span>to <span
|
||||||
class="cmtt-10">Y</span>. The other clauses consider the remaining cases for the
|
class="cmtt-10">Y</span>. The other clauses consider the remaining cases for the
|
||||||
topics.
|
topics.
|
||||||
<!--l. 372--><p class="noindent">
|
<!--l. 367--><p class="noindent" >
|
||||||
<h3 class="sectionHead"><span class="titlemark">7 </span> <a
|
<h3 class="sectionHead"><span class="titlemark">7 </span> <a
|
||||||
id="x1-70007"></a>Additional Files</h3>
|
id="x1-70007"></a>Additional Files</h3>
|
||||||
<!--l. 373--><p class="noindent">In the directory where Yap keeps the library files (usually <span
|
<!--l. 368--><p class="noindent" >In the directory where Yap keeps the library files (usually <span
|
||||||
class="cmtt-10">/usr/local/share/ Yap</span>)
|
class="cmtt-10">/usr/local/share/ Yap</span>)
|
||||||
you can find the directory <span
|
you can find the directory <span
|
||||||
class="cmtt-10">cplint </span>that contains the files:
|
class="cmtt-10">cplint </span>that contains the files:
|
||||||
@ -861,13 +750,13 @@ class="cmtt-10">student.cpl</span></span></span>: student example from Figure 1.
|
|||||||
href="#XGetFri01-BC">5</a>]</span>.
|
href="#XGetFri01-BC">5</a>]</span>.
|
||||||
</li>
|
</li>
|
||||||
<li class="itemize"><span
|
<li class="itemize"><span
|
||||||
class="cmtt-10">win.cpl, light.cpl, trigger.cpl, throws.cpl, hiv.cpl,</span>
|
class="cmtt-10">win.cpl, light.cpl, trigger.cpl, throws.cpl, hiv.cpl,</span><br
|
||||||
<br class="newline" /> <span
|
class="newline" /> <span
|
||||||
class="cmtt-10">invalid.cpl</span>: programs taken from <span class="cite">[<a
|
class="cmtt-10">invalid.cpl</span>: programs taken from <span class="cite">[<a
|
||||||
href="#XCP-logic-unp">13</a>]</span>. <span
|
href="#XCP-logic-unp">13</a>]</span>. <span
|
||||||
class="cmtt-10">invalid.cpl </span>is an example
|
class="cmtt-10">invalid.cpl </span>is an example
|
||||||
of a program that is invalid but sound.</li></ul>
|
of a program that is invalid but sound.</li></ul>
|
||||||
<!--l. 398--><p class="noindent">The files <span
|
<!--l. 393--><p class="noindent" >The files <span
|
||||||
class="cmtt-10">*.uni </span>that are present for some of the examples are used by the
|
class="cmtt-10">*.uni </span>that are present for some of the examples are used by the
|
||||||
semantical modules. Some of the example files contain in an initial comment
|
semantical modules. Some of the example files contain in an initial comment
|
||||||
some queries together with their result.
|
some queries together with their result.
|
||||||
@ -875,18 +764,18 @@ class="cmtt-10">*.uni </span>that are present for some of the examples are used
|
|||||||
<li class="itemize">Subdirectory <span
|
<li class="itemize">Subdirectory <span
|
||||||
class="cmtt-10">doc</span>: contains this manual in latex, html and pdf.</li></ul>
|
class="cmtt-10">doc</span>: contains this manual in latex, html and pdf.</li></ul>
|
||||||
|
|
||||||
<!--l. 401--><p class="noindent">
|
<!--l. 396--><p class="noindent" >
|
||||||
<h3 class="sectionHead"><span class="titlemark">8 </span> <a
|
<h3 class="sectionHead"><span class="titlemark">8 </span> <a
|
||||||
id="x1-80008"></a>License</h3>
|
id="x1-80008"></a>License</h3>
|
||||||
<!--l. 406--><p class="noindent"><span
|
<!--l. 401--><p class="noindent" ><span
|
||||||
class="cmtt-10">cplint</span>, as Yap, follows the Artistic License 2.0 that you can find in Yap CVS root
|
class="cmtt-10">cplint</span>, as Yap, follows the Artistic License 2.0 that you can find in Yap CVS root
|
||||||
dir. The copyright is by Fabrizio Riguzzi.
|
dir. The copyright is by Fabrizio Riguzzi.
|
||||||
<!--l. 411--><p class="indent"> The program uses the library <a
|
<!--l. 406--><p class="indent" > The program uses the library <a
|
||||||
href="http://vlsi.colorado.edu/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}fabio/" > CUDD </a> for manipulating BDDs that is included in
|
href="http://vlsi.colorado.edu/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}fabio/" > CUDD </a> for manipulating BDDs that is included in
|
||||||
glu. For the use of CUDD, the following license must be accepted:
|
glu. For the use of CUDD, the following license must be accepted:
|
||||||
<!--l. 416--><p class="indent"> Copyright (c) 1995-2004, Regents of the University of Colorado
|
<!--l. 411--><p class="indent" > Copyright (c) 1995-2004, Regents of the University of Colorado
|
||||||
<!--l. 418--><p class="indent"> All rights reserved.
|
<!--l. 413--><p class="indent" > All rights reserved.
|
||||||
<!--l. 420--><p class="indent"> Redistribution and use in source and binary forms, with or without modification,
|
<!--l. 415--><p class="indent" > Redistribution and use in source and binary forms, with or without modification,
|
||||||
are permitted provided that the following conditions are met:
|
are permitted provided that the following conditions are met:
|
||||||
<ul class="itemize1">
|
<ul class="itemize1">
|
||||||
<li class="itemize">Redistributions of source code must retain the above copyright notice, this
|
<li class="itemize">Redistributions of source code must retain the above copyright notice, this
|
||||||
@ -899,8 +788,8 @@ are permitted provided that the following conditions are met:
|
|||||||
<li class="itemize">Neither the name of the University of Colorado nor the names of its
|
<li class="itemize">Neither the name of the University of Colorado nor the names of its
|
||||||
contributors may be used to endorse or promote products derived from
|
contributors may be used to endorse or promote products derived from
|
||||||
this software without specific prior written permission.</li></ul>
|
this software without specific prior written permission.</li></ul>
|
||||||
<!--l. 437--><p class="noindent">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
|
<!--l. 432--><p class="noindent" >THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS <br
|
||||||
<br class="newline" />AND CONTRIBUTORS ”AS IS” AND ANY EXPRESS OR IMPLIED
|
class="newline" />AND CONTRIBUTORS ”AS IS” AND ANY EXPRESS OR IMPLIED
|
||||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
@ -908,12 +797,12 @@ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|||||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
INTERRUPTION) HOWEVER CAU-SED
|
INTERRUPTION) HOWEVER CAU-SED <br
|
||||||
<br class="newline" />AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
class="newline" />AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
<!--l. 451--><p class="indent"> <span
|
<!--l. 446--><p class="indent" > <span
|
||||||
class="cmtt-10">lpad.pl</span>, <span
|
class="cmtt-10">lpad.pl</span>, <span
|
||||||
class="cmtt-10">semlpad.pl </span>and <span
|
class="cmtt-10">semlpad.pl </span>and <span
|
||||||
class="cmtt-10">cpl.pl </span>are based on the SLG system by <a
|
class="cmtt-10">cpl.pl </span>are based on the SLG system by <a
|
||||||
|
Binary file not shown.
@ -7,6 +7,7 @@
|
|||||||
\documentclass{article}
|
\documentclass{article}
|
||||||
\usepackage{graphicx}
|
\usepackage{graphicx}
|
||||||
\DeclareGraphicsExtensions{.png, .gif, .jpg}
|
\DeclareGraphicsExtensions{.png, .gif, .jpg}
|
||||||
|
\newcommand{\url}[1]{\Link[#1]{}{} #1 \EndLink}
|
||||||
\newcommand{\href}[2]{\Link[#1]{}{} #2 \EndLink}
|
\newcommand{\href}[2]{\Link[#1]{}{} #2 \EndLink}
|
||||||
\newcommand{\hypertarget}[2]{\Link[]{}{#1} #2 \EndLink}
|
\newcommand{\hypertarget}[2]{\Link[]{}{#1} #2 \EndLink}
|
||||||
\newcommand{\hyperlink}[2]{\Link[]{#1}{} #2 \EndLink}
|
\newcommand{\hyperlink}[2]{\Link[]{#1}{} #2 \EndLink}
|
||||||
@ -15,7 +16,7 @@
|
|||||||
|
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\title{\texttt{cplint} Version beta2.0 Manual}
|
\title{\texttt{cplint} Version 2.0 Manual}
|
||||||
|
|
||||||
|
|
||||||
\author{Fabrizio Riguzzi\\
|
\author{Fabrizio Riguzzi\\
|
||||||
@ -57,39 +58,33 @@ The modules for answering queries using the definition of the semantics of LPADs
|
|||||||
%For program with function symbols, the semantics of LPADs and CP-logic are not defined. However, the interpreter accepts programs with function symbols and, if it does not go into a loop, it returns an answer. What is the meaning of this answer is subject of current study.
|
%For program with function symbols, the semantics of LPADs and CP-logic are not defined. However, the interpreter accepts programs with function symbols and, if it does not go into a loop, it returns an answer. What is the meaning of this answer is subject of current study.
|
||||||
|
|
||||||
\section{Installation}
|
\section{Installation}
|
||||||
\texttt{cplint} is distributed in source code in the CVS version of Yap. It includes Prolog and C files. Download it by following the instruction in \href{http://www.ncc.up.pt/~vsc/Yap/downloads.html}{http://www.ncc.up.pt/$\sim$vsc/Yap/downloads.html}.
|
\texttt{cplint} is distributed in source code in the git version of Yap. It includes Prolog and C files. Download it by following the instruction in \url{http://www.ncc.up.pt/~vsc/Yap/downloads.html}.
|
||||||
|
|
||||||
\texttt{cplint} requires glu (a subpackage of vis) and glib-2.0.
|
\texttt{cplint} requires cudd and glib-2.0.
|
||||||
You can download glu from \href{http://vlsi.colorado.edu/~vis/getting_VIS_2.1.html}{http://vlsi.colorado.edu/$\sim$vis/getting\_VIS\_2.1.html}
|
You can download cudd from \url{http://vlsi.colorado.edu/~fabio/CUDD/}.
|
||||||
You can download glib-2.0 (version $\geq 2.0$) from \href{http://www.gtk.org/}{http://www.gtk.org/}. This is a standard GNU package
|
You can download glib-2.0 (version $\geq 2.0$) from \url{http://www.gtk.org/}. This is a standard GNU package
|
||||||
so it is easy to install it using the package management software of your Linux or Cygwin
|
so it is easy to install it using the package management software of your Linux or Cygwin
|
||||||
distribution.
|
distribution.
|
||||||
|
|
||||||
Install glu:
|
Compile cudd:
|
||||||
\begin{enumerate}
|
\begin{enumerate}
|
||||||
\item downlad \texttt{glu-2.1.tar.gz}
|
\item downlad \texttt{cudd-2.4.2.tar.gz}
|
||||||
\item decompress it
|
\item decompress it
|
||||||
\item \texttt{cd glu-2.1}
|
\item \texttt{cd cudd-2.4.2}
|
||||||
\item \texttt{mkdir arch}
|
\item check makefile options
|
||||||
\item \texttt{cd arch}
|
|
||||||
\item \texttt{../configure}
|
|
||||||
\item \texttt{make}
|
\item \texttt{make}
|
||||||
\item \texttt{su}
|
|
||||||
\item \texttt{make install}
|
|
||||||
\end{enumerate}
|
\end{enumerate}
|
||||||
This will install glu into \texttt{/usr/local}, if you want to install to a different \texttt{DIR}
|
|
||||||
use \texttt{../configure --prefix DIR}
|
|
||||||
|
|
||||||
Install Yap together with \texttt{cplint}:
|
Install Yap together with \texttt{cplint}:
|
||||||
when compiling Yap following the instuction of the \texttt{INSTALL} file in the root of the Yap folder, use
|
when compiling Yap following the instuction of the \texttt{INSTALL} file in the root of the Yap folder, use
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
configure --enable-cplint
|
configure --enable-cplint=DIR
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
Under Windows, you have to use Cygwin (glu does not compile under MinGW), so\\
|
Under Windows, you have to use Cygwin (glu does not compile under MinGW), so\\
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
configure --enable-cplint --enable-cygwin
|
configure --enable-cplint=DIR --enable-cygwin
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
If you installed glu in \texttt{DIR}, use \texttt{--enable-cplint=DIR}
|
where \texttt{DIR} is the path to the directory \texttt{cudd-2.4.2} (including \texttt{cudd-2.4.2}).
|
||||||
|
|
||||||
After having performed \texttt{make install} you can do \texttt{make installcheck} that will execute a suite of tests of the various programs. If no error is reported you have a working installation of \texttt{cplint}.
|
After having performed \texttt{make install} you can do \texttt{make installcheck} that will execute a suite of tests of the various programs. If no error is reported you have a working installation of \texttt{cplint}.
|
||||||
|
|
||||||
@ -201,7 +196,7 @@ Variables: [(2,[X=2,X1=1]),(2,[X=1,X1=0]),(1,[])]
|
|||||||
In the example above variable \texttt{X0} corresponds to clause \texttt{2} with the substitutions \texttt{X=2,X1=1},
|
In the example above variable \texttt{X0} corresponds to clause \texttt{2} with the substitutions \texttt{X=2,X1=1},
|
||||||
variable \texttt{X1} corresponds to clause \texttt{2} with the substitutions \texttt{X=1,X1=0} and
|
variable \texttt{X1} corresponds to clause \texttt{2} with the substitutions \texttt{X=1,X1=0} and
|
||||||
variable \texttt{X2} corresponds to clause \texttt{1} with the empty substitution.
|
variable \texttt{X2} corresponds to clause \texttt{1} with the empty substitution.
|
||||||
You can view the graph with \texttt{graphviz} (\href{www.graphviz.org}{www.graphviz.org}) using the
|
You can view the graph with \texttt{graphviz} (\url{www.graphviz.org}) using the
|
||||||
command
|
command
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
dotty cpl.dot &
|
dotty cpl.dot &
|
||||||
|
Reference in New Issue
Block a user