Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

universal and existential quantifier in prolog

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.
like image 593
user2064809 Avatar asked Jan 29 '15 16:01

user2064809


People also ask

What are universal and existential quantifiers?

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.

What is the difference between universal and existential quantifiers give example of each?

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).

Does Prolog have quantifiers?

(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.

What is a universal quantifier in logic?

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.


1 Answers

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.
like image 179
gusbro Avatar answered Oct 22 '22 11:10

gusbro