public bool plfcEntails(KnowledgeBase kb, Symbol q)
{
List<HornClause> hornClauses = asHornClauses(kb.getSentences());
while (agenda.Count != 0)
{
Symbol p = agenda.Pop();
while (!inferred(p))
{
_inferred.Add(p, true);
for (int i = 0; i < hornClauses.Count; i++)
{
HornClause hornClause = hornClauses[i];
if (hornClause.premisesContainsSymbol(p))
{
decrementCount(hornClause);
if (countisZero(hornClause))
{
if (hornClause.head().Equals(q))
{
return true;
}
else
{
agenda.Push(hornClause.head());
}
}
}
}
}
}
return false;
}