S U B S T ( , )
S U B S T ( { x / S a m , y / P a m } , L i k e s ( x , y ) ) = L i k e s ( S a m , P a m )
"
g
"
S U B S T ( { / g } , )
"x L i k e s ( x , I c e C r e a m ) { x / B e n }
L i k e s ( B e n , I c e C r e a m )
"
k
"
S U B S T ( { / k } , )
"x K i l l ( x , V i c t i m )
K i l l ( M u r d e r e r , V i c t i m ) M u r d e r e r
"x F a t h e r ( x , J o h n ) { x / J o h n }
F a t h e r ( J o h n , J o h n )
"
g
" S U B S T ( { g / } , )
L i k e s ( I a n , I c e C r e a m )
"x L i k e s ( x , I c e C r e a m )
"
p i , p , i = 1 , . . . , n q
i
"i S U B S T ( , p ) = S U B S T ( , p i )
i
p , p , . . . , p , ( p 1 '" p 2 '" . . . '" p n ! q )
n
1 2
S U B S T ( , q )
"
"
"
"
"
"
"
" U N I F Y p , q
p , q
U N I F Y ( p , q ) = S U B S T ( , p ) = S U B S T ( , q )
" U N I F Y f a i l
" K n o w s ( J o h n , x ) ! H a t e s ( J o h n , x )
"
K n o w s ( J o h n , J a n e )
K n o w s ( y , L e o n )
K n o w s ( y , M o t h e r ( y ) )
K n o w s ( x , E l l e n )
"
U N I F Y ( K n o w s ( J o h n , x ) , K n o w s ( J o h n , J a n e ) ) = { x / J a n e }
U N I F Y ( K n o w s ( J o h n , x ) , K n o w s ( y , L e o n ) ) = { x / L e o n , y / J o h n }
U N I F Y ( K n o w s ( J o h n , x ) , K n o w s ( y , M o t h e r ( y ) ) ) =
{ y / J o h n , x / M o t h e r ( J o h n ) }
U N I F Y ( K n o w s ( J o h n , x ) , K n o w s ( x , E l l e n ) ) = f a i l
x J o h n E l l e n
" p
"
p
" p '" r '" . . . '" s ! q
r , s , . . .
q
L i k e s ( x , I c e C r e a m ) , L i k e s ( y , I c e C r e a m )
L i k e s ( x , x ) , L i k e s ( x , y )
C O M P O S E ( 1 , 2 )
S U B S T ( C O M P O S E ( 1 , 2 ) , p ) = S U B S T ( 2 , S U B S T ( 1 , p ) )
p r o c e d u r e ( K B , p )
i f K B p t h e n r e t u r n
p K B
f o r e a c h ( p 1 '" . . . '" p n ! q ) i n K B
i , U N I F Y ( p i , p ) = d o
( K B , [ p 1 , . . . , p i - 1 , p i + 1 , . . . , p n ] , q , )
e n d
p r o c e d u r e ( K B , p r e m i s e s , c o n c l u s i o n , )
i f p r e m i s e s = [ ] t h e n
( K B , S U B S T ( , c o n c l u s i o n ) )
e l s e f o r e a c h p i n K B
U N I F Y ( p , S U B S T ( , F I R S T ( p r e m i s e s ) ) ) = 2 d o
K B , R E S T ( p r e m i s e s ) , c o n c l u s i o n , C O M P O S E ( , 2 ) )
e n d
"
"
"
f u n c t i o n ( K B , q ) r e t u r n s
( K B , [ q ] , { } )
f u n c t i o n ( K B , q l i s t , ) r e t u r n s
i n p u t s K B
q l i s t
l o c a l v a r i a b l e s a n s w e r s
i f q l i s t t h e n r e t u r n { }
q ! F I R S T ( q l i s t )
f o r e a c h q i i n K B i ! U N I F Y ( q , q i ) d o
C O M P O S E ( , i ) a n s w e r s
e n d
f o r e a c h ( p 1 '" . . . '" p n ! q i ) i n K B
i ! U N I F Y ( q , q i ) d o
a n s w e r s ! (
K B , S U B S T ( i , [ p 1 . . . p n ] ) , C O M P O S E ( , i ) ) *" a n s w e r s
e n d
r e t u r n ( K B , R E S T ( q l i s t ) , )
"a n s w e r s
"x P ( x ) ! Q ( x )
"x P ( x ) ! R ( x )
"x Q ( x ) ! S ( x )
"x R ( x ) ! S ( x )
S ( A ) { x / A }
"x P ( x ) ! R ( x )
R
i f K B | = t h e n K B R
p i , q i
U N I F Y ( p j , q k ) =
p 1 (" . . . p j . . . (" p m ,
q 1 (" . . . q k . . . (" q n
S U B S T ( , ( p 1 (" . . . p j - 1 (" p j + 1 . . . (" p m (" q 1 (" . . . q k - 1 (" q k + 1 . . . (" q n ) )
p i , q i , r i , s i
U N I F Y ( p j , q k ) =
p 1 '". . . p j . . . '"p n 1 !r 1 (". . . ("r n 2 ,
s 1 '". . . '"s n 3 !q 1 (". . . q k . . . ("q n 4
S U B S T ( , ( p 1 '". . . p j - 1 '"p j + 1 . . . '"p n 1 '"s 1 '". . . '"s n 3 !r 1 (". . . ("r n 2 ("q 1 (". . . q k - 1 ("q k + 1 . . . ("q n 4 ) )
P ( w ) (" Q ( w ) P ( w ) ! Q ( w )
P ( x ) (" R ( x ) T r u e ! P ( x ) (" R ( x )
Q ( y ) (" S ( y ) Q ( y ) ! S ( y )
R ( z ) (" S ( z ) R ( z ) ! S ( z )
, ! T r u e ! , !
T r u e !
S ( A ) K B
P ( w ) ! Q ( w ) Q ( y ) ! S ( y )
{ y / w }
P ( w ) ! S ( w ) T r u e ! P ( x ) (" R ( x )
{ w / x }
T r u e ! S ( x ) (" R ( x ) R ( z ) ! S ( z )
{ x / A , z / A }
T r u e ! S ( A ) (" S ( A )
S ( A ) (" S ( A ) = S ( A )
T r u e ! S ( A )
S ( A ) K B
P ( w ) ! Q ( w ) Q ( y ) ! S ( y )
{ y / w }
P ( w ) ! S ( w ) T r u e ! P ( x ) (" R ( x )
{ w / x }
T r u e ! S ( x ) (" R ( x ) R ( z ) ! S ( z )
{ z / x }
T r u e ! S ( x ) S ( A ) ! F a l s e
( K B '" P ! F a l s e ) ! ( K B ! P )
T r u e ! F a l s e
p ! q a" p (" q ( "x P ( x ) ) (" ( "x Q ( x ) )
p
( p (" q ) a" p '" q x p (" "x q
( p '" q ) a" p (" q "x p (" q
"x p a" "x p
"x p a" "x p
p a" p
" "x P ( x )
P ( A ) A ( a (" b ) (" c ( a (" b (" c )
( a '" b ) '" c ( a '" b '" c )
"x P e r s o n ( x ) ! "y H e a r t ( y ) '"
H a s ( x , y )
"x P e r s o n ( x ) !
H e a r t ( F ( x ) ) '" H a s ( x , F ( x ) )
'" ("
( a '" b ) (" c
( a (" c ) '" ( b (" c )
( a ("
b ("c ("d ) ( a '"b ! c ("d )
"x D o g ( x ) '" O w n s ( J a c k , x ) D o g ( D )
O w n s ( J a c k , D )
"x ( "y D o g ( y ) '" O w n s ( x , y ) ) ! D o g ( y ) '" O w n s ( x , y ) !
A n i m a l L o v e r ( x ) A n i m a l L o v e r ( x )
"x A n i m a l L o v e r ( x ) ! A n i m a l L o v e r ( x ) '" A n i m a l ( y ) '"
( "y A n i m a l ( y ) ! K i l l s ( x , y ) ) K i l l s ( x , y ) ! F a l s e
K i l l s ( J a c k , T u n a ) (" K i l l s ( J a c k , T u n a ) ("
K i l l s ( C u r i o s i t y , T u n a ) K i l l s ( C u r i o s i t y , T u n a )
C a t ( T u n a ) C a t ( T u n a )
"x C a t ( x ) ! A n i m a l ( x ) C a t ( x ) ! A n i m a l ( x )
D o g ( D ) D o g ( y ) '" O w n s ( x , y ) ! A n i m a l L o w e r ( x ) A n i m a l L o w e r ( x ) '" A n i m a l ( y ) '" K i l l s ( x , y ) ! F a l s e
{ y / D }
O w n s ( x , D ) ! A n i m a l L o w e r ( x ) O w n s ( J a c k , D ) C a t ( T u n a ) C a t ( x ) ! A n i m a l ( x )
{ x / J a c k } { x / T u n a }
A n i m a l L o w e r ( J a c k ) A n i m a l ( T u n a )
{ y / T u n a }
K i l l s ( J a c k , T u n a ) (" K i l l s ( C u r i o s i t y , T u n a ) A n i m a l L o w e r ( x ) '" K i l l s ( x , T u n a ) ! F a l s e
{ x / J a c k }
K i l l s ( C u r i o s i t y , T u n a ) ! F a l s e K i l l s ( J a c k , T u n a ) ! F a l s e
{ }
K i l l s ( J a c k , T u n a )
"w K i l l s ( w , T u n a )
{ }
K i l l s ( w , T u n a ) ! F a l s e
F a l s e
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"p S y m p t o m ( p , T o o t h a c h e ) ! D i s e a s e ( p , C a v i t y )
"p S y m p t o m ( p , T o o t h a c h e ) !
D i s e a s e ( p , G u m D i s e a s e ) (" D i s e a s e ( p , I m p a c t e d W i s d o m )
"p D i s e a s e ( p , C a v i t y ) ! S y m p t o m ( p , T o o t h a c h e )
"
"
"
"
"
"
"
"
"
"
P ( A ) A
P ( C a v i t y ) = 0 . 1
" P ( A )
"
P ( W e a t h e r = s u n n y ) = 0 . 7
P ( W e a t h e r = r a i n ) = 0 . 2
P ( W e a t h e r = c l o u d y ) = 0 . 0 8
P ( W e a t h e r = s n o w ) = 0 . 0 2
P ( C a v i t y | T o o t h a c h e ) = 0 . 8
P ( A | B )
B C P ( A | B '" C )
P ( A '" B )
P ( A | B ) =
P ( B )
P ( A '" B ) = P ( A | B ) P ( B )
P ( A '" B ) = P ( B | A ) P ( A )
<