//
// START-InferenceProcedure
public InferenceResult ask(FOLKnowledgeBase kb, Sentence aQuery)
{
//
// Get the background knowledge - are assuming this is satisfiable
// as using Set of Support strategy.
List<Clause> bgClauses = new List<Clause>(kb.getAllClauses());
List<Clause> removeList = SubsumptionElimination.findSubsumedClauses(bgClauses);
foreach (Clause c in removeList)
{
bgClauses.Remove(c);
}
List<Chain> background = createChainsFromClauses(bgClauses);
// Collect the information necessary for constructing
// an answer (supports use of answer literals).
AnswerHandler ansHandler = new AnswerHandler(kb, aQuery, maxQueryTime,this);
IndexedFarParents ifps = new IndexedFarParents(ansHandler
.getSetOfSupport(), background);
// Iterative deepening to be used
for (int maxDepth = 1; maxDepth < int.MaxValue; maxDepth++)
{
// Track the depth actually reached
ansHandler.resetMaxDepthReached();
if (null != tracer)
{
tracer.reset();
}
foreach (Chain nearParent in ansHandler.getSetOfSupport())
{
recursiveDLS(maxDepth, 0, nearParent, ifps, ansHandler);
if (ansHandler.isComplete())
{
return ansHandler;
}
}
// This means the search tree
// has bottomed out (i.e. finite).
// Return what I know based on exploring everything.
if (ansHandler.getMaxDepthReached() < maxDepth)
{
return ansHandler;
}
}
return ansHandler;
}