Prolog procedure does not exist (cant run rules in prolog)

Total
13
Shares

I am new to Prolog and using the SWISH SWI online PROLOG website. https://swish.swi-prolog.org/
I am trying a really basic program:

a('jae').
b('lii').
c('jackson').
happy(A):-sings(A).
happy(B):-dances(B).
goToPlay(C):-free(C).

trying to run happy(jae). gives the following error

procedure `sings(A)' does not exist
Reachable from:
      happy(A)

Please help me solve this.


Solution

If submit the goal

happy(jae).

Then rule

happy(A) :- sings(A).

applies, which means that the next goal to be solved is

sings(A).

with A = jae.

Unfortunately the one-argument predicate sings/1 is nowhere to be found, so you get the same error as for a missing procedure in another programming language.

You have to define sings/1.

Leave a Reply

Your email address will not be published. Required fields are marked *