diff --git a/packages/cplint/doc/manual.css b/packages/cplint/doc/manual.css index 1f45d11a5..1addc2ca6 100644 --- a/packages/cplint/doc/manual.css +++ b/packages/cplint/doc/manual.css @@ -1,123 +1,123 @@ - -/* start css.sty */ -.cmr-7{font-size:70%;} -.cmmi-7{font-size:70%;font-style: italic;} -.cmmi-10{font-style: italic;} -.cmr-17{font-size:170%;} -.cmtt-12x-x-144{font-size:172%;font-family: monospace;} -.cmtt-12x-x-144{font-family: monospace;} -.cmr-12{font-size:120%;} -.cmtt-10{font-family: monospace;} -.cmtt-10{font-family: monospace;} -.cmbx-10{ font-weight: bold;} -.cmti-10{ font-style: italic;} -p.noindent { text-indent: 0em } -td p.noindent { text-indent: 0em; margin-top:0em; } -p.nopar { text-indent: 0em; } -p.indent{ text-indent: 1.5em } -@media print {div.crosslinks {visibility:hidden;}} -a img { border-top: 0; border-left: 0; border-right: 0; } -center { margin-top:1em; margin-bottom:1em; } -td center { margin-top:0em; margin-bottom:0em; } -.Canvas { position:relative; } -img.math{vertical-align:middle;} -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;} -.enumerate2 {list-style-type:lower-alpha;} -.enumerate3 {list-style-type:lower-roman;} -.enumerate4 {list-style-type:upper-alpha;} -div.newtheorem { margin-bottom: 2em; margin-top: 2em;} -.obeylines-h,.obeylines-v {white-space: nowrap; } -div.obeylines-v p { margin-top:0; margin-bottom:0; } -.overline{ text-decoration:overline; } -.overline img{ border-top: 1px solid black; } -td.displaylines {text-align:center; white-space:nowrap;} -.centerline {text-align:center;} -.rightline {text-align:right;} -div.verbatim {font-family: monospace; white-space: nowrap; text-align:left; clear:both; } -.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.minipage{width:100%;} -div.center, div.center div.center {text-align: center; margin-left:1em; margin-right:1em;} -div.center div {text-align: left;} -div.flushright, div.flushright div.flushright {text-align: right;} -div.flushright div {text-align: left;} -div.flushleft {text-align: left;} -.underline{ text-decoration:underline; } -.underline img{ border-bottom: 1px solid black; margin-bottom:1pt; } -.framebox-c, .framebox-l, .framebox-r { padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; } -.framebox-c {text-align:center;} -.framebox-l {text-align:left;} -.framebox-r {text-align:right;} -span.thank-mark{ vertical-align: super } -span.footnote-mark sup.textsuperscript, span.footnote-mark a sup.textsuperscript{ font-size:80%; } -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 {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.td01{ margin-left:0pt; margin-right:5pt; } -div.td10{ margin-left:5pt; margin-right:0pt; } -div.td11{ margin-left:5pt; margin-right:5pt; } -table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; } -td.td00{ padding-left:0pt; padding-right:0pt; } -td.td01{ padding-left:0pt; padding-right:5pt; } -td.td10{ padding-left:5pt; padding-right:0pt; } -td.td11{ padding-left:5pt; padding-right:5pt; } -table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; } -.hline hr, .cline hr{ height : 1px; margin:0px; } -.tabbing-right {text-align:right;} -span.TEX {letter-spacing: -0.125em; } -span.TEX span.E{ position:relative;top:0.5ex;left:-0.0417em;} -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.TEX{ position:relative; left: -0.4em; } -div.float, div.figure {margin-left: auto; margin-right: auto;} -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 p{margin-top:0.4em; margin-bottom:0.4em;} -table.equation {width:100%;} -.equation td{text-align:center; } -td.equation { margin-top:1em; margin-bottom:1em; } -td.equation-label { width:5%; text-align:center; } -td.eqnarray4 { width:5%; white-space: normal; } -td.eqnarray2 { width:5%; } -table.eqnarray-star, table.eqnarray {width:100%;} -div.eqnarray{text-align:center;} -div.array {text-align:center;} -div.pmatrix {text-align:center;} -table.pmatrix {width:100%;} -span.pmatrix img{vertical-align:middle;} -div.pmatrix {text-align:center;} -table.pmatrix {width:100%;} -span.bar-css {text-decoration:overline;} -img.cdots{vertical-align:middle;} -.partToc a, .partToc, .likepartToc a, .likepartToc {line-height: 200%; font-weight:bold; font-size:110%;} -.index-item, .index-subitem, .index-subsubitem {display:block} -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} -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; } -.paragraphHead, .likeparagraphHead { margin-top:2em; font-weight: bold;} -.subparagraphHead, .likesubparagraphHead { font-weight: bold;} -.quote {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; margin-right:1em; text-align:justify;} -.verse{white-space:nowrap; margin-left:2em} -div.maketitle {text-align:center;} -h2.titleHead{text-align:center;} -div.maketitle{ margin-bottom: 2em; } -div.author, div.date {text-align:center;} -div.thanks{text-align:left; margin-left:10%; font-size:85%; font-style:italic; } -div.author{white-space: nowrap;} -.quotation {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; } -.abstract p {margin-left:5%; margin-right:5%;} -div.abstract {width:100%;} -.figure img.graphics {margin-left:10%;} -/* end css.sty */ - + +/* start css.sty */ +.cmr-7{font-size:70%;} +.cmmi-7{font-size:70%;font-style: italic;} +.cmmi-10{font-style: italic;} +.cmr-17{font-size:170%;} +.cmtt-12x-x-144{font-size:172%;font-family: monospace;} +.cmtt-12x-x-144{font-family: monospace;} +.cmr-12{font-size:120%;} +.cmtt-10{font-family: monospace;} +.cmtt-10{font-family: monospace;} +.cmbx-10{ font-weight: bold;} +.cmti-10{ font-style: italic;} +p.noindent { text-indent: 0em } +td p.noindent { text-indent: 0em; margin-top:0em; } +p.nopar { text-indent: 0em; } +p.indent{ text-indent: 1.5em } +@media print {div.crosslinks {visibility:hidden;}} +a img { border-top: 0; border-left: 0; border-right: 0; } +center { margin-top:1em; margin-bottom:1em; } +td center { margin-top:0em; margin-bottom:0em; } +.Canvas { position:relative; } +img.math{vertical-align:middle;} +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;} +.enumerate2 {list-style-type:lower-alpha;} +.enumerate3 {list-style-type:lower-roman;} +.enumerate4 {list-style-type:upper-alpha;} +div.newtheorem { margin-bottom: 2em; margin-top: 2em;} +.obeylines-h,.obeylines-v {white-space: nowrap; } +div.obeylines-v p { margin-top:0; margin-bottom:0; } +.overline{ text-decoration:overline; } +.overline img{ border-top: 1px solid black; } +td.displaylines {text-align:center; white-space:nowrap;} +.centerline {text-align:center;} +.rightline {text-align:right;} +div.verbatim {font-family: monospace; white-space: nowrap; text-align:left; clear:both; } +.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.minipage{width:100%;} +div.center, div.center div.center {text-align: center; margin-left:1em; margin-right:1em;} +div.center div {text-align: left;} +div.flushright, div.flushright div.flushright {text-align: right;} +div.flushright div {text-align: left;} +div.flushleft {text-align: left;} +.underline{ text-decoration:underline; } +.underline img{ border-bottom: 1px solid black; margin-bottom:1pt; } +.framebox-c, .framebox-l, .framebox-r { padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; } +.framebox-c {text-align:center;} +.framebox-l {text-align:left;} +.framebox-r {text-align:right;} +span.thank-mark{ vertical-align: super } +span.footnote-mark sup.textsuperscript, span.footnote-mark a sup.textsuperscript{ font-size:80%; } +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 {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.td01{ margin-left:0pt; margin-right:5pt; } +div.td10{ margin-left:5pt; margin-right:0pt; } +div.td11{ margin-left:5pt; margin-right:5pt; } +table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; } +td.td00{ padding-left:0pt; padding-right:0pt; } +td.td01{ padding-left:0pt; padding-right:5pt; } +td.td10{ padding-left:5pt; padding-right:0pt; } +td.td11{ padding-left:5pt; padding-right:5pt; } +table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; } +.hline hr, .cline hr{ height : 1px; margin:0px; } +.tabbing-right {text-align:right;} +span.TEX {letter-spacing: -0.125em; } +span.TEX span.E{ position:relative;top:0.5ex;left:-0.0417em;} +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.TEX{ position:relative; left: -0.4em; } +div.float, div.figure {margin-left: auto; margin-right: auto;} +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 p{margin-top:0.4em; margin-bottom:0.4em;} +table.equation {width:100%;} +.equation td{text-align:center; } +td.equation { margin-top:1em; margin-bottom:1em; } +td.equation-label { width:5%; text-align:center; } +td.eqnarray4 { width:5%; white-space: normal; } +td.eqnarray2 { width:5%; } +table.eqnarray-star, table.eqnarray {width:100%;} +div.eqnarray{text-align:center;} +div.array {text-align:center;} +div.pmatrix {text-align:center;} +table.pmatrix {width:100%;} +span.pmatrix img{vertical-align:middle;} +div.pmatrix {text-align:center;} +table.pmatrix {width:100%;} +span.bar-css {text-decoration:overline;} +img.cdots{vertical-align:middle;} +.partToc a, .partToc, .likepartToc a, .likepartToc {line-height: 200%; font-weight:bold; font-size:110%;} +.index-item, .index-subitem, .index-subsubitem {display:block} +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} +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; } +.paragraphHead, .likeparagraphHead { margin-top:2em; font-weight: bold;} +.subparagraphHead, .likesubparagraphHead { font-weight: bold;} +.quote {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; margin-right:1em; text-align:justify;} +.verse{white-space:nowrap; margin-left:2em} +div.maketitle {text-align:center;} +h2.titleHead{text-align:center;} +div.maketitle{ margin-bottom: 2em; } +div.author, div.date {text-align:center;} +div.thanks{text-align:left; margin-left:10%; font-size:85%; font-style:italic; } +div.author{white-space: nowrap;} +.quotation {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; } +.abstract p {margin-left:5%; margin-right:5%;} +div.abstract {width:100%;} +.figure img.graphics {margin-left:10%;} +/* end css.sty */ + diff --git a/packages/cplint/doc/manual.html b/packages/cplint/doc/manual.html index f3b62bd24..be84d3496 100644 --- a/packages/cplint/doc/manual.html +++ b/packages/cplint/doc/manual.html @@ -1,1523 +1,1522 @@ - - -cplint Manual - - - - - - - - -
- - - -

