-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attributed variables: High-level considerations #3
Comments
Is there good source material on the implementation of attributed variables? Holzbaur doesn't appear to be what I'm looking for. I found a paper on the XSB system by Warren that contains some details, but its focus is removed from the basics. |
One standard reference is:
Please consider that as a useful starting point. Beware though! The following publication (Section 4.7) explains that this interface is insufficient in general:
A good implementation of attributed variables must first and foremost enable the required generality of its interface predicates. This may require a completely different approach! |
It's a start. Thanks Markus. |
OK, I've read the papers, SICStus documentation, and most of the SWI Prolog issue thread. Nevertheless, I've concluded that implementing |
It is also my impression that implementing In SWI-Prolog, interest for constraint-related functionality is exceptionally low (for a Prolog system), so I think the reason this is not implemented is mostly that nobody has seriously looked into it. Also, there are only two or three people working on constraint-related features in SWI-Prolog that are even aware of the need for this feature. In general, there should be no major stumbling blocks. Any existing binding must be undone, the hook must run, and then the scheduled goals must be invoked. It may be useful to consider a concrete program that uses https://www.metalevel.at/clpb/clpb.pl Once you manage to run this program in your system, it will also give you a free CLP(B) system. Only a few libraries are needed to make this work. Please let me know any time if you have any questions about this! |
What does the |
Yes, exactly! 7.4.2.6 initialization/1 A directive initialization(T) converts the term T to a goal G and includes it in a set of goals which shall be executed immediately after the Prolog text has been prepared for execution. The order in which any such goals will be executed shall be implementation defined. Note that it does not matter where the directive is placed in the file! It is always loaded after the (entire) file "has been prepared for execution". |
Attributed variables work very well so far! Thank you a lot, this is a very nice achievement! |
# This is the 1st commit message: revert changes # This is the commit message mthom#2: Implement run_query() in terms of run_query_iter() # This is the commit message mthom#3: Drop implementation for QueryState Fix not backtracking on query with no variables Ignore new tests to make Miri happy Remove TODO comment about QueryState::drop() working generator finish query generator make machine_new() return machine, change fns to use machine refs eliminate comment add cbindgen
# This is the 1st commit message: revert changes # This is the commit message mthom#2: Implement run_query() in terms of run_query_iter() # This is the commit message mthom#3: Drop implementation for QueryState Fix not backtracking on query with no variables Ignore new tests to make Miri happy Remove TODO comment about QueryState::drop() working generator finish query generator make machine_new() return machine, change fns to use machine refs eliminate comment add cbindgen make cbindgen header generation location relative to manifest_dir make cbindgen header generation location relative to manifest_dir Update Cargo.toml Co-authored-by: Bennet Bleßmann <bennet.blessmann+github@googlemail.com> cargo fmt fix docs mthom#2465 (comment) rename functions mthom#2465 (comment) mthom#2465 (comment) mthom#2465 (comment) fix docs mthom#2465 (comment) mthom#2465 (comment) https://github.com/mthom/scryer-prolog/pull/2465/files#r1712066209 cargo fmt, various docstring Changes mthom#2465 (comment) mthom#2465 (comment) mthom#2465 (comment) mthom#2465 (comment)
I would like to contribute some of the experience I gained with attributed variables, usable at your discretion in later stages of this project. I am mentioning this now, at a rather high level, because adding these provisions later may turn out to be very complex. I will, at your request or initiative, gladly discuss any of these aspects in their own separate issues.
At the surface, adding attributes to variables does not seem hard. However, once you look a bit more into it, there are several tough issues involved. I start with what proved to be the toughest part in SWI-Prolog, and is still unresolved: There should be a predicate like
verify_attributes/3
. Please see SWI-Prolog/roadmap#14 for the justification. This deserves its own issue, and so I only bring it briefly to your attention here, for future consideration.Next, please take a look at Precise Garbage Collection in Prolog by Neumerkel et al.. This paper is critical to understand how an efficient implementation of
library(pio)
is possible, reclaiming stack space as soon as possible and thus lazily parsing a file with low memory overhead.Finally, a critical predicate when working with attributed variables is
call_residue_vars/2
. Briefly, it lets you reason about all variables whose attributes were modified during the execution of a goal. This facility is of critical importance when reasoning about constraint logic programs. I only briefly touch on this essential topic here by showing the following example:With this sample program, we have:
This although declaratively, the goal cannot hold! To reason about these constraints, we can do:
This exposes the variables that are still involved in constraints whose satisfiability is not yet determined.
Overall, once you implement setting/getting attributes and a hook like
verify_attributes/3
, the relevant constraints likedif/2
and also CLP(FD) can be implemented in Prolog itself.The text was updated successfully, but these errors were encountered: