prolog

ERROR: /2: Arguments are not sufficiently instantiated -> swi-PROLOG

Hello, I 'm trying to create a program that prints how many smooth numbers are, between an interval. A part of the code is here: countsmooth(_, [], _, _, Count) :- Count is 0. countsmooth(X, [H|T], Min, Max, Count) :- ( Y is X*H, Y =< Max -> ( Y >= Min -> NewX is X*H, countsmooth(X, T, Min, Max, NCount1), countsmooth(NewX, [H|...

Variable binding in Prolog

Hi all, I have written a predicate common_participant(Person, PairEvent). which returns pairs of facts from my knowledge base. I was wondering whether there is any way to perform variable binding and collect all results without using the semicolon every time. Thanks, I. ...

Why is this prolog query both true and false?

My SWI-Prolog knowledge base contains the following two facts: f(a,b). f(a,c). Now if I pose the query ?- f(a,c). true. But ?- f(a,b). true ; false. Why is f(a,b) both true and false? This also happens when there are three facts in the KB. If I append f(a,d). to the KB, then f(a,d) is true (only), but f(a,b) and f(a,c) are bo...

Stoping generator in first answer, use return instead

I am using too much to my taste the pattern (after every possible solution branch of the search). This is the code to find boggle words in given square. It had a bug if the words are not preselected to include only those whose letter pairs are neighbours, which I fixed now by changing comparrision not pos to pos is None. def word_path(w...

Prolog - find words in matrix

A friend of mine is taking a course in Programming Languages that involve Prolog. I took this course a while back and I'm pretty rusty with Prolog. My friend asked me a question in Prolog and I'm not sure how to solve it, but I guess for a seasoned Prolog programmer this would be pretty easy. If you could solve it (or at least give me th...

prolog IDE in Ubuntu 9.10

I am starting off learning Prolog. I am on Ubuntu 9.10, can someone suggest an IDE to me ? Unfortunately SCITE doesn't support Prolog and I am trying to avoid Eclipse and NetBean. ...

Why "ERROR: Out of global stack"

%(SWI-Prolog)You can run the program by: ?- bestfs([8,1,3,7,0,2,6,5,4],P). initial([8,1,3,7,0,2,6,5,4]). goal([1,2,3,8,0,4,7,6,5]). operators([left, right, up, down]). % 8-puzzle solution % initial([8,1,3,7,0,2,6,5,4]). % goal([1,2,3,8,0,4,7,6,5]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Best-first Search % %%%%%%%...

Prolog List Processing

Hello to all, i would like to define a list(List of Bank Customer) from predicate and process the list using some rule. For instance, i have the customer predicate like this customer(peter,bank(maybank),customertype(personal), citizen(malaysian),age(62),credit(50000), income(4500),property(car),bankemployee(no) ). customer(ma...

Prolog Or(;) Rule Return Multiple Result

Hello to all, i have define a rule with or operator but it return multiple true or false. isloanaccept(Name,Guarantor,LoanType,LoanAmount,LoanTenure) :- customer(Name,bank(_),customertype(_), citizen(Ci),age(Age),credit(C), income(I),property(_),bankemployee(_)), Ci == 'malaysian', Age >= 18, C > 500, I > (LoanAmount / Loa...

Multiway tree construction from a node string

There is a wonderful problem set called Ninety-Nine Prolog Problems. Problem P70 is the one referred to in the title. And here is a great Prolog solution of this problem which takes only 5 lines. However, my understanding of Prolog is limited. How does this solution look like in a C-like form (no itertools available)? Edited by request...

Forward Chaining vs Backward Chaining

What is one good for that the other's not in practice? I understand the theory of what they do, but what are their limitations and capabilities in practical use? I'm considering Drools vs a java prolog for a new AI project, but open to other suggestions. What are some popular approaches for inferencing on a complicated relational data...

Why programming competition contestants use C++ and Java?

After competing in and following this year's Google Code Jam competition, I couldn't help but notice the incredible number of [successful] contestants that used C/C++ and Java. The distribution of languages used throughout the competition can be seen here. After programming in C/C++ for several years, I recently fell in love with Pytho...

built predicate into prolog

input = * value = 3 output = ***(3 star) use prolog to write out the coding when key in value is 3 than the output is ***(3star) or when key in value is 5 than output is *****(5 star). so i want to ask what are the coding in prolog for this question. my answer is like below but cannot compile and have error. can check for me?? start...

Reverse lookup in Prolog? (how do I find everything that is true about X?)

So, let's say I have the following in a Prolog database: person(john). person(mary). happy(john). It is clear to that if I want to list all people, I can type: person(X). But, what if I want to find all the things that are true about john? I cannot do: X(john). But the effect I would like is to be able to put in "john" and get ...

variable is only used once.

Hello, I am using ancient Turbo Prolog since it is included in our curriculum. Why is this program not working? domains disease, indication = symbol Patient = string Fe,Ra,He,Ch,Vo,Ru = char predicates hypothesis(Patient,disease) symptom(Patient,indication,char) response(char) go clauses go:- ...

Prolog findall existential quantifier

Hey. I have a problem with a problem in Prolog. Here's some of the code I use. has_same_elements([X|_],Y) :- permutation(X,Xnew), member(Xnew,Y), !. has_same_elements([_|Tail],Y) :- has_same_elements(Tail,Y). This gets two lists of lists as input, and decides whether or not they contain lists with the same elements...

Erlang Programming: Will Learning Prolog Help?

Will learning Prolog help to learn Erlang in a way specific to Erlang? Erlang started as a concurrent Prolog, but is modern Erlang connected to Prolog (beyond syntax)? I understand that learning Prolog might be good in the way learning Lisp is good for programming in any language, but I want to know if learning Prolog will help me to lea...

Beginner in PROLOG

What book would you recommend for a beginner in PROLOG? I currently know Perl. ...

Hello world in Prolog

I'm tearing my hair out trying to find how to just write a Hello World program in Prolog. I just want to create a program that runs like so: > ./hw Hello, world! > The problem is that every single example I can find works in a REPL, like so: ?- consult(hello_world). % hello compiled 0.00 sec, 612 bytes Yes ?- hello_world. Hello Wor...

Programming deontic logic

I need to write rules for deontic logic, is there any programming language to do that? I saw prolog and I'm learning now but how to express deontic logic in PROLOG? please help ...