19. 9 INFERENCE IN
FIRST-ORDER LOGIC
¹ 7 k
function U NIFY( , , ) returns a substitution to make and identical k 7
k
inputs: , a variable, constant, list, or compound
7
, a variable, constant, list, or compound
, the substitution built up so far (optional, defaults to empty)
¹
if = failure then return failure
¹
k
else if = then return 7 ¹
k
else if VARIABLE ?( ) then return U NIFY-VAR( , , ) ¹ 7 k
7
else if VARIABLE ?( ) then return U NIFY-VAR( , , ) ¹ k 7
else if C OMPOUND ?( ) and C OMPOUND ?( ) then k 7
return U NIFY(A RGS[ ], A RGS[ ], U NIFY(O P[ ], O P[ ], ))k 7 k 7 ¹
k
else if L IST ?( ) and L IST ?( ) then 7
k
return U NIFY(R EST[ ], R EST[ ], U NIFY(F IRST[ ], F IRST[ ], )) 7 k 7 ¹
else return failure
function U NIFY-VAR( , , ) returns a substitution ¹ k $1d
£
inputs: $$d
£
, a variable
k
, any expression
, the substitution built up so far
¹
if ¹ U»¦Š d º £
$$I$$1d ‰
then return U NIFY( , , ) ¹ k $$d
¹U»¦Š $14º )‰
else if d ¼ then return U NIFY( , , ) ¹
$1d £$$d
else if O CCUR -C HECK ?( k $$d
£
, ) then return failure
else return add / to ¹ Š k $$d ‰
£
Figure 9.2
19
21. 21
procedure OTTER( , ) ¤'§43 $¤
¡ quot;
inputs: $¤
quot;
, a set of support—clauses defining the problem (a global variable)
¤'§43
¡
, background knowledge potentially relevant to the problem
repeat
%
clause the lightest member of $§
quot;
move from ¡ 3
I$@¥
to ¡
¤¤I3 quot;
$¤
P ROCESS(I NFER( , ), $quot;¤ ¤'§43 I$@¥
) ¡ ¡ 3
until $¤
quot; —–
= or a refutation has been found
function I NFER( (§'¤I3 I$@¥
¡ ¡ 3
, ) returns clauses
resolve I$@¥
¡ 3
with each member of ¤'§43
¡
return the resulting clauses after applying F ILTER
procedure P ROCESS( $¤ ¤I$@¥
quot; ¡ 3
, )
¡ 3
I$@¥
for each in do ¡ 3
¤I$@¥
P¤41¤¥
% ¡ 3
S IMPLIFY( I$@¥
¡ 3
)
merge identical literals
discard clause if it is a tautology
[% quot;
`$§ — I$@¥
¡ 3
] quot;
$§
I$@¥
¡ 3
if has no literals then a refutation has been found
¡I$@¥
if 3 has one literal then look for unit refutation
Figure 9.19