0% found this document useful (0 votes)
19 views19 pages

Variable Substitution in Logic

An instance of an atom or clause is obtained by substituting terms for variables uniformly. A substitution assigns terms to distinct variables. Applying a substitution to an atom or clause replaces all occurrences of each variable with its assigned term. Reasoning with variables involves applying substitutions to relate atoms and clauses. Logical proofs can be constructed using both bottom-up and top-down proof procedures on a knowledge base to derive conclusions.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views19 pages

Variable Substitution in Logic

An instance of an atom or clause is obtained by substituting terms for variables uniformly. A substitution assigns terms to distinct variables. Applying a substitution to an atom or clause replaces all occurrences of each variable with its assigned term. Reasoning with variables involves applying substitutions to relate atoms and clauses. Logical proofs can be constructed using both bottom-up and top-down proof procedures on a knowledge base to derive conclusions.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Reasoning with Variables

An instance of an atom or a clause is obtained by uniformly


substituting terms for variables.
A substitution is a finite set of the form {V1 /t1 , . . . , Vn /tn },
where each Vi is a distinct variable and each ti is a term.
The application of a substitution = {V1 /t1 , . . . , Vn /tn } to
an atom or clause e, written e, is the instance of e with
every occurrence of Vi replaced by ti .

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 1

Application Examples
The following are substitutions:
1 = {X /A, Y /b, Z /C , D/e}
2 = {A/X , Y /b, C /Z , D/e}
3 = {A/V , X /V , Y /b, C /W , Z /W , D/e}
The following shows some applications:
p(A, b, C , D)1 =
p(X , Y , Z , e)1 =
p(A, b, C , D)2 =
p(X , Y , Z , e)2 =
p(A, b, C , D)3 =
p(X , Y , Z , e)3 =

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 2

Application Examples
The following are substitutions:
1 = {X /A, Y /b, Z /C , D/e}
2 = {A/X , Y /b, C /Z , D/e}
3 = {A/V , X /V , Y /b, C /W , Z /W , D/e}
The following shows some applications:
p(A, b, C , D)1 = p(A, b, C , e)
p(X , Y , Z , e)1 = p(A, b, C , e)
p(A, b, C , D)2 = p(X , b, Z , e)
p(X , Y , Z , e)2 = p(X , b, Z , e)
p(A, b, C , D)3 = p(V , b, W , e)
p(X , Y , Z , e)3 = p(V , b, W , e)

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 3

Unifiers

Substitution is a unifier of e1 and e2 if e1 = e2 .


Substitution is a most general unifier (mgu) of e1 and e2 if
I
I

is a unifier of e1 and e2 ; and


if substitution 0 also unifies e1 and e2 , then e 0 is an instance
of e for all atoms e.

If two atoms have a unifier, they have a most general unifier.

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 4

Unification Example
Which of the following are unifiers of p(A, b, C , D) and
p(X , Y , Z , e):
1 = {X /A, Y /b, Z /C , D/e}
2 = {Y /b, D/e}
3 = {X /A, Y /b, Z /C , D/e, W /a}
4 = {A/X , Y /b, C /Z , D/e}
5 = {X /a, Y /b, Z /c, D/e}
6 = {A/a, X /a, Y /b, C /c, Z /c, D/e}
7 = {A/V , X /V , Y /b, C /W , Z /W , D/e}
8 = {X /A, Y /b, Z /A, C /A, D/e}
Which are most general unifiers?

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 5

Unification Example
p(A, b, C , D) and p(X , Y , Z , e) have as unifiers:
1 = {X /A, Y /b, Z /C , D/e}
4 = {A/X , Y /b, C /Z , D/e}
7 = {A/V , X /V , Y /b, C /W , Z /W , D/e}
6 = {A/a, X /a, Y /b, C /c, Z /c, D/e}
8 = {X /A, Y /b, Z /A, C /A, D/e}
3 = {X /A, Y /b, Z /C , D/e, W /a}
The first three are most general unifiers.
The following substitutions are not unifiers:
2 = {Y /b, D/e}
5 = {X /a, Y /b, Z /c, D/e}

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 6

Proofs

A proof is a mechanically derivable demonstration that a


formula logically follows from a knowledge base.
Given a proof procedure, KB ` g means g can be derived
from knowledge base KB.
Recall KB |= g means g is true in all models of KB.
A proof procedure is sound if KB ` g implies KB |= g .
A proof procedure is complete if KB |= g implies KB ` g .

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 7

Bottom-up proof procedure

KB ` g if there is g 0 added to C in this procedure where g = g 0 :


