prolog and backtracking



I'M Trying To Write This Prolog Interpreter For A Subset Of The Prolog
Grammar In Java And I Encountered Problems With Bakctracking.

For example

Given the following database:

father(bill,jake).
father(bill,ruby).
mother(carmen, jake).
mother(carmen, ruby).
parent(X,Y):-father(X,Y).
parent(X,Y):-mother(X,Y).
sibling(X,Y):-parent(P,X),parent(P,Y).

What i'm trying to do is, since this grammar does not
include lists or cuts or any of prolog's built in
goals, i'm going to solve for all the possible goals
for the rules so that when the user asks a query, it
would be easier to solve. So, using the said idea in
the above mentioned database, this would be the list
of goals.


father(bill,jake).
father(bill,ruby).
mother(carmen, jake).
mother(carmen, ruby).
parent(bill,jake).
parent(bill,ruby).
parent(carmen, jake).
parent(carmen, ruby).
sibling(jake,ruby).

I think it's a good idea but it would still have to
use prolog's standard way of solving goals. So, my
problem is, how do i tell prolog where to restart a
search when i want to find all solutions for a query.
For example

sibling(X,Y):-parent(P,X),parent(P,Y).

It would first solve parent(P,X)

parent(P,X):-father(P,X).
so
P=bill
X=jake.

so...

sibling(X,Y):-parent(bill,jake),parent(bill,Y).

parent(bill,Y):-father(bill,Y).
but...
father(bill,Y).
Y=jake

but jake has already been found and it should be
different from the result of the first parent. Any
tips on how to remedy this. Also, if for example the
second parent(P,Y) has found all its solutions and the
first parent(P,X) will solve for the next X, how do i
tell that it should look at the next father fact? I
tried storing the current state of the facts needed to
solve parent(P,Y) inside the node of parent(P,Y) but
java said there was an out of memory exception. Is
there a simpler way to address this problem?
.



Relevant Pages

  • Re: Networking in Prolog - a survey
    ... I coded it in Java ... kindly asked if it was possible to extend the interpreter with various ... the state of the art in Prolog networking libraries to see if I could ...
    (comp.lang.prolog)
  • Re: Recommendations for a free Prolog interpreter in Java
    ... >> What is the advantage of using Prolog in a Java environment? ... > Prolog in Java is good for the present Internet / distributed ... >> code running on server. ...
    (comp.lang.prolog)
  • Re: Prolog in a Java Tomcat environnement
    ... >> I'm now upgrading to the latest stable version of swi because in mine ... to be carefull with install stuff and file naming, ... > What Java SDK do you use? ... > Run the JPL examples (Java and Prolog) to verify that your ...
    (comp.lang.prolog)
  • Re: In which cases/problems is Prolog faster than Java?
    ... We've OOP languages built from functional languages foundations ... they are envy of imperative programming styles. ... still a predicate either in plain Prolog or encapsulated in a Prolog ... People often use Java not because its OO features per se but because ...
    (comp.lang.prolog)
  • Re: Recommendations for a free Prolog interpreter in Java
    ... Paul Singleton wrote: ... >> one these types of Prolog systems that work completely in Java. ... code running on server. ...
    (comp.lang.prolog)