How to solve a problem with an infinite loop [beginners question]



Hi everybody,

I have the following grammar

gleich(a,b).
gleich(b,c).

gleich(A,B) :-
A=B.

gleich(A,B) :-
gleich(B,A).

gleich(A,B) :-
gleich(A,X),gleich(X,B).

I want to ask prolog the following questions (which should all lead to
the answer true):

gleich(a,a).
gleich(a,b).
gleich(b,a).
gleich(a,c).
gleich(c,a).

gleich(a,c) and gleich(c,a) leads to an infinity loop how can I avoid
this?

best wishes

Philipp

.



Relevant Pages

  • Re: Boolean search query parsing (hierarchical)
    ... Using a parser generator is precisely what I was trying to avoid. ... I was trying to avoid having to write the grammar for Boolean ... That I haven't been able to find a grammar for Boolean queries on ...
    (comp.lang.java.programmer)
  • Re: Boolean search query parsing (hierarchical)
    ... > Using a parser generator is precisely what I was trying to avoid. ... I was trying to avoid having to write the grammar for Boolean ... have a class Disjunction, a class Conjunction, and so on. ...
    (comp.lang.java.programmer)
  • Re: query: grammars for Prolog?
    ... >> One of the things that continues to surprise me as I ... >> continue to work with Prolog is that none of the Prolog ... >> the language that doesn't have dynamically declared ... >> grammar to understand the syntax. ...
    (comp.lang.prolog)
  • Re: If-Else in prolog
    ... Please give me a rough idea of how the grammar would ... some other programming language? ... Assuming that you're just wondering how to do if/else in Prolog, ...
    (comp.lang.prolog)
  • Re: java.lang.StackOverflowError
    ... grammar, and i'll follow your hint and try to post in comp.compilers. ... could i avoid the stackoverflow by resizing the ...
    (comp.lang.java.programmer)