cplint Manual

-
Fabrizio Riguzzi -
fabrizio.riguzzi@unife.it

-
October 10, 2011
-
-

1 Introduction

-

cplint is a suite of programs for reasoning with ICL [13], LPADs [2223] and -CP-logic programs [2021]. It contains programs both for inference and -learning. -

-

2 Installation

-

cplint is distributed in source code in the source code development tree of Yap. It -includes Prolog and C files. Download it by following the instruction in -http://www.ncc.up.pt/ vsc/Yap/downloads.html . -

cplint requires CUDD . You can download CUDD from -ftp://vlsi.colorado.edu/pub/cudd-2.4.2.tar.gz . -

Compile CUDD: -

    -
  1. decompress cudd-2.4.2.tar.gz -
  2. -
  3. cd cudd-2.4.2 -
  4. -
  5. see the README file for instructions on compilation
-

Install Yap together with cplint: when compiling Yap following the instruction of -the INSTALL file in the root of the Yap folder, use - -

-configure --enable-cplint=DIR -
-

where DIR is the directory where CUDD is, i.e., the directory ending with -cudd-2.4.2. Under Windows, you have to use Cygwin (CUDD does not compile -under MinGW), so
- -

-configure --enable-cplint=DIR --enable-cygwin -
-

-

After having performed make install you can do make installcheck that will -execute a suite of tests of the various programs. If no error is reported you have a -working installation of cplint. -

-

3 Syntax

-

LPAD and CP-logic programs consist of a set of annotated disjunctive clauses. -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 -used. For example, the CP-logic clause -

-h1 : p1 ∨...∨ hn : pn ← b1,...,bm,¬c1,...,¬cl
is -represented by - -
-h1:p1 ; ... ; hn:pn :- b1,...,bm,\+ c1,....,\+ cl -
-

No parentheses are necessary. The pi 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 -one. -

If the clause has an empty body, it can be represented like this - -

-h1:p1 ; ... ;hn:pn. -
-

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. - -

-h1:- b1,...,bm,\+ c1,...,\+ cl. -
-

stands for - -

-h1:1 :- b1,...,bm,\+ c1,...,\+ cl. -
-

-

The coin example of [23] is represented as (see file coin.cpl) - -

-heads(Coin):1/2 ; tails(Coin):1/2:- - 
     toss(Coin),\+biased(Coin). - 

heads(Coin):0.6 ; tails(Coin):0.4:- - 
     toss(Coin),biased(Coin). - 

fair(Coin):0.9 ; biased(Coin):0.1. - 

toss(coin). -
-

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 -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 -that we toss a coin with certainty. -

Moreover, the bodies of rules can contain the built-in predicates: - -

-is/2, >/2, </2, >=/2 ,=</2, - 
=:=/2, =\=/2, true/0, false/0, - 
=/2, ==/2, \=/2 ,\==/2, length/2 -
-

The bodies can also contain the following library predicates: - -

-member/2, max_list/2, min_list/2 - 
nth0/3, nth/3 -
-

plus the predicate - -

-average/2 -
-

that, given a list of numbers, computes its arithmetic mean. -

The syntax of ICL program is the one used by the AILog 2 system. -

4 Inference

-

cplint contains various modules for answering queries. -

These modules answer queries using using goal-oriented procedures: -

-

These modules answer queries using the definition of the semantics of LPADs and -CP-logic: -

-

-

4.1 Commands

-

The LPAD or CP-logic program must be stored in a text file with extension .cpl. -Suppose you have stored the example above in file coin.cpl. In order to answer -queries from this program, you have to run Yap, load one of the modules (such as for -example lpad.pl) by issuing the command - -

-use_module(library(lpad)). -
-

at the command prompt. Then you must parse the source file coin.cpl with the -command - -

-p(coin). -
-

if coin.cpl is in the current directory, or - -

-p(’path_to_coin/coin’). -
-

if coin.cpl is in a different directory. At this point you can pose query to the -program by using the predicate s/2 (for solve) that takes as its first argument a -conjunction of goals in the form of a list and returns the computed probability -as its second argument. For example, the probability of the conjunction -head(coin),biased(coin) can be asked with the query - -

-s([head(coin),biased(coin)],P). -
-

For computing the probability of a conjunction given another conjunction you can -use the predicate sc/3 (for solve conditional) that take takes as input the query -conjunction as its first argument, the evidence conjunction as its second argument -and returns the probability in its third argument. For example, the probability of the -query heads(coin) given the evidence biased(coin) can be asked with the -query - -

-sc([heads(coin)],[biased(coin)],P). -
-

After having parsed a program, in order to read in a new program you must restart -Yap when using semlpadsld.pl and semlpad.pl. With the other modules, you can -directly parse a new program. -

When using lpad.pl, the system can print the message “Uunsound program” in -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 -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 -function symbols. -

