[m-users.] Inferring over dynamic data

Stepp, Nigel D ndstepp at hrl.com
Tue Jan 18 09:44:17 AEDT 2022


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.


More information about the users mailing list