prolog

How can I connect C# and Sicstus prolog?

I am trying to connect prolog project with C#. How can i Do this? ...

PROLOG: basic question: duplicate solutions

I have a problem trying to get some code that returns unique answers to my query. For example, defining stuff(A,B,C) :- A=C ; B=C. morestuff([],[],[]). morestuff([A|AA],[B|BB],[C|CC]) :- stuff(A,B,C), morestuff(AA,BB,CC). then running morestuff([A,A],[A,B],[a,b]). gives the output: A = a B = b ? ; A = a B = b ? ; yes. As you c...

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

Custom reverse of a list in Prolog

Hello, I am trying to write a predicate that given the following list in Prolog: [[1,a,b],[2,c,d],[[3,e,f],[4,g,h],[5,i,j]],[6,k,l]] will produce the following list: [[6,k,l],[[5,i,j],[4,g,h],[3,e,f]],[2,c,d],[1,a,b]] As you can see I would like to preserve the order of the elements at the lowest level, to produce elements in the ...

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

How do I store and access a list within a variable in Prolog?

I am attempting to learn the basics of Prolog for a class. I'm running into the seemingly simple problem of not being able to store a list within a rule and retrieve it for usage in other clauses. For example: % These are the contents of the pl file I want to consult % Numbers I want to process inputList([3,2,1,0]). % Prints out the c...

Formulating a problem in Prolog

I currently have the following problem, that I want to solve with Prolog. It's an easy example, that would be easy to solve in Java/C/whatever. My problem is that I believe to be too tied to Java's thinking to actually formulate the problem in a way that makes useof Prolog's logic power. The problem is.. I have a set of 6 arrows, eithe...

"Returning" a list from a predicate in Prolog

resolve(K, K, _) :- writeln('finished'). %goal state resolve(CurrentState, GoalState, Path) :- suc(_, CurrentState, NextState, GoalState), append(Path, [CurrentState], NextPath), resolve(NextState, GoalState, NewPath). I currently have this algorithm, and it works as it should. I am running it like this: resolve(0, 10, Pa...

yap prolog read predicate

I am experimenting with prolog, reading "Programming in prolog using the ISO standard, fith edition". I have installed yap (yet another prolog) on my ubuntu 10.10 Maverick RC system, installed using synaptic. I am running prolog from within emacs23 using prolog-mode. The following code (from chapter five of book) does not give results a...

Traversing a graph (with possible loops) and returning the path in Prolog

I'm given a list of arcs: arc(a,b). arc(b,c). arc(c,d). arc(d,b). arc(d,e). arc(e,e). arc(e,f). I've written a set of clauses which will tell me if theres a path from node X to node Y. Loops may occur and I've accounted for that. path(X,Y) :- arc(X,Y). path(X,Y) :- arc(X,Z), path(Z,Y,[X]). path(X,Y,P) :- arc(X,Y). path(X,Y,...

Executing prolog code on an iPhone

Hello, I currently have the need to execute prolog code in an application I am making. I am aware that Apple probably never would allow something like this in the App Store, but that is not the intention either. This is more a private project that will never reach the App Store. Purpose In this case prolog is used to describe an objec...

clauses defining member and construct clauses for a predicate even_member

i done my prolog coding and no error when run it. but still cannot get the output i want. so i want to ask where is the problem. my coding is like bellow even_member(X, [X|_]). even_member(X, [_|Tail]) :- 0 is X mod 2, write(X), nl, even_member(X, Tail). the output i need it is when key in even_member(2,[1,2,3,4,5,6]). w...

Datalog vs CLIPS vs Prolog

As many programmers I studied Prolog in university, but only very little. I understand that Prolog and Datalog are closely related, but Datalog is simpler? Also, I believe that I read that Datalog does not depend on ordering of the logic clauses, but I am not sure why this is advantages. CLIPS is supposedly altogether different, but i...

How would you code a program in Prolog to print numbers from 1 to 10 using recursion?

How would you code a program in Prolog to print numbers from 1 to 10 using recursion? I've tried the following but it doesn't work, can you tell me why? print_numbers(10) :- write(10). print_numbers(X) :- write(X),nl,X is X + 1, print_numbers(X). ...

How to get the list of values during Prolog backtracking?

Say I have the following piece of code: edge(a, b). edge(a, c). edge(a, d). Now when I do neighbors(V, N) :- edge(V, N), writeln(N), fail. I can get a list of the neighbors printed out to the console. But how can I get it as a result list? Something like neighbors(V, Vs) :- edge(V, N), not(member(N, Vs)), neighbor...

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 - formulas in propositional logic

I am trying to make a predicate in order to validate if a given input represents a formula. I am allowed to use only to propositional atoms like p, q, r, s, t, etc. The formulas which I have to test are the following: neg(X) - represents the negation of X and(X, Y) - represents X and Y or(X, Y) - represents X or Y imp(X, Y) - represe...

Which of these extensions to my little logic language are unifiable?

I plan to make a little obfuscatory logic language. It's going have some features prolog doesn't. Probable some of the features I want aren't possible to unify. But before I ask what features I should drop you should know what my language is. A comma means and. A semicolon means or. Things which would be zero-ary constructors take one ar...

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