When using semcpl.pl, you can print the execution process by using the -command print. after p(file). Moreover, you can build an execution -process given a context by issuing the command parse(file). and then -build(context). where context is a list of atoms that are true in the context. -semcpl.pl can print “Invalid program” in the case in which no execution process -exists. -

When using cpl.pl you can print a partial execution model including all the -clauses involved in the query issued with print. cpl.pl can print the messages -“Uunsound program”, “It requires the choice of a head atom from a non ground -head” and “Invalid program”. -

For approx/deepit.pl and approx/deepdyn.pl the command - -

-solve(GoalsList, ProbLow, ProbUp, ResTime, BddTime) -
-

takes as input a list of goals GoalsList and returns a lower bound on the -probability ProbLow, an upper bound on the probability ProbUp, the CPU time spent -on performing resolution ResTime and the CPU time spent on handling BDDs -BddTime. -

For approx/bestk.pl the command - -

-solve(GoalsList, ProbLow,  ResTime, BddTime) -
-

takes as input a list of goals GoalsList and returns a lower bound on the -probability ProbLow, the CPU time spent on performing resolution ResTime and the -CPU time spent on handling BDDs BddTime. -

For approx/bestfirst.pl the command - -

-solve(GoalsList, ProbLow, ProbUp, Count, ResTime, BddTime) -
-

takes as input a list of goals GoalsList and returns a lower bound on the -probability ProbLow, an upper bound on the probability ProbUp, the number of -BDDs generated by the algorithm Count, the CPU time spent on performing -resolution ResTime and the CPU time spent on handling BDDs BddTime. -

For approx/montecarlo.pl the command - -

-solve(GoalsList, Samples, Time, Low, Prob, Up) -
-

takes as input a list of goals GoalsList and returns the number of samples taken -Samples, the time required to solve the problem Time, the lower end of the -confidence interval Lower, the estimated probability Prob and the upper end of the -confidence interval Up. -

For mcintyre.pl: the command - -

-solve(Goals, Samples, CPUTime, WallTime, Lower, Prob, Upper) :- -
-

takes as input a conjunction of goals Goals and returns the number of samples taken -Samples, the CPU time required to solve the problem CPUTime, the wall time -required to solve the problem CPUTime, the lower end of the confidence interval -Lower, the estimated probability Prob and the upper end of the confidence interval -Up. -

For approx/exact.pl the command - -

-solve(GoalsList, Prob, ResTime, BddTime) -
-

takes as input a conjunction of goals Goals and returns the probability Prob, the -CPU time spent on performing resolution ResTime and the CPU time spent on -handling BDDs BddTime. -

-

4.1.1 Parameters
-

The modules make use of a number of parameters in order to control their behavior. -They that can be set with the command - -

-set(parameter,value). -
-

from the Yap prompt after having loaded the module. The current value can be read -with - -

-setting(parameter,Value). -
-

from the Yap prompt. The available parameters are: -

- -

-

4.2 Semantic Modules

-

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 .uni (for universe) -in the same directory where the .cpl file is. -

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 -example, in our case the current directory will contain a file coin.uni that is a -Prolog file containing facts of the form - -

-universe(var_list,const_list). -
-

where var_list is a list of variables names (each must be included in single quotes) -and const_list is a list of constants. The semantic modules generate the grounding -by instantiating in all possible ways the variables of var_list with the constants of -const_list. 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 -constants. -

The other way to specify how to ground a program consists in using mode and -type information. For each predicate, the file .uni must contain a fact of the -form - -

-mode(predicate(t1,...,tn)). -
-

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 ti must be specified with a fact of -the form - -

-type(ti,list_of_constants). -
-

The file .uni can contain both universe and mode declaration, the ones to be used -depend on the value of the parameter grounding: with value variables, the -universe declarations are used, with value modes the mode declarations are -used. -

With semcpl.pl only mode declarations can be used. -

-

4.3 Extensions

-

In this section we will present the extensions to the syntax of LPADs and CP-logic -programs that lpadsld can handle. -

When using lpadsld.pl, the bodies can contain the predicates setof/3 and -bagof/3 with the same meaning as in Prolog. Existential quantifiers are allowed in -both, so for example the query - -

-setof(Z, (term(X,Y))^foo(X,Y,Z), L). -
-

returns all the instantiations of Z such that there exists an instantiation of X and Y -for which foo(X,Y,Z) is true. -

An example of the use of setof and bagof is in the file female.cpl: - -

-male(C):M/P ; female(C):F/P:- - 
    person(C), - 
    setof(Male,known_male(Male),LM), - 
    length(LM,M), - 
    setof(Female,known_female(Female),LF), - 
    length(LF,F), - 
    P is F+M. - 

person(f). - 

known_female(a). - 
known_female(b). - 
known_female(c). - 
known_male(d). - 
known_male(e). -
-

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 -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 -to 1 (unless P is 0). -

Another use of setof and bagof is to have an attribute depend on an -aggregate function of another attribute, similarly to what is done in PRM and -CLP(BN). -

So, in the classical school example (available in student.cpl) you can find the -following clauses: - -

-student_rank(S,h):0.6 ; student_rank(S,l):0.4:- - 
    bagof(G,R^(registr_stu(R,S),registr_gr(R,G)),L), - 
    average(L,Av),Av>1.5. - 

student_rank(S,h):0.4 ; student_rank(S,l):0.6:- - 
    bagof(G,R^(registr_stu(R,S),registr_gr(R,G)),L), - 
    average(L,Av),Av =< 1.5. -
-

where registr_stu(R,S) expresses that registration R refers to student S and -registr_gr(R,G) expresses that registration R reports grade G which is a natural -number. The two clauses express a dependency of the rank of the student from the -average of her grades. -

Another extension can be used with lpadsld.pl in order to be able to represent -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 -instance referenced in a relationship be chosen uniformly from a set. For example, -consider a domain modeling scientific papers: you have a single entity, paper, and a -relationship, cites, between paper and itself that connects the citing paper to the -cited paper. To represent the fact that the cited paper and the citing paper are -selected uniformly from certain sets, the following clauses can be used (see file -paper_ref_simple.cpl): - -

-uniform(cites_cited(C,P),P,L):- - 
    bagof(Pap,paper_topic(Pap,theory),L). - 

uniform(cites_citing(C,P),P,L):- - 
    bagof(Pap,paper_topic(Pap,ai),L). -
-

The first clauses states that the paper P cited in a citation C is selected -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 -ai. -

These clauses make use of the predicate - -

-uniform(Atom,Variable,List) -
-

in the head, where Atom must contain Variable. The meaning is the following: -the set of all the atoms obtained by instantiating Variable of Atom with a -term taken from List is generated and the head is obtained by having a -disjunct for each instantiation with probability 1∕N where N is the length of -List. -

A more elaborate example is present in file paper_ref.cpl: - -

-uniform(cites_citing(C,P),P,L):- - 
    setof(Pap,paper(Pap),L). - 

cites_cited_group(C,theory):0.9 ; cites_cited_group(C,ai):0.1:- - 
    cites_citing(C,P),paper_topic(P,theory). - 

cites_cited_group(C,theory):0.01;cites_cited_group(C,ai):0.99:- - 
    cites_citing(C,P),paper_topic(P,ai). - 

uniform(cites_cited(C,P),P,L):- - 
    cites_cited_group(C,T),bagof(Pap,paper_topic(Pap,T),L). -
-

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 -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 -theory with probability 0.01 and from the papers about ai with probability -0.99. -

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 -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 -probable if they are about the same topic: - -

-cites(X,Y):0.005 :- - 
    paper_topic(X,theory),paper_topic(Y,theory). - 

cites(X,Y):0.001 :- - 
    paper_topic(X,theory),paper_topic(Y,ai). - 

cites(X,Y):0.003 :- - 
    paper_topic(X,ai),paper_topic(Y,theory). - 

