Questions tagged [sicstus-prolog]

SICStus Prolog is an ISO-standard compliant Prolog dialect developed at the Swedish Institute of Computer Science (SICS).

SICStus Prolog is an ISO-standard compliant Prolog dialect developed at the Swedish Institute of Computer Science (SICS). As of 2021-01-03, the current version is 4.6.0.

Home page.

135 questions
3
votes
1 answer

Alternative SICStus Prolog FFI SP_define_c_predicate()

I pasted the SICStus Prolog 4.3.3 SP_define_c_predicate() sample as-is—and... failed: $ /usr/local/sicstus4.3.3/bin/splfr square.pl square.c square.c: In function ‘square_it’: square.c:7:3: error: unknown type name ‘SP_WORD’ SP_WORD arg1; …
repeat
  • 18,496
  • 4
  • 54
  • 166
3
votes
1 answer

Prolog: testing if bit is set

I'm using arbitrary-precision integers for representing dense bit-vectors—ranging in size from a dozen up to a few thousand. My code frequently needs to check if certain bits are set (or not), so I did a few micro-benchmarks to see if some…
repeat
  • 18,496
  • 4
  • 54
  • 166
3
votes
6 answers

Generalizing Fibonacci sequence with SICStus Prolog

I'm trying to find a solution for a query on a generalized Fibonacci sequence (GFS). The query is: are there any GFS that have 885 as their 12th number? The initial 2 numbers may be restricted between 1 and 10. I already found the solution to find…
Christophe Herreman
  • 15,895
  • 9
  • 58
  • 86
3
votes
0 answers

Search heuristics for cumulatives

I have through several other questions (Use of cumulatives, Expressing setup time with cumulatives) got excellent feedback on use of cumulatives, and how to help the search to achieve reach an optimal solution. However in those questions I only used…
MortenM
  • 522
  • 2
  • 12
3
votes
2 answers

How to use clpfd:automaton to restrict counter value in SICStus Prolog?

I want to implement a very simple automaton that restrict the number of consecutive 1s in a list of ones and zeros (e.g. [0,1,1,0,1,1,1]). My automaton looks like this: % 'Day' is a list of clpfd variables % 'Allowed' is an integer % %…
MartyIX
  • 27,828
  • 29
  • 136
  • 207
3
votes
1 answer

Is it possible to set variable's domain as an enumeration of names in clpfd?

I can specify variable's domain in this way: MyVar in 1..10 or MyVar in {1,10,15} but I have a variable which I would like to specify like this: Activity_1__room in {room_1, room_2} % i.e. as atoms not as integers Is it possible to do it? Of…
MartyIX
  • 27,828
  • 29
  • 136
  • 207
3
votes
2 answers

How to add domain variable to global_cardinality?

I'm trying to add a constraint global_cardinality to my program and in the manual of SICStus Prolog is written: global_cardinality(+Xs,+Vals) global_cardinality(+Xs,+Vals,+Options) where Xs = [X1,...,Xd] is a list of integers or domain variables,…
MartyIX
  • 27,828
  • 29
  • 136
  • 207
3
votes
1 answer

How to define a variable domain to be non-continuous range

I'm starting with SICStus Prolog and I would like to define a variable, say StartingTimes, to have a domain defined by list [1, 5, 10] How can I do it in SICStus Prolog? I would do something like: domain(StartingTimes, 1, 10) StartingTimes #= 1…
MartyIX
  • 27,828
  • 29
  • 136
  • 207
3
votes
1 answer

Task Schedule sicstus prolog

I started sicstus prolog recently and have this homework to solve with CLP (constraint logic programing), please help me understand the problem, what I should be looking for and what I'm doing wrong. So, A building company: To get raw material the…
Vitor Mota
  • 255
  • 2
  • 13
2
votes
2 answers

Switching Modes in Prolog on the Windows Command Line

The Sicstus Prolog manual says to user "| ?- consult(user)." to enter clauses and to "to return to top-level, type ^D.". However, I am using Windows and the manual doesn't have Windows instructions. How can I return to query mode in Windows?
Daniel Sopel
  • 3,535
  • 4
  • 24
  • 17
2
votes
1 answer

What's the use of avl_height/2? And why is assoc_height/2 absent?

The SICStus Prolog libraries assoc and avl both provide tree implementations of association lists. While the binary trees used by library(assoc) are unbalanced (and thus can degrade to linear lists in the worst case), the binary trees used in…
repeat
  • 18,496
  • 4
  • 54
  • 166
2
votes
1 answer

How to set UTF-8 as default for open/3 in SICStus 4.8.0

Since the recent 4.8.0, SICStus supports Unicode above ÿ within Prolog text at least in a quoted context, that is within a quoted token (* 6.4.2 *), a double quoted list (* 6.4 *) and a character code constant (* 6.4.4 *). As a consequence also…
false
  • 10,264
  • 13
  • 101
  • 209
2
votes
0 answers

Combining constraints with catch/3

How do SICStus Prolog style attributed variables and the catch/throw Prolog exception handling mechanism interact? Deep within the source code of library(clpz), there's a piece of code I don't quite comprehend: with_local_attributes(Vars, Goal,…
repeat
  • 18,496
  • 4
  • 54
  • 166
2
votes
0 answers

Using attribute_goal/2 the right way in SICStus Prolog

I'm writing a "solver" using the SICStus Prolog attributed variables interface: :- module(attach2, [attach2/2]). :- use_module(library(atts)). :- attribute att/2. attach2(X,Y) :- put_atts(X,att(X,Y)), …
repeat
  • 18,496
  • 4
  • 54
  • 166
2
votes
2 answers

Setting order method in Sicstus prolog Samsort

I am trying to sort a list of lists such as Books=[[5,1,science,24,3,2018],[6,1,math,24,3,2019],[4,2,science,24,5,2019],[6,2,science,23,3,2019],[3,1,math,24,3,2020]]. I want to order this list based on the 5th value of each element. I tried to…
Luis2105
  • 33
  • 6
1 2
3
8 9