All Questions
61
questions
0
votes
0
answers
21
views
Iterating a list in a rule
The following is in a file called couples.pl
likes(X,Y).
likes(Y,X).
couple(X,Y):-
likes(X,Y),
likes(Y,X).
%
docouple(X|[]).
docouple(X|[H|T]) :-
likes(X,H),
likes(H,X),
couple(X,H),
...
0
votes
0
answers
31
views
Prolog rule is returning an exception with semi-colon usage
So, whilst I cannot share the exact code, I have something like this:
belongsTo(A,B) :- bag(A,B); shoe(A,B); sunglasses(A,B).
If bag B belongs to person A, or shoe B belongs to person A, or sunglass ...
1
vote
3
answers
224
views
Is there a way to Reverse a Rule's logic in Prolog?
I understand that the \+ symbol in Prolog stands for "not provable", which evaluates to false if some clause is provable.
This got me thinking about the reversibility of a Rule's logic, is ...
0
votes
1
answer
38
views
Trouble with this Prolog Rule
If i have facts such as these:
ss(30, 1).
ss(29, 2).
ss(27, 3).
ss(23, 5).
ss(18, 7).
ss(13, 8).
ss( 8, 9).
ss( 4, 11).
ss( 3, 12).
How can i define a rule:
calculate_ss(Year, Score)
that ...
0
votes
1
answer
413
views
Python: Is there a way a swipl query results in value true not {}?
To call prolog programs in python there is the libary pyswip.
Is there a possibility to get information if a rule for a given value is true or false. If I call a fact in console from swipl I get e.g.
...
1
vote
1
answer
108
views
Prolog how to get adjacent numbers in rule
Very new to prolog, Anyways
I have a database with names,road number,address.
habite('Name', Num, 'Address').
I want to create a rule voisins(X,Y) which returns the names of people with the same ...
0
votes
0
answers
64
views
Rules and logic programming with time as parameter: what language to use?
I am (hobby) programming a kind of scoreboard for a game with rules similar to ice hockey. So far, all ok with python and classes and methods (OOP; I am NOT good, but can survive the coding). Is there ...
1
vote
1
answer
777
views
Prolog: facts and rules
I have the following situation, I have to make a predicate that represents a doctor attending a patient, but it does not work.
doctor(adele).
doctor(inez).
doctor(elin).
patient(aurora).
patient(...
0
votes
1
answer
44
views
How to use a rule correctly in Prolog
I have begun on a short journey of trying to understand how Prolog works, I need some help trying to figure out how to approach a problem and what my code is actually doing. I want to build a sentence ...
1
vote
3
answers
2k
views
Prolog only check variable is instantiated
In Prolog, is it possible to check if the variable is certain value only if the variable is instantiated.
? - my_rule(X).
my_rule(X):-
X = 4,
write('continue').
Here I am trying to check ...
2
votes
2
answers
433
views
Prolog, trying to append 2 lists but kept on getting false
lists([a,b,c]).
first(F):-lists([F,_,_]).
second(S):-lists([_,S,_]).
last(L):-lists([_,_,L]).
sf(X):-append(second(X),first(X),X).
?-sf(X) //returns false
I'm basically trying to get a ...
0
votes
0
answers
65
views
Homework Prolog Help: =:=/2: Arguments are not sufficiently instantiated
I don't want to have to post the whole homework assignment and all my code online, so I'll just put where the specific problems takes place. I can add and explain more if necessary.
But essentially, ...
2
votes
1
answer
708
views
How can I assign multiple values to a variable (like a string) in Prolog?
Earlier today I asked for help for building a database in prolog and how to search by parameters, and somebody came up with this:
You can also add a list of terms to every processor, like:
...
3
votes
3
answers
309
views
Using OR operator with different / non existent facts in Prolog
I have a fact:
loves(romeo, juliet).
then i have an 'or' rule:
dances(juliet) :- loves(romeo, juliet).
dances(juliet) :- dancer(juliet).
As you can see dancer fact does not exist but this should ...
1
vote
1
answer
2k
views
Prolog rule within a rule
I have a simple prolog program that is trying to determine who trusts who based of the trusts rule and the knows rule. Here it is
know(joe,jack).
know(joe,sue).
know(joe,betty).
know(sue,betty).
...