<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div class="">Hi Roberto, other developers,</div>
<div class=""><br class="">
</div>
<div class="">Thanks for the package PPL! I'm just going to use it for the first time, and I have read</div>
<div class="">some documentation, but it looks really great.</div>
<div class=""><br class="">
</div>
<div class="">I had some issues when installing and using the Parma Polyhedra Library for the first time.</div>
<div class="">Everything seems to be working now, so I hope you can use my experience to improve the</div>
<div class="">documentation a bit (which is already quite extensive!).</div>
<div class=""><br class="">
</div>
<div class="">What I need are disjunctions of conjunctions of inequations, so I decided to go for the</div>
<div class="">pointset powerset domain. I was already using CLP, so I decided to go for the SWI Prolog</div>
<div class="">bindings. (Probably not directly the easiest path into using PPL)</div>
<div class=""><br class="">
</div>
<div class="">At the end, some suggestion how a “more Prolog-like” interface could look like.</div>
<div class=""><br class="">
</div>
<div class="">I really hope this helps you and future users.</div>
<div class=""><br class="">
</div>
<div class="">Kind regards,</div>
<div class="">Jaco van de Pol</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I am using PPL version 1.2, on a Mac Notebook with MacOS Sierra 10.12.6, with SWI Prolog version 7.2.3.</div>
<div class=""><br class="">
</div>
<div class="">I was using the following documentation:</div>
<div class="">- <a href="http://bugseng.com/products/ppl/documentation//user/ppl-user-prolog-interface-1.2-html/domains_predicates.html" class="">
http://bugseng.com/products/ppl/documentation//user/ppl-user-prolog-interface-1.2-html/domains_predicates.html</a></div>
<div class=""><br class="">
</div>
<div class="">Here are some issues:</div>
<div class="">1. "brew install ppl" nicely installs PPL, but it doesn't provide the SWI bindings / library,</div>
<div class="">so I decided to install it myself from the source code.</div>
<div class=""><br class="">
</div>
<div class="">2. The documentation suggests that SWI bindings should be generated automatically if swipl is on the path.</div>
<div class="">This was not true: I had to explicitly add: --enable-interfaces=SWI_PROLOG  (and this was not documented a.f.a.i.k.)</div>
<div class=""><br class="">
</div>
<div class="">3. The library is called "*.so", where swipl expects it to be called "*.dylib". I found a comment on the web about it,</div>
<div class="">but the documentation didn't mention it. It requires either making a ln -s link manually, or loading the library with</div>
<div class="">:- load_foreign_library('<prefix>/lib/ppl/libppl_swiprolog.so').</div>
<div class=""><br class="">
</div>
<div class="">4. I found it hard to understand how variables are handled. Apparently I need something like '$Var'(VarId).</div>
<div class="">It appears in the grammar ("predicate specifications") but it is not explained what this is supposed to mean</div>
<div class="">and what the rules are.</div>
<div class=""><br class="">
</div>
<div class="">5. I found it hard to get started with disjunctions (Pointset_Powerset). The documentation seems incomplete,</div>
<div class="">and it was not clear what the various +Iterators and +Handles are referring to exactly.</div>
<div class=""><br class="">
</div>
<div class="">6. The feature I was lacking most was how to create an initial Pointset_Powerset.</div>
<div class="">I found out that the following was working, but this function seems to be missing entirely</div>
<div class="">from the documentation. I understand that this follows a general pattern, but it makes</div>
<div class="">it hard to get started with powerset domains:</div>
<div class="">ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension(0,empty,R),</div>
<div class=""><br class="">
</div>
<div class="">7. The documentation says:</div>
<div class="">ppl_Pointset_Powerset_C_Polyhedron_iterator_get_disjunct(+Iterator, -Handle)</div>
<div class="">Unifies with Handle a reference to the disjunct referred to by Iterator_1.</div>
<div class="">However, the real name appears to be: <b class="">ppl_Pointset_Powerset_C_Polyhedron_get_disjunct</b></div>
<div class=""><br class="">
</div>
<div class="">8. The documentation says:</div>
<div class="">ppl_Pointset_Powerset_C_Polyhedron_iterator_increment(+Iterator)</div>
<div class="">Increments the iterator referenced by Iterator so that it "points" to the next disjunct.</div>
<div class="">However, the real name appears to be: <b class="">ppl_Pointset_Powerset_C_Polyhedron_increment_iterator</b></div>
<div class="">8b. (probably similar with decrement; I didn't check it)</div>
<div class=""><br class="">
</div>
<div class="">9. It would help to add some code examples, if only in the test scripts for PPL, but preferably to the documentation.</div>
<div class="">It seems that example code (with prolog) is missing throughout the documentation. Here is my first example,</div>
<div class="">maybe you can use it. (In particular: nice to see how the two boxes are glued together in a single box!)</div>
<div class=""><br class="">
</div>
<div class="">load_foreign_library('/Users/vdpol/lib/ppl/libppl_swiprolog.so').</div>
<div class="">X='$VAR'(0),</div>
<div class="">Y='$VAR'(1),</div>
<div class="">ppl_new_C_Polyhedron_from_constraints([X>=2, Y>=1, 5-X >= Y],P),</div>
<div class="">ppl_new_C_Polyhedron_from_constraints([X=<4, Y=<3, Y >= 5-X],Q),</div>
<div class="">ppl_Polyhedron_get_constraints(P,LP),</div>
<div class="">ppl_Polyhedron_get_constraints(Q,LQ),</div>
<div class="">ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension(2,empty,R),</div>
<div class="">ppl_Pointset_Powerset_C_Polyhedron_add_disjunct(R,P),</div>
<div class="">ppl_Pointset_Powerset_C_Polyhedron_add_disjunct(R,Q),</div>
<div class="">ppl_Pointset_Powerset_C_Polyhedron_pairwise_reduce(R),</div>
<div class="">ppl_Pointset_Powerset_C_Polyhedron_begin_iterator(R,I),</div>
<div class="">ppl_Pointset_Powerset_C_Polyhedron_get_disjunct(I,P1),</div>
<div class="">ppl_Polyhedron_get_constraints(P1,L1).</div>
<div class=""><br class="">
</div>
<div class="">9. Handling handles and iterators is quite error-prone</div>
<div class="">(in particular handling their side effects, and the implicit typing rules).</div>
<div class="">This can even lead to segfaults, consider the following (wrong) attempt</div>
<div class="">(there is no second disjunct after pairwise_reduce):</div>
<div class="">load_foreign_library('/Users/vdpol/lib/ppl/libppl_swiprolog.so').</div>
<div class="">X='$VAR'(0),</div>
<div class="">Y='$VAR'(1),</div>
<div class="">ppl_new_C_Polyhedron_from_constraints([X>=2, Y>=1, 5-X >= Y],P),</div>
<div class="">ppl_new_C_Polyhedron_from_constraints([X=<4, Y=<3, Y >= 5-X],Q),</div>
<div class="">ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension(2,empty,R),</div>
<div class="">ppl_Pointset_Powerset_C_Polyhedron_add_disjunct(R,P),</div>
<div class="">ppl_Pointset_Powerset_C_Polyhedron_add_disjunct(R,P),</div>
<div class="">ppl_Pointset_Powerset_C_Polyhedron_pairwise_reduce(R),</div>
<div class="">ppl_Pointset_Powerset_C_Polyhedron_begin_iterator(R,I),</div>
<div class="">ppl_Pointset_Powerset_C_Polyhedron_increment_iterator(I),</div>
<div class="">ppl_Pointset_Powerset_C_Polyhedron_get_disjunct(I,P2),</div>
<div class="">ppl_Polyhedron_get_constraints(P2,L).</div>
<div class="">(I ran into quite some more segfaults from SWI-Prolog (!))</div>
<div class=""><br class="">
</div>
<div class="">10. Handling handles and iterators is quite un-Prolog-like (side effects).</div>
<div class="">To me, it seems more natural to provide a Prolog-interface at the level</div>
<div class="">of "conjunctions from lists of constraints" and</div>
<div class="">"disjunctions from lists of conjunctions".</div>
<div class="">With some simple auxiliary functions I can write code like:</div>
<div class="">X='$VAR'(0),</div>
<div class="">Y='$VAR'(1),</div>
<div class="">conjunction([X>=2, Y>=1, 5-X >= Y],P),</div>
<div class="">conjunction([X=<4, Y=<3, Y >= 5-X],Q),</div>
<div class="">disjunction([P,Q],2,R),</div>
<div class="">get_disjuncts(R,D).</div>
<div class=""><br class="">
</div>
<div class="">The code to get the disjuncts reads as follows. (Maybe I shouldn't have called</div>
<div class="">ppl_Polyhedron_get_constraints in this code; I'm not yet sure if I want to</div>
<div class="">encapsulate the handles, or keep them in my prolog program)</div>
<div class=""><br class="">
</div>
<div class="">get_all_disjuncts(_,Begin,End,[]) :- </div>
<div class="">    ppl_Pointset_Powerset_C_Polyhedron_iterator_equals_iterator(Begin,End),</div>
<div class="">    !,</div>
<div class="">    ppl_delete_Pointset_Powerset_C_Polyhedron_iterator(Begin),</div>
<div class="">    ppl_delete_Pointset_Powerset_C_Polyhedron_iterator(End).</div>
<div class=""><br class="">
</div>
<div class="">get_all_disjuncts(D,Begin,End,[Cs|L]) :-</div>
<div class="">    ppl_Pointset_Powerset_C_Polyhedron_get_disjunct(Begin,C),</div>
<div class="">    ppl_Polyhedron_get_constraints(C,Cs),</div>
<div class="">    ppl_Pointset_Powerset_C_Polyhedron_increment_iterator(Begin),</div>
<div class="">    get_all_disjuncts(D,Begin,End,L).</div>
<div class="">    </div>
<div class="">get_disjuncts(D,L) :-</div>
<div class="">    ppl_Pointset_Powerset_C_Polyhedron_begin_iterator(D,B),</div>
<div class="">    ppl_Pointset_Powerset_C_Polyhedron_end_iterator(D,E),</div>
<div class="">    get_all_disjuncts(D,B,E,L).</div>
<div class=""><br class="">
</div>
<div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<span class="Apple-style-span" style="border-collapse: separate; font-variant-ligatures: normal; font-variant-east-asian: normal; font-variant-position: normal; line-height: normal; border-spacing: 0px;">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="font-size: 12px;" class="">--</div>
<div style="font-size: 12px;" class="">Prof. Jaco van de Pol</div>
<div class="">University of Twente (NL)</div>
<div style="font-size: 12px;" class="">Formal Methods and Tools </div>
<div style="font-size: 12px;" class=""><a href="http://www.cs.utwente.nl/~vdpol" class="">http://www.cs.utwente.nl/~vdpol</a></div>
</div>
</span></div>
</div>
</div>
<br class="">
</body>
</html>