Smth_Unknown
Smth_Unknown

Reputation: 133

prolog predicate logic(negation)

I have the following logical task:

If David is interested in logic, then he will either enroll in the Logic course next semester, or he is lazy. If David studied logic literature on his own, then he is interested in logic. David studied logic literature on his own. David is not lazy.

This is how I presented it in prolog

a(X,Y):-d(X,Y).
not(b(X)):-d(X,_).
d(X,Y):-c(X,Y).
c(david,logic).
b(david).

where

a(X,Y) X will enroll in the next semester for classes on the course Y

b(X) X is not lazy

c(X,Y) X independently studied literature on Y

d(X,Y) X is interested in Y

and I seem to have written my program correctly, because the question is?-a(david,logic) I get true

but this line confuses me: not(b(X)):-d(X,_).

As for me, it looks very strangely written. Tell me if I did something wrong

Upvotes: 0

Views: 66

Answers (1)

CapelliC
CapelliC

Reputation: 60004

The clause not(b(X)):-d(X,_). is never used in your query, that is solved by the following subset:

a(X,Y):-d(X,Y).
d(X,Y):-c(X,Y).
c(david,logic).

Upvotes: 1

Related Questions