DEDUCTIVE DATABASES
Introduction to Deductive Databases
Overview of Deductive Databases Prolog/Datalog Notation Datalog Notation Clausal Form and Horn Clauses Interpretation of Rules Datalog Programs and Their Safety Use the Relational Operations Evaluation of Non-recursive Datalog Queries
Overview of Deductive Databases
Declarative Language
Language to specify rules
Can deduce new facts by interpreting the rules Related to logic programming
Inference Engine (Deduction Machine)
Prolog language (Prolog => Programming in logic) Uses backward chaining to evaluate
Top-down application of the rules
Overview of Deductive Databases
Speciation consists of:
Facts
Similar to relation specification without the necessity of including attribute names Similar to relational views (virtual relations that are not stored)
Rules
Prolog/Datalog Notation
Predicate has
a name a fixed number of arguments
Convention:
Constants are numeric or character strings
Variables start with upper case letters States that Supervisor SUPERVISE(s) Supervisee
E.g., SUPERVISE(Supervisor, Supervisee)
Prolog/Datalog Notation
Rule
Is of the form head :- body
where :- is read as if and only iff
E.g., SUPERIOR(X,Y) :- SUPERVISE(X,Y) E.g., SUBORDINATE(Y,X) :- SUPERVISE(X,Y)
Prolog/Datalog Notation
Query
Involves a predicate symbol followed by y some variable arguments to answer the question
where :- is read as if and only iff
E.g., SUPERIOR(james,Y)? E.g., SUBORDINATE(james,X)?
(a) Prolog notation (b) Supervisory tree
Datalog Notation
Datalog notation
Program is built from atomic formulae
Literals of the form p(a1, a2, an) where
p predicate name n is the number of arguments E.g., <, <=, etc.
Built-in predicates are included
A literal is either
An atomic formula An atomic formula preceded by not
Clausal Form and Horn Clauses
A formula can have quantifiers
Universal Existential
10
Clausal Form and Horn Clauses
In clausal form, a formula must be transformed into another formula with the following characteristics
All variables are universally quantified Formula is made of a number of clauses where each clause is made up of literals connected by logical ORs only Clauses themselves are connected by logical ANDs only.
11
Clausal Form and Horn Clauses
Any formula can be converted into a clausal form
A specialized case of clausal form are horn clauses that can contain no more than one positive literal
Datalog program are made up of horn clauses
12
Interpretation of Rules
There are two main alternatives for interpreting rules:
Proof-theoretic Model-theoretic
13
Interpretation of Rules
Proof-theoretic
Facts and rules are axioms Ground axioms contain no variables Rules are deductive axioms Deductive axioms can be used to construct new facts from existing facts This process is known as theorem proving
14
Proving a new fact
15
Interpretation of Rules
Model-theoretic
Given a finite or infinite domain of constant values, we assign the predicate every combination of values as arguments If this is done fro every predicated, it is called interpretation
16
Interpretation of Rules
Model
An interpretation for a specific set of rules
Whenever a particular substitution to the variables in the rules is applied, if all the predicated are true under the interpretation, the predicate at the head of the rule must also be true Cannot change any fact from true to false and still get a model for these rules
17
Model-theoretic proofs
Minimal model
Minimal model
18
Datalog Programs and Their Safety
Two main methods of defining truth values
Fact-defined predicates (or relations)
Listing all combination of values that make a predicate true Head (LHS) of 1 or more Datalog rules, for example
Rule-defined predicates (or views)
19
Datalog Programs and Their Safety
A program is safe if it generates a finite set of facts
Fact-defined predicates (or relations)
Listing all combination of values that make a predicate true Head (LHS) of 1 or more Datalog rules.
Rule-defined predicates (or views)
20
Use the Relational Operations
Many operations of relational algebra can be defined in the for of Datalog rules that defined the result of applying these operations on database relations (fact predicates)
Relational queries and views can be easily specified in Datalog
21
Evaluation of Non-recursive Datalog Queries
Define an inference mechanism based on relational database query processing concepts
Predicate Dependencies
22
THANK YOU
23