cites(X,Y):0.008 :- - 
    paper_topic(X,ai),paper_topic(Y,ai). -
-

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 -of a paper X is theory and of paper Y is theory, there is a probability of 0.005 that -there is a citation from X to Y. The other clauses consider the remaining cases for the -topics. -

-

4.4 Files

-

In the directory where Yap keeps the library files (usually /usr/local/share/ Yap) -you can find the directory cplint that contains the files: -

- -

-

5 Learning

-

cplint contains the following learning algorithms: -

-

-

5.1 Input

-

To execute the learning algorithms, prepare four files in the same folder: -

-

where <stem> is your dataset name. Examples of these files can be found in the dataset -pages. -

In <stem>.kb the example interpretations have to be given as a list of Prolog -facts initiated by begin(model(<name>)). and terminated by end(model(<name>)). -as in - -

-begin(model(b1)). - 
sameperson(1,2). - 
movie(f1,1). - 
movie(f1,2). - 
workedunder(1,w1). - 
workedunder(2,w1). - 
gender(1,female). - 
gender(2,female). - 
actor(1). - 
actor(2). - 
end(model(b1)). -
-

The interpretations may contain a fact of the form - -

-prob(0.3). -
-

assigning a probability (0.3 in this case) to the interpretations. If this is omitted, the -probability of each interpretation is considered equal to 1∕n where n is the total -number of interpretations. prob/1 can be used to set different multiplicity for the -different interpretations. -

In order for RIB to work, the input interpretations must share the Herbrand -universe. If this is not the case, you have to translate the interpretations in this was, -see for example the sp1 files in RIB’s folder, that are the results of the conversion of -the first fold of the IMDB dataset. -

<stem>.bg can contain Prolog clauses that can be used to derive additional -conclusions from the atoms in the interpretations. -

<stem>.l contains the declarations of the input and output predicates, of the -unseen predicates and the commands for setting the algorithms’ parameters. Output -predicates are declared as - -

-output(<predicate>/<arity>). -
-

and define the predicates whose atoms in the input interpretations are used as the -goals for the prediction of which you want to optimize the parameters. Derivations -for these goals are built by the systems. -

Input predicates are those for the predictions of which you do not want to -optimize the parameters. You can declare closed world input predicates -with - -

-input_cw(<predicate>/<arity>). -
-

For these predicates, the only true atoms are those in the interpretations, the -clauses in the input program are not used to derive atoms not present in the -interpretations. -

Open world input predicates are declared with - -

-input(<predicate>/<arity>). -
-

In this case, if a subgoal for such a predicate is encountered when deriving the atoms -for the output predicates, both the facts in the interpretations and the clauses of the -input program are used. -

For RIB, if there are unseen predicates, i.e., predicates that are present in the -input program but not in the interpretations, you have to declare them -with - -

-unseen(<predicate>/<arity>). -
-

-

For SLIPCASE, you have to specify the language bias by means of mode -declarations in the style of Progol . - -

