Professional Documents
Culture Documents
March 9, 2007
Textbook §5
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 1
Recap Datalog Syntax Datalog Semantics
Lecture Overview
1 Recap
2 Datalog Syntax
3 Datalog Semantics
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 2
Recap Datalog Syntax Datalog Semantics
ac := “yes ← q1 ∧ . . . ∧ qk ”
repeat
select atom ai from the body of ac;
choose clause C from KB with ai as head;
replace ai in the body of ac by the body of C
until ac is an answer.
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 3
Recap Datalog Syntax Datalog Semantics
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 4
Recap Datalog Syntax Datalog Semantics
in(alan,r123). alan
part_of(r123,cs_building). r123
in(X,Y) ← r023
part_of(Z,Y) ∧ cs_building
in(X,Z). in( , )
part_of( , )
person( )
in(alan,cs_building)
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 5
Recap Datalog Syntax Datalog Semantics
Lecture Overview
1 Recap
2 Datalog Syntax
3 Datalog Semantics
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 6
Recap Datalog Syntax Datalog Semantics
Syntax of Datalog
Definition (variable)
A variable starts with upper-case letter.
Definition (constant)
A constant starts with lower-case letter or is a sequence of digits.
Definition (term)
A term is either a variable or a constant.
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 7
Recap Datalog Syntax Datalog Semantics
Definition (atom)
An atomic symbol (atom) is of the form p or p(t1 , . . . , tn ) where p
is a predicate symbol and ti are terms.
a
|{z} ← b1 ∧ · · · ∧ bm
| {z }
head body
in(alan, R) ←
teaches(alan, cs322) ∧
in(cs322, R).
grandf ather(william, X) ←
f ather(william, Y ) ∧
parent(Y, X).
slithy(toves) ←
mimsy ∧ borogroves ∧
outgrabe(mome, Raths).
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 9
Recap Datalog Syntax Datalog Semantics
Lecture Overview
1 Recap
2 Datalog Syntax
3 Datalog Semantics
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 10
Recap Datalog Syntax Datalog Semantics
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 11
Recap Datalog Syntax Datalog Semantics
Formal Semantics
Definition (interpretation)
An interpretation is a triple I = hD, φ, πi, where
D, the domain, is a nonempty set. Elements of D are
individuals.
φ is a mapping that assigns to each constant an element of
D. Constant c denotes individual φ(c).
π is a mapping that assigns to each n-ary predicate symbol a
relation: a function from Dn into {TRUE, FALSE}.
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 12
Recap Datalog Syntax Datalog Semantics
Example Interpretation
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 13
Recap Datalog Syntax Datalog Semantics
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 14
Recap Datalog Syntax Datalog Semantics
Truth in an interpretation
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 15
Recap Datalog Syntax Datalog Semantics
Example Truths
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 16
Recap Datalog Syntax Datalog Semantics
Example Truths
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 16
Recap Datalog Syntax Datalog Semantics
Example Truths
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 16
Recap Datalog Syntax Datalog Semantics
Example Truths
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 16
Recap Datalog Syntax Datalog Semantics
Example Truths
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 16
Recap Datalog Syntax Datalog Semantics
Example Truths
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 16
Recap Datalog Syntax Datalog Semantics
Example Truths
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 16
Recap Datalog Syntax Datalog Semantics
Example Truths
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 16
Recap Datalog Syntax Datalog Semantics
Example Truths
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 16
Recap Datalog Syntax Datalog Semantics
Variables
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 17
Recap Datalog Syntax Datalog Semantics
Definition (model)
A model of a set of clauses is an interpretation in which all the
clauses are true.
Logic: Datalog Syntax and Semantics CPSC 322 Lecture 22, Slide 18