C := {};
repeat
select clause h b1 . . . bm in KB such that
there is a substitution such that
for all i, there exists bi0 C where bi = bi0 and
there is no h0 C such that h0 is more general than h
C := C {h}
until no more clauses can be selected.

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 8

Example

live(Y ) connected to(Y , Z ) live(Z ). live(outside).


connected to(w6 , w5 ). connected to(w5 , outside).

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 9

Example

live(Y ) connected to(Y , Z ) live(Z ). live(outside).


connected to(w6 , w5 ). connected to(w5 , outside).
C = {live(outside),
connected to(w6 , w5 ),
connected to(w5 , outside),
live(w5 ),
live(w6 )}

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 10

Soundness of bottom-up proof procedure


If KB ` g then KB |= g .
Suppose there is a g such that KB ` g and KB 6|= g .
Then there must be a first atom added to C that has an
instance that isnt true in every model of KB. Call it h.
Suppose h isnt true in model I of KB.
There must be a clause in KB of form
h0 b1 . . . bm
where h = h0 . Each bi is true in I . h is false in I . So this
clause is false in I . Therefore I isnt a model of KB.
Contradiction.

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 11

Fixed Point
The C generated by the bottom-up algorithm is called a
fixed point.
C can be infinite; we require the selection to be fair.
Herbrand interpretation: The domain is the set of constants.
We invent one if the KB or query doesnt contain one.
Each constant denotes itself.
Let I be the Herbrand interpretation in which every ground
instance of every element of the fixed point is true and every
other atom is false.
I is a model of KB.
Proof: suppose h b1 . . . bm in KB is false in I . Then h
is false and each bi is true in I . Thus h can be added to C .
Contradiction to C being the fixed point.
I is called a Minimal Model.
c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 12

Completeness

If KB |= g then KB ` g .
Suppose KB |= g . Then g is true in all models of KB.
Thus g is true in the minimal model.
Thus g is in the fixed point.
Thus g is generated by the bottom up algorithm.
Thus KB ` g .

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 13

Top-down Proof procedure

A generalized answer clause is of the form


yes(t1 , . . . , tk ) a1 a2 . . . am ,
where t1 , . . . , tk are terms and a1 , . . . , am are atoms.
The SLD resolution of this generalized answer clause on ai
with the clause
a b1 . . . bp ,
where ai and a have most general unifier , is
(yes(t1 , . . . , tk )
a1 . . . ai1 b1 . . . bp ai+1 . . . am ).

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 14

To solve query ?B with variables V1 , . . . , Vk :


Set ac to generalized answer clause yes(V1 , . . . , Vk ) B;
While ac is not an answer do
Suppose ac is yes(t1 , . . . , tk ) a1 a2 . . . am
Select atom ai in the body of ac;
Choose clause a b1 . . . bp in KB;
Rename all variables in a b1 . . . bp ;
Let be the most general unifier of ai and a.
Fail if they dont unify;
Set ac to (yes(t1 , . . . , tk ) a1 . . . ai1
b1 . . . bp ai+1 . . . am )
end while.

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 15

Example

live(Y ) connected to(Y , Z ) live(Z ). live(outside).


connected to(w6 , w5 ). connected to(w5 , outside).
?live(A).

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 16

Example

live(Y ) connected to(Y , Z ) live(Z ). live(outside).


connected to(w6 , w5 ). connected to(w5 , outside).
?live(A).
yes(A) live(A).
yes(A) connected to(A, Z1 ) live(Z1 ).
yes(w6 ) live(w5 ).
yes(w6 ) connected to(w5 , Z2 ) live(Z2 ).
yes(w6 ) live(outside).
yes(w6 ) .

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 17

Function Symbols

Often we want to refer to individuals in terms of components.


Examples: 4:55 p.m. English sentences. A classlist.
We extend the notion of term . So that a term can be
f (t1 , . . . , tn ) where f is a function symbol and the ti are
terms.
In an interpretation and with a variable assignment, term
f (t1 , . . . , tn ) denotes an individual in the domain.
One function symbol and one constant can refer to infinitely
many individuals.

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 18

Lists
A list is an ordered sequence of elements.
Lets use the constant nil to denote the empty list, and the
function cons(H, T ) to denote the list with first element H
and rest-of-list T . These are not built-in.
The list containing sue, kim and randy is
cons(sue, cons(kim, cons(randy , nil)))
append(X , Y , Z ) is true if list Z contains the elements of X
followed by the elements of Y
append(nil, Z , Z ).
append(cons(A, X ), Y , cons(A, Z )) append(X , Y , Z ).

c
D.
Poole and A. Mackworth 2010

Artificial Intelligence, Lecture 12.4, Page 19

You might also like