Week 9 Horn Clauses and Logic Programming
Week 9 Horn Clauses and Logic Programming
Logic Programming
→ A (propositional) definite clause
program is a set P
Harn clauses
of definite in rule form
{ }
→ •
P
if
=
→ a
→ R
O → S
R S,
→ T
Queries
→ A conjunctive query is a
conjunction of (positive literals
di In Ii Iz In
A ② A . . .
A , ,
- - - .
premises / data)
the to the conclusion / query)
↳ starting with the data we ask :
that follow from the data
"
"
what are the
necessary consequences
→ Resolution proceeds
data
in a backwards direction from the
to the
query
↳ with the conclusion
starting we ask :
"
what are the sufficient conditions that would prove the query "
Resolution Procedure
?T
step 2) Identify the
first occurrence d- rule from the a
logic program
7 that matches the first conjunct of the
e-
query
9
? T R S ,
→ T
2. Rt S /
,
-
step 4) Repeat until all conjuncts of the query have been eliminated
after having been matched by fact ( with a an
empty tail)
OR
At least one tonjunct is left which fails to match the
head of any rule
e. g 1
?T R ,
S → T → p
p
RFP
→ 0
? → R p → R
¥ O → S
? → P R S ,
→ T
?
% → s
P → ce
? Es p
✓
☐ →
empty box means successful Resolution
step 5) In the event that there are more than one rules whose
head matches the first conjunct of the query , we
need to backtrack if the first rule leads to a
may
deadlock
2
e.
g
? T R→ T → p
?R✓d a → R
→ R P → R
i. R - T
p
e
?R P→ R
'
✓
P
7-
→
on
rewriting rules they only care about the syntactic
,