Git Product home page Git Product logo

Comments (15)

 avatar commented on July 28, 2024

You can compare with GNU Prolog, what one gets there.
The ISO core standard sections is 8.9.1 asserta/1
8.9.2 assertz/1 . The example from the ISO core standard
is assertz((foo ....), which would dynamically add foo/0.

grafik

from sandbox.

 avatar commented on July 28, 2024

Oho, its even worse. assertz/1 doesn't work at all. When
trying to retrieve the facts via normal Prolog execution.
Is it required to do dynamic/1 ? I am confused.

tau

from sandbox.

 avatar commented on July 28, 2024

P.S.: I am fully aware that these details might take months if
not years. I just wanted to document my findings. With dynamic
database a lot of examples become available. For example NLP.
I will do some more testing, maybe dynamic/1 is required.

Natural Language Processing Techniques in Prolog
Patrick Blackburn and Kristina Striegnitz
http://cs.union.edu/~striegnk/courses/nlp-with-prolog/html/index.html

from sandbox.

 avatar commented on July 28, 2024

Ok, I tried the dynamic/1 directive, it didn't change anything:

dyn_no

from sandbox.

jariazavalverde avatar jariazavalverde commented on July 28, 2024

I guess it stopped working when we added threads. I'll check it. Thanks for the report.

from sandbox.

jariazavalverde avatar jariazavalverde commented on July 28, 2024

Predicates are fine. It's a problem of the sandbox. When you run a goal, the session restarts, loads the program and runs the goal.

from sandbox.

jariazavalverde avatar jariazavalverde commented on July 28, 2024

assert

from sandbox.

 avatar commented on July 28, 2024

SWISH has the same problem. Thats a little strange:

swish

from sandbox.

 avatar commented on July 28, 2024

But with Tau Prolog there might be less problems. You could
keep the session in the browser. Also some of the NLP examples
might go on that you run multiple queries and have a session state.
Thats actually the natural expectation, and not what SWISH does.

from sandbox.

 avatar commented on July 28, 2024

The Webassembly Prototype of SWI-Prolog can do it:
http://demos.rlaanemets.com/swi-prolog-wasm/example/

session_webassm

from sandbox.

jariazavalverde avatar jariazavalverde commented on July 28, 2024

In the sandbox, we consult the program each time the user runs a goal. If we don't restart the session, the clauses of the predicates will be duplicated.

We should put explicit options to load programs and goals, ask for answers and restart the session.

try

from sandbox.

 avatar commented on July 28, 2024

You could reset the sesssion when the end-user presses the Browser
reload button. But otherwise the session should persists.
Also the program should not be consulted but reconsulted. In

a reconsult clauses don't get duplicated. You could reconsult
when the program text field was changed by the enduser. So
it would be a toplevel with an automatic make/0. Here is an

example where you see that reconsult doesn't duplicate
clauses, I start with this file:

unbenannt

I am consulting an running it in SWI7:

grafik

Now I change the file:

unbenannt2

And I ask SWI7 for make/0 and rerun:

grafik

The documentation says consult, but consult always means reconsult:
http://www.swi-prolog.org/pldoc/doc_for?object=make/0

from sandbox.

 avatar commented on July 28, 2024

The session and the consulted code should be 2 different states.
In the above this is easy, really new predicates asserted would go
into the session which is the pseudo module user, and the code

was named foo. In Tau Prolog you don't have a name for the program.
But since it is a program, and not ?- [user], it has an independent state,
which can be reconsulted. Except if you consider it a ?- [user]. But

you could consider it the single SWISH notebook, hence a program.

from sandbox.

 avatar commented on July 28, 2024

Take your time, this can be kind of difficult under the hood. There
was a many decades long evolution of Prolog systems concerning
reconsult. Reconsult gets tricky when multifile predicates are involved.

In as far the reconsult policy, also in Prolog systems such as SWI7
has slightly changed. Typically you consider all predicates as multifile,
and for changed files you first remove the clauses which were consulted

from the changed file. And you do not really abolish predicates during
reconsult, only if they get really empty. This is to allow reconsult also
of multifile predicates. The SWI7 toplevel doesn't do it, but I guess the

SWI7 consult works like this, and I have also implemented it like that
in my system. Even in SWI7 there were still changes to this mechanism
over the last years, and SWI7 adds a lot of tracking information to their

clauses, thats why they can report -1 clause here:

swi7_tracking

In my system I am not going that far... :-( :-)

from sandbox.

jariazavalverde avatar jariazavalverde commented on July 28, 2024

reconsult

I'll add information about the parsed program (#52).

from sandbox.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.