AIMA.Core.Logic.FOL.KB.FOLKnowledgeBase.store C# (CSharp) Method

store() private method

private store ( Sentence aSentence ) : void
aSentence Sentence
return void
        private /*lock*/ void store(Sentence aSentence)
        {
            originalSentences.Add(aSentence);

            // Convert the sentence to CNF
            CNF cnfOfOrig = cnfConverter.convertToCNF(aSentence);
            List<Clause> conjunctionOfClauses = cnfOfOrig.getConjunctionOfClauses();
            foreach (Clause c in conjunctionOfClauses)
            {
                c.setProofStep(new ProofStepClauseClausifySentence(c, aSentence));
                if (c.isEmpty())
                {
                    // This should not happen, if so the user
                    // is trying to add an unsatisfiable sentence
                    // to the KB.
                    throw new ArgumentException(
                            "Attempted to add unsatisfiable sentence to KB, orig=["
                                    + aSentence + "] CNF=" + cnfOfOrig);
                }

                // Ensure all clauses added to the KB are Standardized Apart.
                Clause c2 = _standardizeApart.standardizeApart(c, variableIndexical);

                // Will make all clauses immutable
                // so that they cannot be modified externally.
                c2.setImmutable();
                if (!clauses.Contains(c2))
                {
                    clauses.Add(c2);
                    // If added keep track of special types of
                    // clauses, as useful for query purposes
                    if (c2.isDefiniteClause())
                    {
                        allDefiniteClauses.Add(c2);
                    }
                    if (c2.isImplicationDefiniteClause())
                    {
                        implicationDefiniteClauses.Add(c2);
                    }
                    if (c2.isUnitClause())
                    {
                        indexFact(c2.getLiterals().First<Literal>());
                    }
                }
            }
        }