CLPQ or CLP(Q) is a Prolog language extension for Constraint Logic Programming over the rationals.
Questions tagged [clpq]
16 questions
10
votes
4 answers
I'm curious if Logic Programs can do algebra
I read a brief article about Prolog and Logic Programming. I'm curious if Logic Programs can do algebra. Like would you be able to ask what the Variable of X is in the equation 5+X = 7 and get an answer of -2?

James Scourtos
- 691
- 6
- 7
8
votes
1 answer
Solving a simple geometric puzzle in CLPQ/R (Prolog)
Consider the following square:
You are given three constraints:
All rectangles (A, B, C, D and E) have the same area;
Their geometric layout constitutes a square; and
The height of A is 2.
Now, I know this is very simple to solve by hand, but I…

Hugo Sereno Ferreira
- 8,600
- 7
- 46
- 92
5
votes
2 answers
SWI-Prolog and constraints, library CLP(FD)
I'm playing around with constraints in (swi) prolog using the clpfd library.
I'm trying to identify when one set of constraints encapsulates or subsumes the other, e.g. X<4 encapsulates X<7 as whenever the former is true, the latter is true. This…

Nir
- 61
- 6
3
votes
1 answer
Why won't Prolog/clpq solve this quadratic equation?
I'm using SWI-Prolog and I'm very new and still learning. Practically speaking, this question is a follow-up to Why can't my rule solve for X in a simple algebraic equation?
I have imported clpq.
?- use_module(library(clpq)).
true.
My equation is…
user457586
3
votes
1 answer
Constraint Values on Local Variable
I'm currently working on a scheduling problem using the :- use_module(library(clpq)) library.
My problem lies with retrieving the full solution to my problem statement.
schedule(BestSchedule, BestTotTime) :- %BestSchedule of format…

Timbo925
- 281
- 4
- 16
2
votes
1 answer
How to install clpq library in swi-prolog
I am running SWI-Prolog (Multi-threaded, 64 bits, Version 7.2.3) on Debian Stable Linux.
I want to install clpq package for Constraint Logic Programming.
However, it does not seem to be there on querying with pack_list command:
?-…

rnso
- 23,686
- 25
- 112
- 234
2
votes
1 answer
Equation solver in SWI-Prolog
I want to write a program in SWI-Prolog that solves equations. I know GNU Prolog and that makes me nervous... What is wrong here?
equation(X1,X2) :-
{
2*X1 + 3*X2 =:= 6,
{X1 is 0; X1 is 1},
{X2 is 0; X2 is 1}
}.
X1 and X2 always…

Nickon
- 9,652
- 12
- 64
- 119
1
vote
4 answers
How do I work with equations that are passed on in the goal/query of prolog?
I have this scenario wherein I get a linear equation in the Prolog query like below:
?- myquery( 3X + 5Y = 10, Result).
So my query has an equation 3X + 5Y = 10, which in general assumes the form AX + BY = C, where A=3, B=5 and C=10.
Now, in my…

kallakafar
- 725
- 3
- 11
- 27
1
vote
1 answer
Alternative for swi prologs clpq library for soving simplex
Excuse me if this is the wrong place to ask.
I have been using SWI Prolog's clpq library to solve simplex. I find the syntax pretty simple and expressive. It looks like this:
:- use_module(library(clpq)).
main(U, V, W) :-
{ 0 =< U, U =< 1,
…

Edd Barrett
- 3,425
- 2
- 29
- 48
1
vote
1 answer
Simple Constraint Logic Programming sample CLP(Q) gives error in Prolog
I've started to learn Prolog and I follow the RIPTutorial PDF. At the Constraint Logic Programming CLP(Q) section, it says:
Constraint Logic Programming CLP(Q) implements reasoning over rational numbers
Example:
?- { 5/6 = X/2 + 1/3 }.
X = 1.
When…

Lars Malmsteen
- 738
- 4
- 23
1
vote
0 answers
Prolog with inequalities
I found this inequality solving program from some Internet source.It works well.This is the program.
:-use_module(library(clpq)).
dec_inc(Left,Right):-
copy_term(Left-Right,CopyLeft-CopyRight).
tell_cs(CopyLeft).
max(CopyRight,Right,Leq).
…

ict
- 95
- 1
- 5
1
vote
2 answers
Inequalities solver using prolog
I am new to Prolog and inequalities.I want to solve following type of inequality question using Prolog. I am using SWI-Prolog.
eg: 2x+3>5 is the question.How can I write a program to get the answer of this program x>1.

ict
- 95
- 1
- 5
1
vote
1 answer
unnecessary variable in result from minimize in constraint logic programming with swi-prolog
I am following Ivan Bratkos 'Prolog programming for Artificial Intelligence fourth edition', and I'm currently reading about constraint logic programming.
In the book theres a small optimization example for task scheduling that goes like this:
{Ta…

Michelrandahl
- 3,365
- 2
- 26
- 41
1
vote
2 answers
CLP error when running plweb
I downloaded plweb from http://www.swi-prolog.org/git/plweb.git/snapshot/7cd70cef6011b480ef05f2b8679728abba719c0c.tar.gz
$cd plweb-7cd70ce/
$./run
ERROR: plweb-7cd70ce/register.pl:35:
source_sink `library(smtp)' does not exist
Warning:…

z_axis
- 8,272
- 7
- 41
- 61
0
votes
1 answer
Inequality solving using Prolog
I am working on solving inequality problems using prolog.I have found a code and it solves ax+b>=0 type equations.
The code I have used is as follows.
:-use_module(library(clpr)).
dec_inc(left,right):-
…

ict
- 95
- 1
- 5