//
// PROTECTED METHODS
//
// Note: You can subclass and override this method in order
// to re-implement the OCCUR-CHECK?() to always
// return false if you want that to be the default
// behavior, as is the case with Prolog.
protected bool occurCheck(Dictionary <Variable, Term> theta, Variable var,
FOLNode x)
{
if (x is Function)
{
List <Variable> varsToCheck = _variableCollector
.collectAllVariables((Function)x);
if (varsToCheck.Contains(var))
{
return(true);
}
// Now need to check if cascading will cause occurs to happen
// e.g.
// Loves(SF1(v2),v2)
// Loves(v3,SF0(v3))
// or
// P(v1,SF0(v1),SF0(v1))
// P(v2,SF0(v2),v2 )
// or
// P(v1, F(v2),F(v2),F(v2),v1, F(F(v1)),F(F(F(v1))),v2)
// P(F(v3),v4, v5, v6, F(F(v5)),v4, F(v3), F(F(v5)))
return(cascadeOccurCheck(theta, var, varsToCheck,
new List <Variable>(varsToCheck)));
}
return(false);
}