Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to express universal quantifier in the body of a datalog rule?

Tags:

datalog

I want to use universal quantifier in the body of a predicate rule, i.e., something like

A(x,y) <- ∀B(x,a), C(y,a).

It means that only if for each a from C(y, a), B(x,a) always has x to match (x,a), then A(x,y) is true.

Since in Datalog, every variable bounded in rule body is existential quantifier by default, the a would be an existential quantifier too. What should I do to express universal quantifier in the body of a predicate rule?

Thank you.

P.S. The Datalog engine I am using is logicblox.

like image 697
silverbullettt Avatar asked Oct 12 '13 23:10

silverbullettt


People also ask

What is universal quantifier with an example?

There are two types of quantifiers: universal quantifier and existential quantifier. The universal quantifier turns, for example, the statement x > 1 to "for every object x in the universe, x > 1", which is expressed as " x x > 1". This new statement is true or false in the universe of discourse.

How do you express a statement using quantifiers?

Quantifiers provide a notation that allows us to quantify (count) how many objects in the universe of discourse satisfy the given predicate. Let P(x) be the statement “x spends more than five hours every weekday in class,” where the domain for x consists of all students.

How do you write the negations of universal and existential quantifiers?

The negation of a universal statement ("all are") is logically equivalent to an existential statement ("Some are not"). Similarly, an existential statement is false only if all elements within its domain are false. The negation of "Some birds are bigger than elephants" is "No birds are bigger than elephants."


1 Answers

The basic idea is to use the logical axiom

x φ(x) ⇔ ¬∃x ¬φ(x)

to put your rules in a form where only existential quantifiers are required (along with negation). Intuitively, this usually means computing the complement of your answer first, and then computing its complement to produce the final answer.

For example, suppose you are given a graph G(V,E) and you want to find the vertices which are adjacent to all others in the graph. If universal quantification were allowed in a Datalog rule body, you might write something like

Q(x) <- ∀y E(x,y).

To write this without the universal quantifier, you first compute the vertices which are not adjacent to all others

NQ(x) <- V(x), V(y), !E(x,y).

then return its complement as the answer

Q(x) <- V(x), !NQ(x).

The same kind of trick can be used in SQL, which also lacks universal quantifiers.

like image 197
factotum Avatar answered Oct 14 '22 01:10

factotum