Dogelog runtime has stepped up its game
concerning pattern matching. It now provides
ECLiPSe Prolog disjunction and if-then-else
indexing. Take this example:
?- [user].
foo(X,Y) :- X=baz, Y=2; X=bar -> Y=1.
SWI-Prolog leaves a choice point, so no
clause indexing used:
/* SWI-Prolog 8.3.26 */
?- foo(baz,Z).
Z = 2 ; %%% Spurious Choice Point
false.
Dogelog doesn't leave a choice point, since
it can index the disjunction and if-then-else:
On Thursday, 2 September 2021 at 17:24:43 UTC+2, burs...@gmail.com wrote:
In that scheme, your current implementation is like indexing on all arguments at level 1
Try SWI-Prolog 8.3.xx something, this test case:
f(X) :- X = 1.
f(X) :- X = 2.
?- f(1).
%%% what do you see here, with devel SWI-Prolog?
Will not anymore leave a spurious choice point.
I had this in Jekejeke Prolog. It got then adopted by
SWI-Prolog. And I added it to Dogelog runtime this week.
Jekejeke Prolog: (Inofficial future DNS pages.jekejeke.ch, not yet announce) Body Indexing http://pages.jekejeke.ch/doctab/doclet/en/docs/05_run/02_reference/07_theories/01_kernel/06_sharing.html
SWI-Prolog:
Indexing for body code
https://www.swi-prolog.org/pldoc/man?section=indexbody
Dogelog runtime:
Preview: Dogelog Runtime does clause body indexing. (Jekejeke) https://twitter.com/dogelogch/status/1433235977955430400
Having clause body indexing is prerequesite to having
disjunction and if-then-else indexing in Dogelog runtime.
So possibly you find clause body indexing also
in ECLiPSe Prolog which has disjunction and if-then-else indexing. ju...@diegidio.name schrieb am Freitag, 3. September 2021 um 12:57:12 UTC+2:
```
% SWI-Prolog 8.2.0
?- retractall(f(_)).
true.
?- assertz(f(X) :- X = 1), assertz(f(X) :- X = 2).
true.
?- X = 1, call_cleanup(f(X), Det=yes).
X = 1 ;
false.
```
% SWI-Prolog 8.2.0
?- retractall(f(_)).
true.
?- assertz(f(X) :- X = 1), assertz(f(X) :- X = 2).
true.
?- X = 1, call_cleanup(f(X), Det=yes).
X = 1 ;
false.
What is novel in the Dogelog runtime, you somehow have
full control on how the index key is computed. Since Dogelog
runtime itself is written in Prolog itself, assertz/1 and ensure_loaded/1
are also written in Prolog itself. It was not clear that some of
the index key computation can in fact be "out sourced" into
Prolog itself. But somehow I managed to do that, for the simple
scenario of first argument indexing. Currently the index key
computation for a clause is seen here:
- index_clause(R, O):
The predicate succeeds in O with the indexing value of the clause with head R.
- index_static(R, L, O):
The predicate succeeds in O with the indexing value of the clause with head R and body L.
https://gist.github.com/jburse/d10ac03547a9d59b858c2ef2342e488b#file-index-pl
You find it also on GitHub in compile.p:
https://github.com/jburse/dogelog-moon/tree/main/devel/transpiler
index_clause/2 is the classical first argument index key.
index_static/3 implements a very simple clause body index key.
As you see it has an additional parameter, you need to
pass the body as well, since it is clause **body** indexing.
Mostowski Collapse schrieb am Freitag, 3. September 2021 um 15:18:48 UTC+2:
Try SWI-Prolog 8.3.xx something, this test case:
f(X) :- X = 1.
f(X) :- X = 2.
?- f(1).
%%% what do you see here, with devel SWI-Prolog?
Will not anymore leave a spurious choice point.
I had this in Jekejeke Prolog. It got then adopted by
SWI-Prolog. And I added it to Dogelog runtime this week.
Jekejeke Prolog: (Inofficial future DNS pages.jekejeke.ch, not yet announce)
Body Indexing http://pages.jekejeke.ch/doctab/doclet/en/docs/05_run/02_reference/07_theories/01_kernel/06_sharing.html
SWI-Prolog:
Indexing for body code https://www.swi-prolog.org/pldoc/man?section=indexbody
Dogelog runtime:
Preview: Dogelog Runtime does clause body indexing. (Jekejeke) https://twitter.com/dogelogch/status/1433235977955430400
Having clause body indexing is prerequesite to having
disjunction and if-then-else indexing in Dogelog runtime.
So possibly you find clause body indexing also
in ECLiPSe Prolog which has disjunction and if-then-else indexing. ju...@diegidio.name schrieb am Freitag, 3. September 2021 um 12:57:12 UTC+2:
```
% SWI-Prolog 8.2.0
?- retractall(f(_)).
true.
?- assertz(f(X) :- X = 1), assertz(f(X) :- X = 2).
true.
?- X = 1, call_cleanup(f(X), Det=yes).
X = 1 ;
false.
On Thursday, 2 September 2021 at 17:24:43 UTC+2, burs...@gmail.com wrote:<snip>
programs. Just consider this:Dogelog doesn't leave a choice point, sinceI think it's unfair to call it spurious, it's you who are doing something extra-ordinary.
it can index the disjunction and if-then-else:
And something that may not always be desirable: that optimisation disallows the easy/clean way to keep the choice point should one want to, which is with code as above vs using constants directly as head arguments. (And as seen in the example below.)
Use cases for precise control of language features? Didactics and research spring to mind, and even more should certified software, also scenarios like coordinating concurrency, etc., there may be more. Anyway, clause indexing changes the semantics of
```implementations, up to which nested level to index: 0 for the head, 1 for the body, 2 for a body goal's body, etc. In that scheme, your current implementation is like indexing on all arguments at level 1), sure possibly with reasonable defaults: then it'
% SWI-Prolog 8.2.0
?- retractall(f(_)).
true.
?- assertz(f(X) :- X = 1), assertz(f(X) :- X = 2).
true.
?- X = 1, call_cleanup(f(X), Det=yes).
X = 1 ;
false.
?- retractall(f(_)).
true.
?- assertz(f(1)), assertz(f(2)).
true.
?- X = 1, call_cleanup(f(X), Det=yes).
X = 1,
Det = yes.
```
Along that line, I'd rather wish we could attribute predicates to have control on indexing (maybe just an extension to meta_predicate/1, it's simply an indexing option per argument, whether to index it or not, or even, in more sophisticated
It was always open source:
Open Source: Dogelog Runtime https://github.com/jburse/dogelog-moon/tree/main/devel
User Manual: Dogelog Runtime https://github.com/jburse/dogelog-moon/tree/main/manual
ju...@diegidio.name schrieb am Freitag, 3. September 2021 um 16:34:19 UTC+2:
I am partly speculating as I haven't seen the source code.
I am partly speculating as I haven't seen the source code.
It was always open source:
On Friday, 3 September 2021 at 17:49:28 UTC+2, burs...@gmail.com wrote:
It was always open source:That's not what I was asking, open source isn't the same as open project...
Julio
You can raise an issue here when you think there
is something wrong with Dogelog license:
Issue Tracking: Dogelog Runtime
https://github.com/jburse/dogelog-moon/issues
Basically it has an elongated open source license.
This means it has a copyright license that makes
the source code available with a product, but it
also covers usage in a lunar environment, or
even in the milky way. Thats why its full name is:
Dogelog Runtime, Prolog to the Moon
ju...@diegidio.name schrieb am Freitag, 3. September 2021 um 18:26:43 UTC+2:
On Friday, 3 September 2021 at 17:49:28 UTC+2, burs...@gmail.com wrote:
It was always open source:That's not what I was asking, open source isn't the same as open project...
Julio
Dogelog, stupid meme Prolog, total waste of time,
dogecoin.avi
https://www.youtube.com/watch?v=H3oiThw2R
LoL
Mostowski Collapse schrieb am Freitag, 3. September 2021 um 20:14:16 UTC+2:
You can raise an issue here when you think there
is something wrong with Dogelog license:
Issue Tracking: Dogelog Runtime https://github.com/jburse/dogelog-moon/issues
Basically it has an elongated open source license.
This means it has a copyright license that makes
the source code available with a product, but it
also covers usage in a lunar environment, or
even in the milky way. Thats why its full name is:
Dogelog Runtime, Prolog to the Moon
ju...@diegidio.name schrieb am Freitag, 3. September 2021 um 18:26:43 UTC+2:
On Friday, 3 September 2021 at 17:49:28 UTC+2, burs...@gmail.com wrote:
It was always open source:That's not what I was asking, open source isn't the same as open project...
Julio
I still find it rewarding to work on Dogelog runtime.
Now spinning the idea of introducing occurs check
flag. Since the Albufeira instruction set has first_var/1
and var/1 instructions, we could take the route that
we followed some months ago with Jekejeke Prolog
and optimize away some occurs checks.
But we will possibly not able to realize the dynamic
freshness check as is now ultimately used in Jekejeke Prolog,
since we do not have reference counting.
Mostowski Collapse schrieb am Freitag, 3. September 2021 um 20:59:53 UTC+2:
BTW: Julio, if you want to implement your
own Dogelog, give it a try. You only need
this paper here (basis for Dogelog):
A portable Prolog compiler
Conference: Logic Programming Workshop - Albufeira, Portugal
William Clocksin - January 1983 https://www.researchgate.net/publication/273888197
Dogelog Runtime, Prolog to the Moon https://qiita.com/j4n_bur53/items/17f86429745426bd14fd
And the ISO core standard. Its probably
better to start from scratch than to fork
something if you have some ideas.
BTW: Julio, if you want to implement your
own Dogelog, give it a try. You only need
this paper here (basis for Dogelog):
A portable Prolog compiler
Conference: Logic Programming Workshop - Albufeira, Portugal
William Clocksin - January 1983 https://www.researchgate.net/publication/273888197
Dogelog Runtime, Prolog to the Moon https://qiita.com/j4n_bur53/items/17f86429745426bd14fd
And the ISO core standard. Its probably
better to start from scratch than to fork
something if you have some ideas.
There are obviously some advantage of doing Prolog parts
in Prolog itself. I am not promoting some frivolous translator
like Logtalk. But things that are used during runtime, either
for compilation or interpretation.
The advantages of doing Prolog parts in Prolog itself:
Portability: If you write in Prolog you can port to other C (or
some other host language). For example you are usually
not dependent on 32-bit versus 64-bit.
Conciseness: If you write in Prolog you can profit from a
nice rule format, it makes it usually easy to handle different
cases. (Situation has a little changed since more and more
languages provide pattern matching)
Prolog Stack: If you write in Prolog you can profit from the
Prolog stack. You don’t need to have head aches for stack
overflow in case of very large term input.
On the drawbacks one might see:
Lower Level Term Views: When you do things in Prolog you
might be deprieved from some lower functions, like
same_term/2 etc… In C (or some other host language) terms
look usually different and you have a more direct handle.
Additional Lower Level Interfaces: When you do things in
Prolog you might arrive at points where you need nevertheless
interface with some lower level data structure. This might
blow up your Prolog code a little or ask for new built-ins.
Slight Performance Penality: Even if you have a very good
Prolog system, there might be a slight performance penality
when doing things in Prolog instead of C (or some other host
language). Or you have a surprise that it is faster!
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 42:24:44 |
Calls: | 6,648 |
Files: | 12,193 |
Messages: | 5,329,573 |