lpTheory3
lpTheory3
NI VER
S
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
| ?- display(a + b * c = 4).
=(+(a,*(b,c)),4)
yes
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
d
c
a b
base
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
I ( base ) = base I( a ) = a
I( b ) = b I ( on ) = on
..
.
IT
TH
Y
O F
H
G
E
R
D I U
N B
S |= F
S |= P(c)
look at I ( P ) and I ( c ):
IT
TH
Y
O F
H
G
E
R
D I U
N B
S |= A ∧ B iff S |= A and S |= B
S |= A ∨ B iff S |= A or S |= B
S |= A → B iff ( not (S |= A)) or S |= B
S |= ¬A iff not (S |= A)
IT
TH
Y
O F
H
G
E
R
D I U
N B
Roughly, the idea is that for any statement Φ(v ) which talks about
variable v :
IT
TH
Y
O F
H
G
E
R
D I U
N B
if S |= F1 and . . . and S |= Fn ,
then S |= G.
F1 , F2 . . . Fn |= G.
IT
TH
Y
O F
H
G
E
R
D I U
N B
p(t1 , . . . , tn )
A1 ∧ · · · ∧ An → B
IT
TH
Y
O F
H
G
E
R
D I U
N B
S |= A1 ∧ . . . An .
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
It turns out that in the case of the term syntax we have given, if
two terms t1 , t2 are unifiable, then there is a most general unifier
(mgu) S. This means that
1. t1 S = t2 S
2. for any S 0 , if t1 S 0 = t2 S 0 , then S 0 4 S.
The most general unifier is not unique as a substitution; however,
any two mgus are equivalent in the following sense
If S1 , S2 are mgus for t1 , t2 , then S1 4 S2 and S2 4 S1 .
This last property in fact just means that t1 S1 , t1 S2 just differ by
renaming of variables back and forth.
IT
TH
Y
O F
H
G
E
R
D I U
N B
p1 θ, p2 θ, . . . , pn θ, (p1 ∧ p2 ∧ . . . ∧ pn ⇒ q)
where θ is mgu of q 0 , q
q0θ
IT
TH
Y
O F
H
G
E
R
D I U
N B
For goal
ancestor (Q, kay ),
we can use clause
daughter (X , Y ) → ancestor (Y , X )
with unifier
{ Y /Q, X /kay }
to get subgoal
daughter (kay , Q).
IT
TH
Y
O F
H
G
E
R
D I U
N B
If we use only this rule, then what are the choice points in the
search?
Which clause to pick;
there may be several clauses whose heads match a given query.
This is an OR choice: it is enough for any one such choice to
succeed.
The order to tackle the subgoals;
this is an AND choice: all the subgoals must be shown, but
the order may affect if a derivation is found, depending on the
search strategy used.
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
IT
TH
Y
O F
H
G
E
R
D I U
N B
Good News!
The backchain rule gives a complete inference system with respect
to the standard semantics of first-order logic: for given clauses C
and query Q, if C |= Qθ for some θ, then there is a derivation of
Qθ using the backchain rule.
Bad News!
However: the Prolog inference strategy is incomplete: it may fail
to find a derivation, even when a derivation exists. (Examples are
easy to find.)
Bad News!
Also, it is known that there is no decision procedure for the
problem of showing if a query follows or not from a set of definite
clauses. (This is hard to show)
IT
TH
Y
O F
H
G
E
R
D I U
N B