swi-prolog

invoking swi-prolog from php

I am trying to invoke swi-prolog from within a php script like : exec("start plwin.exe -f C:\\path\\load.pl -g run_from_file.", $os1); print_r($os1); I can see that prolog window gets opened and complies the file, but immediately exits displaying an exit status as 1. I am sure that it is not executing the predicate I want to to execut...

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|...

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...

SWI Prolog - Simplifying expressions

Hi, All! I want to write a procedure simplify (E, E1) which is able to simplify expressions. I have only one operation +, and symbolic and numeric operands. Examples of this procedure: simplify(a + 1 + b + 5, E) ------> E = a + b + 6 simplify(1 + b + 9 + a + 5 + c, E) ------> E = b + a + c + 15 All the characters we shift to the b...

code to compare two strings in prolog

hi, I have been learning prolog.. I'm using a editor named prol1.1.1 I need to write rule to compare 2 strings, when i give something like rel(a1,b1). rel(a2,b2). rel(b2,c2). associatedWith(X,Y,Z) :- rel(X,Y),rel(Y,Z). ?- associatedWith(X,Y,Z). it works but when i give ?- associatedWith(X,Y,Z),X=\=Z. i get parser exception Par...

SWI-Prolog error on make: Failed to save system resources

I'm running the Terminal through Snow Leopard (with the developer packages, which contain missing gnu components). Upon attempting to run the makefile to build SWI-Prolog, this is what I get: bin/i386-darwin10.4.0/swipl -f none -O -o boot32.prc -b boot/init.pl Loading boot file ... Loading Prolog startup files % messages boot compiled ...

Problem with prolog code

Predicates is_a(X,Y) X is a doctor/handyman drives(X,Y) X drives Y We are given that a doctor drives a sportscar and a handyman drives a 4WD is_a(john,doctor). is_a(david,handyman). Now i want the code decide what kind of car john/david are driving. I tried doing: drives(X,sportscar) :- is_a(X,doctor). drives(Y,4WD) :- is_a...

writing prolog statement with not operator

Hi, I have prolog statements like this verb('part_of-8'). noun('doctor_investigation_system-2'). noun('dis-4'). berelation('be-6'). verb('be-6'). noun('hospital_information_system-11'). noun('his-13'). rel('part_of-8', 'doctor_investigation_system-2'). rel('doctor_investigation_system-2', 'dis-4'). rel('part_of-8', 'be-6'). rel('part_o...

Prolog type checking

Is there a way to determine the type of an element within a list in Prolog? I know that variables aren't explicitly typed in Prolog, but I need to check whether an element is a number, a specific character, etc. How can this be accomplished? ...

trace the closest helicopter to the base station

heli_link_dis(h1,b1,800). heli_link_dis(h1,b3,1400). heli_link_dis(h1,b2,600). heli_link_dis(h1,b8,1200). heli_link_dis(h2,b4,400). heli_link_dis(h2,b3,2000). heli_link_dis(h2,b5,500). heli_link_dis(h3,b5,1000). heli_link_dis(h3,b6,400). heli_link_dis = helicopter linked distance h1 mean the name of a helicopter b1 m...

Getting "true; false" set of two answers for a set of rules

Hi everybody, first off thanks for helping. I am writing a prolog program describing family relationships, including all versions of in-laws. The logic is all there, what I need help with is some prolog problems as I am not very experienced with it. I am trying to set up multiple possibilities for each rule through use of semicolons. T...

Prolog: Getting unique atoms from propositional formulas

Hi there, I can easily write a predicate to get unique elements from a given list in Prolog e.g. no_doubles( [], [] ). no_doubles( [H|T], F ) :- member( H, T ), no_doubles( T, F ). no_doubles( [H|T], [H|F] ) :- \+ member( H, T ), no_doubles( T, F ). However, how can you do the same thing but for something other than a normal lis...

Prolog type definition in swi-prolog

Hi,in visual prolog there is "domains" section in a prolog program in which you can define types. Is there any similar thing in swi-prolog? In visual prolog a type is defined like: domains NewType = thing1; thing2 ...

how to split a sentence in swi-prolog

Hi, I am trying my hands on swi-prolog in win xp. I am trying to understsnad how to split a sentence in prolog into spearate atoms. Ex : Say I have a sentence like this : "this is a string" Is there any way to get individual words to get stored in a variable? like : X = this Y = is .... and so forth. Can anyone please expla...

Matching Multiple Lists

Hi there, I can write a predicate that is satisfied when two lists are equal e.g. equal([2,3],[2,3]) would be true and equal([2,3],[4,5]). would be false. However, what if I want to have a list and try and match it with any list in a list of lists e.g. match([2,3],[[5,6],[4,6,2],[2,3]]). would be true because of the last list in the li...

Prolog - call a rule with fact

TL;DR: Need help calling a rule with a fact I´ve started out with prolog, coming from C and got stuff working... until they evidently got broken. I´m writing a small car-paint program for myself as I´m learning this new language Im trying to call a rule with a fact (is this possible?), what I want to do is use one fact "cars" and anothe...

Prolog - return value from base case

Ok, here's the deal: I've got two piles of shirts I want to take a random shirt from each pile and put them in a new pile Then get the new pile out And here is the code: mix([],[],_). mix(P1,P2, Pile):- takeshirt(P1,1,Taken1,Rem1), takeshirt(P2,1,Taken2,Rem2), #Take one append(Pile,Taken1,New), append(New,Taken2,New...

Help In Learning Prolog

Hello Guys Please forgive me if this is the wrong place for asking this question. Kindly point me to the right place. Thanks. I am learning prolog and need help finding a good book that can help me understand it so that i can do all my assigments. At the moment i have LEARN PROLOG NOW from Blackburn but it seems i still miss some thing...

writing a wrapper for a programming language

I want to write a ruby wrapper swi-prolog. Can anyone please tell me how to proceed with writing one? I would appreciate if anyone please explain me what steps need to be considered while attempting to write this sort. ...

Prolog - get the first list from a list of lists

I've got a list consisting of smaller lists inside of it, each list consisting of 2 items: [[a,1],[b,2],[c,3]] I'm using a function called take(1,L,R) to take the first item from list L and return the item R. The code for the take function is here: take(0,X,X). take(N,[H|T],[H|R]):- N>0, M is N-1, take(M,T,R). At t...