Open In App

Horn Clauses in Deductive Databases

Horn clause is clause (a disjunction of literals) with at most one positive, i.e. unnegated, literal. A clause with at most one positive (unnegated) literal is called a Horn Clause.

Deductive Database:
A type of database which can make conclusions based on sets of well-defined rules, stored in database. RDBMS and logic programming are combined using this. Deductive database designing is done with help of pure declarative programming language known as Datalog.



Types of Horn Clauses :

In Datalog, rules are expressed as a restricted form of clauses called Horn clauses, in which a clause can contain at most one positive literal.



A formula can have following quantifiers:

Forms of a Horn Clause :

  1. NOT(P1) OR NOT(P2) OR ... OR NOT(Pn) OR Q
  2. NOT(P1) OR NOT(P2) OR ... OR NOT (Pn)

Transformation of Horn Clause :
The Horn clause in (1) can be transformed into clause –

P1 AND P2 AND ... AND Pn → Q 

which is written in Datalog as following rules

Q :- P1, P2, ..., Pn 

The above Datalog Rule, is hence a Horn clause.

If predicates P1 AND P2 AND … AND Pn, are all true for a particular binding to their variable arguments, then Q is also true and can hence be inferred.

The Horn clause in (2) can be transformed into –

P1 AND P2 AND ... AND Pn → 

which is written in Datalog as follows:

P1, P2, ..., Pn 

The above Datalog expression can be considered as an integrity constraint, where all predicates must be true to satisfy query.

A query in Datalog consists of two components:

Article Tags :