--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
Visit this group at http://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.
Hi Eyal,What you describe sounds like Paul Tarau’s ‘logic engines', which give you access to an object thatyou can extract solutions from one by one. We’d be able to implement such a thing if we haddelimited continuations, but they only exist in an experimental form in hProlog. (Tarau’s binprologis indeed a continuation based implementation of Prolog.)
On 09/26/2015 09:51 PM, Samer Abdallah wrote:
> Hi Eyal,
>
> What you describe sounds like Paul Tarau’s ‘logic engines', which
> give you access to an object that you can extract solutions from one
> by one. We’d be able to implement such a thing if we had delimited
> continuations, but they only exist in an experimental form in
> hProlog. (Tarau’s binprolog is indeed a continuation based
> implementation of Prolog.)
delimited continuations will likely end up in SWI-Prolog as well
at some point. Note that Tarau's engines are basically the same
as SWI-Prolog threads.
On 09/27/2015 02:48 PM, Julio Di Egidio wrote:
> On Sunday, September 27, 2015 at 1:39:09 PM UTC+1, Jan Wielemaker wrote:
> On 09/27/2015 02:32 PM, Julio Di Egidio wrote:
> >
> > delimited continuations will likely end up in SWI-Prolog as well
> > at some point. Note that Tarau's engines are basically the same
> > as SWI-Prolog threads.
> >
> > Tarau's Fluents (*) may boil down to executing a goal in a separate
> > thread, but his Interactors (**) are more than just that.
> >
> > Namely, can we do anything like this with pengines?
> >
> > nat(N) :- return(N), N1 is N+1, nat(N1).
>
> Yes, return(X) is basically pengine_output(X), except that the client
> can distinguish whether the new term was produced by a pengine_output
> or by a solution to the goal.
>
> Unless I am missing something, it is not: that return suspends the
> computation in nat...
Is the suspension in any way relevant?
AFAIK, Paul's interactors run
on the same thread and thus they must suspend to give control back to
the thing interacting with it.
Threads do not need to suspend. If
you want to suspend you can use pengine_input(+Prompt, -Reply), where
Prompt, is an arbitrary Prolog term
> But I'd expect Pengines and my Answer Sources to share *a lot* of code:
> threads, two queues for each pair client-worker, and so on, they are
> indeed there. Could be interesting to converge rather than
> duplicate/overlap, i.e. extend Pengines to full Interactors. Or not,
> but then they are not.
Torbjörn was (AFAIK) unaware of interactors. He modelled pengines to the
Prolog toplevel and the goal is to access and control Prolog notably
from JavaScript. I was aware of Paul's work, but I fear I must admit it
was when Torbjörn and I wrote an ICLP article about Pengines that I
became aware how closely they are related.
I'm not sure how much purpose is there in trying to avoid the overlap.
They serve rather different goals. The interactors allow you to
implement control structures that are hard to implement in normal
Prolog. They are light-weight. Pengines concentrate on remote execution.
That is much more heavyweight anyway and comes with problems such as
resource management, security and isolation (between pengines).
If you really want interactors in SWI-Prolog, I think you need to do
this:
On Sunday, September 27, 2015 at 8:47:25 PM UTC+1, Jan Burse wrote:
One of the benefit of Taraus
paper is, that he suggests a book keeping for spawning iterators, via the
trail, although I am not sure whether this is necessarily the way to go.
On Sunday, September 27, 2015 at 9:06:55 PM UTC+1, Jan Burse wrote:
> P.S.: A lazy list interface is the same as an iterator interface. If
> you do a force on a list cell, this is practically the same as the
> next on an iterator. Right?
Not really. In a lazy list you can usually go back and access previous
solutions as well. In Prolog iterators, previous solutions will be gone
when you issue a next. Prolog will destroy previous variable bindings
and previous choice points to some degree.
3 Fluent Classes and their Operations
Fluent(Prog p) {trailMe(p);}
Regardless: to my understanding, iterators are fluents, not yet interactors. For one
thing, with an interactor you do not need to destroy bindings to enumerate solutions,
you are in fact completely freed from the backtracking cycle.
(most Fluents also call stop on >>backtracking<<, through their internal undo operation).
Question is what you mean by completely freed from backtracking concerning
a child interpreter which was spawned by answer_source/3. In my optionion
answer_source/3 spawns a normal Prolog interpreter which might also
used backtracking. I don't know how you want to free a Prolog interpreter from
backtracking.
Even when the answer_source/3 produces the first solution it might already
have used backtracking. Just imagine the goal was:
p(X,Y), q(X).
And the databse was:
p(a,b).
p(b,c).
q(b).if you start an answer_source/3 with the above goal, and the output
(X,Y) you will get (X,Y) = (b,c) as a first solution through simple
backtracking. Obviously further get/2 calls on an answer source
will also force a backtracking.
Bye
Regardless: to my understanding, iterators are fluents, not yet interactors. For one
thing, with an interactor you do not need to destroy bindings to enumerate solutions,
you are in fact completely freed from the backtracking cycle.
I guess you are talking about possible backtracking in the child interpreter,
and not in the parent interpreter. The parent interpreter has obviously
backtracking and a trail and undo steps.
"The existence of this simple meta-interpreter indicates that
answer
sources lift expressiveness of first-order Horn Clause logic significantly."
Is there a way to define a findall-like predicate that produces a lazy list of solutions? That is, a list of solutions whose tail is frozen. Thanks.