prolog

Prolog fact doesn't get interpreted


I have been struggling with this issue for more than 2 days now. My Prolog code is as simple as that:

father(abraham,isaac).
mother(sarah,isaac).
parent(X, Y):- father(X, Y).
parent(X, Y):- mother(X, Y).

When I try to run the question ?-parent(X, isaac). The result is:

X = abraham .

instead of:

X = abraham .
X = sarah .

I am using SWI-Prolog version 9.0.4 (stable) in Windows 11. I have tried uninstalling/reinstalling SWI-Prolog multiple times and I have also tried my code on macOS and I get the same result. Any ideas about what's wrong with my code?


Solution

  • Works on my machine. If you're using the Prolog console, after the first solution is found, you'll need to type ; to backtrack and search for the next solution, repeating the typing of ; to search for further solutions, until no more solutions are found and the search fails, terminating execution of your query.

    Try it here in SWI Prolog's Swish, where you'll need to click the Next button:

    https://swish.swi-prolog.org/p/TmKQIrpL.pl

    1st Solution!

    2nd (and last) Solution!