How can I implement following rules in prolog.
I write the “ No spiders are mammals” sentence as Existential and universal:
¬∃x(mammals(X) ∧ spider(X) ) //It is not the case that mammals are spider
∀X(mammals(X) ⇒ ¬spider(X)) //All mammals are non-spider.
Suppose you have a database with the following facts:
mammals(cat).
mammals(dog).
...
spider(blackwidow).
...
Now you can issue a rewrite your sentence into a prolog query quite straightforward:
¬∃x(mammals(X) ∧ spider(X) ) //It is not the case that mammals are spider
?- \+((mammals(X), spider(X))).
true.
and
∀X(mammals(X) ⇒ ¬spider(X)) //All mammals are non-spider.
?- forall(mammals(X), \+spider(X)).
true.