prolog

Input in Prolog

I'm currently working on a recursive Prolog program to link routes together to create a basic GPS of the Birmingham area. At the moment I can get output as so: Input routeplan(selly_oak, aston, P). Output P = [selly_oak, edgbaston, ... , aston] What I would like to do is have my program provide some sort of interface, so if I were...

Prolog Family tree

Hi I have a Question in prolog , I did it but its not showing answers When i ask about the brothers,sisters,uncles,aunts This is what I wrote, what's wrong ? /*uncle(X, Y) :– male(X), sibling(X, Z), parent(Z, Y).*/ /*uncle(X, Y) :– male(X), spouse(X, W), sibling(W, Z), parent(Z, Y).*/ uncle(X,Y) :- parent(Z,Y), brother(X,Z). au...

Prolog Path Finding

If I have the following predicate door, which declare that there is a door between the two rooms: door(office, hall). door(kitchen, office). door(hall, "dining room"). door(kitchen, cellar). door("dining room", kitchen). And the predicate doorstate which declares the state of a door: doorstate(hall, office, closed). doorstate(hall, "...

unique results from prolog

Is there a easy way to make a query in prolog only return each result once? for instance I'm trying something like: deadly(Xn) :- scary(X), Xn is X - 1, Xp is X + 1, not(safe(Xn)), safe(Xp). deadly(Xp) :- scary(X), Xn is X - 1, Xp is X + 1, not(safe(Xp)), safe(Xn). deadly(X). and getting X = 5 X = 5 X = 5 X = 5 .... Not to us...

prolog to SQL converter.

Without thinking to much, it seems to me that a large set of Prolog's functionality could be implemented as relational calculus (a.k.a. SQL). Has anyone heard of any tools to automatically convert Prolog to SQL? ...

What is SML used for?

Hello everyone, What are the uses of SML in the real word? Are its practical uses similar to that of Prolog? ...

Where is Prolog used for traffic control systems?

The user Laurent had an interesting reply to the question [Why hasn’t logic programming caught on?]: If you look at the influence logic-programming has had in the field of -- air traffic control -- I don't think it can be said logic-programming has not caught on. A question arises: Where is prolog used for traffic cont...

Towers of Hanoi puzzle (prolog)

Hi , every one know the famous hanoi prolog and you can find it HERE and its great but when i write this query move(3,left,right,center). its not showing these results Move top disk from left to right Move top disk from left to center Move top disk from right to center Move top disk from left to right Move top disk from center to...

Prolog operator precedence and rules matching

I have the next two facts loaded in my prolog interpreter: foo(U+V,1). foo(U*V,2). Now I try the next queries with that results: foo(x*x+x,R). --> R = 1 foo(x+x*x,R). --> R = 1 foo(x*x*x,R). --> R = 2 Now I try with the next query: foo(x*x-x,R). --> no As I understand, this is explained by how the operator precedence bui...

Breadth-First in Prolog

What is the general idea of using breadth-first over the default depth-first search scheme in Prolog? Not taking infinite branches? Is there any general way to use breadth-first in Prolog? I've been googling around and I didn't find too much useful info for a novice. ...

Prolog -- symetrical predicates

I have to simulate family tree in prolog. And i have problem of symetrical predicates. Facts: parent(x,y). male(x). female(y). age(x, number). Rules: blood_relation is giving me headache. this is what i have done: blood_relation(X,Y):-ancestor(X,Y). blood_relation(X,Y):-uncle(X,Y);brother(X,Y);sister(X,Y);(mother(Z,Y),sister(X,Z));...

prolog sum & sub using successors ?

Hi , what is substraction and summation using successors , can any one show me an example for that i know how to do it the normal way . /* sub(X, Y, Z) ---subtraction */ sub(X, Y, Z) :- add(Y, Z, X). ...

Declaring a predicate dynamic in gprolog

I have this code in Prolog: dynamic(player_at/1). player_at(house). goto(X) :- retract(player_at(house)), assert(player_at(X)). But I still get this error: uncaught exception: error(permission_error(modify,static_procedure,player_at/1),retract/1) when I execute goto(foo). I've read the dynamic documentation, but I can't figure out...

Getting all the solutions to a predicate in Prolog

I'm writing a text adventure game in Prolog, and I am printing out room exits. I have code that does: exits_from(Room) :- connected(Room, X), write(X), write(' '). where connected/2 is: connected(X, Y) :- path(X, Y). connected(X, Y) :- path(Y, X). and path is: path(room, hallway). path(hallway, foyer). and so on. When I am...

Leaf nodes of directed graph - Prolog

Does anybody know, how to get a list of leaf nodes in Prolog? Let's say, I have a simple directed graph described by these directed edges: de(0,1). de(0,2). de(2,3). de(2,4). de(3,4). de(4,5). Now, how to recursively browse the graph and write a list of those 2 leaf nodes (node 1 & 5)? Thanks for any answer! Edit: Well, I have 1st...

How to use JPL (bidirectional Java/Prolog interface) on windows?

I'm interested in embedding a Prolog interpreter in Java. One option is using JPL, but the download links on the JPL site are broken, and the installation page mentions a jpl.zip that I can't find. I downloaded SWI-Prolog which seems to include JPL (it lists it as a component when installing), but I'm still not sure how I'd use it along ...

What is the best AI language/framework for .NET?

I'm building an academic work that consists in a turn-based strategy game. I'm using XNA 3 for the graphics but didn't decide what to use for AI. I was considering to use P#, a Prolog interpreter for .NET but i found it a bit poor. Do you anything better for game AI than Prolog (maybe Haskell?) or a better interpreter then P#? ...

What are your recomendations for a C++ interface to Prolog?

I'm interested in using Prolog in a C++ program I'm developing. I've come across the SWI-Prolog interface for C++, but I wanted to ask the SO crowd what your personal experience and reccomendation would be before I get serious about developing my application. The reason I'm looking into this is in order to embed a relatively simple and...

Prolog predicate problems

I'm just starting with Prolog, and I can't figure out why the the following doesn't work as I expect it to. I'm trying to create a predicate that returns true if list L2 is contained in L1. This is what I wrote: assert(contains (L1, L1)). assert(contains(L1, [X|L2]):-member(X, L1), contains(L1, L2)). assert(contains(L1, [])). I fig...

Prolog Compiler for .Net

Can anyone recommend a Prolog compiler for .Net. The ones that I have been able to find searching the net, do not appear to have been updated for several years. Thanks Shiraz ...