prolog

Prolog Read Skips Lines ?

Hello, Im trying to read a file in gprolog, but I have a small problem, it seems to read a line, then skip one, then read the next one, etc... Heres my code : readFichierEnt([],Fichier_Ent) :- read(end_of_file). readFichierEnt(ExampleList,Fichier_Ent) :- read(X), write(X), readFichierEnt(ExampleList,Fichier_Ent). If I provided train...

prolog syntax problem

I can't distinguish these symbols: = and =:= \= and =\= [X,Y] and [X|Y] What’s the difference ? ...

Prolog statement syntax

member(K,[a,b,c,d]) if for one of ... What's the statement for two of ...? ...

Prolog syntax problem

How to define a as a integer/float number ? I want to find the results of a+b+c+d=10 where a,b,c,d is integer and >=0. ...

What problems have you solved using constraint programming?

I'd like to know about specific problems you - the SO reader - have solved using constraint programming and what constraint logic language you used. Questions: What problems have you used constraint programming to solve? What constraint logic language did you use? I'm looking for first-hand experiences, so please do not answer unles...

existential qualifier in prolog, using setof / bagof

Hi, I had a quick question re. existential qualifier using setof in prolog (i.e. ^). using SICStus it seems that (despite what a number of websites claim), S does indeed appear to be quantified in the code below (using the bog standard, mother of / child of facts, which i havent included here): child(M,F,C) :- setof(X,(mother(S,X)),C)...

How to process formula by prolog?

If a+b+c=1 a^2+b^2+c^2=2 a^3+b^3+c^3=3 then a^4+b^4+c^4=? I've known the result is 25/6,but how to calculate it by prolog? I tried this but failed: [1] 5 ?- A+B+C=:=1,A**2+B**2+C**2=:=2,A**3+B**3+C**3=:=3. ERROR: Unhandled exception: =:=/2: Arguments are not sufficiently instantiated ...

Becoming operational in Prolog ASAP

Hi all, May be this sort of question has been asked many times( as I see the list when I move the cursor to this messagebox), But my company has a project running in Prolog and I want to clarify few things about how to go about learning it. I know Prolog is different. It should not be learnt just like any other language. Having said t...

read numbers from file in prolog and sorting

how to read numbers from file and sorting that in (prolog programming) ...

Prolog Arguments are not sufficiently instantiated

I'm trying to match a subset of the facts I'm creating, and my testcase was working great! x([1,2,3,4],'bleah'). x([1,2,4],'bleah2'). x([1,2],'bleah8'). x([1,3,4],'bleah3'). x([5,6,7,8],'bleah5'). x([6,7,8,9],'bleah6'). fuzzy(X,R) :- x(Z, R), subset(X,Z) . remaining(X,Y,D,M) :- x(Z,D) , select(X,Z,N), select(Y,N,M). pair(X,Y,R) :- x(...

Having troubles with a simple Prolog question

I was resolving some prolog exercises when I fond myself with some difficulties resolving the following one: Consider you have this fact base about object: object(obj1). object(obj2). object(obj3). object(obj4). object(obj5). material(obj1,wood). material(obj2,wood). material(obj3, glass). material(obj4, glass). material(obj5, ...

What AI topic should i pick for my class project??

I'm taking my first AI course this semester at uni and we were asked to do a project on any AI topic that we find interesting and to impliment the code in "Prolog". One example is Implementing 4 or 5 search algorithms and comparing the effeciency in different selected special cases. I just need a topic in the same level. plz HELP! ps. A...

Prolog shortcut to creating a custom enumeration

I am trying to create a custom enumeration via a series of facts. greater(X,Y) :- less (Y,X). less(a,b). less(b,c). less(c,d). This works fine, however there is significant repetition. I'm trying to cut that down. Is there a way to use an array for a simple linear series of facts via a transformation? transform([a,b,c,d]) result...

Defining is_a predicate in prolog?

Hello, I'm trying to define the inheritance-check predicate is_a/2 in Prolog, but so far all my trials failed. The is_a(X, Y) predicate should return true whenever Y is a superclass of X. For example: object(bare). object(mammal). object(animal). object(bird). is_a(bare, mammal). is_a(mammal, animal). is_a(bird, animal). is_a(X, Y):- ...

how to display blackshashes in SWI-Prolog

Hi, I am trying to display a network share path in my Prolog output code. The path is like : \\fileserver\path\to\file.txt (ex1) or \\\\fileserver\\path\\to\\file.txt (ex2) but If I try displaying it using format : pri(Z):- format('Printing Zx : \"~w\"',[Z]). the slashes get truncated to \fileserverpathtofile.txt...

Implementation of DPLL algorithm in Prolog

I'm trying to apply the simplified algorithm in Prolog, but I'm not a Prolog master. I need it without any mistakes, so I thought you guys might be able to help. What is the implementation of DPLL algorithm in Prolog? ...

how can i load programs in YAP prolog? and is YAP able to load the extention .pro?

i'm learning YAP on my own. i have a ready made program in YAP .. and i don't know how to consult it to load it to the program menu! the code is in C:\Users\Majd\Desktop\XXX.pl ...

jpl:communicating prolog from java

I'm implementing a software by jpl provided by swi-prolog for calling prolog from java. I'm using Eclipse as IDE. I don't know how to start this example very useful for my purposes that I found on line with other prolog files. Here the java code: package prolog; import java.awt.Container; import java.awt.FlowLayout; import java.awt.ev...

Prolog First Order Logic - Printing a Truth Table

I have to write program that prints a truth table of expressions. So, I wrote the following function: bool(true). bool(fail). tableBody(A,B,E) :- bool(A), bool(B) , write(A) , write(' '), write(B), write(' '), write(E),nl, fail. My problem is that E (wich is expression that contains A and B) is not e...

create a list from a list of lists

Hello all. I need to do the following: given a list of lists I need to find all possible combinations of the lists such that if some of these lists belong in such a combination, then they have no elements in common and the list created by appending the lists in the combination has a given length. Any ideas? Thanx ...