<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Yes, this is exactly the kind of thing I'm interested in. What I don't get, though, is how you can use backtracking and forward inference chaining, etc on the data structure as if it were a collection of facts. When I think about doing that, it seems as
though I am reimplementing part of the core language.<br>
</p>
<p><br>
</p>
<p>If anyone has pointers to an example of this kind of method, I would be very appreciative.<br>
</p>
<p><br>
</p>
<p>Is it the case that every predicate that would otherwise rely on the database of facts, should instead have a preamble that extracts and attempts unification with some part of the data structure?<br>
</p>
<p><br>
</p>
<p>Something like (but almost certainly not actually using memberchk):<br>
</p>
<p><br>
</p>
<p>p(Facts,A,B) :-</p>
<p> memberchk(factA(A),Facts),<br>
</p>
<p> memberchk(factB(B),Facts),<br>
</p>
<p> ...<br>
</p>
<p><br>
</p>
<p>I feel like what I want is something like a monadic state a la Haskell where the database used for solving is provided that way.<br>
</p>
<p><br>
</p>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
-- <br>
Nigel Stepp, Ph.D. Information and System Sciences Lab HRL Laboratories, LLC.<br>
3011 Malibu Canyon Road, Malibu, CA 90265 Office: +1 310-317-5267<br>
<br>
</div>
</div>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Richard O'Keefe <raoknz@gmail.com><br>
<b>Sent:</b> Monday, January 17, 2022 5:44 PM<br>
<b>To:</b> Stepp, Nigel D<br>
<b>Cc:</b> users@lists.mercurylang.org<br>
<b>Subject:</b> Re: [m-users.] Inferring over dynamic data</font>
<div> </div>
</div>
<div>
<table class="MsoNormalTable" border="0" cellpadding="0">
<tbody>
<tr>
<td style="background:white; padding:.75pt .75pt .75pt .75pt">
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" align="left" width="100%" style="width:100.0%; margin-left:.75pt; margin-right:.75pt">
<tbody>
<tr>
<td style="background:#910A19; padding:5.25pt 1.5pt 5.25pt 1.5pt"><br>
</td>
<td width="100%" style="width:100.0%; background:#FDF2F4; padding:5.25pt 3.75pt 5.25pt 11.25pt; word-wrap:break-word">
<div>
<p class="MsoNormal" style=""><span style="font-family:"Verdana",sans-serif; color:#212121">This message was sent from outside of HRL. Please do not click links or open attachments unless you recognize the sender and know that the content is safe.</span><span style="font-size:12.0pt; font-family:"Times New Roman",serif"></span></p>
</div>
</td>
</tr>
</tbody>
</table>
<pre><span style="color:black"><br> </span></pre>
</td>
</tr>
</tbody>
</table>
<div>
<div dir="ltr">
<div class="gmail_default" style="font-family:monospace,monospace">A dynamic predicate in Prolog is, to a first approximation,</div>
<div class="gmail_default" style="font-family:monospace,monospace">a set of terms. Way back in the 80s, I did some experiments,</div>
<div class="gmail_default" style="font-family:monospace,monospace">and found that several examples that I tried worked faster</div>
<div class="gmail_default" style="font-family:monospace,monospace">if I represented such a set of terms as a data structure.</div>
<div class="gmail_default" style="font-family:monospace,monospace">It depended on what exactly the program was doing, and how</div>
<div class="gmail_default" style="font-family:monospace,monospace">much work I put into indexing the data structure. But it</div>
<div class="gmail_default" style="font-family:monospace,monospace">was the rule, not the exception, for a data structure to be</div>
<div class="gmail_default" style="font-family:monospace,monospace">a better choice than a dynamic predicate, *in Prolog*.</div>
<div class="gmail_default" style="font-family:monospace,monospace"><br>
</div>
<div class="gmail_default" style="font-family:monospace,monospace">I still remember with somewhat mixed feelings demonstrating</div>
<div class="gmail_default" style="font-family:monospace,monospace">to a Quintus customer that his program could run 700 times</div>
<div class="gmail_default" style="font-family:monospace,monospace">faster if he didn't use the dynamic data base. Good feelings</div>
<div class="gmail_default" style="font-family:monospace,monospace">because 700 times faster. Bad feelings because we lost that</div>
<div class="gmail_default" style="font-family:monospace,monospace">customer. (:-(<br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, 18 Jan 2022 at 11:49, Stepp, Nigel D <<a href="mailto:ndstepp@hrl.com">ndstepp@hrl.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
Hello all,<br>
<br>
I am very interested in switching a prolog codebase to mercury, but parts of the codebase follow a pattern like:<br>
<br>
- receive a list of facts<br>
- assert facts<br>
- do inference using static predicates<br>
- retract facts<br>
<br>
I'm well aware that mercury does not support assert/retract, and I read a very old thread that was an interesting discussion (<a href="https://protect2.fireeye.com/v1/url?k=31323334-501d2dca-3131c93c-454455534531-ee10946f769ec827&q=1&e=8071032b-1c25-4ccf-936e-df8008a89317&u=https%3A%2F%2Flists.mercurylang.org%2Farchives%2Fusers%2F2006-January%2F003388.html" rel="noreferrer" target="_blank">https://lists.mercurylang.org/archives/users/2006-January/003388.html</a>).<br>
<br>
The issues in that thread were complicated by dynamic loading of modules, however. I am only interested in the list-of-facts part.<br>
<br>
What is a good way (or I guess any way) of transforming a pattern like the above to something in mercury?<br>
<br>
A tiny example is something like this:<br>
<br>
:- dynamic factA/1.<br>
:- dynamic factB/1.<br>
<br>
p(A,B) :- factA(A), factB(B).<br>
<br>
callP(Facts, ABs) :-<br>
assertFacts(Facts),<br>
findall(X, p(X,X), Xs),<br>
retractFacts(Facts).<br>
<br>
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].<br>
<br>
--<br>
Nigel Stepp, Ph.D. Information and System Sciences Lab HRL Laboratories, LLC.<br>
3011 Malibu Canyon Road, Malibu, CA 90265 Office: +1 310-317-5267<br>
<br>
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.<br>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.mercurylang.org" target="_blank">users@lists.mercurylang.org</a><br>
<a href="https://protect2.fireeye.com/v1/url?k=31323334-501d2dca-3131c93c-454455534531-90cbb4a841f9c436&q=1&e=8071032b-1c25-4ccf-936e-df8008a89317&u=https%3A%2F%2Flists.mercurylang.org%2Flistinfo%2Fusers" rel="noreferrer" target="_blank">https://lists.mercurylang.org/listinfo/users</a><br>
</blockquote>
</div>
</div>
</div>
</div>
<div style="font-size:10pt; font-family: 'Calibri',sans-serif;"><b>CONFIDENTIALITY NOTICE:</b> 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.
</div>
</body>
</html>