public Dictionary<Variable, Term> unify(FOLNode x, FOLNode y,
Dictionary<Variable, Term> theta)
{
// if theta = failure then return failure
if (theta == null)
{
return null;
}
else if (x.Equals(y))
{
// else if x = y then return theta
return theta;
}
else if (x is Variable)
{
// else if VARIABLE?(x) then return UNIVY-VAR(x, y, theta)
return unifyVar((Variable)x, y, theta);
}
else if (y is Variable)
{
// else if VARIABLE?(y) then return UNIFY-VAR(y, x, theta)
return unifyVar((Variable)y, x, theta);
}
else if (isCompound(x) && isCompound(y))
{
// else if COMPOUND?(x) and COMPOUND?(y) then
// return UNIFY(x.ARGS, y.ARGS, UNIFY(x.OP, y.OP, theta))
return unify(args(x), args(y), unifyOps(op(x), op(y), theta));
}
else
{
// else return failure
return null;
}
}