[m-users.] Inferring over dynamic data
Richard O'Keefe
raoknz at gmail.com
Tue Jan 18 12:44:29 AEDT 2022
A dynamic predicate in Prolog is, to a first approximation,
a set of terms. Way back in the 80s, I did some experiments,
and found that several examples that I tried worked faster
if I represented such a set of terms as a data structure.
It depended on what exactly the program was doing, and how
much work I put into indexing the data structure. But it
was the rule, not the exception, for a data structure to be
a better choice than a dynamic predicate, *in Prolog*.
I still remember with somewhat mixed feelings demonstrating
to a Quintus customer that his program could run 700 times
faster if he didn't use the dynamic data base. Good feelings
because 700 times faster. Bad feelings because we lost that
customer. (:-(
On Tue, 18 Jan 2022 at 11:49, Stepp, Nigel D <ndstepp at hrl.com> wrote:
> Hello all,
>
> I am very interested in switching a prolog codebase to mercury, but parts
> of the codebase follow a pattern like:
>
> - receive a list of facts
> - assert facts
> - do inference using static predicates
> - retract facts
>
> I'm well aware that mercury does not support assert/retract, and I read a
> very old thread that was an interesting discussion (
> https://lists.mercurylang.org/archives/users/2006-January/003388.html).
>
> The issues in that thread were complicated by dynamic loading of modules,
> however. I am only interested in the list-of-facts part.
>
> What is a good way (or I guess any way) of transforming a pattern like the
> above to something in mercury?
>
> A tiny example is something like this:
>
> :- dynamic factA/1.
> :- dynamic factB/1.
>
> p(A,B) :- factA(A), factB(B).
>
> callP(Facts, ABs) :-
> assertFacts(Facts),
> findall(X, p(X,X), Xs),
> retractFacts(Facts).
>
> Where assertFacts/1 and retractFacts/1 do the obvious-sounding things.
> Facts might be something like [factA(x),factB(y),factA(y)], with answer
> Xs=[y].
>
> --
> Nigel Stepp, Ph.D. Information and System Sciences Lab HRL Laboratories,
> LLC.
> 3011 Malibu Canyon Road, Malibu, CA 90265 Office: +1 310-317-5267
>
> CONFIDENTIALITY NOTICE: The information transmitted in this email,
> including attachments, is intended only for the person(s) or entity to
> which it is addressed and may contain confidential, proprietary and/or
> privileged material exempt from disclosure under applicable law. Any
> review, retransmission, dissemination or other use of, or taking of any
> action in reliance upon this information by persons or entities other than
> the intended recipient is prohibited. If you received this message in
> error, please contact the sender immediately and destroy any copies of this
> information in their entirety.
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20220118/4a80c287/attachment.html>
More information about the users
mailing list