errata in TBoS

43 views
Skip to first unread message

Mark Tarver

unread,
Sep 15, 2022, 10:15:18 AM9/15/22
to Shen
The online version of TBoS is accumulating marginal errata and additional comments which will eventually make their way into the hardcopy.

To begin I've upgraded the estimated performance of Shen Prolog under Chez Scheme based on my ATP experiments; the marginal notes are in


If any further errata are found you can raise them here and I'll pencil in some marginal notes.

Mark

nha...@gmail.com

unread,
Sep 16, 2022, 4:38:12 AM9/16/22
to Shen
Supposedly, SICSTUS prolog has a speed penalty for dynamic predicates, where as in SWI there is only a marginal difference.

This is relevant to Shen because all defprolog statements are dynamic.  

Mark Tarver

unread,
Sep 16, 2022, 5:04:19 AM9/16/22
to qil...@googlegroups.com
Is that so?.  I thought that Shen Prolog predicates were static.
The Poplog Prolog compiler maintains two different forms of procedure
compiled from a predicate definition. In the first form, called the
static form, all the clauses in the definition are compiled into a
single procedure. In the second form, the dynamic form, a separate
procedure is compiled for each clause and a special "interpreting"
procedure is used to execute each of these clause procedures in turn. A
given predicate can be compiled in either form, but the static version
will run considerably faster than its dynamic equivalent. The reason for
the dynamic form is that it supports the operations of assert and
retract: individual clause procedures can be added or removed from the
set of clauses associated with a predicate without disruption.
Mark


--
You received this message because you are subscribed to the Google Groups "Shen" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qilang+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/qilang/355fd599-bc12-4c9e-8a63-4ecc5c01ee7dn%40googlegroups.com.

nha...@gmail.com

unread,
Sep 16, 2022, 5:58:55 AM9/16/22
to Shen
They are static in that sense, but they are evaluated interactively at the top-level with eval. How do you implement eval in Sicstus with static predicates? It seems like you would have to string convert and print into a file before loading it. 

"All Prolog procedures are classified as being either static or dynamic procedures. Static procedures can be changed only by completely redefining them using the Load Predicates (see ref-lod). "

I wanted to use Sicstus instead of SWI for my Scheme/Prolog Shen backend, but this issue was one of the main technical reasons why I didn't pick it. SWI's license is also more compatible with Chez and Shen, plus you can create prolog terms directly from the SWI C api, and there's less of a penalty for dynamic predicates.

Mark Tarver

unread,
Sep 16, 2022, 6:08:05 AM9/16/22
to qil...@googlegroups.com
Sicstus is one of the fastest commercial Prologs out there.  

M.

You received this message because you are subscribed to a topic in the Google Groups "Shen" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qilang/xV0AXFrckjg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qilang+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/qilang/850eb541-7a4a-4a5e-833a-2d8fd8c2d54dn%40googlegroups.com.

nha...@gmail.com

unread,
Sep 16, 2022, 6:28:59 AM9/16/22
to Shen
It is unclear to me if it is faster on dynamic predicates though:

"The benchmark set indicates SWI-Prolog is only faster than SICStus on the dynamic database. "

Also, from the Shen/Scheme/Prolog point of view:

Keep in mind there is a lot of conversion back and forth between Scheme terms and Prolog terms at each FFI boundary.

Maybe this can be mitigated in different ways in the backend, but at the moment there's not much going on in that regard. 

There is always the possibility of writing a custom GC (Ulterior Reference Counting maybe?) for Chez plus extending what types SWI can unify against but that seems like tons of work.

Scryer prolog will probably end up being the best backend for the Prolog bits of Shen, since that was the authors original intent. I'm not sure how much his priorities have shifted though. 

Mark Tarver

unread,
Sep 16, 2022, 7:58:50 AM9/16/22
to qil...@googlegroups.com
I've tested SWI's assert and retract and it is fast, but, precisely IMO because
the implementation itself is slow.  The compiler does less work than Sicstus.

M.

Mark Tarver

unread,
Sep 16, 2022, 8:01:15 AM9/16/22
to qil...@googlegroups.com
This is a very topical subject for me at the moment because I'm writing up
the FTP (in incarnation v 43) and this passage occurs.

The FTP has the same ability as the PTTP to compile theories into code and uses similar technology wrt contrapositives except that the compiler is set up to handle sequents and not simple goals.  Like the PTTP a background theory can exist in compiled form prior to SOLVE accepting a problem and this allows for fast execution.  However unlike the PTTP CHAIN has to cope with assumptions thrown at it by the action of SOLVE.  An analogy to the execution of functional programming will help understanding the relations involved.

 

A functional program is executed in a global environment which exists between computations and is permanent (unless overwritten by the user).  This global environment maintains associations between symbols and the functions attached to them.  In addition to the global environment there is a succession of local environments which are dynamically created by user input and which maintain temporary information concerning the association of variables with data structures. 

 

A similar situation exists with CHAIN.  The global environment is the theory compiled at compile time and the local environment is the list of props that are handed down from SOLVE as the assumptions needed to solve a goal.  Indirect chaining augments these assumptions as it works backwards to solve the goals.   These local assumptions are only in play for as long as it takes to solve the problem.  When computation ends, the global environment still exists but the local assumptions must vanish.

 

The most direct way to do this in Prolog would be through assert and retract [??].    However Shen Prolog lacks these features, nor can they be plausibly added to a Prolog implementation that lacks dynamic predicates [??].  Instead the reasoning in the local assumptions was carried out by a Prolog interpreter which talks with the global compiled theory. 


Mark 



Reply all
Reply to author
Forward
0 new messages