I’ve thrown a glance at Prolog, and this is my first little try at writing it: it directly bugs at my first queries. (in the example below i asked for word(‘test’).)
I meant to state:
- word/1
- alias/2
- alias is commutative
- if a variable is an alias of another then it is a word
- A, C, and D are word
- B is an alias of A.
this is the knowledge base when I do a listing. in SWI-Prolog console.
?- listing.
word(A) :-
alias(A, B).
word('A').
word('C').
word('D').
alias(A, B) :-
alias(B, A).
alias('A', 'B').
Yes
3 ?- word('test').
ERROR: Out of local stack
Exception: (59,743) alias(_L147, test) ?
Any clue what’s going wrong with my knwoledge base?
this is an infinite loop.
for example, if you call
alias(2,4)then the trace would be something like: