Re: Prologs with Occurs Check constantly on?
- From: ulrich@xxxxxxxxxxxxxxxxxxxxxxxxxx (Ulrich Neumerkel)
- Date: Tue, 11 Oct 2011 09:35:55 GMT
Jan Burse <janburse@xxxxxxxxxxx> writes:
Dear All,....
Are there any Prologs with Occurs Check
constantly on?
Looking at some program examples and
oportunities that are present when code
is generated. I have the feeling that
Prologs with Occurs Check on should run
in similar time as Prologs with Occurs
Check off.
append([],X,X).....
append([X|Y],Z,[X|T]) :- append(Y,Z,T).
For occurs check constantly on, I would
only need to replace the following lines:
2' unify_term_with_occurs_check _1, _2
4' unify_compound_with_occurs_check _2, [X | T]
So the code already reduced the number
of needed unification with occurs checks.
4' could profit from unraveling the unification
and we would end up with:
4'' unify_term_with_occurs_check _2', _0'
Any Prolog which distinguishes local variables not occuring in structures
from heap variables can do your optimizations without any adaptation
of the intermediate code.
E.g., in SWI for 2', there is one occurs-check in the head of the fact,
but only if neither the 2nd nor 3rd argument is a local variable.
4'' will always be occurs-checked, because the heads of the
lists will always be allocated on the heap.
Since append([], X,s(X)) and append([X],[],[s(X)]) require the
occurs-check, an optimization in that place would need to take
goals like them into account.
I have the feeling something could be done
with a ref count annotation. ...
Possible. One argument against reference counting has been its
inability to detect cycles. But if the occurs-check is always on,
there are no cyclic structures. Not sure if this leads to anything
useful. There are many kinds of reference counting schemes like one bit,
weighted ...
.
- Follow-Ups:
- Re: Prologs with Occurs Check constantly on?
- From: Jan Burse
- Re: Prologs with Occurs Check constantly on?
- References:
- Prologs with Occurs Check constantly on?
- From: Jan Burse
- Prologs with Occurs Check constantly on?
- Prev by Date: Re: Prologs with Occurs Check constantly on?
- Next by Date: Re: ISO Section 7.6 Converting ..., known Gap?
- Previous by thread: Re: Prologs with Occurs Check constantly on?
- Next by thread: Re: Prologs with Occurs Check constantly on?
- Index(es):