Questions tagged [prolog-setof]

setof/3 is a built-in predicate of ISO Prolog. It determines the set of solutions as a list for each different instantiation of the free variables.

69 questions
2
votes
1 answer

Prolog: existentially quantifying

I am trying to understand the usage of existentially quantifying. What I know by now is this technique is used with setof, findall, bagof. Further, I found a tutorial. However, I am not sure when and how I do the Vars^Goal (existentially…
Woden
  • 1,054
  • 2
  • 13
  • 26
2
votes
1 answer

How can I get facts from my knowledge base into a list?

Say I have these facts: person(fred). person(jim). person(mary). is_person(person(_)). I would like to get a list like: [person(fred), person(jim), person(mary)] but my query with findall/3 does not give the expected result: ?-…
Nicholas Hubbard
  • 527
  • 2
  • 15
2
votes
1 answer

Non-destructive universal quantification in Prolog

A good language for logic programming should allow the programmer to use a language close to the language used by the mathematicians. Therefore, I have always considered the lack of proper universal quantifier in Prolog an important…
A. Zinoviev
  • 101
  • 5
2
votes
1 answer

setof creates many list instead of one list prolog

I have a function I created using prolog and for some reason it always creating multi list for each element instead of one list, can someone please help me with that? here is what I wrote:(problem is the last functin creates many…
secret
  • 505
  • 4
  • 16
2
votes
1 answer

setof with compound predicate

I am struggling with a question in an assignment with prolog. So, I have the following fact database in prolog: student(name(doe, [john]), 33332, ['CSI1120'] ). student(name(doe, [jane]), 33336, ['CSI1120'] ). evaluation('CSI1120', homework(1),…
PapaEcho
  • 38
  • 5
2
votes
0 answers

What is the meaning of "^" in prolog?

I have a knowledge base about movies. My actor and actress predicates look like this: % actor(M,A,R) -- actor A played role R in movie M % actress(M,A,R) -- actress A played role R in movie M I'm trying to count the distinct actors and actresses in…
Barbi
  • 37
  • 7
2
votes
1 answer

setof/3 does not seem to be removing duplicates

I'm attempting to find the complement of a list, given a list L1, and a universal list L2 with the following code: complement(L1, L2, Res):- setof(X, (nth0(N, L2, X), not(member(X,L1))),Res). However, my results include duplicates and are not…
Zenadia Groenewald
  • 107
  • 1
  • 3
  • 12
2
votes
1 answer

Prolog multiple predicates in findall/setof

I'm trying to find ancestors of the Greek mythological Muses using the following facts and rules (simplified): /* parent(A, B) - A is the parent of B */ parent(zeus, calliope). parent(zeus, clio). parent(zeus, melpomene). parent(zeus,…
Chris Cirefice
  • 5,475
  • 7
  • 45
  • 75
2
votes
2 answers

Using Pattern Matching in Prolog to Find Submultisets

I am new to prolog and I was wondering if anyone could help me with this problem. The problem: given the integers 1,2,3,4, and the predicates mult/2, div/2, div/2, minus/2, and minus/2, and eval/2, I need to write a predicate solutions/1 that,…
Maclafel7
  • 23
  • 5
2
votes
2 answers

why findall/3 in swi-prolog ignores variable binding?

The following codes give these results: ?- X = a, findall(Element, ( member(Z, [a,b,c]), Element = Z:X ), Set). X = a, Set = [a:a, b:a, c:a]. But when I want that all elements will share the same unbound variable (instead of a), then things are…
Fibo Kowalsky
  • 1,198
  • 12
  • 23
2
votes
1 answer

Assistance writing a Prolog rule

Given that I have entered the following facts into the factbase. Each sidedish has two ingredients: maindish(thanksgiving, turkey). sidedish(thanksgiving,pie). ingredient(pie,spice). ingredient(pie,sugar). I have written the following rule to…
AnimusComplex
  • 31
  • 1
  • 2
2
votes
2 answers

Setof returning list every time, prolog

I am using a predicate that looks like this: predicate(Country, X):- setof(Length, anotherPredicate(Country,Length), X). My problem here is that my code returns the list X for every value. What I want is to return a big list containing all the…
Fjodor
  • 529
  • 1
  • 7
  • 19
2
votes
1 answer

How to avoid a meta argument warning in SICStus SPIDER?

This is probably related to a comp.lang.prolog-discussion. I'm getting several warnings like this using Eclipse with the SICStus SPIDER: The plain meta argument (Y) is passed as a closure argument (with 0 suppressed arguments) to the callee. Here…
Rune
  • 698
  • 1
  • 7
  • 22
2
votes
2 answers

Using a self-created list in prolog

I'm pretty new to Prolog, Don't be too hard on me. Anyhow, I've got the next problem in Prolog: I've created a small 'database' of actors, defined by: actor(ID, Name). Same goes for movies,cast,Director, Defined by: movie(ID,Name, Director,…
StationaryTraveller
  • 1,449
  • 2
  • 19
  • 31
2
votes
2 answers

Check if variable is empty or filled

I have the following problem: prolog prog: man(thomas, 2010). man(leon, 2011). man(thomas, 2012). man(Man) :- once(man(Man, _). problem: ?- man(thomas). true ; %i want only on true even if there are more "thomas" *working because of…
Spenhouet
  • 6,556
  • 12
  • 51
  • 76