clpfd Questions
4
Can someone helping me to find a way to get the inverse factorial in Prolog...
For example inverse_factorial(6,X) ===> X = 3.
I have been working on it a lot of time.
I currently have the factor...
4
Solved
I have to write a Prolog program for solving a cryptarithmetic puzzle.
I need to write a function solve([A, M, P, D, Y]) which assigns the variables [A, M, P, D, Y] to values from 0 to 9 so that i...
Yila asked 14/12, 2012 at 0:35
2
Solved
Given a grid how can I determine if elements of a grid are all in a single region. In the below case is true because each element in the matrix has a neighbor.
Example1:
gridneighbours([[1,1],[1...
4
Solved
In my Prolog-inspired language Brachylog, there is the possibility to label CLP(FD)-equivalent variables that have potentially infinite domains. The code that does this labelization can be found he...
3
How to write correctly the effect axiom for empty(b,t)-action using the predicate contains(b,l,t) The predicate evaluates True , if the bucket b holds l liters of water at time t.
empty(b,t): comp...
Lorie asked 1/8, 2016 at 0:35
1
Solved
I'm trying to learn Prolog. I looked at this script:
:- use_module(library(clpfd)).
puzzle([S,E,N,D] + [M,O,R,E] = [M,O,N,E,Y]) :-
Vars = [S,E,N,D,M,O,R,Y],
Vars ins 0..9,
all_different(Vars),
...
Rom asked 8/8, 2016 at 3:22
2
Solved
I have a predicate that finds the correct solution but then goes on to find solutions which are not right.
?- data(D),data_threshold_nonredundantbumps(D,5,Bs),write(D).
[3,6,7,8,2,4,5,6,9,4,7,3]
D...
2
Solved
I'm starting learning Prolog and I want a program that given a integer P gives to integers A and B such that P = A² + B². If there aren't values of A and B that satisfy this equation, false should ...
Snippet asked 20/7, 2016 at 12:25
3
Solved
Can someone provide a simple example of channelling constraints?
Channelling constraints are used to combine viewpoints of a constraint problem. Handbook of Constraint Programming gives a good exp...
Feola asked 21/6, 2016 at 14:48
1
Solved
The operator #= is mentioned on some page, e.g. https://www.metalevel.at/prolog but not on most other pages, e.g.: http://www.swi-prolog.org/pldoc/man?section=operators
What does this operator mea...
3
Solved
I'm brand new to Prolog, and I'm interested in converting the following word problem into (SWI) Prolog:
There are 4 children: Abe, Dan, Mary, and Sue. Their ages, in no particular order, are 3, ...
2
Solved
I #> 0, I #< 10, indomain(I).
The previous code obviously does the following:
I = 1 ;
I = 2 ;
I = 3 ;
I = 4 ;
I = 5 ;
I = 6 ;
I = 7 ;
I = 8 ;
I = 9.
The following code does not work (arg...
4
Solved
It seems to me one ought to be able to process binary data with DCGs on a list of bytes. To make it work generally, though, one has to use bitwise operations which means is/2 is involved, which mea...
Podophyllin asked 31/10, 2014 at 21:35
3
Solved
I have an upcoming Logic exam and have been studying some past papers from my course. I've come across a question regarding reification and have posted it below;
Illustrate reification by using i...
Intransitive asked 8/5, 2016 at 10:12
4
Solved
I'm trying to figure out how to create a predicate in prolog that sums the squares of only the even numbers in a given list.
Expected output:
?- sumsq_even([1,3,5,2,-4,6,8,-7], Sum).
Sum = 120 ;...
2
Solved
Suppose I want to represent integers like so: integer:Sign:[FirstDigit,SecondDigit,...]. For instance, 42 would be represented as integer:positive:[4,2].
I need a predicate that generates the valu...
Chancre asked 21/4, 2016 at 17:32
1
Solved
There are some instances where recursive predicates can be CLP(FD)-fied with the benefit that the predicate turns bidirectional. What are the limits of this method? For example can the following co...
4
Solved
Look at the following goals (I am using swi-prolog with clpfd from Markus Triska):
result(Input,Result) :-
Input #> 10,
Result=decline.
result(Input,Result) :-
Input in 0..20,
Result=offer....
1
Solved
I was working on a Prolog problem consisting in counting the number of elements of a list:
count([], 0).
count([H|T], N) :-
count(T, X),
N is X+1,
N > 0.
I can understand why it's written...
4
I am trying to compute arrangements of K elements in Prolog, where the sum of their elements is equal to a given S. So, I know that arrangements can be computed by finding the combinations and then...
Kiblah asked 12/2, 2016 at 8:58
5
I made a Prolog predicate posAt(List1,P,List2) that tests whether the element at position P of List1 and List2 are equal:
posAt([X|Z], 1, [Y|W]) :-
X = Y.
posAt([Z|X], K, [W|Y]) :-
K > 1,
Kr...
Harbert asked 20/3, 2012 at 0:56
1
Solved
Assuming that:
A+B+C=24
E+F+G=11
J+K+L=22
N+O+P=14
A+E=17
B+F+J+N=26
C+G+K+O=15
L+P=13
How could i find a possible solution to the problem, given the constraints above, using the predicate sol...
4
Solved
Here is the problem:
$ swipl
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.6-5-g5aeabd5)
Copyright (c) 1990-2015 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTEL...
2
I'm new to prolog for constraint programming. I have an issue with CLPFD not reducing a domain as I expect it to. This is probably really simple.
[A,B] ins 1..5,A*B#=5.
I expect it to reduce th...
3
This question is a followup from this question.
I'm running a large number of tests in Sicstus prolog:
runtest:-
t1,
t2,
t3,
.
.
t100.
Each test is standalone and will print its result to...
Gladstone asked 12/2, 2014 at 7:11
© 2022 - 2024 — McMap. All rights reserved.