Comments (15)
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.
from sandbox.
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.
from sandbox.
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.
Ok, I tried the dynamic/1 directive, it didn't change anything:
from sandbox.
I guess it stopped working when we added threads. I'll check it. Thanks for the report.
from sandbox.
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.
from sandbox.
SWISH has the same problem. Thats a little strange:
from sandbox.
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.
The Webassembly Prototype of SWI-Prolog can do it:
http://demos.rlaanemets.com/swi-prolog-wasm/example/
from sandbox.
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.
from sandbox.
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:
I am consulting an running it in SWI7:
Now I change the file:
And I ask SWI7 for make/0 and rerun:
The documentation says consult, but consult always means reconsult:
http://www.swi-prolog.org/pldoc/doc_for?object=make/0
from sandbox.
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.
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:
In my system I am not going that far... :-( :-)
from sandbox.
I'll add information about the parsed program (#52).
from sandbox.
Related Issues (11)
- Entering space cancels line of entered text under Mobile Firefox HOT 3
- Feature request non-blocking sandbox, ev. needs yielding engine HOT 9
- Output Strings in the Sandbox Console.
- strange slowdown when typing query larger than input field HOT 2
- sandbox: save dialog cannot be cancelled HOT 2
- HTML eats < HOT 1
- It could be the case that not all errors in the program are reported HOT 6
- Feature request write family of predicates in the sandbox HOT 3
- Consider indent through write/1 HOT 1
- Parsing error gives JavaScript error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sandbox.