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.
The phrase "for every x'' (sometimes "for all x'') is called a universal quantifier and is denoted by ∀x. The phrase "there exists an x such that'' is called an existential quantifier and is denoted by ∃x.
The universal quantifier, meaning "for all", "for every", "for each", etc. The existential quantifier, meaning "for some", "there exists", "there is one", etc. A statement of the form: x, if P(x) then Q(x).
(Prolog does have a limited form of existential quantification for local variables in rules, as discussed in Section 4.1.) For instance, if we know that something is wrong with an appliance, then there exists a component X of the appliance such that X has a fault in it.
In mathematical logic, a universal quantification is a type of quantifier, a logical constant which is interpreted as "given any" or "for all". It expresses that a predicate can be satisfied by every member of a domain of discourse.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With