AIMA.Core.Logic.FOL.KB.Data.Literal.getAtomicSentence C# (CSharp) Method

getAtomicSentence() public method

public getAtomicSentence ( ) : AtomicSentence
return AtomicSentence
        public AtomicSentence getAtomicSentence()
        {
            return atom;
        }

Usage Example

Ejemplo n.º 1
0
        private void calculateFactors(List <Clause> parentFactors)
        {
            nonTrivialFactors = new List <Clause>();

            Dictionary <Variable, Term> theta = new Dictionary <Variable, Term>();
            List <Literal> lits = new List <Literal>();

            for (int i = 0; i < 2; i++)
            {
                lits.Clear();
                if (i == 0)
                {
                    // Look at the positive literals
                    lits.AddRange(positiveLiterals);
                }
                else
                {
                    // Look at the negative literals
                    lits.AddRange(negativeLiterals);
                }
                for (int x = 0; x < lits.Count; x++)
                {
                    for (int y = x + 1; y < lits.Count; y++)
                    {
                        Literal litX = lits[x];
                        Literal litY = lits[y];

                        theta.Clear();
                        Dictionary <Variable, Term> substitution = _unifier.unify(litX
                                                                                  .getAtomicSentence(), litY.getAtomicSentence(),
                                                                                  theta);
                        if (null != substitution)
                        {
                            List <Literal> posLits = new List <Literal>();
                            List <Literal> negLits = new List <Literal>();
                            if (i == 0)
                            {
                                posLits
                                .Add(_substVisitor
                                     .subst(substitution, litX));
                            }
                            else
                            {
                                negLits
                                .Add(_substVisitor
                                     .subst(substitution, litX));
                            }
                            foreach (Literal pl in positiveLiterals)
                            {
                                if (pl == litX || pl == litY)
                                {
                                    continue;
                                }
                                posLits.Add(_substVisitor.subst(substitution, pl));
                            }
                            foreach (Literal nl in negativeLiterals)
                            {
                                if (nl == litX || nl == litY)
                                {
                                    continue;
                                }
                                negLits.Add(_substVisitor.subst(substitution, nl));
                            }
                            // Ensure the non trivial factor is standardized apart
                            _standardizeApart.standardizeApart(posLits, negLits,
                                                               _saIndexical);
                            Clause c = new Clause(posLits, negLits);
                            c.setProofStep(new ProofStepClauseFactor(c, this));
                            if (isImmutable())
                            {
                                c.setImmutable();
                            }
                            if (!isStandardizedApartCheckRequired())
                            {
                                c.setStandardizedApartCheckNotRequired();
                            }
                            if (null == parentFactors)
                            {
                                c.calculateFactors(nonTrivialFactors);
                                nonTrivialFactors.AddRange(c.getFactors());
                            }
                            else
                            {
                                if (!parentFactors.Contains(c))
                                {
                                    c.calculateFactors(nonTrivialFactors);
                                    nonTrivialFactors.AddRange(c.getFactors());
                                }
                            }
                        }
                    }
                }
            }

            factors = new List <Clause>();
            // Need to add self, even though a non-trivial
            // factor. See: slide 30
            // http://logic.stanford.edu/classes/cs157/2008/lectures/lecture10.pdf
            // for example of incompleteness when
            // trivial factor not included.
            factors.Add(this);
            factors.AddRange(nonTrivialFactors);
        }
All Usage Examples Of AIMA.Core.Logic.FOL.KB.Data.Literal::getAtomicSentence