patrickkr
patrickkr

Reputation: 21

SWI Prolog equivalence

I think this is a really simple question, but I still can´t solve it.

How can I define a logical consequence in both directions in Prolog?

For example my database contains this:

need_umbrealla(X) :- rainy(X).
rainy(X) :- need_umbrealla(X).

It always results in a permanent loop if I do the request

rainy(X).

to my interpreter.

What can I do there?

Thanks for your help =)

Upvotes: 0

Views: 206

Answers (1)

g3muse
g3muse

Reputation: 121

The variable X that you are declaring as rainy is the same variable that needs an umbrella. What is X? Does the weather need an umbrella?

You could just declare:
needs_umbrella(X , rainy).

with the request:

needs_umbrella(monday, rainy).  
true

needs_umbrella(monday, sunny).
false

Upvotes: 1

Related Questions