Questions tagged [clpq]

CLPQ or CLP(Q) is a Prolog language extension for Constraint Logic Programming over the rationals.

15 questions
11
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
  • 701
  • 5
  • 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,665
  • 6
  • 41
  • 88
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
  • 271
  • 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
  • 20,794
  • 19
  • 81
  • 167
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
  • 8,180
  • 10
  • 52
  • 105
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
  • 695
  • 3
  • 11
  • 25
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
  • 2,751
  • 2
  • 23
  • 37
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
  • 105
  • 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
  • 105
  • 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
  • 2,895
  • 2
  • 22
  • 39
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
  • 7,414
  • 6
  • 37
  • 56
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
  • 105
  • 1
  • 5
0
votes
2 answers

Define a cube and three intervals in Prolog

I need to define a cube and three intervals Cx, Cy, and Cz as the projections of the cuboid on the x-, y-, and z-axes, respectively. I'm supposed to use the interval predicate interval_dur. The image on the link may more clear what i need…
Nil
  • 171
  • 9