Questions tagged [clpz]

CLP(Z) is an instance of the general CLP(.) scheme, extending logic programming with reasoning over specialised domains. CLP(Z) enables reasoning about integers in a way that honors the relational nature of Prolog. In comparison to similar approaches like CLP(FD), CLP(Z) features a (1) support for fully relational, logically monotonic execution and (2) enumeration procedures that always terminate.

7 questions
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
1 answer

Different ways of computing list length in Prolog

Here are 4 different ways of computing list length in Prolog: :- use_module(library(clpz)). list_length1([], 0). list_length1([_|T], N) :- N #> 0, N1 #= N - 1, list_length1(T, N1). list_length2(A, N) :- N #>= 0, …
vasily
  • 2,850
  • 1
  • 24
  • 40
2
votes
1 answer

clp(Z) vs. Kiselyov relational arithmetic

I am struggling to understand the difference in functionality between clp(Z) and another relational arithmetic system used in MiniKanren. In particular, clp(Z) apparently applies to bounded fields while Kiselyov et al. is described to apply to…
Raoul
  • 1,872
  • 3
  • 26
  • 48
2
votes
1 answer

Utilizing CLMUL in SICStus Prolog

How can I get the SICStus Prolog JIT to use any of the following ISA? Intel BMI: POPCNT, LZCNT, TZCNT, PDEP, PEXT Intel CLMUL: PCLMULQDQ ARM AArch64: RBIT I need them for supercharging clpz. Right now, I got: http://www.hackersdelight.org/ and…
repeat
  • 18,496
  • 4
  • 54
  • 166
2
votes
2 answers

Find powers of 2 in a list Prolog

I'm trying to create a list in Prolog (SWI Prolog) and check which numbers are powers of 2 and second find how many times a specific number is in the list (in this example I'm trying to find how many times the number 3 is in the list). For a…
yannisalexiou
  • 605
  • 12
  • 25
0
votes
0 answers

How to debug non-termination

I'm trying to implement n_factors/2 predicate that works in all directions. :- use_module(library(clpz)). n_factors(N, Fs) :- integer(N), N > 1, primes(Ps), n_factors0(N, Fs, Ps), !. n_factors(N, Fs) :- var(N), …
vasily
  • 2,850
  • 1
  • 24
  • 40
0
votes
0 answers

prolog clp label - ignore some variable?

My base definition use_module(library(clpfd)). /* base definitions */ ice_cream(vanilla). ice_cream(chocolate). ice_cream(strawberry). Turn words into integers /*get falavor position */ icecream_index(Icecream,Icecreamlist,Start,End) :- …