sicstus-prolog

Verify_attributes in SICStus Prolog

你。 提交于 2019-12-10 15:26:53
问题 Attribute variables permit to extend unification. The following is about arcane details of the interface. Let's cut right to the chase! In sicstus-prolog library(atts) provides predicates for using attributed variables. I think I get what the SICStus Prolog User's Manual page for library(atts) says, except for one detail about verify_attributes(-Var, +Value, -Goals) : [...] verify_attributes/3 is called before Var has actually been bound to Value. If it fails, the unification is deemed to

Appending facts into an existing prolog file

自作多情 提交于 2019-12-10 12:10:54
问题 I'm having trouble inserting facts into an existing Prolog file, without overwriting the original contents. Suppose I have a file test.pl: :- dynamic born/2. born(john,london). born(tim,manchester). If I load this in prolog, and I assert more facts: | ?- assert(born(laura,kent)). yes I'm aware I can save this by doing: |?- tell('test.pl'),listing(born/2),told. Which works but test.pl now only contains the facts, not the ":- dynamic born/2": born(john,london). born(tim,manchester). born(laura

Prolog powerset predicate [closed]

风流意气都作罢 提交于 2019-12-06 09:29:48
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center . Closed 6 years ago . I wish to define a predicate powerset(X, P) which is true when P is the powerset of X. Should work whether or not P is ground. Alexander Serebrenik Since you use SICStus Prolog you can use the subseq0(+Sequence, ?SubSequence) from library(lists), which "is true when SubSequence is a subsequence of Sequence, but

make/0 functionality for SICStus

别等时光非礼了梦想. 提交于 2019-11-29 15:01:26
How can I ensure that all modules (and ideally also all other files that have been loaded or included) are up-to-date? When issuing use_module(mymodule) , SICStus compares the modification date of the file mymodule.pl and reloads it, if newer. Also include -ed files will trigger a recompilation. But it does not recheck all modules used by mymodule . Brief, how can I get similar functionality as SWI offers it with make/0 ? There is nothing in SICStus Prolog that provides that kind of functionality. A big problem is that current Prologs are too dynamic for something like make/0 to work reliably

Optimizing pathfinding in Constraint Logic Programming with Prolog

送分小仙女□ 提交于 2019-11-28 11:06:00
I am working on a small prolog application to solve the Skyscrapers and Fences puzzle. An unsolved puzzle: A solved puzzle: When I pass the program already solved puzzles it is quick, almost instantaneous, to validate it for me. When I pass the program really small puzzles (2x2, for example, with modified rules, of course), it is also quite fast to find a solution. The problem is on computing puzzles with the "native" size of 6x6. I've left it running for 5 or so hours before aborting it. Way too much time. I've found that the part that takes the longest is the "fences" one, not the

make/0 functionality for SICStus

萝らか妹 提交于 2019-11-28 09:46:19
问题 How can I ensure that all modules (and ideally also all other files that have been loaded or included) are up-to-date? When issuing use_module(mymodule) , SICStus compares the modification date of the file mymodule.pl and reloads it, if newer. Also include -ed files will trigger a recompilation. But it does not recheck all modules used by mymodule . Brief, how can I get similar functionality as SWI offers it with make/0 ? 回答1: There is nothing in SICStus Prolog that provides that kind of

Prolog Constraint Processing : Packing Squares

怎甘沉沦 提交于 2019-11-28 09:36:03
I'm trying to solve a constraint processing problem in prolog. I need to pack 4 squares of 5x5,4x4,3x3 and 2x2 in a grid of 10x10. They may not overlap. My variables look like this: Name: SqX(i), i=1..10, domain: 1..10 Where X is either 5,4,3 or 2. The index i represents the row, the domain the column in the grid. My first constraints try to define the width and height of the squares. I formulate it as such: Constraint: SqX(i) > SqX(j)-X /\ i>j-X, range: i>0 /\ j>0 So that the possible points are constrained to be within X rows and columns from each other. Prolog however, stops on these

Optimizing pathfinding in Constraint Logic Programming with Prolog

吃可爱长大的小学妹 提交于 2019-11-27 05:54:34
问题 I am working on a small prolog application to solve the Skyscrapers and Fences puzzle. An unsolved puzzle: A solved puzzle: When I pass the program already solved puzzles it is quick, almost instantaneous, to validate it for me. When I pass the program really small puzzles (2x2, for example, with modified rules, of course), it is also quite fast to find a solution. The problem is on computing puzzles with the "native" size of 6x6. I've left it running for 5 or so hours before aborting it. Way

Prolog Constraint Processing : Packing Squares

一世执手 提交于 2019-11-27 03:02:46
问题 I'm trying to solve a constraint processing problem in prolog. I need to pack 4 squares of 5x5,4x4,3x3 and 2x2 in a grid of 10x10. They may not overlap. My variables look like this: Name: SqX(i), i=1..10, domain: 1..10 Where X is either 5,4,3 or 2. The index i represents the row, the domain the column in the grid. My first constraints try to define the width and height of the squares. I formulate it as such: Constraint: SqX(i) > SqX(j)-X /\ i>j-X, range: i>0 /\ j>0 So that the possible points