public IInferenceResult Ask(FOLKnowledgeBase KB, ISentence alpha) { ISet<Clause> sos = new HashedSet<Clause>(); ISet<Clause> usable = new HashedSet<Clause>(); // Usable set will be the set of clauses in the KB, // are assuming this is satisfiable as using the // ISet of Support strategy. //foreach (var standardizedC in KB.GetAllClauses().Select(c => KB.StandardizeApart(c))) foreach (var standardizedC in KB.GetAllClauses()) { standardizedC.SetStandardizedApartCheckNotRequired(); usable.UnionWith(standardizedC.GetFactors()); } // Ensure reflexivity axiom is added to usable if using paramodulation. if (this.UseParamodulation) { // Reflexivity Axiom: x = x var reflexivityAxiom = new TermEquality(new Variable("x"), new Variable("x")); var reflexivityClause = new Clause(); reflexivityClause.AddLiteral(new Literal(reflexivityAxiom)); reflexivityClause = KB.StandardizeApart(reflexivityClause); reflexivityClause.SetStandardizedApartCheckNotRequired(); usable.Add(reflexivityClause); } ISentence notAlpha = new NotSentence(alpha); // Want to use an answer literal to pull // query variables where necessary var answerLiteral = KB.CreateAnswerLiteral(notAlpha); var answerLiteralVariables = KB .CollectAllVariables(answerLiteral.AtomicSentence); var answerClause = new Clause(); if (answerLiteralVariables.Count > 0) { ISentence notAlphaWithAnswer = new ConnectedSentence(Connectors.Or, notAlpha, answerLiteral.AtomicSentence); // foreach (var standardizedC in // KB.ConvertToClauses(notAlphaWithAnswer).Select(KB.StandardizeApart)) foreach (var standardizedC in KB.ConvertToClauses(notAlphaWithAnswer)) { Clause c = KB.StandardizeApart(standardizedC); c.SetProofStep(new ProofStepGoal(c)); c.SetStandardizedApartCheckNotRequired(); sos.UnionWith(c.GetFactors()); } answerClause.AddLiteral(answerLiteral); } else { //foreach (var standardizedC in // KB.ConvertToClauses(notAlpha).Select(KB.StandardizeApart)) foreach (var standardizedC in KB.ConvertToClauses(notAlpha)) { Clause c = KB.StandardizeApart(standardizedC); c.SetProofStep(new ProofStepGoal(c)); c.SetStandardizedApartCheckNotRequired(); sos.UnionWith(standardizedC.GetFactors()); } } // Ensure all subsumed clauses are removed usable.ExceptWith(SubsumptionElimination.FindSubsumedClauses(usable)); sos.ExceptWith(SubsumptionElimination.FindSubsumedClauses(sos)); var ansHandler = new OTTERAnswerHandler(answerLiteral, answerLiteralVariables, answerClause, this.MaxQueryTime); var idxdClauses = new IndexedClauses(LightestClauseHeuristic, sos, usable); return this.Otter(ansHandler, idxdClauses, sos, usable); }