-modeh(<recall>,<predicate>(<arg1>,...). -
-

specifies the atoms that can appear in the head of clauses, while - -

-modeb(<recall>,<predicate>(<arg1>,...). -
-

specifies the atoms that can appear in the body of clauses. <recall> can be an -integer or * (currently unused). -

The arguments are of the form - -

-+<type> -
-

for specifying an input variable of type <type>, or - -

--<type> -
-

for specifying an output variable of type <type>. or - -

-<constant> -
-

for specifying a constant. -

-

5.2 Parameters

-

In order to set the algorithms’ parameters, you have to insert in <stem>.l commands -of the form - -

-:- set(<parameter>,<value>). -
-

The available parameters are: -

-

-

5.3 Commands

-

To execute CEM, load em.pl with - -

-?:- use_module(library(’cplint/em’)). -
-

and call: - -

-?:- em(stem). -
-

To execute RIB, load rib.pl with - -

-?:- use_module(library(’cplint/rib’)). -
-

and call: - -

-?:- ib_par(stem). -
-

To execute EMBLEM, load slipcase.pl with - -

-?:- use_module(library(’cplint/slipcase’)). -
-

and call - -

-?:- em(stem). -
-

To execute SLIPCASE, load slipcase.pl with - -

-?:- use_module(library(’cplint/slipcase’)). -
-

and call - -

-?:- sl(stem). -
-

-

-

6 License

-

cplint, as Yap, follows the Artistic License 2.0 that you can find in Yap CVS root -dir. The copyright is by Fabrizio Riguzzi. -

The modules in the approx subdirectory use SimplecuddLPADs, a modification of -the Simplecudd library whose copyright is by Katholieke Universiteit Leuven and -that follows the Artistic License 2.0. -

Some modules use the library CUDD for manipulating BDDs that is included in -glu. For the use of CUDD, the following license must be accepted: -

Copyright (c) 1995-2004, Regents of the University of Colorado -

All rights reserved. -

Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: -

-

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
AND CONTRIBUTORS ”AS IS” AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAU-SED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -

lpad.pl, semlpad.pl and cpl.pl are based on the SLG system by Weidong -Chen and David Scott Warren , Copyright (C) 1993 Southern Methodist University, -1993 SUNY at Stony Brook, see the file COYPRIGHT_SLG for detailed information -on this copyright. -

-

References

-

-

-

- [1]   K. R. Apt and M. Bezem. Acyclic programs. New Gener. Comput., - 9(3/4):335–364, 1991. -

-

- [2]   Elena Bellodi and Fabrizio Riguzzi. EM over binary decision diagrams - for probabilistic logic programs. In Proceedings of the 26th Italian - Conference on Computational Logic (CILC2011), Pescara, Italy, 31 August - 31-2 September, 2011, 2011. -

-

- [3]   Elena Bellodi and Fabrizio Riguzzi. EM over binary decision - diagrams for probabilistic logic programs. Technical Report CS-2011-01, - Dipartimento di Ingegneria, Universitą di Ferrara, Italy, 2011. -

-

- [4]   Elena Bellodi and Fabrizio Riguzzi. Learning the structure of - probabilistic logic programs. In Inductive Logic Programming, 21th - International Conference, ILP 2011, London, UK, 31 July-3 August, 2011, - 2011. -

-

- [5]   Elena Bellodi and Fabrizio Riguzzi. Expectation Maximization over - - binary decision diagrams for probabilistic logic programs. Intel. Data Anal., - 16(6), 2012. -

-

- [6]   H. Blockeel. Probabilistic logical models for mendel’s experiments: An - exercise. In Inductive Logic Programming (ILP 2004), Work in Progress - Track, 2004. -

-

- [7]   Stefano Bragaglia and Fabrizio Riguzzi. Approximate inference for logic - programs with annotated disjunctions. In Paolo Frasconi and Francesca - Lisi, editors, Inductive Logic Programming 20th International Conference, - ILP 2010, Florence, Italy, June 27-30, 2010. Revised Papers, volume 6489 - of LNCS, pages 30–37. Springer, 2011. -

-

- [8]   Weidong Chen and David Scott Warren. Tabled evaluation with - delaying for general logic programs. Journal of the ACM, 43(1):20–74, 1996. -

-

- [9]   L. De Raedt, A. Kimmig, and H. Toivonen. ProbLog: A probabilistic - Prolog and its application in link discovery. In International Joint - Conference on Artificial Intelligence, pages 2462–2467, 2007. -

-

- [10]   G. Elidan and N. Friedman. Learning hidden variable networks: The - information bottleneck approach. Journal of Machine Learning Research, - 6:81–127, 2005. -

-

- [11]   L. Getoor, N. Friedman, D. Koller, and A. Pfeffer. Learning - probabilistic relational models. In Saso Dzeroski and Nada Lavrac, editors, - Relational Data Mining. Springer-Verlag, Berlin, 2001. -

-

- [12]   L. Getoor, N. Friedman, D. Koller, and B. Taskar. Learning - probabilistic models of relational structure. Journal of Machine Learning - Research, 3:679–707, December 2002. - -

-

- [13]   David Poole. The independent choice logic for modelling multiple agents - under uncertainty. Artificial Intelligence, 94(1-2):7–56, 1997. -

-

- [14]   Fabrizio Riguzzi. A top down interpreter for LPAD and CP-logic. In - Congress of the Italian Association for Artificial Intelligence, volume 4733 - of LNAI, pages 109–120. Springer, 2007. -

-

- [15]   Fabrizio Riguzzi. A top down interpreter for LPAD and CP-logic. - In Proceedings of the 14th RCRA workshop Experimental Evaluation of - Algorithms for Solving Problems with Combinatorial Explosion, 2007. -

-

- [16]   Fabrizio Riguzzi. Extended semantics and inference for the Independent - Choice Logic. Logic Journal of the IGPL, 17(6):589–629, 2009. -

-

- [17]   Fabrizio Riguzzi. MCINTYRE: A Monte Carlo algorithm for - probabilistic logic programming. In Proceedings of the 26th Italian - Conference on Computational Logic (CILC2011), Pescara, Italy, 31 - August-2 September, 2011, 2011. -

-

- [18]   Fabrizio Riguzzi and Nicola Di Mauro. Applying the information - bottleneck to statistical relational learning. Machine Learning, 2011. To - appear. -

-

- [19]   V. Santos Costa, D. Page, M. Qazi, and J. Cussens. CLP(BN): - Constraint logic programming for probabilistic knowledge. In Uncertainty - in Artificial Intelligence. Morgan Kaufmann, 2003. -

-

- [20]   J. Vennekens, M. Denecker, and M. Bruynooghe. Representing causal - information about a probabilistic process. In Proceedings of the 10th - European Conference on Logics in Artificial Intelligence, LNAI. Springer, - September 2006. - -

-

- [21]   J. Vennekens, Marc Denecker, and Maurice Bruynooghe. CP-logic: - A language of causal probabilistic events and its relation to logic - programming. Theory Pract. Log. Program., 9(3):245–308, 2009. -

-

- [22]   J. Vennekens and S. Verbaeten. Logic programs with annotated - disjunctions. Technical Report CW386, K. U. Leuven, 2003. -

-

- [23]   J. Vennekens, S. Verbaeten, and M. Bruynooghe. Logic programs - with annotated disjunctions. In International Conference on Logic - Programming, volume 3131 of LNCS, pages 195–209. Springer, 2004. -

-
- - - - - + + +cplint Manual + + + + + + + + +
+ + + +

cplint Manual

+
Fabrizio Riguzzi +
fabrizio.riguzzi@unife.it

+
July 12, 2013
+
+

1 Introduction

+

cplint is a suite of programs for reasoning with ICL [13], LPADs [2223] and +CP-logic programs [2021]. It contains programs both for inference and +learning. +

+

2 Installation

+

cplint is distributed in source code in the source code development tree of Yap. It +includes Prolog and C files. Download it by following the instruction in +http://www.dcc.fc.up.pt/˜vsc/Yap/downloads.html . +

cplint requires CUDD . You can download CUDD from +ftp://vlsi.colorado.edu/pub/cudd-2.4.2.tar.gz . +

Compile CUDD: +

    +
  1. decompress cudd-2.4.2.tar.gz +
  2. +
  3. cd cudd-2.4.2 +
  4. +
  5. see the README file for instructions on compilation
+

Install Yap together with cplint: when compiling Yap following the instruction of +the INSTALL file in the root of the Yap folder, use + +

+configure --enable-cplint=DIR +
+

where DIR is the directory where CUDD is, i.e., the directory ending with +cudd-2.4.2. Under Windows, you have to use Cygwin (CUDD does not compile +under MinGW), so
+ +

+configure --enable-cplint=DIR --enable-cygwin +
+

+

After having performed make install you can do make installcheck that will +execute a suite of tests of the various programs. If no error is reported you have a +working installation of cplint. +

+

3 Syntax

+

LPAD and CP-logic programs consist of a set of annotated disjunctive clauses. +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 +used. For example, the CP-logic clause +

+h1 : p1 ∨...∨ hn : pn ← b1,...,bm,¬c1,...,¬cl
is +represented by + +
+h1:p1 ; ... ; hn:pn :- b1,...,bm,\+ c1,....,\+ cl +
+

No parentheses are necessary. The pi 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 +one. +

If the clause has an empty body, it can be represented like this + +

+h1:p1 ; ... ;hn:pn. +
+

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. + +

+h1:- b1,...,bm,\+ c1,...,\+ cl. +
+

stands for + +

+h1:1 :- b1,...,bm,\+ c1,...,\+ cl. +
+

+

The coin example of [23] is represented as (see file coin.cpl) + +

+heads(Coin):1/2 ; tails(Coin):1/2:- + 
     toss(Coin),\+biased(Coin). + 

heads(Coin):0.6 ; tails(Coin):0.4:- + 
     toss(Coin),biased(Coin). + 

fair(Coin):0.9 ; biased(Coin):0.1. + 

toss(coin). +
+

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 +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 +that we toss a coin with certainty. +

Moreover, the bodies of rules can contain the built-in predicates: + +

+is/2, >/2, </2, >=/2 ,=</2, + 
=:=/2, =\=/2, true/0, false/0, + 
=/2, ==/2, \=/2 ,\==/2, length/2 +
+

The bodies can also contain the following library predicates: + +

+member/2, max_list/2, min_list/2 + 
nth0/3, nth/3 +
+

plus the predicate + +

+average/2 +
+

that, given a list of numbers, computes its arithmetic mean. +

The syntax of ICL program is the one used by the AILog 2 system. +

4 Inference

+

cplint contains various modules for answering queries. +

These modules answer queries using using goal-oriented procedures: +

+

These modules answer queries using the definition of the semantics of LPADs and +CP-logic: +

+

+

4.1 Commands

+

The LPAD or CP-logic program must be stored in a text file with extension .cpl. +Suppose you have stored the example above in file coin.cpl. In order to answer +queries from this program, you have to run Yap, load one of the modules (such as for +example lpad.pl) by issuing the command + +

+use_module(library(lpad)). +
+

at the command prompt. Then you must parse the source file coin.cpl with the +command + +

+p(coin). +
+

if coin.cpl is in the current directory, or + +

+p(’path_to_coin/coin’). +
+

if coin.cpl is in a different directory. At this point you can pose query to the +program by using the predicate s/2 (for solve) that takes as its first argument a +conjunction of goals in the form of a list and returns the computed probability +as its second argument. For example, the probability of the conjunction +head(coin),biased(coin) can be asked with the query + +

+s([head(coin),biased(coin)],P). +
+

For computing the probability of a conjunction given another conjunction you can +use the predicate sc/3 (for solve conditional) that take takes as input the query +conjunction as its first argument, the evidence conjunction as its second argument +and returns the probability in its third argument. For example, the probability of the +query heads(coin) given the evidence biased(coin) can be asked with the +query + +

+sc([heads(coin)],[biased(coin)],P). +
+

After having parsed a program, in order to read in a new program you must restart +Yap when using semlpadsld.pl and semlpad.pl. With the other modules, you can +directly parse a new program. +

When using lpad.pl, the system can print the message “Uunsound program” in +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 +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 +function symbols. +

When using semcpl.pl, you can print the execution process by using the +command print. after p(file). Moreover, you can build an execution +process given a context by issuing the command parse(file). and then +build(context). where context is a list of atoms that are true in the context. +semcpl.pl can print “Invalid program” in the case in which no execution process +exists. +

When using cpl.pl you can print a partial execution model including all the +clauses involved in the query issued with print. cpl.pl can print the messages +“Uunsound program”, “It requires the choice of a head atom from a non ground +head” and “Invalid program”. +

For approx/deepit.pl and approx/deepdyn.pl the command + +

+solve(GoalsList, ProbLow, ProbUp, ResTime, BddTime) +
+

takes as input a list of goals GoalsList and returns a lower bound on the +probability ProbLow, an upper bound on the probability ProbUp, the CPU time spent +on performing resolution ResTime and the CPU time spent on handling BDDs +BddTime. +

For approx/bestk.pl the command + +

+solve(GoalsList, ProbLow,  ResTime, BddTime) +
+

takes as input a list of goals GoalsList and returns a lower bound on the +probability ProbLow, the CPU time spent on performing resolution ResTime and the +CPU time spent on handling BDDs BddTime. +

For approx/bestfirst.pl the command + +

+solve(GoalsList, ProbLow, ProbUp, Count, ResTime, BddTime) +
+

takes as input a list of goals GoalsList and returns a lower bound on the +probability ProbLow, an upper bound on the probability ProbUp, the number of +BDDs generated by the algorithm Count, the CPU time spent on performing +resolution ResTime and the CPU time spent on handling BDDs BddTime. +

For approx/montecarlo.pl the command + +

+solve(GoalsList, Samples, Time, Low, Prob, Up) +
+

takes as input a list of goals GoalsList and returns the number of samples taken +Samples, the time required to solve the problem Time, the lower end of the +confidence interval Lower, the estimated probability Prob and the upper end of the +confidence interval Up. +

For mcintyre.pl: the command + +

+solve(Goals, Samples, CPUTime, WallTime, Lower, Prob, Upper) :- +
+

takes as input a conjunction of goals Goals and returns the number of samples taken +Samples, the CPU time required to solve the problem CPUTime, the wall time +required to solve the problem CPUTime, the lower end of the confidence interval +Lower, the estimated probability Prob and the upper end of the confidence interval +Up. +

For approx/exact.pl the command + +

+solve(GoalsList, Prob, ResTime, BddTime) +
+

takes as input a conjunction of goals Goals and returns the probability Prob, the +CPU time spent on performing resolution ResTime and the CPU time spent on +handling BDDs BddTime. +

+

4.1.1 Parameters
+

The modules make use of a number of parameters in order to control their behavior. +They that can be set with the command + +

+set(parameter,value). +
+

from the Yap prompt after having loaded the module. The current value can be read +with + +

+setting(parameter,Value). +
+

from the Yap prompt. The available parameters are: +

+ +

+

4.2 Semantic Modules

+

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 .uni (for universe) +in the same directory where the .cpl file is. +

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 +example, in our case the current directory will contain a file coin.uni that is a +Prolog file containing facts of the form + +

+universe(var_list,const_list). +
+

where var_list is a list of variables names (each must be included in single quotes) +and const_list is a list of constants. The semantic modules generate the grounding +by instantiating in all possible ways the variables of var_list with the constants of +const_list. 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 +constants. +

The other way to specify how to ground a program consists in using mode and +type information. For each predicate, the file .uni must contain a fact of the +form + +

+mode(predicate(t1,...,tn)). +
+

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 ti must be specified with a fact of +the form + +

+type(ti,list_of_constants). +
+

The file .uni can contain both universe and mode declaration, the ones to be used +depend on the value of the parameter grounding: with value variables, the +universe declarations are used, with value modes the mode declarations are +used. +

With semcpl.pl only mode declarations can be used. +

+

4.3 Extensions

+

In this section we will present the extensions to the syntax of LPADs and CP-logic +programs that lpadsld can handle. +

When using lpadsld.pl, the bodies can contain the predicates setof/3 and +bagof/3 with the same meaning as in Prolog. Existential quantifiers are allowed in +both, so for example the query + +

+setof(Z, (term(X,Y))^foo(X,Y,Z), L). +
+

returns all the instantiations of Z such that there exists an instantiation of X and Y +for which foo(X,Y,Z) is true. +

An example of the use of setof and bagof is in the file female.cpl: + +

+male(C):M/P ; female(C):F/P:- + 
    person(C), + 
    setof(Male,known_male(Male),LM), + 
    length(LM,M), + 
    setof(Female,known_female(Female),LF), + 
    length(LF,F), + 
    P is F+M. + 

person(f). + 

known_female(a). + 
known_female(b). + 
known_female(c). + 
known_male(d). + 
known_male(e). +
+

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 +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 +to 1 (unless P is 0). +

Another use of setof and bagof is to have an attribute depend on an +aggregate function of another attribute, similarly to what is done in PRM and +CLP(BN). +

So, in the classical school example (available in student.cpl) you can find the +following clauses: + +

+student_rank(S,h):0.6 ; student_rank(S,l):0.4:- + 
    bagof(G,R^(registr_stu(R,S),registr_gr(R,G)),L), + 
    average(L,Av),Av>1.5. + 

student_rank(S,h):0.4 ; student_rank(S,l):0.6:- + 
    bagof(G,R^(registr_stu(R,S),registr_gr(R,G)),L), + 
    average(L,Av),Av =< 1.5. +
+

where registr_stu(R,S) expresses that registration R refers to student S and +registr_gr(R,G) expresses that registration R reports grade G which is a natural +number. The two clauses express a dependency of the rank of the student from the +average of her grades. +

Another extension can be used with lpadsld.pl in order to be able to represent +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 +instance referenced in a relationship be chosen uniformly from a set. For example, +consider a domain modeling scientific papers: you have a single entity, paper, and a +relationship, cites, between paper and itself that connects the citing paper to the +cited paper. To represent the fact that the cited paper and the citing paper are +selected uniformly from certain sets, the following clauses can be used (see file +paper_ref_simple.cpl): + +

+uniform(cites_cited(C,P),P,L):- + 
    bagof(Pap,paper_topic(Pap,theory),L). + 

uniform(cites_citing(C,P),P,L):- + 
    bagof(Pap,paper_topic(Pap,ai),L). +
+

The first clauses states that the paper P cited in a citation C is selected +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 +ai. +

These clauses make use of the predicate + +

+uniform(Atom,Variable,List) +
+

in the head, where Atom must contain Variable. The meaning is the following: +the set of all the atoms obtained by instantiating Variable of Atom with a +term taken from List is generated and the head is obtained by having a +disjunct for each instantiation with probability 1∕N where N is the length of +List. +

A more elaborate example is present in file paper_ref.cpl: + +

+uniform(cites_citing(C,P),P,L):- + 
    setof(Pap,paper(Pap),L). + 

cites_cited_group(C,theory):0.9 ; cites_cited_group(C,ai):0.1:- + 
    cites_citing(C,P),paper_topic(P,theory). + 

cites_cited_group(C,theory):0.01;cites_cited_group(C,ai):0.99:- + 
    cites_citing(C,P),paper_topic(P,ai). + 

uniform(cites_cited(C,P),P,L):- + 
    cites_cited_group(C,T),bagof(Pap,paper_topic(Pap,T),L). +
+

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 +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 +theory with probability 0.01 and from the papers about ai with probability +0.99. +

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 +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 +probable if they are about the same topic: + +

+cites(X,Y):0.005 :- + 
    paper_topic(X,theory),paper_topic(Y,theory). + 

cites(X,Y):0.001 :- + 
    paper_topic(X,theory),paper_topic(Y,ai). + 

cites(X,Y):0.003 :- + 
    paper_topic(X,ai),paper_topic(Y,theory). + 

cites(X,Y):0.008 :- + 
    paper_topic(X,ai),paper_topic(Y,ai). +
+

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 +of a paper X is theory and of paper Y is theory, there is a probability of 0.005 that +there is a citation from X to Y. The other clauses consider the remaining cases for the +topics. +

+

4.4 Files

+

In the directory where Yap keeps the library files (usually /usr/local/share/ Yap) +you can find the directory cplint that contains the files: +

+ +

+

5 Learning

+

cplint contains the following learning algorithms: +

+

+

5.1 Input

+

To execute the learning algorithms, prepare four files in the same folder: +

+

where <stem> is your dataset name. Examples of these files can be found in the dataset +pages. +

In <stem>.kb the example interpretations have to be given as a list of Prolog +facts initiated by begin(model(<name>)). and terminated by end(model(<name>)). +as in + +

+begin(model(b1)). + 
sameperson(1,2). + 
movie(f1,1). + 
movie(f1,2). + 
workedunder(1,w1). + 
workedunder(2,w1). + 
gender(1,female). + 
gender(2,female). + 
actor(1). + 
actor(2). + 
end(model(b1)). +
+

The interpretations may contain a fact of the form + +

+prob(0.3). +
+

assigning a probability (0.3 in this case) to the interpretations. If this is omitted, the +probability of each interpretation is considered equal to 1∕n where n is the total +number of interpretations. prob/1 can be used to set different multiplicity for the +different interpretations. +

In order for RIB to work, the input interpretations must share the Herbrand +universe. If this is not the case, you have to translate the interpretations in this was, +see for example the sp1 files in RIB’s folder, that are the results of the conversion of +the first fold of the IMDB dataset. +

<stem>.bg can contain Prolog clauses that can be used to derive additional +conclusions from the atoms in the interpretations. +

<stem>.l contains the declarations of the input and output predicates, of the +unseen predicates and the commands for setting the algorithms’ parameters. Output +predicates are declared as + +

+output(<predicate>/<arity>). +
+

and define the predicates whose atoms in the input interpretations are used as the +goals for the prediction of which you want to optimize the parameters. Derivations +for these goals are built by the systems. +

Input predicates are those for the predictions of which you do not want to +optimize the parameters. You can declare closed world input predicates +with + +

+input_cw(<predicate>/<arity>). +
+

For these predicates, the only true atoms are those in the interpretations, the +clauses in the input program are not used to derive atoms not present in the +interpretations. +

Open world input predicates are declared with + +

+input(<predicate>/<arity>). +
+

In this case, if a subgoal for such a predicate is encountered when deriving the atoms +for the output predicates, both the facts in the interpretations and the clauses of the +input program are used. +

For RIB, if there are unseen predicates, i.e., predicates that are present in the +input program but not in the interpretations, you have to declare them +with + +

+unseen(<predicate>/<arity>). +
+

+

For SLIPCASE, you have to specify the language bias by means of mode +declarations in the style of Progol . + +

+modeh(<recall>,<predicate>(<arg1>,...). +
+

specifies the atoms that can appear in the head of clauses, while + +

+modeb(<recall>,<predicate>(<arg1>,...). +
+

specifies the atoms that can appear in the body of clauses. <recall> can be an +integer or * (currently unused). +

The arguments are of the form + +

++<type> +
+

for specifying an input variable of type <type>, or + +

+-<type> +
+

for specifying an output variable of type <type>. or + +

+<constant> +
+

for specifying a constant. +

+

5.2 Parameters

+

In order to set the algorithms’ parameters, you have to insert in <stem>.l commands +of the form + +

+:- set(<parameter>,<value>). +
+

The available parameters are: +

+

+

5.3 Commands

+

To execute CEM, load em.pl with + +

+?:- use_module(library(’cplint/em’)). +
+

and call: + +

+?:- em(stem). +
+

To execute RIB, load rib.pl with + +

+?:- use_module(library(’cplint/rib’)). +
+

and call: + +

+?:- ib_par(stem). +
+

To execute EMBLEM, load slipcase.pl with + +

+?:- use_module(library(’cplint/slipcase’)). +
+

and call + +

+?:- em(stem). +
+

To execute SLIPCASE, load slipcase.pl with + +

+?:- use_module(library(’cplint/slipcase’)). +
+

and call + +

+?:- sl(stem). +
+

+

+

6 License

+

cplint, as Yap, follows the Artistic License 2.0 that you can find in Yap CVS root +dir. The copyright is by Fabrizio Riguzzi. +

The modules in the approx subdirectory use SimplecuddLPADs, a modification of +the Simplecudd library whose copyright is by Katholieke Universiteit Leuven and +that follows the Artistic License 2.0. +

Some modules use the library CUDD for manipulating BDDs that is included in +glu. For the use of CUDD, the following license must be accepted: +

Copyright (c) 1995-2004, Regents of the University of Colorado +

All rights reserved. +

Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: +

+

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
AND CONTRIBUTORS ”AS IS” AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAU-SED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +

lpad.pl, semlpad.pl and cpl.pl are based on the SLG system by Weidong +Chen and David Scott Warren , Copyright (C) 1993 Southern Methodist University, +1993 SUNY at Stony Brook, see the file COYPRIGHT_SLG for detailed information +on this copyright. +

+

References

+

+

+

+ [1]   K. R. Apt and M. Bezem. Acyclic programs. New Gener. Comput., + 9(3/4):335–364, 1991. +

+

+ [2]   Elena Bellodi and Fabrizio Riguzzi. EM over binary decision diagrams + for probabilistic logic programs. In Proceedings of the 26th Italian + Conference on Computational Logic (CILC2011), Pescara, Italy, 31 August + 31-2 September, 2011, 2011. +

+

+ [3]   Elena Bellodi and Fabrizio Riguzzi. EM over binary decision + diagrams for probabilistic logic programs. Technical Report CS-2011-01, + Dipartimento di Ingegneria, Universitą di Ferrara, Italy, 2011. +

+

+ [4]   Elena Bellodi and Fabrizio Riguzzi. Learning the structure of + probabilistic logic programs. In Inductive Logic Programming, 21th + International Conference, ILP 2011, London, UK, 31 July-3 August, 2011, + 2011. +

+

+ [5]   Elena Bellodi and Fabrizio Riguzzi. Expectation Maximization over + + binary decision diagrams for probabilistic logic programs. Intel. Data Anal., + 16(6), 2012. +

+

+ [6]   H. Blockeel. Probabilistic logical models for mendel’s experiments: An + exercise. In Inductive Logic Programming (ILP 2004), Work in Progress + Track, 2004. +

+

+ [7]   Stefano Bragaglia and Fabrizio Riguzzi. Approximate inference for logic + programs with annotated disjunctions. In Paolo Frasconi and Francesca + Lisi, editors, Inductive Logic Programming 20th International Conference, + ILP 2010, Florence, Italy, June 27-30, 2010. Revised Papers, volume 6489 + of LNCS, pages 30–37. Springer, 2011. +

+

+ [8]   Weidong Chen and David Scott Warren. Tabled evaluation with + delaying for general logic programs. Journal of the ACM, 43(1):20–74, 1996. +

+

+ [9]   L. De Raedt, A. Kimmig, and H. Toivonen. ProbLog: A probabilistic + Prolog and its application in link discovery. In International Joint + Conference on Artificial Intelligence, pages 2462–2467, 2007. +

+

+ [10]   G. Elidan and N. Friedman. Learning hidden variable networks: The + information bottleneck approach. Journal of Machine Learning Research, + 6:81–127, 2005. +

+

+ [11]   L. Getoor, N. Friedman, D. Koller, and A. Pfeffer. Learning + probabilistic relational models. In Saso Dzeroski and Nada Lavrac, editors, + Relational Data Mining. Springer-Verlag, Berlin, 2001. +

+

+ [12]   L. Getoor, N. Friedman, D. Koller, and B. Taskar. Learning + probabilistic models of relational structure. Journal of Machine Learning + Research, 3:679–707, December 2002. + +

+

+ [13]   David Poole. The independent choice logic for modelling multiple agents + under uncertainty. Artificial Intelligence, 94(1-2):7–56, 1997. +

+

+ [14]   Fabrizio Riguzzi. A top down interpreter for LPAD and CP-logic. In + Congress of the Italian Association for Artificial Intelligence, volume 4733 + of LNAI, pages 109–120. Springer, 2007. +

+

+ [15]   Fabrizio Riguzzi. A top down interpreter for LPAD and CP-logic. + In Proceedings of the 14th RCRA workshop Experimental Evaluation of + Algorithms for Solving Problems with Combinatorial Explosion, 2007. +

+

+ [16]   Fabrizio Riguzzi. Extended semantics and inference for the Independent + Choice Logic. Logic Journal of the IGPL, 17(6):589–629, 2009. +

+

+ [17]   Fabrizio Riguzzi. MCINTYRE: A Monte Carlo algorithm for + probabilistic logic programming. In Proceedings of the 26th Italian + Conference on Computational Logic (CILC2011), Pescara, Italy, 31 + August-2 September, 2011, 2011. +

+

+ [18]   Fabrizio Riguzzi and Nicola Di Mauro. Applying the information + bottleneck to statistical relational learning. Machine Learning, 2011. To + appear. +

+

+ [19]   V. Santos Costa, D. Page, M. Qazi, and J. Cussens. CLP(BN): + Constraint logic programming for probabilistic knowledge. In Uncertainty + in Artificial Intelligence. Morgan Kaufmann, 2003. +

+

+ [20]   J. Vennekens, M. Denecker, and M. Bruynooghe. Representing causal + information about a probabilistic process. In Proceedings of the 10th + European Conference on Logics in Artificial Intelligence, LNAI. Springer, + September 2006. + +

+

+ [21]   J. Vennekens, Marc Denecker, and Maurice Bruynooghe. CP-logic: + A language of causal probabilistic events and its relation to logic + programming. Theory Pract. Log. Program., 9(3):245–308, 2009. +

+

+ [22]   J. Vennekens and S. Verbaeten. Logic programs with annotated + disjunctions. Technical Report CW386, K. U. Leuven, 2003. +

+

+ [23]   J. Vennekens, S. Verbaeten, and M. Bruynooghe. Logic programs + with annotated disjunctions. In International Conference on Logic + Programming, volume 3131 of LNCS, pages 195–209. Springer, 2004. +

+
+ + + + + diff --git a/packages/cplint/doc/manual.pdf b/packages/cplint/doc/manual.pdf index aa9923b7a..3f963b1f8 100644 Binary files a/packages/cplint/doc/manual.pdf and b/packages/cplint/doc/manual.pdf differ diff --git a/packages/cplint/doc/manual.tex b/packages/cplint/doc/manual.tex index d4bb57fe9..ff2ae9bf6 100644 --- a/packages/cplint/doc/manual.tex +++ b/packages/cplint/doc/manual.tex @@ -31,9 +31,9 @@ fabrizio.riguzzi@unife.it} \texttt{cplint} is a suite of programs for reasoning with ICL \cite{DBLP:journals/ai/Poole97}, LPADs \cite{VenVer03-TR,VenVer04-ICLP04-IC} and CP-logic programs \cite{VenDenBru-JELIA06,DBLP:journals/tplp/VennekensDB09}. It contains programs both for inference and learning. \section{Installation} -\texttt{cplint} is distributed in source code in the source code development tree 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} is distributed in source code in the source code development tree of Yap. It includes Prolog and C files. Download it by following the instruction in \url{http://www.dcc.fc.up.pt/\string ~vsc/Yap/downloads.html}. -\texttt{cplint} requires \href{http://vlsi.colorado.edu/~fabio/CUDD/}{CUDD}. +\texttt{cplint} requires \href{http://vlsi.colorado.edu/\string ~fabio/CUDD/}{CUDD}. You can download CUDD from \url{ftp://vlsi.colorado.edu/pub/cudd-2.4.2.tar.gz}. Compile CUDD: @@ -114,7 +114,7 @@ average/2 \end{verbatim} that, given a list of numbers, computes its arithmetic mean. -The syntax of ICL program is the one used by the \href{http://www.cs.ubc.ca/~poole/aibook/code/ailog/ailog2.html}{AILog 2} system. +The syntax of ICL program is the one used by the \href{http://www.cs.ubc.ca/\string ~poole/aibook/code/ailog/ailog2.html}{AILog 2} system. \section{Inference} \texttt{cplint} contains various modules for answering queries. @@ -143,7 +143,7 @@ It is also able to deal with extensions of LPADs and CP-logic: the clause bodies \item \texttt{montecarlo.pl} performs Monte Carlo \cite{BraRig10-ILP10-IC} \item \texttt{mcintyre.pl}: implements the algorithm MCINTYRE (Monte Carlo INference wiTh Yap REcord) \cite{Rig11-CILC11-NC} \end{itemize} -\item \texttt{approx/exact.pl} as \texttt{lpadsld.pl} but uses SimplecuddLPADs, a modification of the \href{www.cs.kuleuven.be/~theo/tools/simplecudd.html}{Simplecudd} instead of the \texttt{cplint} library for building BDDs and computing the probability. +\item \texttt{approx/exact.pl} as \texttt{lpadsld.pl} but uses SimplecuddLPADs, a modification of the \href{http://www.cs.kuleuven.be/\string ~theo/tools/simplecudd.html}{Simplecudd} instead of the \texttt{cplint} library for building BDDs and computing the probability. \end{itemize} These modules answer queries using the definition of the semantics of LPADs and CP-logic: @@ -504,7 +504,7 @@ unseen(/). \end{verbatim} For SLIPCASE, you have to specify the language bias by means of mode declarations in the style of -\href{http://www.doc.ic.ac.uk/~shm/progol.html}{Progol}. +\href{http://www.doc.ic.ac.uk/\string ~shm/progol.html}{Progol}. \begin{verbatim} modeh(,(,...). \end{verbatim} @@ -610,10 +610,10 @@ and call \texttt{cplint}, as Yap, follows the Artistic License 2.0 that you can find in Yap CVS root dir. The copyright is by Fabrizio Riguzzi. \vspace{3mm} -The modules in the approx subdirectory use SimplecuddLPADs, a modification of the \href{www.cs.kuleuven.be/~theo/tools/simplecudd.html}{Simplecudd} library whose copyright is by Katholieke Universiteit Leuven and that follows the Artistic License 2.0. +The modules in the approx subdirectory use SimplecuddLPADs, a modification of the \href{http://www.cs.kuleuven.be/\string ~theo/tools/simplecudd.html}{Simplecudd} library whose copyright is by Katholieke Universiteit Leuven and that follows the Artistic License 2.0. \vspace{3mm} -Some modules use the library \href{http://vlsi.colorado.edu/~fabio/}{CUDD} for manipulating BDDs that is included in glu. +Some modules use the library \href{http://vlsi.colorado.edu/\string ~fabio/}{CUDD} for manipulating BDDs that is included in glu. For the use of CUDD, the following license must be accepted: \vspace{3mm} @@ -654,7 +654,7 @@ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \texttt{lpad.pl}, \texttt{semlpad.pl} and \texttt{cpl.pl} are based on the SLG system -by \href{http://engr.smu.edu/~wchen/}{Weidong Chen} and \href{http://www.cs.sunysb.edu/~warren/}{David Scott Warren}, +by Weidong Chen and \href{http://www.cs.sunysb.edu/\string ~warren/}{David Scott Warren}, Copyright (C) 1993 Southern Methodist University, 1993 SUNY at Stony Brook, see the file COYPRIGHT\_SLG for detailed information on this copyright. \bibliographystyle{plain} diff --git a/packages/cplint/doc/manual0x.png b/packages/cplint/doc/manual0x.png index 784505839..395c9bc8d 100644 Binary files a/packages/cplint/doc/manual0x.png and b/packages/cplint/doc/manual0x.png differ