AIMA.Core.Logic.FOL.Inference.FOLTFMResolution.TFMAnswerHandler.checkForPossibleAnswers C# (CSharp) Метод

checkForPossibleAnswers() публичный Метод

public checkForPossibleAnswers ( List resolvents ) : void
resolvents List
Результат void
            public void checkForPossibleAnswers(List<Clause> resolvents)
            {
                // If no bindings being looked for, then
                // is just a true false query.
                foreach (Clause aClause in resolvents)
                {
                    if (answerClause.isEmpty())
                    {
                        if (aClause.isEmpty())
                        {
                            proofs.Add(new ProofFinal(aClause.getProofStep(),
                                    new Dictionary<Variable, Term>()));
                            complete = true;
                        }
                    }
                    else
                    {
                        if (aClause.isEmpty())
                        {
                            // This should not happen
                            // as added an answer literal, which
                            // implies the database (i.e. premises) are
                            // unsatisfiable to begin with.
                            throw new ApplicationException(
                                    "Generated an empty clause while looking for an answer, implies original KB is unsatisfiable");
                        }

                        if (aClause.isUnitClause()
                                && aClause.isDefiniteClause()
                                && aClause.getPositiveLiterals()[0]
                                        .getAtomicSentence().getSymbolicName()
                                        .Equals(
                                                answerLiteral.getAtomicSentence()
                                                        .getSymbolicName()))
                        {
                            Dictionary<Variable, Term> answerBindings = new Dictionary<Variable, Term>();
                            List<FOLNode> answerTerms = aClause.getPositiveLiterals()
                                    [0].getAtomicSentence().getArgs();
                            int idx = 0;
                            foreach (Variable v in answerLiteralVariables)
                            {
                                answerBindings.Add(v, (Term)answerTerms[idx]);
                                idx++;
                            }
                            bool addNewAnswer = true;
                            foreach (Proof.Proof p in proofs)
                            {
                                if (p.getAnswerBindings().Equals(answerBindings))
                                {
                                    addNewAnswer = false;
                                    break;
                                }
                            }
                            if (addNewAnswer)
                            {
                                proofs.Add(new ProofFinal(aClause.getProofStep(),
                                        answerBindings));
                            }
                        }
                    }

                    if (DateTime.UtcNow.Ticks > finishTime)
                    {
                        complete = true;
                        // Indicate that I have run out of query time
                        timedOut = true;
                    }
                }
            }